Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruipin
Copy link

@ruipin ruipin commented Mar 23, 2024

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
Copy link
Author

ruipin commented Mar 23, 2024

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