Terminal Tip: Find out which files won't be backed up

Backing up is one of the most important things you can do on a Mac, and thankfully, it's a pretty trivial affair with Time Machine built right in. Of course, when you're looking at what needs backing up, people often overlook what doesn't need backing up (or isn't, but should be).
A good example of this would be a rented media file, like a TV show rented from iTunes. It's only valid for 48 hours, so even if you do back it up, by the time you've restored your machine after a system failure, it's unlikely to play anyway. In essence, it's wasted space.
Thankfully, OS X has a built-in system of defining what should and shouldn't be backed up using metadata, and for the most part, it happens under your nose without you even noticing. There are times when it would be useful to see what's marked for backup and what's not, however, and that's where we turn to Terminal.
Simply fire up Terminal, and enter this:
sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"
Type in your password, and it'll tell Spotlight to find anything marked with com_apple_backup_excludeItem, which is the 'do not back me up' indicator.
If you happen to spot something you think should be backed up, but is marked as excluded, you can remove the metadata tag with:
xattr -d com.apple.metadata:com_apple_backup_excludeItem yourfilenamehere
Where 'yourfilenamehere' should be replaced with the name and extension of the file you want to remove the 'do not backup' flag from. If you're using Time Machine, be aware that some (often pretty large) files, like virtual memory caches, will get backed up over and over again if deflagged, taking up vast amounts of space on any backup drives.
Share
Backing up is one of the most important things you can do on a Mac, and thankfully, it's a pretty trivial affair with Time Machine...
Add a Comment
I get these:
/Users/Fede/Music/iTunes/iTunes Music Library.xml
/Users/Fede/Documents/iChats/2009-11-04/iPod Photo Cache
/Users/Fede/Desktop/Temp/iPhoto Library/iPod Photo Cache
/Users/Fede/Music/iTunes/Album Artwork/Cache
/Users/Fede/Library/iTunes/iPhone Software Updates
/Users/Fede/Pictures/iPod Photo Cache
Totally makes sense, but I wish they included ALL caches and trashes by default
Why do you want your caches and trashes backed up? These contain "transient" data that can either be recreated (caches) or are no longer needed (trashes).
April 12 2011 at 10:10 PM Report abuse Permalink rate up rate down ReplyThat list (which contains excluded elements) *includes* *some caches*, I wish that list included *all caches*. Basically I don't want ANY cache to be backed up *by default*.
Sorry for not being clear from the beginning
The reason that time machine dose not back up the iTunes Library.xml file is because that is redundant data that can be recreated using the iTunes Library.itl file. The ITL file is the real database that stores your playlists and ratings, the xml is just there so that third-party applications can also access that data.
Reference: http://support.apple.com/kb/ht1660
Seems like a somewhat strange endeavour if you ask me. This sort of functionality is in the TM prefpane already and anyone who wanted to be able to exclude files from being backed up through Terminal would probably be running their own rsync daemon.
April 12 2011 at 10:34 AM Report abuse Permalink rate up rate down ReplyDeals of the Day
more deals- Used Apple Magic Mouse for $36 + $4 s&h
- Apple TV Media Receiver for $90 + free shipping
- 9-Piece iPhone Bundle, includes 1,900mAh battery for $8 + free shipping
- Skullcandy Riot Earbud Headphones for $10 + free shipping
- Apple Wireless Bluetooth Keyboard for $40 + $8 s&h
- Refurb Mac Pro Xeon Quad-Core 2.8GHz Workstation for $1,150 + $38 s&h, more
9 Comments