Skip to content

Do not snapshot child filesystem if it has a more specific config#105

Open
ruipin wants to merge 2 commits into
yboetz:masterfrom
ruipin:master
Open

Do not snapshot child filesystem if it has a more specific config#105
ruipin wants to merge 2 commits into
yboetz:masterfrom
ruipin:master

Conversation

@ruipin

@ruipin ruipin commented Mar 23, 2024

Copy link
Copy Markdown

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 called rpool/swap we don't want to snapshot at all.

Per the documentation, we would expect the following to work:

[rpool]
# ... other settings here ...
snap = yes

[rpool/swap]
snap = no

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 the rpool config has snap = yes, this means that rpool/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:

[rpool]
# ... other settings here ...
monthly = 3

[rpool/some-dataset]
monthly = 0

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 the rpool config has a non-zero monthly setting, this would trigger a monthly snapshot.

Interestingly, if clean = yes for rpool/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.

@ruipin

ruipin commented Mar 23, 2024

Copy link
Copy Markdown
Author

Removed some printing/debug code that I had accidentally left in the commit. The latest commit should be clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant