Edwin Huertas
web developer – software engineer – linux sys admin

Feb/10

13

Backup your Gmail account with getmail in ubuntu 8.04 LTS

Recently we needed to have backups for old email accounts in our Google apps account. We needed to free up some space and a way to reference back to the emails in these accounts.

I’ve found various options with Thunderbird and Mac Mail. But all require to play with the off-line or sync features. Also I needed something that I could run from the backup server without moving 25GB of email from one computer to another. After couple queries in google, I found a good solution which was using getmail to retrieve emails from POP Gmail accounts.

So, here it is. Please remember to activate POP or IMAP feature in your Gmail account settings before start.

1. Install getmail

  1. $ sudo apt-get install getmail4

2. Create a folder and file to store the emails

  1. $ mkdir backup-emails
  2. $ cd backup-emails
  3. $ touch someuser-backup.mbox

3. Create getmail folder and config file and add settings

  1. $ mkdir .getmail
  2.  
  3. $ cd .getmail
  4.  
  5. $ vi .getmail-gmail
  6.  
  7. [retriever]
  8. type = SimpleIMAPSSLRetriever  // Using IMAP here, if you want POP use: SimplePOP3SSLRetriever
  9. server = imap.gmail.com //for POP use: pop.gmail.com
  10. username = someuser@yourdomain.com // or someuser@gmail.com
  11. password = yourpassword
  12. [destination]
  13. type = Mboxrd  // (**)
  14. path = backup-emails/someuser-backup.mbox // (**)

** Please check references links below for more info about other options.

4. start backup, sit back and relax

  1. $ cd
  2. $ getmail -d -r .getmail/getmail.gmail

I’m using -d here because I don’t need to keep those email account anymore. So you will need to remove it if you’re planning to continue using the account.

That’s all, add the command to a cronjob and you are all set.

References:
http://pyropus.ca/software/getmail/

http://blog.pengdeng.com/2008/03/backup-gmail-via-imap-using-getmail_16.html
http://www.mattcutts.com/blog/backup-gmail-in-linux-with-getmail/

RSS Feed

«

Find it!

Theme Design by devolux.org