Lost mail rules when upgrading to ML, can't restore from time machine

Hi,

I've installed mountain lion and restored from time machine and mail rules were not there. There's only news from apple.

I tried to restore the rules myself (MessageRules.plist and MessageRules.plist.backup) but when opening mail rules were not there yet. Nevertheless, i can add rules manually, so if there was a way of looking at the past rules I could just copy them (though it's not the best way).

Apple Mail-OTHER, OS X Mountain Lion

Posted on Jul 26, 2012 3:51 AM

Reply
55 replies

Apr 29, 2013 12:25 PM in response to lotdrops

The topic of losing Mail Rules never seems to go out of fashion. My circumstance - I already had Mountain Lion running on all my Macs - is somewhat different than the upgrading cases above however, so I am going to post the solution here.


I lost my Rules when I (foolishly) deleted them from my (mobile) MacBook Pro in a moment of whimsey while on a business trip. (I thought that my iCloud syncing of the Mail application was turned off, and hence there would be no pathway to sync this change with my iMac at home.) The exact context of my stupidity is not as important as is the restoration process for Rules in the case where you have inadvertently deleted them via iCloud and have consistent backup - I use Time Machine. The following assumes that you know how to access your account Library (it's hidden in the Finder's Go list under ML unless you hold down the Option key). In my case, my primary email server (account) was not with iCloud but rather with another ISP, but both were active.

  1. Quit Mail
  2. Open ~/Library from the Go menu in Finder as described above
  3. Navigate to the ~/Library/Mobile Documents/com~apple~mail/Data folder using Finder.
  4. Restore ~/Library/Mobile Documents/com~apple~mail/Data/MailData from a date when the Rules were intact, i.e. as soon as possible before the Rules deletion misadventure.
  5. Re-launch Mail

Examine your Mail/Preferences/Rules to verify that your former Rules have been restored. (You will need to reactivate them.)


The major lesson/distinction here is that, when the loss of your Mail Rules is between computers on both of which you maintain an iCloud account, it is because Mail preferences - e.g. Rules - apply across all your Mail accounts and will be propagated as long as those accounts are active on both machines and iCloud synching is turned on.


The major remedy provided here is that you can restore Mail preferences from a backup source by restoring

~/Library/Mobile Documents/com~apple~mail/Data/MailData from an earlier version.

Aug 31, 2013 10:22 AM in response to blainetransue

Big thanks to everyone who contributed to this thread, especially blainetransue and Karabuni for your clear and well-written instructions! My (extremely important to me) mail rules vanished when I switched from a 2009 Unibody Macbook with Snow Leopard to a late 2012 MPB with Mountain Lion earlier this month. Apple told me that the only recourse was to recreate my rules from scratch, and when I pointed them to this discussion thread, they refused to talk to me about it. But thanks to you all, I was able to overcome my near-total ignorance of programming to reconstruct my rules, and they are working like a charm!


I used blainetransue's copy and paste method and incorporated Karabuni's edits into it. I also included a line about "send notification" that someone else suggested. I did also fix the indentation, as the rules I copied from MessageRules.plist were tabbed differently from the rules that already existed in SyncedRules.plist. Someone here mentioned that the tabs do nothing but help make it more comprehensible to humans, but it helped me, so I went ahead and did it, even though it took some time. I also did one rule at a time, copying it from MessageRules.plist, pasting it into UnsyncedRules.plist, then making my edits. After every rule, I saved the plist and launched Mail to see that the rule had appeared, and it did! All I had to do was click to make it active, and my inbox was back in business! (And when I went back to UnsyncedRules, the code I had just copied had moved to SyncedRules.) Overall, it took me a while to do this, but I feel confident about the results.


I'd like to add a little clarification, for any other non-programmers (like me) who may encounter this thread. When I first read blainetransue's explanation and looked at the plist files, I was a little unclear about what exactly constituted one complete, user-defined rule, especially since there were <dict>s and <array>s all over the place, and I wasn't sure where to start and end my copying. I'm sure this was all obvious to everyone else here, but it took me a while to sort it out. Since I've figured it out, I'm going to post one complete rule as it ultimately appeared in my SyncedRules.plist and mark the edits I made. Red marks the edited items, and blue marks some explanatory notes that don't appear in your code. The table appeared when I pasted it here, you won't see it in text editor. Hope this helps someone in the future!



Put your cursor before this <dict> to start copying

<dict>This part is the "introduction" of your rule
There may be a few lines above AllCriteriaMustBeSatisfied - delete them
<key>AllCriteriaMustBeSatisfied</key>
<string>NO</string>
<key>AutoResponseType</key>
<integer>0</integer>
<key>Color</key>
<integer>9158119</integer>
<key>Criteria</key>
<array>These are the individual criteria of your rule
<dict>
<key>CriterionUniqueId</key>
<string>87fecbae-7e2f-49f3-804f-27306d5d3746</string>
<key>Expression</key>
<string>@enews.apple.com</string>
<key>Header</key>
<string>From</string>
</dict>
<dict>
<key>CriterionUniqueId</key>
<string>79488e19-a69c-4be8-b5ca-3854ce992ba3</string>
<key>Expression</key>
<string>@apple-asia.com</string>
<key>Header</key>
<string>From</string>
</dict>



</array>
This part is the "conclusion" of your rule
<key>Deletes</key>
<string>NO</string>
<key>HighlightTextUsingColor</key>
<string>NO</string>
<key>MarkFlagged</key>
<string>NO</string>
<key>MarkRead</key>
<string>NO</string>
<key>NotifyUser</key>
<string>NO</string>
<key>RuleId</key>
<string>9C9E414F-ED65-4B13-AEF2-FFC5B92FC8FC</string>
<key>RuleName</key>
<string>News From Apple</string>
<key>SendNotification</key> - add these two lines here
<string>NO</string>
<key>ShouldCopyMessage</key>
<string>NO</string>
<key>ShouldTransferMessage</key>
<string>NO</string>
<key>StopEvaluatingRules</key>
<string>YES</string>
<key>TimeStamp</key>
<integer>254102125</integer> - switch "string" to "integer"
<key>Version</key> - add these two lines here
<integer>1</integer>
</dict>Put your cursor here to end your selection.



The end of the UnsyncedRules.plist file, that you are pasting into, looks like this:


</dict>

Place your cursor here, when you paste.

</array>

</plist>



I know one of you created a program to automate this editing process, but that was a bit beyond me, so I just did it the slow, manual way.


Many many thanks again to everyone who contributed! I've really learned a lot in the last three days and I couldn't have done it without you. And my rules are back - hooray!!!

Mar 2, 2014 7:55 PM in response to lotdrops

Updating this entry for Mavericks: I recently moved directly from Lion to Mavericks. Smart mailboxes now seem to be migrated automatically; but rules are not. I can't speak to signatures since I didn't have any.


The procedure outlined by MNCrowe works on Mavericks just fine. Some earlier notes suggested modifying the SyncedRules.plist file directly. I had trouble doing that - the old version kept coming back when I restarted mail - so I instead added my rules to UnsyncedRules.plist, as suggested here. In fact, looking back, my problem was most likely that I had a edit - an extra <dict> that spoiled the syntax of the file. However, I'd still suggest modifying UnsyncedRules.plist, as it's smaller - the only thing you'll likely find in there is a built-in rule to handle junk mail (which may not be present if you don't have junk mail filtering enabled). When Mail starts, it will move all your rules from UnsyncedRules.plist to SyncedRules.plist anyway.


