my iMac was slowing down and I noticed rapidly decreasing primary SSD disk space; 30 GB out 1 TB free.
I ran daisy disk which showed more than 450 GB in unidentified purgeable space which daisy disk was strangely unable to purge.
I finally discovered that it was all due to a fluke 435 GB APFS snapshot which I deleted and all is fine.
I therefore decided to write a macro to report weekly by email to myself on the number and size of APFS snapshots in my Mac (the source being mainly Time Machine and CCC).
I basically have 2 problems:
1- the terminal command
tmutil listlocalsnapshots /
lists the snapshot names correctly, but I would like to also list the snapshot path and size in addition to the names. Size is essential. Path not so important.
2- I was wondering how to copy the result (listing of snapshots name, size, if simple path) to a variable which I would put in the body of the email to myself.
Did you find a solution to list the snapshots and their sizes?
The tmutil listlocalsnapshots doesn’t work for me (probably because currently I have no TM running; I only have the snapshots done by CCC).
What works for me is…
diskutil apfs listSnaps <volume>
But this doesn’t give me the sizes of the snapshots (nor the path). The only way I found to get the sizes is via the CCC GUI. (Besides du probably; but for that I would need the path.)
And some facts make me believe that currently it is impossible to get the list and the sizes via a simple command, because:
Also in the CCC GUI it takes a considerable amount of time to display the sizes (currently I have 15 CCC snapshots). Seems like CCC is doing additional queries to get the sizes, which might not be accessible via the shell.
Also with diskutil apfs listSnaps in the Terminal it takes some time to only build the list of snapshots – without any sizes, or paths.
For the reason above, I think that it's important to keep a close eye on APFS snapshots.
1- for me, listing snapshots without any reference to size is useless. My only concern with snapshots is how much disk space they use. In addition, the idea that once should not be concerned with purgeable space because the OS deletes it automatically is nonsense. I was running out of space to such an extent that I got a 'no space availalble' message when I wanted to update my iphone connected to my mac. It worked perfeclty after I deleted a few APFS snapshots.
2- CCC: your email is a coincidence because just yesterday, I found that CCC GUI is the most convenient way to display the size of APFS snapshots. Otherwise, using scripts, I asked everywhere including reddit, and it just seems too complicated and same for finding the path and displaying the files in pathfinder.
There is a problem : right click on the APFS in CCC and click on browse in Finder. In my case pathfinder opens (even if it is not the default file browser) but in no specific folder. What happens if you click on Browse in Finder ?
3- I wanted to discuss deleting snapshots, but before doing I wanted to ask you: what would be the consequences of deleting Time Machine snapshots ?
I don’t have TimeMachine snapshots, but speaking of APFS snapshots in general, if you delete a snapshot…
you will probably gain the disk space of that snapshot, as for example indicated by CCC. However, this may depend on how the indicated space is calculated. (Not sure about that; a deleted file can be “part” of multiple snapshots.)
you will lose the ability to restore to the point of time of the deleted snapshot.
I did some more reading and don't think that erasing snapshots on the mac is a big deal. It's just an added precaution.
From apple's site:
our Time Machine backup disk might not always be available, so Time Machine also stores some of its backups on your Mac. These backups are called local snapshots.
Note that snapshots are an APFS feature, and are not only created by Time Machine (though currently tmutil seems to be the main interface to create them).
For example, I don’t have Time Machine running but I create snapshots with CCC, which will be retained for a certain time according to a certain policy (e.g. one per day for the last 30 days). Also the system seems to automatically create a snapshot before an OS update. You can also create snapshots manually via Terminal.
Obviously snapshots don’t qualify as backup (since they reside on the same disk) but they are useful for example when you have accidentally deleted some files and don’t have a backup of them. So, I wouldn’t erase them, unless you need the space. (Of course, a remaining disk space of only 20GB or so would be a good reason )