Monday, February 11, 2008

Gmail IMAP backup

Today I decided to try out Gmail IMAP. Untill today I downloaded mail via POP from gmail and keep them in my home IMAP server. This way I was able to use thunderbird and have my mail synched on all my computers. Now that gmail offer an integrated imap server I decided to switch to that so I'll able to use also gmail web interface and have all synched (before I used to use OverLook that's quite useful, but really slow... at least on my small home server).

In the end now all my mail reside on gmail and I have no local copy (except for thunderbird local file...). I want to keep a local copy of the gmail account to be able to recover from loss of data by google. Also I want it to be synched daily.

Well, the first solution I thought is imapsync.
Here's how to backup a gmail account with it:

imapsync --host1 imap.gmail.com --ssl1 --user1 user@gmail.com \
--password1 gmailPass --host2 local --user2 user@local \
--password2 localPass --prefix2 INBOX.gmail-backup. \
--authuser1 user@gmail.com --authmech1 LOGIN \
--authmech2 LOGIN --syncinternaldates

A more secure way is to put the passwords in 2 file and use --passfile1 and --passfile2.

1 comment:

diafygi said...

I've written a python-based cli for getmail4 that pretty much does the same thing. However, with mine you can download individual mailboxes. It's called ImapGrab, and it can be used for any IMAP server. I also added a special option for Gmail. Enjoy!
http://daylightpirates.org/index.php/Programs/ImapGrab