10.5: Show files that Time Machine does not back up

Apr 04, '08 07:30:00AM

Contributed by: Anonymous

Leopard's Time Machine is a huge step forward in backup for the average Joe (or Jane). However, one problem is that applications can tell the system to not back up certain files. This is intended to avoid backing up working files, cache files, and such that don't generally need to be backed up. However, we know that VMware, at least, is using the mechanism to quiet exclude virtual machines from being backed up, and others could come. While this makes sense in some ways, it could easily lead to a disaster for those who aren't aware of it happening.

So, with that background, I played around for a few minutes and I figured out how this flag is stored. Turns out that Apple's doing the right thing here and using the metadata store. This means we can find the files with the Spotlight engine. To do this from the command line, do this:

sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"
And you'll get a nice list back. If you're not comfortable with the command line, here's a simple line of AppleScript that you can build into a double-clickable application with Script Editor:

set myItems to do shell script "mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'" > ~/Desktop/Files excluded by Time Machine.txt" with administrator privileges

When you run that script, you'll be asked for an admin login (so that directories other than your home folder can be searched), and the results will be deposited into a file called Files excluded by Time Machine.txt on your desktop.

[robg adds: Note that the output of this command will not reflect any files, folders, or volumes that you've excluded from Time Machine using its preferences panel. As best as I can tell from looking at the mdls output, Time Machine uses an internal mechanism, not metadata, to track those items.]

Comments (32)

Mac OS X Hints