allow to only select parent dataset, non-recursively. (usefull for /var/lib/docker )

This commit is contained in:
Edwin Eefting 2022-08-16 09:04:58 +02:00
parent 4d3aa6da22
commit 564daaa1f8
3 changed files with 13 additions and 3 deletions

View File

@ -146,6 +146,11 @@ test_target1
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 @@ test_target1
# basics
self.assertEqual(s, """[(local): test_source1/fs1,
(local): test_source1/fs1/onlyparent,
(local): test_source1/fs1/sub,
(local): test_source2/fs2/sub]""")

View File

@ -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):

View File

@ -131,7 +131,7 @@ class ZfsDataset:
: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 @@ class ZfsDataset:
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 @@ class ZfsDataset:
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")