summaryrefslogtreecommitdiff
path: root/modules/zfssnap
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-19 15:51:23 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-19 15:51:23 +0100
commit9c37ce946826258711e15cd55ee221fa8fe02256 (patch)
treece5fe1ba2c6b7bc2eabcb4bae04a76e05bbb39b2 /modules/zfssnap
parent4fcf328753b43b7d473ddd43a93acbf5bf64099b (diff)
downloadnixos-9c37ce946826258711e15cd55ee221fa8fe02256.tar
nixos-9c37ce946826258711e15cd55ee221fa8fe02256.tar.gz
nixos-9c37ce946826258711e15cd55ee221fa8fe02256.tar.bz2
nixos-9c37ce946826258711e15cd55ee221fa8fe02256.tar.xz
nixos-9c37ce946826258711e15cd55ee221fa8fe02256.zip
zfssnap: ...
Diffstat (limited to 'modules/zfssnap')
-rw-r--r--modules/zfssnap/zfssnap.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py
index cb91564b..a05440a7 100644
--- a/modules/zfssnap/zfssnap.py
+++ b/modules/zfssnap/zfssnap.py
@@ -83,11 +83,21 @@ def prune(config, dry_run):
83 keep.add(snap) 83 keep.add(snap)
84 84
85 within = config.gettimedelta('KEEP', 'within') 85 within = config.gettimedelta('KEEP', 'within')
86 within_cutoff = _now() - within 86 if within > timedelta(seconds=0):
87 for base, snaps in items.items():
88 time_ref = max(snaps, key=lambda snap: snap['creation'], default=None)
89 if not time_ref:
90 logger.warn('Nothing to keep for ‘{base}’')
91 continue
87 92
88 for base, snap in [(base, snap) for base, snaps in items.items() for snap in snaps]: 93 logger.info('Using ‘{time_ref["name"]}’ as time reference for ‘{base}’')
89 if snap['creation'] >= within_cutoff: 94 within_cutoff = time_ref['creation'] - within
90 keep_because(base, snap['name'], 'within') 95
96 for snap in snaps:
97 if snap['creation'] >= within_cutoff:
98 keep_because(base, snap['name'], 'within')
99 else:
100 logger.warn('Skipping rule ‘within’ since retention period is zero')
91 101
92 prune_timezone = config.gettimezone('KEEP', 'timezone', fallback=tzlocal) 102 prune_timezone = config.gettimezone('KEEP', 'timezone', fallback=tzlocal)
93 103