How to back up a complete IMAP account?

I have a large IMAP email account which contains many emails in a rich structure of directories. How to back up the whole IMAP account to my local computer? The requirements:

  1. Automatically downloading these files. There are many directories, and copying-pasting emails will take too much time.

  2. Keep the directory structures which are used to organize these emails.

I use offlineimap to synchronize the emails when the iMail at HKUST change to @Connect.

On Fedora, installing offlineimap by # yum install offlineimap.

The configuration in my ~/.offlineimaprc:

[general]
accounts = USTiMail

[Account USTiMail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/Mail/USTiMail

[Repository Remote]
type = IMAP
readonly = true
remotehost = imap.ust.hk
remoteuser = zma

To start the backing up, simply run offlineimap and it will ask for the password.

The readonly = true in the Remote repository part is to make sure changes at local by accident are not synced to the remote IMAP side.

After the emails are sync’ed from the IMAP server, archive or compress as you need.

The emails are organized in the Maildir format. Many tools can be used to view the emails. I use mutt by

mutt -f /path/to/a/mail/dir/

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *