[Borgbackup] Issues understanding prune 'keep' rules

Dan Christensen jdc at uwo.ca
Wed Nov 18 18:47:17 EST 2020


On Nov 18, 2020, l0f4r0--- via Borgbackup <borgbackup at python.org> wrote:

> (I) For me, keep-daily/weekly/monthly/yearly were not supposed to
> interfere/interlace with each other. I mean, I thought keep-daily rule
> is applied, then keep-weekly, keep-monthly...
>
> (II) But you seem to explain that if a rule is not satisfied, the next
> ones are evaluated in order to keep archives if applicable, and then
> the previous rule continues if the conditions are still satisfied and
> so on...
> In other words, rules are applied cyclically with precedence until they are used up.
>
> Do other people confirm prune works the (II) way?

The rules are applied strictly in order.  E.g. in the example in the
previous message, when the weekly rule runs, it examines each backup
that is the last in its week, and takes the most recent ones that
haven't already been kept because of an earlier rule.

Then, the monthly rule runs, and considers each backup that is the
last in its month, and keeps any that weren't matched by an earlier
rule like the weekly rule.

In the above example, that causes an interleaving, because the last
backup in a month is not necessarily the last backup in a week.

This interleaving only happens with weekly backups.  All the other
ones nest in the expected way, I believe.

(In any case, I don't think it matters too much.  Borg is so space
efficient that you should just keep lots of history and not worry
too much about which ones get pruned.  But it's fun to think about.)

BTW, I think the development version shows which rules cause each
archive to be kept.

I agree that the example in the web docs would be better if it
had --keep-weekly 4 in it, to illustrate this.

Dan


More information about the Borgbackup mailing list