7

I'm having problems clearing our a backup drive. I want to get rid of a couple large files so I can preserve the other incremental backups.

I can't use the tmutil delete command on entire backups since I'd lose all files from that interval and not just the offending file I want to purge. Additionally, having a script would mean I could recover space from a whole lab's worth of computers by scripting this from the command line. I also expect that script would let me discover which file in the package the GUI is refusing to prune since I can debug a script easier than I can Finder and the Time Machine interface.

In case this is a simple permissions issue - the library package file/folder:

Mac:~ bmike$ ls -laeO  /Volumes/Backups/Backups.backupdb/Mac/2015-04-09-072338/Macintosh\ HD/Users/bmike/Pictures/Photos\ Library.photoslibrary 
total 0
drwxr-xr-x@ 10 bmike staff  - 340 Apr  8 20:05 .
 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
drwx------@ 28 bmike staff  - 952 Apr  9 09:38 ..
 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
 1: group:everyone deny delete
drwxr-xr-x+  2 bmike staff  -  68 Apr  8 09:07 Attachments
 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
drwxr-xr-x+  2 bmike staff  -  68 Apr  8 09:07 Masks
 0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown

When I use the Time Machine interface, it errors out and I don't know which file or instance has errors:

unhelpful finder error

I'm looking for a way to delete these protected files from all backup intervals in a similar manner to the Finder Gear icon action of Delete All Backups of "Photos Library"

Delete All Backups of "Photos Library"

Is this selective pruning of a file/folder possible across all time intervals with Apple's built in tools, a custom script and/or other tool?

5
  • Great. I wonder why there is no good TM tools (maybe except for BackupLoupe) out there. Is this a sign for a decline in developers interested in the MacOS environment?
    – n1000
    Mar 19, 2019 at 7:09
  • Why can't you do this with just rm? Something like sudo rm -rf /Volumes/Backups/Backups.backupdb/Mac/*/Macintosh\ HD/Users/bmike/Pictures/Photos\ Library.photoslibrary. It might be painfully slow, but it should work. If you need to something more sophisticated than just rm you can use find ... -exec.
    – Old Pro
    Aug 1, 2020 at 2:00
  • @OldPro ACL denies rm and shell globbing an easy win.
    – bmike
    Aug 1, 2020 at 2:20
  • What about using bypass as I only now see you found and linked to? If that worked, please post a quick answer to this question so it is easier to find. Took me 20 minutes. :-)
    – Old Pro
    Aug 1, 2020 at 2:26
  • Bypass is the fix for sure @OldPro
    – bmike
    Aug 1, 2020 at 2:27

2 Answers 2

3

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.

2
  • This is a superb answer to a quite dangerous request - you can be sure I will test this quite a bit before scripting this on more than one machine at a time. Especially that the backup destination is still viable for more backups after the “surgery”
    – bmike
    Aug 1, 2020 at 11:54
  • 2
    I suggest to add: stop TM when you do surgery on its FS bypassing TM.
    – dan
    Aug 1, 2020 at 12:17
1

Here is a way to exclude folders from timemachine.

  • Hold the command key and type the space bar to bring up Spotlight.

  • Type Time Machine and open the system preference (not the application).

  • Click the Options... button in the lower right corner of the Time Machine system preference panel.

  • Click the plus button then navigate to the folder you want to exclude.

  • Click on the Exclude button.

  • Click on Save.

https://www.imore.com/how-exclude-files-time-machine-backups

4
  • This is correct in the general sense, but doesn’t address deleting the files after they have been backed up. The crux of my question is deleting something that’s already protected and exists only on the backup volume. I appreciate the effort to help, though. I don’t see any way this answer can prune pre-existing backups per the title of the question, so I am going to -1 it.
    – bmike
    Mar 10, 2019 at 22:03
  • Your just going to get more of them unless you stop them at the source. This is why I thought it relevant. Mar 11, 2019 at 3:48
  • 1
    Agreed. We've already stopped it. Now we're trying to clean up without losing all the history of all the other files. Basically I want to automate all the clocks to get into time machine and remove one specific folder across several machines.
    – bmike
    Mar 11, 2019 at 22:48
  • It looks like I can use this answer to solve this at long last - apple.stackexchange.com/questions/333767/…
    – bmike
    Apr 20, 2019 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .