date: 2008-03-18 22:12:46+00:00
Backup your Gmail account in maildir format using fetchmail
categories: - Howto - Linux - Misc
First of all, enable POP on your gmail account :
- Forwarding and POP/IMAP
- Enable POP for all mail (even mail that's already been downloaded)
Then, the configuration for fetchmail and procmail :
You need to use procmail in order to be able to store the mails in maildir format (1 file per mail, mbox format is 1 big file for all emails)
username "ACCOUNT@gmail.com" password "PASSWORD"
mda "/usr/bin/procmail -m /home/USER/.procmailrc"
We are using the pop3 protocol, we keep messages on the server and use the SSL server to retrieve our emails from.
<code>MAILDIR=/home/USER/ VERBOSE=on :0 Mail/</code>
Initial retrieval :
The first time, you'll need to run fetchmail in USER's session manually to retrieve your mailbox. Indeed, after a while fetchmail will stop retrieving emails, so you need to run it again a couple of times before it's done. I guess gmail limits the number of emails you can retrieve in a session. You should set up a regular cronjob to retrieve emails automatically, you shouldn't wait too long between two retrievals to avoid missing emails due to the restriction.
Setting up a cron job in the USER's session to run the backup every night :
0 1 * * * /usr/bin/fetchmail > /dev/null 2> /home/USER/Mail/fetchmail.log
I set up mutt to read my backup emails from the CLI :