I'm trying to delete all backups of specific items through the command line. I can accomplish this using the GUI through the following steps:
- Enter Time Machine
- Navigate to the file to be deleted
- Right click (or click the gear icon in the finder) and choose
"Delete all backups of …"
How can I replicate this on the command line using tmutil
? Especially, when using Backup Loupe to detect large files it'd be easier to use the Terminal (since I don't have to enter TimeMachine at all each time I want to delete a particular file and can navigate to it using the Finder, and then drop it onto Terminal for a command to delete it).
I was hoping I could use something like this:
sudo tmutil delete /path/to/file
however it gives me the error:
"Invalid deletion target (error 22)"`
This works fine:
sudo tmutil delete /Volume/Backups.backupdb/<machinename>
and this too:
sudo tmutil delete /Volume/Backups.backupdb/<machinename>/<specificbackup>
According to man tmutil
the delete
command should also be able to delete specific items. However, I've been out of luck so far. While there are numerous answers on this site (and elsewhere) to delete specific backups with tmutil
and to delete specific backup items through the GUI (using the method described above) I was unable to find any non-GUI way to delete specific backup items.
Best Answer
I found this SU Q&A titled: How can I delete Time Machine files using the commandline which demonstrates a method for deleting specific files from the CLI. This answer highlighted a method that sounds like what you want:
In that answer it was shown that one could use this method to delete a file:
The method to delete the file uses a helper CLI tool included with Time Machine called
bypass
:bypass's location
Since
bypass
is considered a helper script to Time Machine, it's location is not typically on your$PATH
. Therefore you'll need to specify the full path to the executable. Additionally Apple has relocated it for different versions of macOS.References