Add --snapshot-property argument to pass to zfs snapshot
This commit is contained in:
committed by
DatuX
parent
4873913fa8
commit
911db9b023
@ -70,6 +70,9 @@ class ZfsAutobackup(ZfsAuto):
|
|||||||
help='If nothing has changed, still create empty snapshots. (Faster. Same as --min-change=0)')
|
help='If nothing has changed, still create empty snapshots. (Faster. Same as --min-change=0)')
|
||||||
group.add_argument('--other-snapshots', action='store_true',
|
group.add_argument('--other-snapshots', action='store_true',
|
||||||
help='Send over other snapshots as well, not just the ones created by this tool.')
|
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 = parser.add_argument_group("Transfer options")
|
||||||
group.add_argument('--no-send', action='store_true',
|
group.add_argument('--no-send', action='store_true',
|
||||||
@ -446,7 +449,8 @@ class ZfsAutobackup(ZfsAuto):
|
|||||||
source_node.consistent_snapshot(source_datasets, snapshot_name,
|
source_node.consistent_snapshot(source_datasets, snapshot_name,
|
||||||
min_changed_bytes=self.args.min_change,
|
min_changed_bytes=self.args.min_change,
|
||||||
pre_snapshot_cmds=self.args.pre_snapshot_cmd,
|
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
|
################# sync
|
||||||
# if target is specified, we sync the datasets, otherwise we just thin the source. (e.g. snapshot mode)
|
# if target is specified, we sync the datasets, otherwise we just thin the source. (e.g. snapshot mode)
|
||||||
|
|||||||
@ -180,7 +180,7 @@ class ZfsNode(ExecuteNode):
|
|||||||
self.logger.debug("{} {}".format(self.description, txt))
|
self.logger.debug("{} {}".format(self.description, txt))
|
||||||
|
|
||||||
def consistent_snapshot(self, datasets, snapshot_name, min_changed_bytes, pre_snapshot_cmds=[],
|
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.
|
"""create a consistent (atomic) snapshot of specified datasets, per pool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -218,6 +218,8 @@ class ZfsNode(ExecuteNode):
|
|||||||
# create consistent snapshot per pool
|
# create consistent snapshot per pool
|
||||||
for (pool_name, snapshots) in pools.items():
|
for (pool_name, snapshots) in pools.items():
|
||||||
cmd = ["zfs", "snapshot"]
|
cmd = ["zfs", "snapshot"]
|
||||||
|
if snapshot_property:
|
||||||
|
cmd += ['-o', snapshot_property]
|
||||||
|
|
||||||
cmd.extend(map(lambda snapshot_: str(snapshot_), snapshots))
|
cmd.extend(map(lambda snapshot_: str(snapshot_), snapshots))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user