OfflineIMAP - have a local copy of your mail

While it is very convenient to have all mail available online and it is cheap (Google Mail offers a lot of storage for free), you might sleep better at night if you were sure to have a copy of you mail on your own hard disk drive at home. offlineimap is an open source python software available in most Linux distributions that does the job.

Install using:

sudo aptitude install offlineimap

Edit the configuration file ~/.offlineimaprc and provide up your IMAP connection details:

[general]
accounts = GMail
maxsyncaccounts = 3

[Account GMail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = /home/you/GMail

[Repository Remote]
type = IMAP
remotehost = imap.gmail.com
remoteuser = your.name@gmail.com
ssl = yes
maxconnections = 1
realdelete = no

Instead of the given config for the Repository Remote you can also use the template type=Gmail (found in the annotated conf example).

[Repository Remote]
type = Gmail
remoteuser = your.name@gmail.com
realdelete = no
# The trash folder name is different from [Gmail]/Trash in the UK version of Gmail:
trashfolder = [Google Mail]/Bin
spamfolder = [Google Mail]/Spam
# maintain 3 connections to the server at the same time (faster):
maxconnections = 3

If you additionally provided the password using remotepass = your_password after remoteuser then you can set up the automated cron call using crontab -e:

00 23 * * * offlineimap -u Noninteractive.Quiet

To have a real backup of the mail (OfflineIMAP isn't) do an rsync:

rsync -a /home/you/GMail /home/you/GMail_Backup

resources:

Comments