How to back up a complete IMAP account?
Posted on In QAI 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:
-
Automatically downloading these files. There are many directories, and copying-pasting emails will take too much time.
-
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/