Both Lion and Mavericks rulesets contain "magic" junk mail rules that you won't see in the list of defined rules. They are easy to recognize in the .plist files because they have entries of the form:


<key>IsOneAndOnlyJunkRule</key>

<string>YES</string>


I deleted my Lion junk mail rule when copying. Since others didn't do that, Mail presumably just silently cleans this up.

My Lion ruleset also had a similar "magic" rule marked as "IsOneAndOnlyICalRule". I deleted that one, too. It turns out that this implements the preference setting "Add Invitations To Calendar"; it re-appeared (perhaps in a Mavericks-specific form) in UnsyncedRules.plist when I set the preference to Automatically.


-- Jerry

Mar 6, 2014 5:46 AM in response to leichter

So glad to hear it works on Mavericks! I've been avoiding Mavericks because I was afraid I would have to go through all that again. But you went straight from Lion to Mavericks without going through Mountain Lion, right? So maybe there is hope for those of us already using Mountain Lion. In any case, I'm going to wait till I have some free time to even consider that upgrade.


Glad that method worked for you!

Aug 23, 2015 2:28 AM in response to lotdrops

Hi,


So I have the same issue and I realise this preference folder, was storage in iCloud.

As I have two iCloud account, I lost access to my rules, signatures and smart folders when changed my iCoud account from System Preferences.

Sign in back to my original account fixed the issue.

I think you can save this folder ~/Library/Mobile Documents/com~apple~mail/ while connected to the correct iCloud account, then sign in to your second iCloud account if you have two account too and restore this folder (while mail is not open)

Feb 28, 2016 11:47 AM in response to Keith Thirgood

Just to clarify, as there seem to be several different solutions but not all scenarios are fixed by each solution:


I am using 10.9.5, iCloud is On (the Mail option is off) - Documents & Data are selected.


Everything was working fine until I started to migrate to a 2nd machine (via a cloned drive), at some point I may have had Mail running on both computers.


Sinatures & Rules "disappeared". (The plist files were still there, just not being used.) Turning Off 'Documents & Data' provides a temporary solution.


However this post fixed it for me:

https://www.quora.com/How-do-you-transfer-Rules-in-Apple-Mail-7-from-one-machine -to-another


How do you transfer Rules in Apple Mail 7 from one machine to another?



My web search has been fruitless. When I copy the apparent rules files,
(RulesActiveState.plist SyncedRules.plist UnsyncedRules.plist) to ~Library/Mail/V2/MailData they get overwritten by the previous copies when I restart Mail. Clearly the rules are being synced and stored somewhere, but I can't find where. I don't want to manually re-create all these rules. What's the process?


1 Answer



User uploaded file


Craig Good, Teller of stories, many of which are true.


1k Views



Found the answer to my own question, so I may as well share it here.

So you got a new Mac, and want to port your Rules from Mail from your old machine to your new one. But when you copy the files from MailData they get overwritten when Mail.app starts up. Well, here's where having Unix under your GUI pays off. Thanks to the find command I figured it out.
Here’s how to get your rules AND your signatures ported over:
Quit Mail on the target machine.
Log out of iCloud on the target machine. (This may prove difficult. I had to force quit System Preferences and reboot the machine at various times because it wedged up.)
Look in ~/Library/Mobile\ Documents/com\~apple\~mail/Data/MailData for
ubiquitous_SyncedRules.plist
ubiquitous_SyncedSmartMailboxes.plist
and a folder called Signatures
Copy them from the source to the target machine.
Log back in to iCloud. If it refuses to set up Mail, reboot.
Start Mail.
Enjoy your Rules.
(Remember to turn them off on the old machine.)


The only additional steps I took were to restore the MailData folder of the same date to avoid any incorrect reference issues.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Lost mail rules when upgrading to ML, can't restore from time machine

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.