Backing up Gmail

November 20, 2011 - 2 minutes read

Like much of the Internet these days I love my cloud based email. For a decade or so I ran my own mailserver, and as much fun as learning the ins and outs of a sendmail configuration file was and constantly battling spammers I decided to switch my domain to Gmail. All was great in cloud mail land until one day my euphoric bubble of cloud infallibility was popped by a Gmail fail. While Google later asserted that all email was recovered it triggered the Eagle Scout in me and I decided to be prepared for a future Gmailpocalypse.

There are a variety of ways to attack this problem, the simplest of which is to just use an IMAP or POP client to backup like Thunderbird. Never one to take the easy way out, and wanting direct control over how my archive was handled, I choose to use a program called getmail. I did the backup on a Windows machine using Cygwin following these instructions. Upon running getmail for the first time I kept getting a python error, something along the lines of fatal error unable to remap. After Googling a bit I came across this wiki on rebasing which fixed the problem.

The next problem I encountered was that getmail was marking all messages as read, which isn’t what you want if you are just using this to backup. There is some debate about how to fix this, or if it is even broken, but all I know is it isn’t the behavior I want. There is a pretty simple two line patch here which worked for me. I actually applied the patch by hand. I navigated to my Cygwin directory, which for me was C:cygwinlibpython2.6site-packagesgetmailcore . I found the two lines the patch mentions and changed them and all was well.

The next how to I suppose should be on restoring your email. I have some ideas, but hope I never have to write that one out of necessity.