Backup Gmail with Getmail

There are numerous pages with example Getmail configurations; these two are particularly useful:

…then there is also the official Getmail website and Getmail examples.

However, none of the above has a single, comprehensive configuration for backing/migrating Gmail the way I want. Here’s my ~/.getmail/getmailrc

[retriever] type = SimpleIMAPSSLRetriever server = port = 993 username = your gmail username password = your gmail password mailboxes = ( “[Gmail]/All Mail”, “[Gmail]/Sent Mail”, “[Gmail]/Drafts” ) [destination] type = MultiDestination destinations = (‘[mboxrd-destination]’, ‘[maildir-destination]’) [mboxrd-destination] type = Mboxrd path = /path/to/where/you/want/your/mbox/backup/ [maildir-destination] type = Maildir path = /path/to/where/you/want/your/maildir/backup/ [options] verbose = 2 delete = false message_log = ~/.getmail/log-gmail # do not alter messages delivered_to = false received = false # retrieve only new messages # if set to true it will re-download ALL messages every time! read_all = false

This config uses both mbox and maildir formats, includes Sent and Drafts folders as well as the Inbox, and works over IMAP, which isn’t as problematic as POP3 retrieval.