Time Machine Backups
I use an Apple MacBook as my primary work laptop. One of the nice features that are automatically included in OSX is Time Machine, allowing you to do automatic backups.
You can do the backups to an external disk (via USB) or to a network connected disk. I also have a Synology NAS with a volume (encrypted of course) configured for the backups. I have set a quota for this volume to prevent the backups from filling up my entire NAS.
If you do backups to a USB disk then Time Machine will automatically delete older backups. Unfortunately this didn’t happen on the network volume via the Synology disk, Time Machine did not delete the old backups. This resulted in a full backup volume. I could not find the cause for this problem. File access permissions etc. were set correctly and nothing unusual was found in the logs. So instead of relying on the auto delete by Time Machine I decided to rely on manually deleting backups.
Manually delete Time Machine backups
You can manually delete your Time Machine backups via the GUI but this quickly becomes a tedious process. I wanted to automate the deletion of the backups via a script. You can control the Time Machine backups via tmutil. Listing your backups can be done via
Deleting is done via
tmutil delete PATH_TO_BACKUP
One warning. The Time Machine volume gets mounted on your OSX when Time Machine starts. Check with
mount|grep -i backup
This should return a list containing
/Volumes/Time Machine Backups
If you try to delete a backup without having the volume mounted then you’ll receive an error
No such file or directory (error 2) Total deleted: 0B
The trick is to first have the volume mounted (via listbackups) and then do the delete.