Using imapsync to backup / archieve your Gmail emails

1. Download and install the latest version of imapsync at As of today, the latest version is 1.255.

2. imapsync requires Mail-IMAPClient 2.2.9. Most recent Linux distribution comes with version > 3.x, so you will need to manually download it at

3. Extract it, and install Mail-IMAPClient 2.2.9

tar xzf Mail-IMAPClient-2.2.9.tar.gz
cd Mail-IMAPClient-2.2.9
perl Makefile.PL
make install

4. You are set to go. The typical command to synchronize from Gmail to your other mail server will be similar to this:

imapsync --host1 --user1 --password1 mypassword \
    --host2 my_other_mail_server --user2 changeme --password2 mypassowrd \
    --syncinternaldates --ssl1 -ssl2 --noauthmd5 --split1 100 --split2 100 \
    --exclude All Mail|Spam|Trash

Obviously you need to provide your actual email address and credentials. It can also work for Gmail Apps, just replace to, provided you are Gmail Apps customer.

The parameter "--exclude All Mail|Spam|Trash" is there to ensure that you won't download the Gmail/All Mail folder from Gmail, as it is actually a collection of all your emails from all your other folders. So essentially, you will end up storing duplicates, and will require twice as much storage if you don't specify it.

So there it goes. It might take a while to complete, and Gmail might lock you with Lockdown in Sector 44 if you try do open multiple connections. Once its done, you can sleep at night knowing the you have the copy of the emails your stored with the big G.