Sanoid doesn't keep the right amount of snapshots?

I’m wondering if I’m doing anything wrong. I’ve got some laptops which get daily snapshots, and according to the policy I’ve set they should be retained longer than they are:

This is in /etc/sanoid/sanoid.conf

[datapool/nas/backups/hosts]
        use_template = host_backups
        recursive = yes
        process_children_only = yes

[template_host_backups]
        frequently = 0
        hourly = 0
        daily = 30
        monthly = 12
        yearly = 5
        autosnap = no
        autoprune = yes
        daily_warn = 2d
        daily_crit = 3d
        monthly_warn = 0
        monthly_crit = 0
        monitor = yes

Yet, when looking at the snapshots on the system using zfs list -H -o name -t snapshot

datapool/nas/backups/hosts@daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-02_13:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-03_20:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-04_20:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-05_20:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-06_20:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-07_20:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-08_15:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-09_12:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-10_21:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-11_20:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-14_19:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-15_08:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-16_14:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-17_10:20:02_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-22_14:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-23_13:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-24_21:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-25_16:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-26_20:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-27_20:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-28_19:20:02_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-29_15:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-30_14:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-03-31_21:20:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-01_19:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-02_19:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-03_20:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-04_21:00:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-05_13:40:01_daily
datapool/nas/backups/hosts/hermes@autosnap_2025-04-06_13:00:01_daily
datapool/nas/backups/hosts/hermes@daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-03_20:41:47_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-04_20:21:14_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-05_19:40:05_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-06_20:21:05_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-07_17:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-08_11:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-09_12:21:02_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-10_21:01:12_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-11_20:41:01_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-13_22:20:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-14_08:00:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-15_14:40:01_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-16_15:00:01_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-17_10:20:56_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-22_12:20:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-23_12:00:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-24_07:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-25_08:00:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-26_07:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-27_06:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-28_16:20:05_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-29_15:20:46_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-30_10:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-03-31_15:00:05_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-01_16:20:05_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-02_19:01:13_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-03_18:40:04_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-04_21:00:59_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-05_13:40:56_daily
datapool/nas/backups/hosts/loki@autosnap_2025-04-06_13:00:43_daily
datapool/nas/backups/hosts/loki@daily

Both hosts have been backed up for way longer than they are here - am I missing something?
(the backups are being sent offsite daily, so I have those there anyhow, but I’d like to have them locally too)

These laptops are pushing snaps to this server? Or, does the server just ‘call’ for snaps when needed?

Tell me more about that process.. might be some hints there. Do the laptops have all the snaps you’re expecting?

1 Like

Well, the laptops don’t have ZFS, I’m pulling in the necessary files using rsync, and then creating a snapshot. The script runs every 20 mins, trying to contact the hosts and pull the files, and once an rsync completes successfully the script creates a snapshot.

So writing this down made me realise that I’m expecting sanoid to rotate the snapshot (rename it), which I’m not even sure if it actually does this? How does it actually do this monthly/yearly thing?

It accepts the snapshot name, so that works, and it deletes the old ones. Just not ‘rename’ it to the monthly/yearly ones.

Great question! It doesn’t ‘rotate’ them, like say rsnapshot would.

It just makes them :slight_smile:

Interesting angle here.

Sanoid doesn’t do any sort of rotation, it just looks at the snaps you have, compares it to what your config says you should have and creates snapshots based on that.

i.e. - If your config says you should have monthlies, when sanoid runs it checks to see if you have a snapshot named ‘monthly’ taken this month. If yes, we move on. If no, it takes a snapshot. This means your monthly snap will be taken the first time sanoid runs in a given month. If you don’t run ‘sanoid --take-snapshots’ until the 15th, your monthly won’t be created until then.

If you enable ‘autosnap’ in your config, sanoid will take care of making these other snaps. And, likewise, autoprune will remove the ones it no longer needs. Ask for 3 monthlies? On the 1st day of the 4th month it will make a new monthly, and delete the oldest one.

Assuming your rsync script is ‘smart’ enough to run only once per day, which it does appear to do, I’d remove all the snap logic from that script and just let sanoid manage the snaps. Your data on the server changes once a day so when you snap it is less important… at least to my mind.

I do something similar to this, but I use syncthing on the mobile devices. It keeps my data always in sync (or reasonably so) and I have sanoid snap that dataset hourly.

I think, based on your process, you might be assuming sanoid is ‘smarter’ than it is? Think of it like a camera on a schedule. If you tell it to take a picture each month, each day, and each hour – it will; But that is all it will do. Those photos don’t represent the sum total of all things that happened that month. It’s just an image of what the camera saw at that moment.

2 Likes

So yeah, it was a “thinko” on my end :wink:

Thx!