浏览代码

Keep oldest archive when retention target is not met

Alf Mikula 4 年之前
父节点
当前提交
943088df2c
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/borg/helpers/misc.py

+ 4 - 0
src/borg/helpers/misc.py

@@ -58,6 +58,10 @@ def prune_split(archives, rule, n, kept_because=None):
                 kept_because[a.id] = (rule, len(keep))
                 if len(keep) == n:
                     break
+    # Keep oldest archive if we didn't reach the target retention count
+    if len(keep) < n and a.id not in kept_because:
+        keep.append(a)
+        kept_because[a.id] = (rule+"[oldest]", len(keep))
     return keep