How to manually restore your Mail folder from Time Machine

If 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.

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.

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 > > Data > Library > Preferences
  2. Locate the file called “,” 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 > > 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.

The Mail preferences file to replace will be in subdirectories contained in the Containers > 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.


Mac Issues

At Mac Issues, we're dedicated to helping you learn how to use your Macbook properly. With tutorials, how-to troubleshooting guides & real reviews, hopefully we can make your day that little bit easier.

Read more from Mac Issues