Restoring email from cache

As some of you know, about a month and a half ago my server hard-drive crashed, and I lost all my data on the drive, most of which was un-backed-up.
One of the more important things I lost was my email archive. This included all email in the last two years, since I stopped using gmail. (I was using imap to keep the email synchronized across all my mail clients on different computers). The silver lining of this was that I was able to recover some fraction of my email (mainly from my inbox) by using the cache my email client maintains to make re-reading emails more efficient.

This post should serve as a simple how-to. It’s actually quite simple if you had my setup. So — using Mutt as my mail client, I have a great deal of control over the way its configured. One of the configuration items was to use a message cache:

set message_cachedir = "~/.mutt/imapcache"

This meant that as I read emails, they were downloaded to the computer I was reading them from, and saved in a file under my home directory, in the .mutt/imapcache directory. It was using a separate folder to store email from each remote mail folder. So, to restore them, all I needed to do once I had my new mail server up-and-running was:

  1. concatenate all the emails into a single file (cat * > ~/tempfolder)
  2. open the new “folder” from within mutt (<change-folder> ~/tempfolder)
  3. tag all the messages and save them to the appropriate folder on the remove server

The real trick is that each message is being stored in a standard format. Then, concatenating them together creates a mailbox format called mbox, making it easy to access them all at once. Then the mutt mail client can use imap to store them back on the remote server.

In my case, I was able to repeat this from each computer I use to read mail — there were about 3 of them. I was able to recover about half of my inbox, and a few other assorted messages which had been read recently. Not as good as having backups, but better than nothing!

Leave a Reply

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