5

Due to APFS having a mind of its own and filling the hard disk with unwanted snapshots, I made a cron to run tmutil deletelocalsnapshots xxx. Later I found out that running this command while a backup is in progress will stop the backup. How can I know if a time machine backup is in progress to avoid running the command? The man page for tmutil doesn't list any status command.

Right now I'm doing the following in the script, since now backups mount at /Volumes/Time Machine Backups/:

ls -d /Volumes/Time* 2>/dev/null|grep Machin >/dev/null

if [[ $? != 0 ]]; then
     # run here tmutil snapshot deletion commands
fi

However, this doesn't seem to be very precise. The volume may be mounted some minutes later after a backup has started, and also stopping a backup leaves that mounted volume for a while. Finally, the name of the mounted volume might change in the future, making the check useless.

  • Rather than edit your post - I'll try to answer in a way that helps. Problems I see are 1) APFS is on SSD and no HD - you'd need a very detailed follow up question to explain how / why you have APFS on HD and if you are backing up to APFS or from APFS. 2) Local snapshots really don't take extra space in practice. The space is already committed and thins when you need it. What exact storage allocation is in the volume that's running low? Perhaps this is an XY question. – bmike Feb 25 '18 at 14:24
  • I only have one SSD with APFS and an external ethernet time capsule. 2) I process many huge video files. Many days I end up my work day with 20GB free, leave the computer on, and in the morning I'm 140GB free. Those snapshots are really annoying when I need those 120GB now.
  • – Grzegorz Adam Hankiewicz Feb 25 '18 at 14:57
  • 1
    That's easy to script. tmutil thinlocalsnapshots \ 100... with enough zeros to get you to 120 GB. If you have paid support, I would open a case with Apple on that use case. Seems one tmdiagnose and the engineers could make sure their configuration works for your use case. I'll edit my post to get you a 1 GB purge. Great question +2 if I could vote twice. – bmike Feb 25 '18 at 15:04
  • Ugh, yeah, thanks, that's why I started this question, because I'm trying to script those commands, and deletelocalsnapshots simply works better than thinlocalsnapshots in my experience. – Grzegorz Adam Hankiewicz Feb 25 '18 at 15:07
  • Excellent - feel free to list your script if no one delivers one and you need to tweak the thin example. I don't know if Apple exposed a way to measure the snapshots so I'm using thinlocalsnapshots over deletelocalsnapshots when I need to urgently free up space. (say when pre-staging a 50 GB Adobe install over a week or two period so we can install them all from local image rather than over the network) – bmike Feb 25 '18 at 15:09
  • You can exclude your videofiles from the time machine backup if they are large and you don't need them in your backup. – Thorbjørn Ravn Andersen Jul 11 '19 at 07:03