diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-19 15:32:54 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-19 15:32:54 +0100 |
commit | d795c8e4031243f27ced42ad0001f0718626b02e (patch) | |
tree | d8153b44fd0e4e09c9b2ba308738bf6f4af68acd /modules/zfssnap | |
parent | 4ec3abc5a5e0c0f5a5790d9713201023b26d3bc7 (diff) | |
download | nixos-d795c8e4031243f27ced42ad0001f0718626b02e.tar nixos-d795c8e4031243f27ced42ad0001f0718626b02e.tar.gz nixos-d795c8e4031243f27ced42ad0001f0718626b02e.tar.bz2 nixos-d795c8e4031243f27ced42ad0001f0718626b02e.tar.xz nixos-d795c8e4031243f27ced42ad0001f0718626b02e.zip |
vidhar: ...
Diffstat (limited to 'modules/zfssnap')
-rw-r--r-- | modules/zfssnap/zfssnap.py | 11 |
1 files changed, 6 insertions, 5 deletions
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(): | |||
202 | except KeyError: | 202 | except KeyError: |
203 | pass | 203 | pass |
204 | 204 | ||
205 | all_snap_names = set() | ||
205 | def do_snapshot(*snap_items, recursive=False): | 206 | def do_snapshot(*snap_items, recursive=False): |
206 | nonlocal items | 207 | nonlocal items, all_snap_names |
207 | snap_names = {_snap_name(item) for item in snap_items} | 208 | snap_names = {_snap_name(item) for item in snap_items} |
208 | all_snap_names = None | ||
209 | if recursive: | 209 | if recursive: |
210 | all_snap_names = set() | ||
211 | for snap_item in snap_items: | 210 | for snap_item in snap_items: |
212 | all_snap_names |= {_snap_name(item) for item in items if item.startswith(snap_item)} | 211 | all_snap_names |= {_snap_name(item) for item in items if item.startswith(snap_item)} |
213 | else: | 212 | else: |
214 | all_snap_names = snap_names | 213 | all_snap_names |= snap_names |
215 | 214 | ||
216 | args = ['zfs', 'snapshot'] | 215 | args = ['zfs', 'snapshot'] |
217 | if recursive: | 216 | if recursive: |
@@ -220,10 +219,12 @@ def autosnap(): | |||
220 | 219 | ||
221 | _log_cmd(*args) | 220 | _log_cmd(*args) |
222 | subprocess.run(args, check=True) | 221 | subprocess.run(args, check=True) |
223 | rename(snapshots=all_snap_names) | ||
224 | 222 | ||
225 | do_snapshot(*single) | 223 | do_snapshot(*single) |
226 | do_snapshot(*recursive, recursive=True) | 224 | do_snapshot(*recursive, recursive=True) |
225 | for snap in all_snap_names: | ||
226 | logger.info(f'Created ‘{snap}’') | ||
227 | rename(snapshots=all_snap_names) | ||
227 | 228 | ||
228 | def main(): | 229 | def main(): |
229 | global logger | 230 | global logger |