I don't know if it has any caveats or risks, but you can also use bypass to delete files on backups:
sudo /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass rm -rf /Volumes/*/Backups.backupdb/*/*/*/Users/$USER/Documents/folder
Yes, you can use the "TM Safety Net" helper bypass
to bypass the ACL restrictions allow you to use rm
the way you normally would. Except, of course, Time Machine uses "hard links" so rm
does not entirely work the way you normally expect it to work.
The bypass
program is not meant for people to use and can be hard to find, and it has moved around in various versions of OS X. I find it using this command:
locate TMSafetyNet.kext | grep bypass
Then you use it to authorize rm
sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rf /Volumes/Backups/Backups.backupdb/Mac/2015-04-09-072338/Macintosh\ HD/Users/bmike/Pictures/Photos\ Library.photoslibrary
Keep in mind, as mentioned, that because of the way Time Machine uses hard links of directories, this rm
command can remove the file from other backups. I would not recommend using it unless you are trying to remove the file from all backups.
In fact, in general, I would not recommend using hidden commands like this. Use the GUI as Apple intended. Of course in this specific case, where you have a lot of computers to execute the same command on and you fully understand the impact of hard links, then go ahead.
If you are going to script this, your script should make sure that Time Machine is (a) disabled and (b) not currently running a backup (because unfortunately (a) does not guarantee (b)) before running commands using bypass
. You probably should do that when running commands manually, too.
Best Answer
Remove the
echo
once you are sure that the output is correct.