Time Machine not respecting extended attributes flags

Discussion in 'macOS' started by jw2002, Mar 1, 2009.

  1. jw2002 macrumors 6502

    Joined:
    Feb 23, 2008
    #1
    I have seen in several places online that you can set the extended attribute of file or directory to keep it from being backed up. This would be a useful feature for me in preventing various .targets directories in my many Subversion snapshots from being backed up. These .targets directories just hold .o and .a files and are not worth backing up because they are easily regenerated during compile time and do nothing but waste space in a back up.

    So anyways as an experiment I set a .targets directory to not back up according to what is claimed online:

    Code:
    % cd /data
    % ls -ld .targets
    drwxr-xr-x@ 4 jw2002  wheel  136 Sep 29 19:50 .targets
    % /usr/bin/xattr -w com.apple.metadata:com_apple_backup_excludeItem com.apple.backupd .targets
    % /usr/bin/xattr -l .targets
    com.apple.metadata:com_apple_backup_excludeItem: com.apple.backupd
    
    Then I went into Time Machine, pointed the window to the right directory, and deleted all backups of .targets. (Note that I set my Finder options to show hidden files). I then performed a Time Machine backup, and the .targets directory still got backed up!

    Code:
    % cd "/Volumes/Backup of blort/Backups.backupd/blort/Latest/Macintosh HD/data"
    % ls -ld .targets
    drwxr-xr-x@ 4 jw2002  wheel  136 Sep 29 19:50 .targets
    % xattr -l .targets
    com.apple.metadata:_kTimeMachineNewestSnapshot:
    0000   62 70 6C 69 73 74 30 30 33 42 2D 63 C3 7F 00 00    bplist003B-c....
    0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................
    0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0030   00 11                                              ..
    
    com.apple.metadata:_kTimeMachineOldestSnapshot:
    0000   62 70 6C 69 73 74 30 30 33 41 AE B6 F2 9A 00 00    bplist003A......
    0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................
    0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0030   00 11                                              ..
    
    com.apple.metadata:com_apple_backup_excludeItem: com.apple.backupd
    
    So not only did Time Machine ignore the metadata that I added, but it added its own with respect to backup times.

    Can anyone suggest what I might be doing wrong here? Do I have the metadata keywords spelled wrong? Or are the metadata not consulted for hidden files?

    I would really like to exclude these directories from backups because they amount to several gigs of constantly changing files that are simply not worth backing up. I was hoping to go the metadata route rather than manually adding these via the Time Machine preferences. I guess I could have a script add them to the com.apple.TimeMachine.plist...

    Thanks.
     
  2. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #2
    I used:

    Code:
    xattr -w com.apple.metadata:com_apple_backup_excludeItem com.apple.backupd somefilename
    My testing indicates that this prevents all files from being backed except for files that started with a ".".

    S-
     
  3. jw2002 thread starter macrumors 6502

    Joined:
    Feb 23, 2008
    #3
    Thanks for the help. My guess is that this has to do with spotlight not cataloging files beginning with a "." dot. The backup process probably performs the equivalent of

    Code:
    % mdfind "com_apple_backup_excludeItem == 'com.apple.backupd'"
    
    to determine the additional excluded files/directories. And mdfind of course can never return a hiddne file as a result. It looks like my only recourse is to add the desired .targets directories to the .plist file.
     

Share This Page