sanoid icon indicating copy to clipboard operation
sanoid copied to clipboard

same_as Setting in sanoid.conf

Open JavaScriptDude opened this issue 11 months ago • 1 comments

With Ubuntu based distribution, the dataset configurations make it challenging to configure snapshots of the default OS datasets in sanoid. In the past, zsys would take care of auto snapshots during apt updates but this now has to be done manually.

At present, I need to have an entry for each dataset that I want snapshots of:

[rpool/ROOT/ubuntu_jhxyhq/var/]
...
[rpool/ROOT/ubuntu_jhxyhq/var/log]
...
[rpool/ROOT/ubuntu_jhxyhq/var/lib]
...
[rpool/ROOT/ubuntu_jhxyhq/var/lib/AccountsService]
...
[rpool/ROOT/ubuntu_jhxyhq/var/lib/NetworkManager]
... etc ...

It would be awesome to have a setting called same_as= eg:

[rpool/ROOT/ubuntu_jhxyhq/var]
        frequently = 0
        hourly = 24
        daily = 5
        ... etc  ...
[rpool/ROOT/ubuntu_jhxyhq/var/log]
       same_as = rpool/ROOT/ubuntu_jhxyhq/var
       daily = 3
[rpool/ROOT/ubuntu_jhxyhq/var/lib]
       same_as = rpool/ROOT/ubuntu_jhxyhq/var
[rpool/ROOT/ubuntu_jhxyhq/var/lib/AccountsService]
       same_as = rpool/ROOT/ubuntu_jhxyhq/var

This same_as setting would carry all the settings from <same_as> entry and any other local settings would take precedence.

Does this sound like something worth implementing?

JavaScriptDude avatar Feb 27 '24 17:02 JavaScriptDude

Why aren't you simply using recursive=yes on [rpool/ROOT/ubuntu_jhxyhq/var]?

Even if you want to make small changes between the child datasets, you can accomplish that with overrides, eg:

[rpool/ROOT/ubuntu_jhxyhq/var]
        frequently = 0
        hourly = 24
        daily = 5
        recursive = yes

[rpool/ROOT/ubuntu_jhxyhq/var/log]
        daily = 3

[rpool/ROOT/ubuntu_jhxyhq/var/lib]
        hourly = 5

... or whatever. Having declared recursive=yes on the parent dataset var, the datasets beneath var automatically get all of var's settings applied to them, without any need to specify the child datasets in sanoid.conf at all.

In the case that you need mostly the same settings but want to override one or two, as you can see above, you can also declare a module for that child dataset, which will have already inherited the settings from the parent where you declared recursive=yes, and you can override the individual setting(s) you'd like different in that module.

I also note that you're apparently not using any templates. I would strongly recommend taking a look at and either using or creating your own versions of the template_production, template_backup, and template_hotspare provided in the OEM sanoid.conf; they'll make your configs easier to read and parse, and potentially save you from "oops I forgot that one thing" type errors as well.

jimsalterjrs avatar Feb 27 '24 22:02 jimsalterjrs

The recursive setting does exactly what I need. I'll look into the templates as you suggest. Thanks for the great tool set!

JavaScriptDude avatar Feb 28 '24 03:02 JavaScriptDude