Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create "sticky" Time Machine exclusions System
You can exclude certain files and folders from your Time Machine backups from the Time Machine pane in System Preferences; you can also do this from the command line. Run this command:

sudo tmutil addexclusion [path]

where [path] is a file or folder. For example, if I want to exclude my Downloads folder from Time Machine backups, I would run the following:

sudo tmutil addexclusion ~/Downloads

The tmutil addexclusion command has an interesting property: it's sticky. When you do this, the item you exclude remains in the Time Machine exclusion list even if you move it, which is not the case when you exclude items from the Time Machine preference pane. If you use the above command with the -p flag, then it will not be sticky, and will be the same as an exclusion you add from the GUI.

[kirkmc adds: Updated to correct an error in the post. I've removed the comments that pointed out the error. Sorry!]
    •    
  • Currently 2.64 / 5
  You rated: 2 / 5 (11 votes cast)
 
[5,261 views]  

Create "sticky" Time Machine exclusions | 3 comments | Create New Account
Click here to return to the 'Create "sticky" Time Machine exclusions ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create "sticky" Time Machine exclusions
Authored by: axcess99 on Apr 03, '13 08:15:22AM

This hint is somewhat vague in its description. What does "the item you exclude remains in the Time Machine exclusion list even if you move it" mean. I could interpret that as either if you move the file the actual file will still be excluded or that the original path will be excluded.

From my own experiments:
1) the flag should be lower-case not upper-case, upper-case -P is not (at least by recognized by 10.8, unless this somehow an old flag that does something different than in 10.8)
2) when -p is absent the exclusion is based on setting metadata on the file. The "physical" file itself is what is being marked as excluded. For example, if you were to `tmutil addexclusion ~/Downloads` and then rename ~/Downloads to ~/Downloads_old, Downloads_old is excluded and any new Downloads directory would be backed up.
3) -p makes it exclude by path. For example, if you were to `tmutil addexclusion -p ~/Downloads` and then rename ~/Downloads to ~/Downloads_old, Downloads_old is now being backed up and and any new ~/Downloads directory would not be.
4) using `-p` requires root privileges, so you need a root shell or you need to be an administrator level user and need to use `sudo tmutil addexclusion -p [path]`





[ Reply to This | # ]
Create "sticky" Time Machine exclusions
Authored by: kirkmc on Apr 03, '13 08:51:22AM

I've corrected the -P to -p.

See man tmutil for more about this.

---
Mac OS X Hints editor - Macworld senior contributor
http://www.mcelhearn.com



[ Reply to This | # ]
Only works where Spotlight is enabled
Authored by: bankshot on Jun 21, '13 11:02:53AM

First, a little addendum to this hint: to find all files and folders that have been excluded this way, the following command works (perhaps there's a way to do it in the Spotlight gui, but just typing the term into the search box didn't work):

mdfind "com_apple_backup_excludeItem = com.apple.backupd"

The above finally helped me figure out an issue with this tmutil hint that has been plaguing me for several weeks. On one of my volumes, I would consistently get the following error message when doing tmutil addexclusion /path/to/file:

Insufficient privileges to change exclusion setting.

I tried running the tmutil addexclusion command as root (using sudo) and tried some other things, but no matter what, it got the same unhelpful error anywhere on that volume. I had resorted to manually adding the com.apple.backup.excludeItem attribute using the xattr command.

Fast forward to today when I was investigating another Time Machine error - I discovered that it had been randomly failing to backup or stopped backing up large portions of my iPhoto library (my iPhoto library resides on a large external disk - the same volume in question). I used the mdfind command to verify that the affected files/folders weren't being excluded, and noticed that no exclusions on the affected volume showed up at all - not even ones that I had manually added.

The lightbulb went off, and I remembered that I had disabled Spotlight on this volume (figured it wasn't worth it since I was going to be mostly storing large, non-searchable data on it). I reenabled Spotlight and suddenly the tmutil addexclusion command worked. Additionally, the next Time Machine backup finally included my entire iPhoto library for the first time (good thing I didn't need that backup before now!).

So the moral of the story is, never disable Spotlight on a volume you want to backup with Time Machine. It will prevent the tmutil addexclusion command from working, but more importantly, it will prevent Time Machine from making a complete backup of that volume (perhaps I should submit a separate hint about this second part since it's pretty important!).



[ Reply to This | # ]