From d795c8e4031243f27ced42ad0001f0718626b02e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 19 Feb 2022 15:32:54 +0100 Subject: vidhar: ... --- modules/zfssnap/zfssnap.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/zfssnap') diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py index 57b0e95f..7404b453 100644 --- a/modules/zfssnap/zfssnap.py +++ b/modules/zfssnap/zfssnap.py @@ -202,16 +202,15 @@ def autosnap(): except KeyError: pass + all_snap_names = set() def do_snapshot(*snap_items, recursive=False): - nonlocal items + nonlocal items, all_snap_names snap_names = {_snap_name(item) for item in snap_items} - all_snap_names = None if recursive: - all_snap_names = set() for snap_item in snap_items: all_snap_names |= {_snap_name(item) for item in items if item.startswith(snap_item)} else: - all_snap_names = snap_names + all_snap_names |= snap_names args = ['zfs', 'snapshot'] if recursive: @@ -220,10 +219,12 @@ def autosnap(): _log_cmd(*args) subprocess.run(args, check=True) - rename(snapshots=all_snap_names) do_snapshot(*single) do_snapshot(*recursive, recursive=True) + for snap in all_snap_names: + logger.info(f'Created ‘{snap}’') + rename(snapshots=all_snap_names) def main(): global logger -- cgit v1.2.3