evan_tech

Previous Entry Share Next Entry
11:17 am, 12 Feb 06

using getmail with gmail

Wanna make a regular backup of your GMail account? At first I installed fetchmail, then I looked at the man page for a second and thought to myself that someone had to have made a more sensible piece of software. (And I don't wanna involve an MDA, I just want a copy of the mail.)

Enter getmail. (No, not the Windows app of the same name.) It even has an amusing and long FAQ about why you shouldn't use fetchmail, which begins:
Short answer: … well, the short answer is mostly unprintable. The long answer is … well, long: [...]


Anyway, here's the recipe.
  1. apt-get install getmail4
  2. mkdir ~/.getmail
  3. Edit ~/.getmail/getmailrc, and put in something like:
    [retriever]
    type = SimplePOP3SSLRetriever
    server = pop.gmail.com
    username = gmail username
    
    [destination]
    # this can be changed to Maildir, etc. RTFM.
    type = Mboxrd
    path = ~/.getmail/inbox
    
    [options]
    # this makes it pick up where it left off
    # instead of downloading everything each time.
    read_all = False
  4. touch ~/.getmail/inbox

  5. run getmail. It'll prompt you for a password.

Three bits of weirdness to be aware of:
  1. gmail tracks the last date you've downloaded from so subsequent getmails will get different counts of messages. If you want to start over, go to Settings→Forwarding and Pop there's a "Status" option which lets you reset the date.
  2. It appears to only download a subset of your messages at a time. So reset the POP date once, then run getmail a few times.
  3. getmail seems to eat a lot of CPU for reasons that are not apparent to me. strace indicates it's stating the same Python modules over and over... ah, software.