Restore IMAP mail from local cache via Time Machine

Posted Posted by Wes in Sysadmin     Comments 6 comments
Jan
16

I had a real scary moment last night. I was cleaning off my server and deleted the home directory for my databasically email account. I don’t host the website on that server, so I thought removing the home directory would be fine. However, I do host the mail on that server and it’s stored in the home directory.

I had Apple Mail.app running and connected to that mailbox. I didn’t really notice it until a few minutes later when a message came in on another account.

My work account was blank. Empty. Also, I had a nice exclamation point saying the account couldn’t be found.

Whoops. Oh hell.

I have my computer hooked to an external hard drive which I’m using as my Time Machine (the built-in Mac backup software) drive. I poked through the folders from an hour ago and found all my mail.

The mail is stored in ~/Library/Mail/, where each IMAP account has a folder called IMAP-user@host. This folder contains many folders with the .imapmbox extension.

Here’s how I restored my mailbox:

  • Recreated my home directory and made sure that the email address still worked. You may want to set up a new account if you’re moving hosts or whatever. Get a working IMAP account up and running.
  • Put the IMAP-user@host folder to my Desktop. Actually, I restored it from Time Machine and then copied it to the Desktop. I selected “Keep both” when doing the Time Machine restore which renamed my existing folder to end in “(original)”. I moved the restored folder to my Desktop and removed the “(original)”.
  • Renamed each folders’ extension from .imapmbox to .mbox . Make sure you get any subfolders as well.
  • Import the file: File > Import Mailboxes > Mail for Mac OS X
  • Select the parent folder (IMAP-user@host) containing all your .mbox files.
  • Your mail will be imported to a folder named Import inside the On My Mac folder.
  • Drag your mail to your new/restored IMAP mailbox. I copied 5000 messages at a time without an issue.

Hopefully you never need this information.

If it helped you out or if you have any other information, please let me know in the comments.

6 Comments to “Restore IMAP mail from local cache via Time Machine”

  • Thanks for this. I ran into the same problem and was wondering why the .imapmbox files wouldn’t import. Your instructions worked like a charm.

  • Thanks, this just saved my butt. I just finished wiping my mailbox, oops! Glad you figured out how to restore from Time Machine, I was just Googling for how do it, found your post.

  • Did not work for me. Had a blank Sent folder in mail, so I chose to Synchronize. That made all my gmail sent mail disappear online. This method did not restore my files. Was told the newly renamed .mbox file/folder was not valid.

  • Works like a charm! Thx

  • Rename from .imapmbox to .mbox. Well I’ll be. Worked! Much happier now. =)

  • Thanks! Plain restoring of the mbox for the accidentally emptied IMAP folder was not enough, but restoring to desktop and then importing + moving the mails to the actual folder in the Mail application did the trick. PHEW! :-)

Post comment

about databasically

We live and work in Kansas City, USA.

We're passionate about helping small businesses succeed and want to help you use technology to get more done.

From server, desktop, network management to programming custom web applications in Ruby on Rails, we're here to lend a hand.

Contact us if you have any questions!