Skip to Content

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.



Categories

Apple Mac OS X

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

*0 / 3000 Character Maximum Comment Moderation Enabled. Your comment will appear after it is cleared by an editor.

9 Comments

Filter by:
bayxsonic

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

April 12 2011 at 6:53 PM Report abuse rate up rate down Reply
2 replies to bayxsonic's comment
aamartin

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 rate up rate down Reply
bayxsonic

That 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

April 12 2011 at 10:14 PM Report abuse rate up rate down Reply
Kyahx

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

April 12 2011 at 11:27 AM Report abuse rate up rate down Reply
treelo

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 rate up rate down Reply
4 replies to treelo's comment
Buy an ad here

Tweets

© 2012 AOL Inc. All Rights Reserved.