Backup a Linux server with IMAP to Gmail

When I compiled the how-to about using Duply to backup a Linux server to a FTP account I mentioned the possibility to backup all data to an IMAP account. So, all we need for our encrypted backup is a reliable IMAP account provider with a few GB of email space. In this post I’m using Gmail which provides up to 7 GB for emails for free, but instead of saving emails Duply will store encrypted backup files on that Gmail account.

I created a new Duply profile named “gmail”. The main difference to the FTP configuration in the how-to is the TARGET setting. In case of Gmail it should look like


Use the Gmail account name without the domain name here just like do when you log in to the Gmail web front end.
It could prove useful to lower the max. chunk size for the backup files. Google states they allow to store email attachments as large as 25 MB. Interestingly, the default in Duply defaults to 25 MB too but I think it’s safer to lower the setting to 10 MB:

# set the size of backup chunks to VOLSIZE MB instead of the default 25MB.
# VOLSIZE must be number of MB's to set the volume size to.
# Uncomment the following two lines to enable this setting.

This is the output of a Duply backup of my /etc folder to Gmail:

root@myserver:~#:duply gmail backup
Start duply v1.5.1.3, time is 01/01/10 16:25:58.
Using profile '/etc/duply/gmail'.
Using installed duplicity version 0.6.06, gpg 1.4.9 (Home: ~/.gnupg)
Test - Decryption with key A614A2CA (OK)
Test - Compare Original w/ Decryption (OK)
Cleanup - Delete '/tmp/duply.8466.1262359558_*'(OK)

--- Start running command BKP 16:25:58.486 ---
Running duplicity - OK
Output: Reading globbing filelist /etc/duply/gmail/exclude
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: none
No signatures found, switching to full backup.
--------------[ Backup Statistics ]--------------
StartTime 1262359559.78 (Fri Jan  1 16:25:59 2010)
EndTime 1262359566.12 (Fri Jan  1 16:26:06 2010)
ElapsedTime 6.34 (6.34 seconds)
SourceFiles 2099
SourceFileSize 10490439 (10.0 MB)
NewFiles 2099
NewFileSize 10490439 (10.0 MB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 2099
RawDeltaSize 9654597 (9.21 MB)
TotalDestinationSizeChange 2281391 (2.18 MB)
Errors 0
--- Finished 16:26:25.459 - Runtime 00:00:26.972 ---

It took Gmail 27 seconds to store 2.18 MB of data. That’s pretty slow but hey, it’s free!

Please be aware that Google may cancel your Gmail account without notice because you inflicted too much traffic on their IMAP servers. To stay on the safe side I’d use it only for small, non-essential backups.

Once your account contains more than ~7 GB of mails Gmail will automatically start to delete your oldest mails (in our case backup chunk files), so you want to make sure you never exceed the storage limit.

This is how the backup looks in the Gmail front end:

If you’re getting “Unknown scheme ‘imap'” when running Duply you’re probably using an old version of Duplicity. Remember, Duply is a wrapper for the mighty Duplicity. You need to update Duplicity in order to be able to store your backups to an IMAP account.
In Debian you would do this with Apt-Pinning. In case you don’t know what this is you may want to have look at Apt-Pinning for beginners. After resolving an unmet dependency in a Python package I was successfully able to update to Duplicity 0.6.06-2 on a Debian “Etch” server.

2 replies on “Backup a Linux server with IMAP to Gmail”

  1. There is a big issue with the last file created using this approach: duplicity-full-signatures.[*].sigtar.gpg can be easily bigger than 25MB. This will result in a backup fail.
    How do you think that this problem could be circumvented?

Comments are closed.