How to backup mail with imap, and how do I read it later?

I have a couple of different mail accounts that I use for different stuff, and all can be accessed with imap (even though I use webmail a lot).

The question is if there is a way to download and backup all of those mails from the command line (a backup script), and how do you later read those downloaded mails? Let's say one of those accounts could have been cancelled.

Does anybody have any good ideas?


Update: Thanks jmohr for stating the obvious.

If I make Thunderbird download everything for offline use, it all ends up in ~/.mozilla-thunderbird/. And then I make sure that will be included in my normal backup when I do normal backup of my home dir.

And to read them again they are right there in Thunderbird.

So the backup will a two step rocket, first it is thunderbird updates the local dirs and then you back that up in a normal way.


Most mail clients have the option to download all messages when using IMAP.

You don't say what mail client you're using, but in Thunderbird the relevant settings are located at:

Account Settings > [email protected] > Offline & Disk Space

Then you can choose to have the messages downloaded for offline use.


I use offlineimap to synchronize my email between my local Maildir folders on my linux box, and the IMAP folders on my email provider's server.


I am currently trying to implement email backup on my NAS (a number of IMAP source servers and a single target with a folder ment for backup/archive)

Because the target is also an IMAP account, it is viewable and searchable using any email client supporting IMAP

Assuming you are on linux, you may be interested with

  • imapfilter
  • imapsync

to get this going.