TimeMachine Snapshots Retention

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
Hello,

I have a multi-user TimeMachine backup setup on my TrueNAS server. It's creating snapshots on each time machine backup successfully, as in this thread: https://www.truenas.com/community/threads/timemachine-snapshots.88778/

However, I've noticed that the retention is going beyond the 7 days it's supposed to. I've tried to set
Code:
tmprotect:retention = 7
but no value seems to prune the old snapshots.

Is there anyway I can control this or at least create a script to prune these old snapshots? As I will have snapshots going back months and even years if this continues.

Any help or insight would be appreciated.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Did you restart the SMB service after setting that aux parameter?
 

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
Did you restart the SMB service after setting that aux parameter?
Yes, I even restarted the entire server.

Running "testparm -s" also confirmed the setting stuck but snapshots were still existing for much past the 7 (or any setting I try) days.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Then look under Tasks->Periodic Snapshot Tasks for your Time Machine snapshot tasks. You can manually set the retention in the task as well.

Expand the task, and click Edit. On the right, you can set the snapshot lifetime.
 

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
Then look under Tasks->Periodic Snapshot Tasks for your Time Machine snapshot tasks. You can manually set the retention in the task as well.

Expand the task, and click Edit. On the right, you can set the snapshot lifetime.
Unfortunately, as per the the thread I linked:
I haven't written documentation yet (since options aren't exposed via API or GUI), I will probably get around to it once I have more feedback / prepare for upstreaming.
There is no GUI option to change this snapshot behaviour. It seems it's a buggy feature that should be addressed in the future. But looking for somebody who may have figured it out.
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Unfortunately, as per the the thread I linked:

There is no GUI option to change this snapshot behaviour. It seems it's a buggy feature that should be addressed in the future. But looking for somebody who may have figured it out.

What version of TrueNAS are you using. I refactored it for 22.02.1 / TrueNAS 13 to adjust snapshot behavior. Note that snapshots are only managed when the SMB client / user in question connects to the share.
 

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
What version of TrueNAS are you using. I refactored it for 22.02.1 / TrueNAS 13 to adjust snapshot behavior. Note that snapshots are only managed when the SMB client / user in question connects to the share.
I am on TrueNAS-SCALE-22.02.0.1.
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Okay. In
I am on TrueNAS-SCALE-22.02.0.1.
Try running following commands
Code:
net conf setparm global "log level" "1 tmprotect:10"
service smbd restart


Then on MacOS run command tmutil startbackup -block
This will start a time machine backup and not return until it completes.
While the backup is running check /var/log/samba4/log.smbd for entries from the tmprotect module.
 

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
Okay. In

Try running following commands
Code:
net conf setparm global "log level" "1 tmprotect:10"
service smbd restart


Then on MacOS run command tmutil startbackup -block
This will start a time machine backup and not return until it completes.
While the backup is running check /var/log/samba4/log.smbd for entries from the tmprotect module.
Thanks for this, it was very helpful. I see now that there is an issue with permissions:

[2022/04/18 12:30:02.198859, 5, pid=765825, effective(1000, 1000), real(1000, 0), class=tmprotect] ../../source3/modules/vfs_tmprotect.c:131(prune_snapshots) prune_snapshots: Appending [aapltm-1649607707] to list of snapshots to be deleted. [2022/04/18 12:30:02.198887, 5, pid=765825, effective(1000, 1000), real(1000, 0), class=tmprotect] ../../source3/modules/vfs_tmprotect.c:142(prune_snapshots) prune_snapshots: num_snaps: 46, num_delete: 8, remaining_snaps: 38, min snaps: 3 cannot destroy snapshots: permission denied [2022/04/18 12:30:02.199156, 0] ../../source3/modules/smb_libzfs.c:1148(smb_zfs_delete_snapshots) smb_zfs_delete_snapshots: Failed to delete snapshots [2022/04/18 12:30:02.199178, 0, pid=765825, effective(1000, 1000), real(1000, 0), class=tmprotect] ../../source3/modules/vfs_tmprotect.c:150(prune_snapshots) prune_snapshots: failed to delete list of expired snapshots: Operation not permitted [2022/04/18 12:30:02.199222, 0, pid=765825, effective(1000, 1000), real(1000, 0), class=tmprotect] ../../source3/modules/vfs_tmprotect.c:304(tmprotect_openat) tmprotect_openat: Failed to prune snapshots

What type of permissions are required to allow this?
 

bearattack11

Dabbler
Joined
Jan 1, 2021
Messages
11
To follow up for any future dwellers: there was an issue with the tmprotect module permissions which should be fixed in a future release. Your old snapshots will get pruned when this fix comes into effect!
 

ChrisD.

Dabbler
Joined
Apr 18, 2022
Messages
26
Thanks. I ask as I also use TimeMachine and noticed that snapshots have not been clearing, but I haven't looked into it yet.

If anyone needs further logs, let me know and I'm more than happy to supply.
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
Thanks. I ask as I also use TimeMachine and noticed that snapshots have not been clearing, but I haven't looked into it yet.

If anyone needs further logs, let me know and I'm more than happy to supply.
If you're using 22.02.01 you can send me a PM and I'll send you the fix.
 

ChrisD.

Dabbler
Joined
Apr 18, 2022
Messages
26
If you're using 22.02.01 you can send me a PM and I'll send you the fix.
I'm on Core. But feel free to ignore me, I've noticed I have two weeks worth and that is what the task is set up for.

I'll get back in my box. :grin:
 
Top