How to restore your Apple Mail rules from Time Machine backup in El Capitan

I have an elaborate set of rules that manage my work email.  Due to a buggy plugin, I lost them recently.  After a few moments of panic, I started researching.  After piecing together what I found on the Interwebs and knowledge I’d gained while debugging said buggy plugin, I found a safe, reliable way to restore mail rules with or without iCloud sync running. *

  • Quit Mail if it’s running, just to be safe
  • Open ~/Library/Mail/V3/MailData (Select the Go menu in the Finder and hold the option key down to see the Library folder)
  • Click on SyncedRules.plist
  • If you’re syncing your rules via iCloud Drive, do this bit of scariness (if you’re not sure whether you’re syncing or not, open System Preferences > iCloud, click “Options…” next to iCloud Drive, see if Mail is checked.  If it is, you’re syncing rules with iCloud Drive):
    • With sync still on, delete all your existing mail rules (iCloud will try to merge your rules later – this way it’ll merge with nothing)
      • Open Mail
      • Go to Preferences > Rules
      • Select all your rules
      • Click Remove to remove all your rules
        • This deletion will sync to iCloud and your other Macs.  btw, it’s probably a good idea to have any other Macs you sync with on for this just to make sure their rules are kept current.
      • Wait around 5 seconds just in case Mail needs to do something to communicate your rule deletion to iCloud
      • Quit Mail
    • THEN, turn off iCloud sync:
      • Open System Preferences > iCloud
      • Click “Options…” in the iCloud Drive line
      • Uncheck Mail
  • Restore SyncedRules.plist from Time Machine **
    • SyncedRules.plist still selected?  Good, Run Time Machine
    • Go back in time, looking at the “modified” time of SyncedRules.plist, until the “modified time” is just before you broke your rules
    • Click the Restore button.  If/when prompted, Replace the old broken rules file (I mean, keep both if you want, but it’s probably already in time machine and if you wanted it, you wouldn’t be doing all this)
  • If you’re not syncing with iCloud Drive, you’re done.  If you are syncing with iCloud Drive, turn Mail syncing back on now:
    • Open System Preferences > iCloud
    • Click “Options…” in the iCloud Drive line
    • Check Mail

At this point, you can launch Mail.  Your rules should be in the state they were at the time of the backup file you restored.  You may need to enable the rules (click the checkboxes) – I did.  (If you’re curious, I think the reason is that Mail stores the enabled state of rules in RulesActiveState.plist.  You probably could restore that file from Time Machine above if you had a really specific set of on/off settings you wanted to keep – I didn’t try).  If you sync your rules with iCloud drive, the restored rules should now be synced to your other computers as well – the sync happens within a few seconds (if they were online during this process – if they were off and have stale old rules, they should update to the new rules, but I haven’t tried that).

* In case you haven’t been looking around on the Interwebs, With or without iCloud sync is important because if you just restore SyncedRules.plist, it will be immediately replaced when you run Mail if you’re using iCloud to sync your rules.  (I use “iCloud” and “iCloud Drive” interchangeably here – rules sync happens using iCloud Drive).  If you just turn off Mail’s iCloud sync, restore SyncedRules.plist, and turn iCloud sync back on, you’ll get a merged mess of whatever was in iCloud (e.g. the rules you’re replacing) and the new rules.  The technique in this article restores your old rules and syncs them as is to iCloud (because there’s nothing there to merge).

** SyncedRules.plist stores your rules – I used Time Machine, but if you have a backup copy anywhere, e.g. CrashPlan, you can use that too; we’re just replacing the file with the bad rules with a file that has good rules in it.