From 911db9b023782fdcf1574749a7865eb98865754e Mon Sep 17 00:00:00 2001 From: digitalsignalperson Date: Sun, 12 Jun 2022 23:04:19 -0700 Subject: [PATCH] Add --snapshot-property argument to pass to zfs snapshot --- zfs_autobackup/ZfsAutobackup.py | 6 +++++- zfs_autobackup/ZfsNode.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zfs_autobackup/ZfsAutobackup.py b/zfs_autobackup/ZfsAutobackup.py index a6f1412..c1f9686 100644 --- a/zfs_autobackup/ZfsAutobackup.py +++ b/zfs_autobackup/ZfsAutobackup.py @@ -70,6 +70,9 @@ 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 = parser.add_argument_group("Transfer options") group.add_argument('--no-send', action='store_true', @@ -446,7 +449,8 @@ class ZfsAutobackup(ZfsAuto): source_node.consistent_snapshot(source_datasets, snapshot_name, min_changed_bytes=self.args.min_change, pre_snapshot_cmds=self.args.pre_snapshot_cmd, - post_snapshot_cmds=self.args.post_snapshot_cmd) + post_snapshot_cmds=self.args.post_snapshot_cmd, + snapshot_property=self.args.snapshot_property) ################# 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 1e0b55d..62dcc8f 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=[]): + post_snapshot_cmds=[], snapshot_property=None): """create a consistent (atomic) snapshot of specified datasets, per pool. """ @@ -218,6 +218,8 @@ class ZfsNode(ExecuteNode): # create consistent snapshot per pool for (pool_name, snapshots) in pools.items(): cmd = ["zfs", "snapshot"] + if snapshot_property: + cmd += ['-o', snapshot_property] cmd.extend(map(lambda snapshot_: str(snapshot_), snapshots))