Technology Stuff

Monday, October 1, 2007

Backup Gmail Data

I ran across an interesting post the other day about making a backup of your email that is hosted by Google. The original author did a good job with instructions, so I won't repeat them here. I will note that I needed to a couple of things differently to make this work on my Mac.

First of all, fetchmail was already available on my Mac. (Don't you just love that OSX is really Unix? I do.)

Secondly, when configuring the .fetchmailrc file, I added a couple of things:

  1. and wants mda "/usr/bin/procmail -d %T" - The default behavior of fetchmail is to try and forward the mail that it downloaded to your systems SMTP service. In my case, I had never intended for my desktop machine to receive mail directly, so this was not enabled. The first time I ran fetchmail, it choked and died at this step. By adding the "mda" option, you direct fetchmail to deliver the mail locally to your default system mailbox. This will be a file that matches your username in the /var/mail directory. You can view it with a texteditor or by using the command 'mail' when you are in the Terminal.

  2. keep - I added this keep option so that I don't need to use the "-k" option when running the fetchmail command. Not sure why the original author didn't do this.


Okay, so my .fetchmailrc file looks like this now:
poll pop.gmail.com with proto POP3 and options no dns
user 'you@gmail.com' there with password 'itsasecret' is 'YourOSXUsername' here and wants mda "/usr/bin/procmail -d %T" options ssl keep


Upon running fetchmail, it downloads a few hundred messages at a time. My Gmail currently has about 1800 messages, so this will take a while to download, but that's fine. My intent here was to get a copy of my mail on my own hard drive just in case my relationship with Google ever fell through. I'll schedule this nightly via cron and in a week or two, I'll have a copy of everything.

3 comments:

Nathan Cain - MandarinMnemonics.com said...

Where do I save the .fetchmailrc file?

Gandolf said...

The .fetchmailrc file should be stored in your home directory. If you are using Terminal in OS X, this will be /Users/(username). On most other flavors of unix, this will be /home/(username).

Nathan Cain - MandarinMnemonics.com said...

I got this error when I ran fetchmail:
tf1ansiansicpg1252cocoartf949fetchmailrc:1: syntax error at {


This is my .fetchmailrc file:
poll pop.gmail.com with proto POP3 and options no dns
user 'ndcain@gmail.com' there with password 'SECRET' is 'Nathan Cain' here and wants mda "/usr/bin/procmail -d %T" options ssl keep

Can you please let me know what I did wrong?