Linux Server Diary

The trials and tribulations of a Linux newbie trying to setup a home server.

Sunday, May 04, 2008

Using Getmail to Backup GMail

Web email services like GMail are a great thing. We can access our email from any web client, the interface is slick, and improvements and new features are added frequently. A downside, however, is that we rely on an outside source to backup our messages.

Now, it's not likely that our GMail message stores will disappear one day without a trace, but things could happen. Google could have a hiccup and decide that they won't or can't recover our messages. (It's happened with other vendors) Also, they may decide to discontinue the service. Internet service could be down for an extended period of time. Finally (and least likely), Google could go out of business - stranding our data in a bankruptcy escrow from where it may never return.

OK, enough with doomsday scenarios. It makes sense to backup any important data, and email is no exception. Today, I'm going to experiment with Getmail.

Matt Cutts provides a nice step-by-step outlining the setup of Getmail with GMail. I'll also mention that I'm using Google Apps instead of the standard gmail.com account.

Unlike many of the projects I tackle, this went exactly as expected. The only small problem I hit was when I copied and pasted the configuration file, spaces were inserted at the left side of each line. Apparently, the program expects things to be in column 1. I removed the spaces, and all is well.

Getmail just finished running for the first time on my server, and it grabbed 289 messages in the first batch. The tutorial mentions that Google will limit the number of messages sent in each run, so it will take a few times to get all 1,500+ items in my archive.

Next comes the cron setup. While the example shows how to run every 10 minutes, I'm setting up mine to run much less often - no more than once an hour, and maybe just once a day. I don't get that much mail, and I don't need it backed up in near real time.

Thanks to Matt for the great instruction!