How to manually restore your Mail folder from Time Machine

MailIconYosemiteXIf you have recently lost a large number of messages in OS X Mail, then provided you have a Time Machine backup of your system, you will have three options for restoring your messages.  The first approach, since you can access Time Machine backups from within Mail, is to go to your mailbox in Mail and then invoke Time Machine and attempt to find and restore your messages from within the Mail interface; however, this is only practical for recovering a few messages, and in some cases this approach may simply not work.

The second option is to restore your entire system to a prior backup, which again is somewhat impractical since you might lose some third-party application registrations, and take the time to perform the full system restore. This being the case, the third and perhaps most straightforward approach for recovering large amounts of lost e-mail is to restore your messages manually in the Finder using Time Machine.

Since Mail keeps all of its data in the Macintosh HD > username > Library > Mail folder, you might consider going to your user account’s library (by holding the Option key and choosing Library from the Go menu in the Finder), and then invoking Time Machine from within the Finder to restore a recent backup of the “Mail” folder Time Machine; however, you will likely find that even though you can view this folder in Time Machine, the “Restore” button will not be available when choosing this folder.

To get around this, you will have to restore your Mail data folder manually, along with the corresponding Mail preferences file, which can be done by first quitting Mail and then performing the following routine:

  1. Open your Time Machine disk, and then go to the backup of your account’s Library folder:
    Backups.backupdb > ComputerName > Latest > Macintosh HD > Users > username > Library

    Note that the “latest” folder here will select your most recent backup, but you can choose from any of the available backup instances, if you think one might be more relevant for the data you are trying to restore.

  2. Select your Mail folder and press Command-C to copy a reference to it.
  3. Go to the Library folder in your active user account, and rename the folder called Mail to something like “Mail-old.” You can also right-click the folder and archive (compress) it as a zip file.
  4. Press Shift-Option-Command-V to paste the previously copied folder exactly as-is, and preserve all permissions. Authenticate when prompted.
Mail folder in the user library

This folder in your Library directory is the one you will be replacing.

Since this folder contains your Mail messages, you might think this is all that’s needed; however, if you try to open Mail immediately after copying the Mail folder from your backup, you may see the following error message in Mail:

“Mail can’t open because you don’t have the necessary permissions to change the folder where it saves information.”

This happens because Time Machine appends hidden permissions settings called ACLs (access control lists) to files, similar to the following, which help prevent them from being modified on the backup drive (see that they “deny” access for “everyone”). When you copied the files from the Time Machine drive, you did so by preserving all permissions settings, including these ACLs.:

0: group:everyone deny write,delete,append,writeattr,writeextattr,chown
0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown

This might be confusing because despite the error that Mail gives you, if you get information on the Mail folder you will see your account has full Read and Write access to it; however, this is because the Finder only shows you the older and simpler “POSIX” unix permissions, and does not show much (if anything) about ACL details.

Finder info window showing permissions

These permissions suggest the owner (me) ought to have full read and write access to the folder; however, hidden ACL entries may take precedence and deny access.

For Mail to properly read from this folder, once it is copied you will need to strip off these ACLs from it and all items contained in it, which can be done by opening the Terminal utility (in the Applications > Utilities folder) and running the following command (copy and paste it to the Terminal to run it):

chmod -R -N ~/Library/Mail

With this step complete, your last step is to restore your old Mail preferences file, which contains the information about the accounts and mailboxes you had configured when the backup of your Mail folder was created.

Restoring this file will ensure Mail will find all of the messages you recovered, and not overlook any mailboxes. For instance, if your loss was from deleting some of your mailboxes (or the entire account, and all of its mailboxes), then your current preference settings will not point to these lost mailboxes, so even if you restore the data, Mail will not look for it. On the other hand, the old preferences file will tell Mail that these mailboxes exists.

Restoring the preference file can be done with the following steps:

  1. Go back to the same Library folder on your Time Machine disk, and then go to the following directory within it:
    Containers > com.apple.mail > Data > Library > Preferences
  2. Locate the file called “com.apple.mail.plist,” and then select it and press Command-C to copy a reference to it.
  3. Go to your user account’s Library folder, and then to the same Containers > com.apple.mail > Data > Library > Preferences folder within it.
  4. Press Command-V to paste (and thereby copy) the preferences file to this folder. Be sure to replace the old one that you have in there.
Mail containers folder in OS X

The Mail preferences file to replace will be in subdirectories contained in the Containers > com.apple.mail folder.

With these steps done, you can now launch Mail, and when you do so, the program will read from the restored preferences file to load details about the prior Mail accounts and mailboxes, and then be able to associate them with the contents of the restored Mail folder on your hard drive.

