HashBackup supports the IMAP protocol to enable email servers to be used as backup destinations. This doesn’t make sense for large backups of course, but is handy as a secondary backup of critical system config files, small software repos, etc.

As an example, the HashBackup software repository (Mercurial), including the development environment and complete history since the first version, is backed up to a Gmail account. The repo itself is around 223MB. The last 30 days' history and 12 monthly histories are stored in the backup, yet the backup is only 220MB.


Most IMAP servers have limits to prevent abuse, and HashBackup has several settings so it can work within these limits. Every IMAP server has different limits, so some experimenting might be required for reliable operation as a backup destination.

IMAP dest.conf Keywords

type (required)

imap - host and port are required

gmail - host and port are set automatically


IMAP server hostname


IMAP server port. The default is port 143 for non-SSL access. Some IMAP servers may reject non-SSL access because userid and password are sent in the clear. Use port 993 for SSL IMAP. The host and port may be automatically set for some destination types like gmail.

userid (required)

IMAP server userid

password (required)

IMAP server password for this userid


The folder name to use on the IMAP server. It is created if it doesn’t already exist. Some IMAP servers may allow a name like hashbackup or /hashbackup, while others may require a name like Inbox.hashbackup. Folder names are usually case-sensitive. This seems to be the most non-standard part of an IMAP setup and may require experimenting.


For IMAP, HB limits all file transfers to 100MB by default, but most IMAP servers have even lower limits. HB sends files as email messages, not as attachments, so email message size is the important limit, not attachment size. An encoding overhead of around 10% must also be taken into consideration.

There are 2 ways to control HB’s file sizes:

  1. Use hb config arc-size-limit to set the maximum archive size. This limit is not always respected exactly, especially with multithreaded backups. Backup’s -p0 option (no multithreading) can be used for better arc file size control. It would not be unusual for HB to create an arc file 5MB larger than arc-size-limit.

  2. The maxsize keyword in dest.conf exactly controls the maximum size of all files sent to a destination. Any file exceeding this limit is split into pieces. See Destination Setup for details.

As an example, if an IMAP server has a 25MB message size limit as Gmail currently does, here are the settings to use:

10% encoding overhead would be 2.5MB, so set maxsize to 20MB to be safe

set arc-size-limit to 15MB to avoid going over maxsize


HashBackup implements long retry times for IMAP connect requests, beginning with 5 seconds and doubling on every error for up to 20 minutes. If this still fails, HB’s normal retry mechanism is used. See retries in Destination Setup for more details about the normal retry mechanism.


Specifies number of concurrent connections to the IMAP server. Many IMAP servers have limits on concurrent connections. Each worker uses 2 x maxsize memory for uploads and downloads, so use smaller arc-size-limit and maxsize to decrease HB memory usage, and/or set workers to 1 to conserve memory.

IMAP Example

destname myemail
type imap
port 143
password mypass
dir HashBackup

Gmail Example

For type gmail, host defaults to and port defaults to 993 for SSL. The dir keyword is the Gmail label to use for the backup files and is created if it doesn’t already exist. As of 2021, Gmail limits email message size to 25MB, so set arc-size-limit to 15mb.

destname myGmail
type gmail
password mypass
dir HashBackup
maxsize 20mb Example is a free email service with a 50MB message limit. Set arc-size-limit to 40mb or less.

destname gmx
type imap
password blah
dir Backup1
maxsize 45mb