bundles/zfs: add option to disable snapshots for dataset tree

This commit is contained in:
Franzi 2022-01-05 09:52:20 +01:00
parent b40a8235d2
commit b6eb12ed90
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -31,8 +31,15 @@ label = argv[1]
with open('/etc/zfs-snapshot-config.json', 'r') as fp:
metadata = loads(fp.read())
output = check_output(['zfs', 'list', '-H', '-o', 'name']).decode('UTF-8')
datasets = set(output.splitlines())
datasets = set()
for line in check_output(['zfs', 'list', '-H', '-o', 'name']).splitlines():
line = line.decode('UTF-8')
for prefix in metadata.get('snapshot_never', set()):
if dataset.startswith(prefix):
break
else:
datasets.add(line)
default_retain = metadata['retain_defaults'][label]
now = datetime.now().strftime('%F-%H%M')