Mail will likely perform an import routine on your restored mail, but this is simply it re-indexing your files. After this is done, you should have the full mailbox organization as you had before you lost your messages, so your lost messages should be somewhere in your mailboxes. If everything checks out, you can then go back to your user library and delete the unused Mail folder (the one you had renamed to “Mail-old”), or the archived zip file that you created of it.

40 thoughts on “How to manually restore your Mail folder from Time Machine

  1. xAirbusdriver

    I may be missing something in your narrative, but I think this process might not save any ‘new’ messages from a POP type account. Any POP messages _after_ the Time Machine restored collection _will_ be in the “Mail-old” file, but retrieving those was not discussed.

    Perhaps Mail is smarter than I am, certainly a possibility! 😉 However, I suspect it may require some direct/manual copying and pasting, perhaps even re-mailing(?) those POP messages to get them back into the Restored collection.

    1. Topher Kessler Post author

      In most cases POP messages will remain on the server for a short while, and not be immediately deleted, so they should be re-retrieved when you open Mail again. In addition, I don’t recommend this for recovering long-lost e-mails, but rather only in instances where some action you just took resulted in the loss of a lot of emails.

      However, this is why preserving the current Mail folder is important, and also that you do not delete it until everything checks out to be there. In addition, if you have only lost a few newer e-mails, then you can get them back from Time Machine within Mail.

  2. A.R.C.

    Curious as to why you could not just do a regular command-v paste of the ~/Library/Mail folder as opposed to the Shift-Option-Command-V method you described . Wouldn’t that negate the permissions problems?

  3. Levi Blumenfeld

    Thanks so much, I just went thru the process and worked very well! I thought I lost all my emails after making the mistake of updating my existing IMAP account with new gmail IMAP, that erased all my old messages, so I followed your instructions and got them back, thanks again!!

  4. caverac

    Thanks for this posting. Unfortunately it didn’t work in my case. After I went through all the steps and opened mail, it seems like all the content of the Library > Mail folder gets removed.

    Don’t know how relevant is this, but I’m trying to restore my emails from a backup I made ~2 years ago. Are these steps the same even if a different OS version was used in the Time Machine?

    1. Filo

      Hi caverac

      do everything he said but with your computer offline. When you restart Apple Mail you should be able to see all messages, restored.

      Select the folders you want to keep (those containing the deleted messages), and go to Mailbox – Export Mailbox. Save the file on the desktop or wherever convenient for you.

      Then reconnect the computer to internet and let all your messages disappear again.

      Go to File – Import Mailboxes.

      Select the previously exported file and let it import it.. you should have everything back again under the On My Mac – Import – mbox folder.

      Select all, mark as read, move them to the destination folder (should be the same one which contained all the messages you deleted by mistake) and you should be up and running again!

  5. Mark

    Hi.

    I having difficulty to get started with this procedure because when I follow the path as you have written, (Backups.backupdb > ComputerName > Latest > Macintosh HD > Users > username > Library) there is no Library folder within the username. There are only the following folders within the username folder: Applications, Desktop, Documents, Downloads, Dropbox, Google Drive, Movies, Music, Pictures & Public.

    In the Macintosh HD Folder, there is a Library Folder. However it does not contain a Mail Folder either.

    I do know that my emails are stored somewhere because if I enter Time Machine from within the Mail app of the computer which had originally created the backup, they can be seen in the Star Wars reminiscent display of Time Machine. However, as you had written in the beginning of your article, restoring the mails that way simply did not work as not all of them were recovered. (viewed yes, recovered no)

    My intention is to re format the computer which had created the backup and once I do, I simply do not trust that Time Machine will restore all emails. Therefore, I would like to achieve it in a manual way as you have instructed. Unfortunately I can not get past the first step for the reason I have described above.

    I would greatly appreciate some help with this.

    As a side note, I have read that it is possible to browse a Time Machine backup disk from a computer which did not create it by clicking on Time Machine and pressing the alt key. This gives you the option to “Browse other backup disks” Although I am being given the option to do so, this option does not work either.

    While the concept of Time Machine seems like a great one, it seems that I can not trust it to perform the basic tasks for which it was created.

    Again, I would appreciate some help.

    Thanks.

    1. xAirbusdriver

      Sounds like you may have added your user Library to the “Exclude list in the Time Machine Pref Panel, or something else did. Open that Pref Panel, click the “Options…” button and check the list there. I suppose it’s possible that you are backing up another user account and added the “Library” of your Admin account accidentally to the “Exclude” list?

      1. Lu

        I have the same problem that Mark described and I didn’t exclude any folder from the options in TM. Is there any chance to recover my Library folder? or I lost all my mails because of this failure?Is the first time that I used the TM instead the Carbon copy and very worried about. Does anyone knows how to solve this? Thanks

  6. Claudia Miro

    I tried all the steps but still getting the permissions error message when I try to relaunch mail…:(

  7. Rietta

    I have the exact same problem as @Mark (no “Library” in the username accounts)…can’t find a file with the word Mail in it anywhere. @xAirbusdriver, there is nothing excluded from backup in the Options folder (other than the backup drive).

    OS X Yosemite 10.10.2, MBP late 2013 model.

    Would really appreciate any help – Mail just lost all my emails, was able to rebuild the ones that were still on the mail server, but had a large old account that was no longer on a server. Seems very odd to me that there’s not a way to find and reconnect the emails right on the machine (I’m sure they’re still there, just not recognized by Mail) but all the things I see say to restore from Time Machine.

  8. xAirbusdriver

    @Rietta

    To see the “Library” of your user account:
    1. Open a Finder window if one is not open
    2. Select the “Go” menu (click once)
    3. Press and hold the ‘option’ key
    4. Just below the “Home” item there should now appear a new item called “Library”
    5. Select that (Library) item and it will open a new Finder window displaying the Library directory for that user.

    To keep that Library available, without the Go / Option key / Select ‘dance’, simply click and hold the “Library” icon shown in the Path bar, to the Side Bar of the open Finder window. If you don’t see a Path Bar, click the View menu and select the “Show Path Bar” item.

    Hope this helps, at least to find/see/use the users Library. 😉

  9. Rietta

    Thanks @Airbusdriver, much appreciated. I had found that but what I can’t seem to make it do is go to the library on the backup drive :-(. It does however open the Library on my main Mac, which is good. By laboriously searching through there, I have indeed confirmed that those old emails are at least partially there (which probably means all there). I just don’t know how to connect them to Mail.
    Other things I have read about restoring lost mail accounts tell you to go through Time Machine (rather than there being some sort of a “reconnect” facility on the Mac itself)…hence the dilemma with not being able to access the Library on the backup drive.

    So appreciate your help and speedy reply!

  10. Krissz

    Thanks! It helped after my MacBook Pro broke down and received a loan machine from the local iStore which I used during the repair of mine. Since the new TimeMachine backup file just did not want to work?!?!?! with my machine, I had to do the restore manually, as written above.

  11. Jeremy

    Thanks, good article. I had completed lost all emails on both Apple mail and web server / host. Following your article I managed to copy all emails back but then Apple Mail sync’d with web server / host and effectively deleted them all again (i use a google mail account) so back to square one!

  12. M Ratcha

    Hm – I’m on Snow Leopard, and there is no directory in my Library called “Containers.” Also, cmd-opt-shift-paste didn’t work, and I had to select just plain Paste from the Finder’s File menu.

  13. Junior Ferney

    Worked perfectly, Time Machine allowed me to Restore and that was it. Pure Bliss to see my mailboxes full again like they were yesterday!!!!!!!!!!

    Thanks so much!!!!!!!!!!!

  14. Lori Dunn

    On OS 10.10.5. I thought I was going along fine and was so excited to be able to restore all the emails that used to be in my folders that disappeared 3 weeks ago. But when I got to “Containers > com.apple.mail > Data > Library > Preferences”, I got stuck. I don’t have that under “Containers”. There is “Containers > com.apple.Preview > Container.plist” or “Containers > com.apple.TextEdit”, or “Containers > com.sharpened.FileViewer”. There is “Data > Library > Preferences” under each of the 3 “Containers” but none have “com.apple.mail.plist”.

    I don’t know where to go now or how to undo this, which I am assuming I would need to do if I can’t proceed. Please help me out with this. Thanks!

  15. Lori Dunn

    I searched again, using Spotlight and going through files that would seems like they might have com.apple.mail.plist but I can not find it anywhere! Can someone please direct me to where I need to look for it, or what the next step is? I am stuck! Thanks.

    1. xAirbusdriver

      First, I’m a little confused about where you are searching; in Time Machine or your local drive(s)?
      You should be looking in your Home folder Library. There are actually three different folders named “Library”, but the one you want is in your home folder. The easiest way to get there is to look for the little “house” icon in the side bar of an open Finder window. Click on that and look for a folder icon labeled “Library”.
      Do you have the Containers/com.apple.mail/Data path there? If not, what do you have?

      Secondly, with a Finder window as stated above, you should now “Enter Time Machine”. That will get you started in the basic area of the back up. From the ‘time line’ on the right-hand side of the screen, select a date that is at least a few months back. Do you see the Containers/com.app.e.mail path yet? If not, try going back a few more months. Please let us know if you can find this path in Time Machine.

      1. Lori Dunn

        I apologize. I lost my link to this message for a while and then trying things on my own when I’ve had time. But I have not been successful at all. At times, I received error messages that Mailboxes could not be copied as it was the same name as a folder on the destination drive, V2 could not be copied as it was the same name, etc. so I would delete the latest backup and do it again.
        I have Library listed in the Side Bar on my drive, and I can open Containers/com.apple.mail/Data/Preferences, etc.
        In Time Machine, from today back to 09.15.2015, it is Containers/com.apple.mail then the folders Container.plist and Data and under Data are Desktop, Documents, Downloads, Library, Movies, Music, Pictures. However, from 09.08.2015 back to 12.10.2014, it is different. The folders under Containers are: com.apple.Preview, com.apple.TextEdit, and com.sharpened.FileViewer. Under all 3 of these are Container.plist and Data, then the same folders under Data as until 09.15.2015.
        It was around the beginning of September when I lost all the saved messages that were in my email folders, when replacing/updating my computer.
        I am sorry if this is confusing but I don’t know how else to explain it. And evidently I do not know how to attach a screen shot, since it did not work.
        Can you provide any insight or assistance? I have absolutely no clue on what happened to lose all my saved messages, how to recover them, or if they even can be recovered. Thanks.

  16. Jan

    This procedure worked perfectly for me in Mavericks. I had to only make the Library visible before making a backup (chflags nohidden ~/Library) – to be executed in Terminal.
    However it doesn’t work in El Capitan. How to import all messages and accounts to El Capitan from a backup made in Mavericks?

  17. Richard

    The problem for me is that the user Library backup on the TM is hidden when going thru the Finder. I have opened the “live” user Library directly on my HD and, yes, when I enter TM using the “Star Wars” interface I can access the user Library backup. If I try to restore the Mail folder from there it will not allow me to do so because I do not have permissions to change info.plists. Again if I just access the Backups.backupdb directly through the Finder, the user Library file on the TM remains hidden. I have tried to access thru a GO TO file path but it is too long and convoluted to get it absolutely correct.

    I’m afraid I’m going to have to attempt a complete Restore using the TM interface, but I was dreading this because it takes dozens of hours to complete and I’m convinced I have some corrupted files in there, which is why I opted for the clean install to begin with.

  18. Richard

    Update: OK, after restarting the unhide terminal command kicked in. I can now see and copy the Mail folder in the Finder in the Backups.backupsdb folder. HOWEVER, when I do this I still get the message “The operation can’t be completed because you don’t have permission to access “Info.plist”.”

    How do I overide this? I cannot move, copy or steal these files off of my own TM.

    1. Bob Dobbs

      You can manually access Time Machine backups via root user in terminal (see Apple Support “Enabling and using the root user in OS X”) …OR … you can gain access to Time Machine folders that are otherwise inaccessible via the current user by setting the Ignore Ownership flag on the Time Machine volume.

      Apple disallows this from the Get Info window for Time Machine volumes (including those volumes used for Time Machine backups in the past), so you will need to MANUALLY set the Ignore Ownership flag for a volume from the terminal using;

      vsdbutil -d ‘/Volumes/TimeMachineVolume’ [use actual name of your volume]

      You can reverse the setting using;

      vsdbutil -a ‘/Volumes/TimeMachineVolume’ [use actual name of your volume]

      Note: as soon as TimeMachine runs again it will re-enable ownership on the volume.

  19. Blake Chandler

    I deleted my archived emails in gmail not realizing that because gmail uses labels I was deleting all of the emails in my other personal folders. I have had time machine running for months so based on everything I’m reading I should be able to restore my emails, but I have not been able to accomplish this using everything I’ve read online.
    With the mail app closed and using TM I have restored my V3 folder in my library which seems to have about 7500 items. I then turn off my internet connection, open the mail app at which point is imports the items, but I see none of the emails in my personal folders, just about 4500 of the items in my sent folder and such. Because of this I can’t export the mailboxes to then reimport them after syncing with the gmail servers.
    I am desperately wanting to get this resolved. Can anyone offer me any help?

  20. Sara

    This procedure worked great for me as in the upgrade to El Capitan I lost all the offline emails I had created and stored in folders in “On My Mac”. I went to a 2013 backup file (because I knew some of the emails I needed were not on the recent backups) and managed to get all my emails back. The only “problem” is that the folders haven’t replicated – I have nothing listed as “On My Mac” – they’re now all in the iCloud folder. If you have any ideas about what I can do to fix this it would be great – the Genius Bar in Italy where I first sorted this out in early October managed to recover them all and in the folders. Then with El Capitan’s patch in late October it wiped them out again. Went to the Genius Bar in Jacksonville FL but they were unable to recover any of my emails, which is why I ended up searching here. Am very happy to have the emails back, it would be nice if there was some way to get them organized without having to manually sort them…

  21. Zee

    This worked perfectly – thank you! And I couldn’t have done it without the app “Invisibility Toggler”, which allowed me to access my user library on my El Capitan Time Machine backup. Hurrah!

  22. lazy

    Hi there, I just want to chime in here and totally agree with A.R.C. above.

    There is no need to do the whole Shift-Option-Command-V method.

    Copy and Paste works perfectly with no permissions errors. At all.

  23. Jonathan Payne

    This excellent tutorial didn’t work for me. I got all the way to the last step and fired up Mail and there are no mailboxes at all.

    I have a different user ID than I had before, but I chown’d the files and that all seemed OK.

    My internet accounts are not set up of course, so maybe Mail tried to get back to its previous state but couldn’t find my accounts or something?

    I tried just importing the Mailboxes folder into Mail, which it did, but that resulted in strange layout in Mail and a bunch of duplication.

    Any thoughts?

    1. Tash Bickley

      Hi Jonathan,

      I have the same issue and I also changed my user Id. Did you resolve the issue of no mailboxes showing up? Can you outline how you fixed the problem.

      Thanks,
      Tash

    2. Jay

      I did everyone as instructed on the instructions, but now when I open mail there is nothing there.

      I also tried doing all entirely off-line, and that also did not work.

      My entire Mail folder is copied into the proper new location, and I also replaced the com.apple.mail.plist with the previous one as instructed.

      Don’t know what the problem is.

      This is a new computer, my previous one was stolen, so I am going from my last Time Machine back up and just want to get the all my previous email from like the last 8 years! Not anything else as that machine had a bunch of crap on it.

      I do have a different username this time for this new computer. Could that be problem? IS there a solution?

      Any advice would be most appreciated. Spent like a whole day on this to no avail. 🙁

  24. Jim Carruth

    Topher,

    You saved my bacon with this solve! After erasing my hard drive because I accidentally pushed the wrong button using Disk Warrior, making my disk case sensitive instead of case insensitive, none of my programs would work any more, including Time Machine. I had to erase the hard drive, and do a restore from Time Machine. It didn’t restore my Mail however, and this was quite disconcerting to me, since I use it for business, and had taken years to set it up with mailboxes, and had over 5 GB of saved e-mails, including sent e-mails which I constantly refer to, going back to 2006.

    After an anxiety-ridden day of amateur repair attempts, and countless calls to my local Mac repair shop, who generously helped me each time I called, I was able to fully restore my computer. Even Mail was restored – for a little while. Then all of a sudden, it reverted, losing all my mailboxes and 5 GB of stored e-mails. It inexplicably went down to 3 MB.

    After yelling at an Earthlink support person, thinking it was his fault for some reason (the settings had changed after the restore, and I mistakenly assumed this was the cause of losing my restored Mail), I asked Mr. Google for help. I came upon your article, and, as I said, it completely saved my bacon.

    A big thank you to you, and a shout out to my repair friends at Di-No computer in Pasadena, CA for their generous help and support. Computer and sanity are restored once again.

    With thanks and gratitude,
    jcarruth
    Pasadena, CA

  25. gclub

    A big thank you to you, and a shout out to my repair friends at Di-No computer in Pasadena, CA for their generous help and support. Computer and sanity are restored once again.

  26. PhilippB

    Did anyone ever find a solution to the Library not showing up in the proper folder in the timemachine backup? Or could someone elaborate on the mentioned “unhide” command?

    1. lkgeo

      I was able to see the Library folder in my TM backup (and all other hidden folders on my Mac) by following the instructions in http://www.macworld.co.uk/how-to/mac-software/how-show-hidden-files-in-mac-os-x-finder-funter-3520878/. When finished, the same article describes how to re-hide them.

  27. piece garage

    Can I just say what a comfort to find a person that really knows what they
    are discussing on the internet. You actually realize how to bring a problem
    to light and make it important. More and more people have to check this out and understand this side of your story.

    I was surprised that you are not more popular given that you most certainly have the gift.

Comments are closed.