Ignoring child dataset for backups using Sanoid

Hello, gents!

I was looking around for a way to ignore a child dataset when using sanoid to create snapshots and stumbled across this thread. I’ve implemented approx. the same changes but the dataset does not seem to get ignored.

The config is more or less the stock one found in the GH repo, albeit with a few minor adjustments:

######################################
# This is a sample sanoid.conf file. #
# It should go in /etc/sanoid.       #
######################################

[tank]
        use_template = production
        # there are two options for recursive: zfs or yes
        # * zfs - taken a zfs snapshot with the '-r' flag; zfs will recursively take a snapshot of the whole
        #         dataset tree which is consistent.
        # * yes - the snapshots will be taken one-at-time through the sanoid code; not necessarily consistent.
        recursive = zfs # default zfs

[flash_temp]
        use_template = production
        # there are two options for recursive: zfs or yes
        # * zfs - taken a zfs snapshot with the '-r' flag; zfs will recursively take a snapshot of the whole
        #         dataset tree which is consistent.
        # * yes - the snapshots will be taken one-at-time through the sanoid code; not necessarily consistent.
        recursive = zfs # default zfs


[tank/containerd]
        use_template = none
        recursive = yes


#############################
# templates below this line #
#############################

[template_demo]
        daily = 60

[template_production]
        frequently = 0
        hourly = 36
        daily = 30
        monthly = 3
        yearly = 0
        autosnap = yes
        autoprune = yes

[template_backup]
        autoprune = yes
        frequently = 0
        hourly = 30
        daily = 90
        monthly = 12
        yearly = 0

        ### don't take new snapshots - snapshots on backup
        ### datasets are replicated in from source, not
        ### generated locally
        autosnap = no

        ### monitor hourlies and dailies, but don't warn or
        ### crit until they're over 48h old, since replication
        ### is typically daily only
        hourly_warn = 2880
        hourly_crit = 3600
        daily_warn = 48
        daily_crit = 60

[template_hotspare]
        autoprune = yes
        frequently = 0
        hourly = 30
        daily = 90
        monthly = 3
        yearly = 0

        ### don't take new snapshots - snapshots on backup
        ### datasets are replicated in from source, not
        ### generated locally
        autosnap = no

        ### monitor hourlies and dailies, but don't warn or
        ### crit until they're over 4h old, since replication
        ### is typically hourly only
        hourly_warn = 4h
        hourly_crit = 6h
        daily_warn = 2d
        daily_crit = 4d

[template_ignore]
        autoprune = no
        autosnap = no
        monitor = no

[template_none]
        autosnap = no
        autoprune = no
        frequently = 0
        hourly = 0
        daily = 0
        monthly = 0
        yearly = 0

However, it looks like snapshots are being taken of tank/containerd anyway - does anyone have any suggestions as to why that might be?

-Cheers

I don’t know for sure why your [template_none] doesn’t do what you want. I’m guessing that specifying values for frequently, hourly and so on triggers the snapshot but the autoprune setting causes them not to be removed.

Have you tried [template_ignore]? Perhaps that would do what you want.

Thanks for the reply, Hank. I’ve now adjusted the config; I’ll update as soon as I find out whether it works or not :slight_smile:

I ran into a similar issue recently as I was trying to exclude docker filesystems from my snapshots.

Your problem is with recursive = zfs. If you change that to yes, then you can overwrite settings for the child datasets. Although as the note says, snapshots will now be taken one at a time, so some datasets may be a few filesystem writes ahead of others.

 [tank]
         use_template = production
         # there are two options for recursive: zfs or yes
         # * zfs - taken a zfs snapshot with the '-r' flag; zfs will recursively take a snapshot of the whole
         #         dataset tree which is consistent.
         # * yes - the snapshots will be taken one-at-time through the sanoid code; not necessarily consistent.
         recursive = zfs # default zfs
1 Like

You were absolutely right! Thank you very much :smiley: