Mac – How to move files or directories marked as a backup

backupcommand linefinderterminaltime-machine

I'm trying to move some files out of my Time Machine backup to a new location on the external drive (outside of the Time Machine folder) that is in use for Time Machine. I want to do this (as opposed to just copying from the original) primarily to retain all the hard links, not only between files under the directory I am moving, but also to previous backups, so I only maintain a single copy of everything. Also, I don't have enough free space to make an additional actual copy! But when I try to move the folder from Finder, I get the error:
"The operation can’t be completed because backup items can’t be modified."

When I try to do it from the command line using mv I get the error: mv: rename [...] to [...]: Operation not permitted

I read this question where in an answer it was explained that the "bypass" utility supposedly "allows you to supply a command and argument to completely bypass the access restrictions."

However, while I found this to work with the rm command, it failed with the same error as above when trying to move a directory.

Update: It appears that if I type the full path to both the source and destination, then it works. But even when it is outside the backup directory, the system still somehow knows it is a "backup" file, causing trouble trying to use it as a normal file. How can I get rid of the "backup" bit or whatever that is making the system think it is a backup?

Best Answer

If you list a file inside the TM backup with the Terminal command ls -l@, you'll see that it has extended attributes:

$ ls -l@ "iTunes Library Genius.itdb"
-rw-r--r--@ 22 admin  501  94208 Sep 17  2013 iTunes Library Genius.itdb
    com.apple.metadata:_kTimeMachineNewestSnapshot     50 
    com.apple.metadata:_kTimeMachineOldestSnapshot     50 

I guess you'll have to remove those from the files that you moved outside the TM backup folder. I haven't tried that myself, though, as I do not want to mess with my backups :)

To remove these attributes, use the attr command with the "c" option, like this:

xattr -c /path/to/file

You may have to use the bypass command for that again.

Let us know whether that works.