Time Machine, freeing space and snapshots

Some years back I created a Time Machine dataset using the “Multi-user Time Machine” SMB preset. It’s been working really well. But recently I’ve noticed the dataset has significantly grown, and I realised I failed to set a dataset quota when I created it.

Knowing that Time Machine will free up space by pruning old backups when it approaches full capacity, I figured I’d just set a quota limit and let it fix itself.

Sure enough, after setting the quota (not much bigger than the space it already has) Time Machine went through its “freeing space” process. But then when the subsequent backup occurred, it failed with “Insufficient Space”.

On inspection, the “data written” was smaller, but the “Space Available” had not changed. And the reason is snapshots.
Time Machine smbd service creates 7 days of snapshots. On my Truenas that’s about 60+ snapshots. The snapshots are there so you can roll back if Time Machine process fails and corrupts the sparse bundle. You can just fix it by rolling back to a working snapshot. Given the erratic problems I’ve had with Time Machine, this is a good thing!

The problem is that although Time Machine frees up space, its not released because its held by the snapshots, and the dataset quota includes the snapshot data.

So now I’m in this Catch-22 situation where Time Machine keeps trying to free up space, but snapshots a retaining the space…. Subsequent backup fails with no space. And its going to be 7 days before those snapshots are deleted… That’s 7 days of no backups.

I’ve overcome the problem for now by playing around with the quota and deleting a bunch of snapshots.

So my question is if this is a problem because I didn’t set quotas from the beginning, or is there an inherent conflict here between the way Time Machine works (i.e freeing space), and Truenas setup (i.e snapshots).

1 Like

Yeah. I’m still trying to work this one out myself.

You can delete the oldest snapshots safely if you want, and that may help.

Yea, that’s what I ended up doing.

  1. force a “freeing space” with a tight quota, then
  2. increase the size of the quota to allow backups ( with now smaller snapshots).
  3. leave it a few days to get a few snapshots, then delete a bunch of older snapshots to get to the smaller sized snapshots.
  4. reduce dasaset quota.
  5. repeat above process if required.

Very messy though. I guess the alternative is to wait the 7 days (with no backups working) for all the snapshots to be flushed out. Down side is you have no backups for 7 days and no snapshots at the end.

2 Likes

Yeah I am in a similar spot where my timemachine back up across multiple machines just keeps growing and growing. I wish macOS has a client side setting to set the max length to keep a snapshot. I am pretty sure I have two+ year old snapshots in there at this point, maybe even older.

What’s the process to do this?

Are we talking about internal Time Machine snapshots (not even sure if that is the right terminology) or are we talking about ZFS snapshots?

Sorry to flood the thread - but I reading this and thinking it made sense but now that I am actually trying it out I am realizing this may be less straight forward then I envisioned.

I just set a quota that was slightly above where the current directory is at. It doesn’t appear to be doing the cleaning process, does the quota have to be lower then the current usage in order to trigger that?

Its the time machine process on the client mac that does the cleaning

Yeah that was my understanding of how it should work, just haven’t seen it do that yet. That is what was making me thinking the quota was off.

You won’t see any space released until the snapshots release it. That’s 7 snapshots later…

Yes. TrueNAS process takes a snapshot after any backup. That way if a TimeMachine backup corrupts the sparsebundle, you can just roll back to the last snapshot saving all prior backups.

Unless the snapshots are hidden from the interface in someways I am not seeing those automatic snapshots. I am Core so it’s entirely possible that is just a Scale feature.

I do have automatic snapshots that I personally setup. I can delete those to confirm but if Time Machine was cleaning up files I would expect the size of those snapshots to increase but I am not seeing that.

I also wasn’t seeing any messaging from Time Machine about cleaning up. I have about 80gigs remaining before the quota is hit. How low did you have to go before Time Machine trigged its clean up mode?

I was able to get Time Machine to clean up the backups, it seemed like I needed a quota that left 6 gigs or less of available space for it to actually trigger a clean up.

I don’t know how well Time Machine actually does at its clean up process. I have 3 machines and one of them post clean ups only has backups since yesterday, despite still taking 1.9 TB. (The MacBook in question only has 1 TB drive, so it doesn’t make sense that it would need this much room for a days backup)

I am going to see how this evolves over time, but if it never cleans up the old backups, which I can see in it’s file structure, I might just delete and recreate the Time Machine backup.

Strangely, another machine I have with 500 GB drive still has backups going back to 2001, while only using 1.1 TB of data. That machine generally has had smaller files, whereas the machine that I am having trouble with had some large files due to some video editing work that I’ve since cleanup and moved to my NAS.

You should see the message “freeing space” when Time Machine does its clean up.
The size of the sparse bundle is initially determined by the size of the backup data, but after that it’s the number of times the data is modified and how big the modified files are.
Unlike snapshots that only save changed segments, Time Machine is holding all changed versions of the entire file. So if a file is changed 100 times, there’s 100 versions of that file. This is how Time Machine can roll back to any version of the file going as far back as your quote will allow. Old versions are only “deleted” once you hit your quota.

So a backup of a small disk with many changes (especially if they are large files) will eventually be larger than the backup of a large disk with minimal changes.