summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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