Recently I was working on a Time Machine backup dataset and caught a misconfiguration I had implemented that I wanted to share.
The Time Machine dataset was being snapshot and replicated to another pool for resiliency. While testing restores, I realized that the backups contained within weren’t reliable. Sometimes, for various unrelated reasons, the snapshot was taken at the same time a Time Machine backup was still locked or in progress. Sometimes the underlying sparsebundle was still being manipulated.
A case of everything working as intended, despite the fact that the outcome would have been bad.
Now the fix.
Time Machine indirectly signals when it has completed a backup to an SMB destination. It sends a specific command to the server. TrueNAS’s Samba VFS module tmprotect
(shoutout to @awalkerix) will then automatically snapshot the dataset, but for this to work the SMB share must be configured as a “Multi-user Time Machine”.
Next, I configured a new dedicated replication task configured as follows:
Also include snapshots with the name: “Matching naming schema”
Also Include Naming Schema:
aapltm-%s
I also prefer to enable the “Save pending snapshots” option and for replication schedule I select “run automatically”. tmprotect
sets snapshot retention to 7 days. but in my testing respects the “save pending snapshots” feature. [Edit: turns out this isn’t the case; TrueNAS prunes these snapshots automatically and it isn’t configurable. I didn’t catch this because of the way I had replication configured. That doesn’t change anything in terms of the ability to replicate “integral” aapltm
snapshots, but it does mean they’re time-limited. If you go 7 days without replicating such a snapshot, and you don’t have other periodic snapshots, you may have to do a full replication from scatch. There is discussion about this further down the thread.]
With this configuration a new snapshot will be created automatically when Time Machine actually completes a backup (due to tmprotect
) and it will then automatically be replicated to the replication destination. The naming schema matches for the name of the snapshot created by tmprotect
.
You may want to add Time Machine datasets to the exceptions for any other snapshot and replication jobs that apply the dataset(s) so that there is no confusion over which snapshots contain a complete backup jobs.
As with anything backup (and data) related make sure you test your backups and assumptions before relying on them!