diff --git a/tests/test_zfsnode.py b/tests/test_zfsnode.py index bcbd4a0..893f549 100644 --- a/tests/test_zfsnode.py +++ b/tests/test_zfsnode.py @@ -146,6 +146,11 @@ def test_getselected(self): shelltest("zfs create test_source1/fs1/subexcluded") shelltest("zfs set autobackup:test=false test_source1/fs1/subexcluded") + # only select parent + shelltest("zfs create test_source1/fs1/onlyparent") + shelltest("zfs create test_source1/fs1/onlyparent/child") + shelltest("zfs set autobackup:test=parent test_source1/fs1/onlyparent") + # should be excluded by being unchanged shelltest("zfs create test_source1/fs1/unchanged") shelltest("zfs snapshot test_source1/fs1/unchanged@somesnapshot") @@ -158,6 +163,7 @@ def test_getselected(self): # basics self.assertEqual(s, """[(local): test_source1/fs1, + (local): test_source1/fs1/onlyparent, (local): test_source1/fs1/sub, (local): test_source2/fs2/sub]""") diff --git a/zfs_autobackup/CliBase.py b/zfs_autobackup/CliBase.py index 8b55c06..518f032 100644 --- a/zfs_autobackup/CliBase.py +++ b/zfs_autobackup/CliBase.py @@ -10,7 +10,7 @@ class CliBase(object): Overridden in subclasses that add stuff for the specific programs.""" # also used by setup.py - VERSION = "3.2-alpha2" + VERSION = "3.2-beta1" HEADER = "{} v{} - (c)2022 E.H.Eefting (edwin@datux.nl)".format(os.path.basename(sys.argv[0]), VERSION) def __init__(self, argv, print_arguments=True): diff --git a/zfs_autobackup/ZfsDataset.py b/zfs_autobackup/ZfsDataset.py index 5efca43..929d885 100644 --- a/zfs_autobackup/ZfsDataset.py +++ b/zfs_autobackup/ZfsDataset.py @@ -131,7 +131,7 @@ def is_selected(self, value, source, inherited, exclude_received, exclude_paths, :type exclude_unchanged: bool :type min_change: bool - :param value: Value of the zfs property ("false"/"true"/"child"/"-") + :param value: Value of the zfs property ("false"/"true"/"child"/parent/"-") :param source: Source of the zfs property ("local"/"received", "-") :param inherited: True of the value/source was inherited from a higher dataset. """ @@ -142,7 +142,7 @@ def is_selected(self, value, source, inherited, exclude_received, exclude_paths, raise (Exception( "{} autobackup-property has illegal source: '{}' (possible BUG)".format(self.name, source))) - if value not in ["false", "true", "child", "-"]: + if value not in ["false", "true", "child", "parent", "-"]: # user error raise (Exception( "{} autobackup-property has illegal value: '{}'".format(self.name, value))) @@ -155,6 +155,10 @@ def is_selected(self, value, source, inherited, exclude_received, exclude_paths, if value == "child" and not inherited: return False + # only select parent, no childs, ignore + if value == "parent" and inherited: + return False + # manually excluded by property if value == "false": self.verbose("Excluded")