Evan Martin (evan) wrote in evan_tech,
Evan Martin

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:
    type = SimplePOP3SSLRetriever
    server = pop.gmail.com
    username = gmail username
    # this can be changed to Maildir, etc. RTFM.
    type = Mboxrd
    path = ~/.getmail/inbox
    # 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.
Tags: howto

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.