Backing up IMAP email

Hi all, sorry if this is an obvious question but I am new to DH.

Is there a fairly simple way to back up my IMAP email? Most of my addresses are low volume and I want to keep it online - but I also want to keep an offline backup that I can get into offline if I really need to.


Julian Knight

There are a few ways you could backup your email. If your email user has a shell/ssh account, then all of your IMAP email will be in a directory called Maildir in your Dreamhost home directory. You can simply copy this elsewhere and all of your email will be backed up.

[connect to your account by ssh]
$ tar czf mail-backup.tar.gz ~/Maildir

The file mail-backup.tar.gz now holds all of the mail for the use you logged in as at the time of backup, so you can copy that file elsewhere (on or off-server) to keep another copy.

There are other some other tools you can use which are mentioned on the Dreamhost wiki under the Email Import section:
These may require a more complex setup, but they can be ajusted to do what you want.

Finally, Dreamhost makes backups of all of your data automatically at certain intervals, including your email. Making your own backups is, of course, still best. But the Dreamhost backups are nice if you accidentally delete a bunch of mail.

I hope this helps.


Hi Hez, thanks for the reply.

I’ve got how to do a simple backup but what I would really like to do would be to translate the imap data file for the folder into either mbox format or JBOTF (just a bunch of text files) so that I do not have to set up an equivalent Linux IMAP server just to read them if I cannot access them from DH (or I’ve archived them).


Julian Knight

The ~/Maildir/ directory is just that - a bunch of plain text files. Each file has one email in it, and each folder has it’s own directory (though they are “hidden” with a leading . in the directory names). So making a .tar(.gz) of that directory should do exactly what you want.

Also, if you would prefer to have the data stored in mbox format rather than Maildir format for your local backup, there are programs which can do the coversion back and forth. I don’t have any links available, but a search for “mbox maildir coverter” should provide some useful results.

Ah found them!

They seem to be in the “cur” folders but because of their odd names, they do not show up in a WinSCP folder list!!


Now I can do everything I need to, thanks everyone.

Julian Knight

There arn’t that many tools it seems. I found a couple of commercial apps that might do it and it looks like the command line MUTT might do it.

Thankfully, now that I’ve found the individual mail files themselves, I no longer need to worry as I know for sure that I will always have archive access to my mail as long as I backup everything.

Thanks to those who replied - I’m still proving to myself that you can do everything you /need/ to do in Linux, I’m from a Windows background mainly.

Julian Knight

We all overcome that in time.

Wholly - Use promo code WhollyMindless for full 97$ credit. Let me know if you want something else!