summaryrefslogtreecommitdiff
path: root/modules/zfssnap/zfssnap.py
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-19 15:35:17 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-19 15:35:17 +0100
commit4fcf328753b43b7d473ddd43a93acbf5bf64099b (patch)
treec565c3b4ece5716498f98495634f4741e6b482db /modules/zfssnap/zfssnap.py
parentf3bafaf453b3029abe0d46b88a9e3610f159cc53 (diff)
downloadnixos-4fcf328753b43b7d473ddd43a93acbf5bf64099b.tar
nixos-4fcf328753b43b7d473ddd43a93acbf5bf64099b.tar.gz
nixos-4fcf328753b43b7d473ddd43a93acbf5bf64099b.tar.bz2
nixos-4fcf328753b43b7d473ddd43a93acbf5bf64099b.tar.xz
nixos-4fcf328753b43b7d473ddd43a93acbf5bf64099b.zip
vidhar: ...
Diffstat (limited to 'modules/zfssnap/zfssnap.py')
-rw-r--r--modules/zfssnap/zfssnap.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py
index 46f1b2da..cb91564b 100644
--- a/modules/zfssnap/zfssnap.py
+++ b/modules/zfssnap/zfssnap.py
@@ -127,9 +127,7 @@ def prune(config, dry_run):
127 127
128 all_snaps = {snap['name'] for _, snaps in items.items() for snap in snaps} 128 all_snaps = {snap['name'] for _, snaps in items.items() for snap in snaps}
129 to_destroy = all_snaps - keep 129 to_destroy = all_snaps - keep
130 if to_destroy: 130 if not to_destroy:
131 logger.info(f'Will prune: %s', ', '.join(map(lambda snap: f'‘{snap}’', to_destroy)))
132 else:
133 logger.info('Nothing to prune') 131 logger.info('Nothing to prune')
134 132
135 for snap in to_destroy: 133 for snap in to_destroy:
@@ -139,6 +137,7 @@ def prune(config, dry_run):
139 args += [snap] 137 args += [snap]
140 _log_cmd(*args) 138 _log_cmd(*args)
141 subprocess.run(args, check=True) 139 subprocess.run(args, check=True)
140 logger.info(f'Pruned ‘{snap}’')
142 141
143def rename(snapshots, destroy=False): 142def rename(snapshots, destroy=False):
144 args = ['zfs', 'get', '-H', '-p', '-o', 'name,value', 'creation', *snapshots] 143 args = ['zfs', 'get', '-H', '-p', '-o', 'name,value', 'creation', *snapshots]