Add --pre-snapshot-cmd and --post-snapshot-cmd options
This commit is contained in:
@ -161,7 +161,7 @@ class ZfsNode(ExecuteNode):
|
||||
"""determine uniq new snapshotname"""
|
||||
return self.backup_name + "-" + time.strftime("%Y%m%d%H%M%S")
|
||||
|
||||
def consistent_snapshot(self, datasets, snapshot_name, min_changed_bytes):
|
||||
def consistent_snapshot(self, datasets, snapshot_name, min_changed_bytes, pre_snapshot_cmd=None, post_snapshot_cmd=None):
|
||||
"""create a consistent (atomic) snapshot of specified datasets, per pool.
|
||||
"""
|
||||
|
||||
@ -191,6 +191,10 @@ class ZfsNode(ExecuteNode):
|
||||
self.verbose("No changes anywhere: not creating snapshots.")
|
||||
return
|
||||
|
||||
if pre_snapshot_cmd:
|
||||
self.verbose("Running pre-snapshot-cmd:\n\t{}".format(pre_snapshot_cmd))
|
||||
self.run(cmd=pre_snapshot_cmd.split(" "), readonly=False)
|
||||
|
||||
# create consistent snapshot per pool
|
||||
for (pool_name, snapshots) in pools.items():
|
||||
cmd = ["zfs", "snapshot"]
|
||||
@ -200,6 +204,10 @@ class ZfsNode(ExecuteNode):
|
||||
self.verbose("Creating snapshots {} in pool {}".format(snapshot_name, pool_name))
|
||||
self.run(cmd, readonly=False)
|
||||
|
||||
if post_snapshot_cmd:
|
||||
self.verbose("Running post-snapshot-cmd:\n\t{}".format(post_snapshot_cmd))
|
||||
self.run(cmd=post_snapshot_cmd.split(" "), readonly=False)
|
||||
|
||||
def selected_datasets(self, exclude_received, exclude_paths):
|
||||
"""determine filesystems that should be backupped by looking at the special autobackup-property, systemwide
|
||||
|
||||
|
||||
Reference in New Issue
Block a user