From 70d36ac45f18c2854fd3eee5bc8e54cb79d33eef Mon Sep 17 00:00:00 2001 From: Matthias Blankertz Date: Mon, 4 Oct 2021 17:57:15 +0200 Subject: [PATCH] Fix snapshot retention times The current period should not count, so e.g. monthly=3 results in the 3 _previous_ months snapshots being kept (plus the snapshot for the current month. --- zfs_smart_snapshot/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zfs_smart_snapshot/main.py b/zfs_smart_snapshot/main.py index 74dff97..504a513 100644 --- a/zfs_smart_snapshot/main.py +++ b/zfs_smart_snapshot/main.py @@ -13,7 +13,7 @@ def keep_time(now, snapshots, convert, delta, count): keep = set() if count < 1: return keep - start = convert(now) - delta*(count-1) + start = convert(now) - delta*count for snapshot in snapshots: snapdate = datetime.strptime(snapshot, 'zfs-smart-snap-%Y-%m-%d-%H%M').replace(tzinfo=timezone.utc) if snapdate >= start: