Do not snapshot child filesystem if it has a more specific config #105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Currently, pyznap triggers a snapshot for all children datasets based on the parent config. However, the way this is implemented can cause multiple issues when we want specific children datasets to have different snapshot settings.
This PR fixes this issue, by forgoing snapshots of children datasets when there is a more specific config targeting them.
Example 1: Disabling snapshots for specific children
Imagine we have a ZFS file system named
rpool
with many children which we want to snapshot, but one calledrpool/swap
we don't want to snapshot at all.Per the documentation, we would expect the following to work:
However, this does not work. Upon seeing the
rpool
config, pyznap will trigger a snapshot of all child filesystems regardless of whether they have a more specific config. Because therpool
config hassnap = yes
, this means thatrpool/swap
would be snapshotted.With this PR, this case works as expected, and
rpool/swap
is not snapshotted.Example 2: Turning off specific types of snapshots for specific children
Image we have a ZFS filesystem named
rpool
with many children for which we want to keep 3 monthly snapshots.However, for one of the children
rpool/some-dataset
, we do not wish to take monthly snapshots at all.Per the documentation, we would expect the following to work:
However, this does not work. Upon seeing the
rpool
config, pyznap will trigger a snapshot of all child filesystems regardless of whether they have a more specific config. Because therpool
config has a non-zeromonthly
setting, this would trigger a monthly snapshot.Interestingly, if
clean = yes
forrpool/some-dataset
, this snapshot would be taken and then immediately cleaned up!With this PR, this case works as expected, and
rpool/some-dataset
will not have monthly snapshots taken.