Easily archive gmail/general IMAP mailboxes with imap-archiver

Posted on ‐ Tagged

Where I work, if an employee quits, we make a backup of all their mail before removing their user account from Google Apps (which we use for all our email/calendar stuff). Since I’m the resident sysadmin guy, this task tends to fall upon me to do whenever someone has left the building.

As gmail supports IMAP, this isn’t a very difficult task to do, since offlineimap coupled with good old tar does the job just fine. However, just the other day I realized this still requires quite a bit of typing on my end. I have to open up the config file I have for this, change out the username and password, then invoke offlineimap and tar themselves, before finally copying the resulting archive over to where all these backups get stored.

In an effort to save up on this typing, and as a good excuse to dive a little deeper into rakefiles, I decided to automate most of this task. The result? imap-archiver. It’s a bit of a niche project, but maybe someone else out there finds it useful too!