diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-19 22:52:50 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-19 22:52:50 +0100 |
commit | 324c66bb75f7c87f4a141854dbe2f0443bc99a8e (patch) | |
tree | 0a0b279a52ed3479382e09de811c353ac4a0345c /modules/zfssnap | |
parent | fff49096859d4b1dac66448eb7dcec8011d504ac (diff) | |
download | nixos-324c66bb75f7c87f4a141854dbe2f0443bc99a8e.tar nixos-324c66bb75f7c87f4a141854dbe2f0443bc99a8e.tar.gz nixos-324c66bb75f7c87f4a141854dbe2f0443bc99a8e.tar.bz2 nixos-324c66bb75f7c87f4a141854dbe2f0443bc99a8e.tar.xz nixos-324c66bb75f7c87f4a141854dbe2f0443bc99a8e.zip |
zfssnap: ...
Diffstat (limited to 'modules/zfssnap')
-rw-r--r-- | modules/zfssnap/zfssnap.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py index 9dcc90a3..281ff586 100644 --- a/modules/zfssnap/zfssnap.py +++ b/modules/zfssnap/zfssnap.py | |||
@@ -166,7 +166,7 @@ def prune(config, dry_run, keep_newest): | |||
166 | else: | 166 | else: |
167 | logger.info(f'Pruned ‘{snap}’') | 167 | logger.info(f'Pruned ‘{snap}’') |
168 | 168 | ||
169 | def rename(snapshots, destroy=False): | 169 | def rename(snapshots, destroy=False, set_is_auto=False): |
170 | args = ['zfs', 'get', '-H', '-p', '-o', 'name,value', 'creation', *snapshots] | 170 | args = ['zfs', 'get', '-H', '-p', '-o', 'name,value', 'creation', *snapshots] |
171 | _log_cmd(*args) | 171 | _log_cmd(*args) |
172 | renamed_to = set() | 172 | renamed_to = set() |
@@ -199,6 +199,12 @@ def rename(snapshots, destroy=False): | |||
199 | subprocess.run(args, check=True) | 199 | subprocess.run(args, check=True) |
200 | renamed_to.add(new_name) | 200 | renamed_to.add(new_name) |
201 | 201 | ||
202 | if set_is_auto: | ||
203 | logger.info(f'Setting is-auto-snapshot on ‘{new_name}’') | ||
204 | args = ['zfs', 'set', 'li.yggdrasil:is-auto-snapshot=true', new_name] | ||
205 | _log_cmd(*args) | ||
206 | subprocess.run(args, check=True) | ||
207 | |||
202 | def autosnap(): | 208 | def autosnap(): |
203 | items = _get_items() | 209 | items = _get_items() |
204 | 210 | ||
@@ -286,6 +292,7 @@ def main(): | |||
286 | prune_parser.add_argument('--config', '-c', dest='config_files', nargs='*', default=list()) | 292 | prune_parser.add_argument('--config', '-c', dest='config_files', nargs='*', default=list()) |
287 | prune_parser.add_argument('--dry-run', '-n', action='store_true', default=False) | 293 | prune_parser.add_argument('--dry-run', '-n', action='store_true', default=False) |
288 | prune_parser.add_argument('--keep-newest', action='store_true', default=False) | 294 | prune_parser.add_argument('--keep-newest', action='store_true', default=False) |
295 | prune_parser.add_argument('--set-is-auto', action='store_true', default=False) | ||
289 | prune_parser.set_defaults(cmd=prune) | 296 | prune_parser.set_defaults(cmd=prune) |
290 | args = parser.parse_args() | 297 | args = parser.parse_args() |
291 | 298 | ||
@@ -297,7 +304,7 @@ def main(): | |||
297 | logger.setLevel(logging.DEBUG) | 304 | logger.setLevel(logging.DEBUG) |
298 | 305 | ||
299 | cmdArgs = {} | 306 | cmdArgs = {} |
300 | for copy in {'snapshots', 'dry_run', 'destroy', 'keep_newest'}: | 307 | for copy in {'snapshots', 'dry_run', 'destroy', 'keep_newest', 'set_is_auto'}: |
301 | if copy in vars(args): | 308 | if copy in vars(args): |
302 | cmdArgs[copy] = vars(args)[copy] | 309 | cmdArgs[copy] = vars(args)[copy] |
303 | if 'config_files' in vars(args): | 310 | if 'config_files' in vars(args): |