From 3f1696024ea1174ce17ee25e280b12eeedcabd6a Mon Sep 17 00:00:00 2001 From: digitalsignalperson Date: Mon, 13 Jun 2022 09:10:08 -0700 Subject: [PATCH] Change --snapshot-property to --set-snapshot-properties to behave in the same was as --set-properties --- zfs_autobackup/ZfsAutobackup.py | 15 ++++++++++++--- zfs_autobackup/ZfsNode.py | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/zfs_autobackup/ZfsAutobackup.py b/zfs_autobackup/ZfsAutobackup.py index c1f9686..963f554 100644 --- a/zfs_autobackup/ZfsAutobackup.py +++ b/zfs_autobackup/ZfsAutobackup.py @@ -70,8 +70,8 @@ class ZfsAutobackup(ZfsAuto): help='If nothing has changed, still create empty snapshots. (Faster. Same as --min-change=0)') group.add_argument('--other-snapshots', action='store_true', help='Send over other snapshots as well, not just the ones created by this tool.') - group.add_argument('--snapshot-property', metavar='PROPERTY=VALUE', default=None, - help='Property to set during snapshot (argument to zfs snapshot)') + group.add_argument('--set-snapshot-properties', metavar='PROPERTY=VALUE,...', type=str, + help='List of properties to set on the snapshot.') group = parser.add_argument_group("Transfer options") @@ -414,6 +414,15 @@ class ZfsAutobackup(ZfsAuto): return set_properties + def set_snapshot_properties_list(self): + + if self.args.set_snapshot_properties: + set_snapshot_properties = self.args.set_snapshot_properties.split(",") + else: + set_snapshot_properties = [] + + return set_snapshot_properties + def run(self): try: @@ -450,7 +459,7 @@ class ZfsAutobackup(ZfsAuto): min_changed_bytes=self.args.min_change, pre_snapshot_cmds=self.args.pre_snapshot_cmd, post_snapshot_cmds=self.args.post_snapshot_cmd, - snapshot_property=self.args.snapshot_property) + set_snapshot_properties=self.set_snapshot_properties_list()) ################# sync # if target is specified, we sync the datasets, otherwise we just thin the source. (e.g. snapshot mode) diff --git a/zfs_autobackup/ZfsNode.py b/zfs_autobackup/ZfsNode.py index 62dcc8f..ed2e399 100644 --- a/zfs_autobackup/ZfsNode.py +++ b/zfs_autobackup/ZfsNode.py @@ -180,7 +180,7 @@ class ZfsNode(ExecuteNode): self.logger.debug("{} {}".format(self.description, txt)) def consistent_snapshot(self, datasets, snapshot_name, min_changed_bytes, pre_snapshot_cmds=[], - post_snapshot_cmds=[], snapshot_property=None): + post_snapshot_cmds=[], set_snapshot_properties=[]): """create a consistent (atomic) snapshot of specified datasets, per pool. """ @@ -218,7 +218,7 @@ class ZfsNode(ExecuteNode): # create consistent snapshot per pool for (pool_name, snapshots) in pools.items(): cmd = ["zfs", "snapshot"] - if snapshot_property: + for snapshot_property in set_snapshot_properties cmd += ['-o', snapshot_property] cmd.extend(map(lambda snapshot_: str(snapshot_), snapshots))