I want to delete some files/directories from my Time Machine Partition using rm, but am unable to do so. I'm pretty sure the problem is related to some sort of access control extended attributes on files in the backup, but do not know how to override/disable them in order to get rm to work. An example of the error I'm getting is:
% sudo rm -rf Backups.backupdb/MacBook/Latest/MacBook/somedir
rm: Backups.backupdb/MacBook/Latest/MacBook/somedir: Directory not empty
rm: Backups.backupdb/MacBook/Latest/MacBook/somedir/somefile: Operation not permitted
There are a number of reasons I do not want to use either the Time Machine GUI or Finder for this. If possible, I'd like to be able to maintain the extended protection for all other files (I'd like not to disable them globally, unless I can re-enable once I've done my work).
Best Answer
To work around "operation not permitted" errors, use the Time Machine Safety Net "bypass" program:
In 10.8 Mountain Lion, bypass moved into 'Helpers':
In 10.10 Yosemite, bypass moved here:
Beware when using this to delete specific snapshots: as Time Machine uses hard links, using
rm -r
on folders might also affect older and newer snapshots of the same machine. (See other answers referring totmutil delete
to safely delete a specific snapshot.) Usingrm
to delete all snapshots for a single machine is okay though. And so is usingrm
to delete a specific file, which will only remove that hard-linked file from the snapshot(s) you specify, assuming the file is not in a hard-linked directory as then you'd actually remove the file from all those hard-linked directories.