Automatically Backing up Gmail to a Linux Server

2009/01/18 11:49:00
Print Friendly

So, today I decided to set about the task of backing up my Gmail to my home server. I pay Google for 99% uptime, and really don’t expect their service to fail, but I have to account for more likely scenarios. For example, I may conceivably delete a message and find out I need it later; or, I may not want to keep a message on Gmail anymore but still need to retain it.

The players in this setup are a server running CentOS 5.2 and Gmail itself. My plan is to create a cron job that backs up the email at some fixed interval (daily) and saves it to a folder. At some point, I will back that up to DVD in case I or Gmail lose everything one day.

Gmail Backup runs on Windows and Linux. Gmail Backup does something that fetchmail or other solutions fail to provide: your Gmail labels are actually stored. This made it appear to be a better solution overall, so I decided to give it a whirl.

It is written in Python and requires Python to run on Linux (the Windows version is compiled). Unfortunately for me, the Python that comes with CentOS 5.2 is Python 2.4.3 and Gmail Backup requires Python 2.5.

I could just rip out the Python 2.4.3 libraries and replace them with Python 2.5 libs, but that would create problems for some of CentOS’s native utilties. So, I’ve installed Python 2.5 and wxpython in a different directory on my server and pointed Gmail Backup at the correct Python files.

According to the documentation, I just needed to run:

gmail-backup.sh backup my-backup-directory gmail-username gmail-password

The first attempt at running Gmail Backup met with failure:

Error: IMAP: [ALERT] Invalid credentials (Failure)

which I realized was because the shell was not escaping the ! in my password, so I changed the password.

Then I got:

ValueError: time data did not match format:  data=XXXXX  fmt=%Y%m%d

The XXXXX was the last half of my new password, which had a space in it. I consider this a bug in the implementation of Gmail Backup. I’ll contact the author with a fix later. So, I removed the space from my password.

That did it. Off I went. Gmail Backup nicely put my email into a directory. Each message is stored as a text file in directories indexed by year and date. All of the labels are stored in a text file.

Restoring to Gmail is as easy as:

gmail-backup.sh restore my-backup-directory gmail-username gmail-password

With a little scripting and a cron job, now I can automate Gmail Backup with a script, having it create periodic backups of all of my messages, then compressing the backup directory into one big file for storage and offloading.

Thanks Gmail Backup for making this so much easier!

Little Projects on Blogger

2009/01/05 21:52:00
Print Friendly

In my effort to deal with the economic crisis, I’ve began looking at lower cost alternatives to renting my own server. I would like to affirm that eSecureData is an excellent hosting service that has given me far more than I could have expected. Their prices and hardware offerings definitely eclipsed those of Layered Tech.

At this point, though, with the availability of services like flickr and Picasa, I no longer need the disc space for my photos that pushed me to begin renting a server. Also, with the services and amount of space available on Gmail, I no longer need a server for my mail either.

So, I’ve gotten myself a Google Apps Account and am moving items over to Blogger as you read this. I’ve been running Gmail, as part of Google Apps For Your Domain, for more than two weeks now and am quite happy with the results.

This will save me roughly $65 per month on server rentals and free my time up a bit. If you need a simple web hosting service with email, I heavily suggest Google Apps.

Google Toolbar for Your Domain

2009/01/03 01:24:00
Print Friendly

As I’ve been testing out Gmail for my domain, I read in “Google Apps: The Missing Manual” that the Google Toolbar had all kinds of nice buttons that integrated nicely with Google Apps. The problem is, with initial install, that the Google Toolbar would only work with my initial Google account and not the one associated with my domain, where my central email would be accessed.

This site gives information on how to change the Gmail button to act the same, but for Google Apps for Your Domain (cutely abbreviated GAFYD in the article):
http://tech.blorge.com/Structure:%20/2008/02/23/google-toolbar-for-firefox-make-the-gmail-button-work-with-google-apps/