Skip to content

Refactor the interval-based pruning example#1

Merged
Goddesen merged 3 commits into
Goddesen:prune-timely-by-intervalfrom
PhrozenByte:Goddesen/prune-timely-by-interval
Jun 14, 2026
Merged

Refactor the interval-based pruning example#1
Goddesen merged 3 commits into
Goddesen:prune-timely-by-intervalfrom
PhrozenByte:Goddesen/prune-timely-by-interval

Conversation

@PhrozenByte

Copy link
Copy Markdown

See my review on borgbackup#8775

Comment thread docs/misc/prune-example-interval.txt Outdated
Comment on lines +103 to +104
2026-05-28 16:00 is exactly one week before `--since`. Since `create` always
runs at or after 16:00, the archive created on 2026-05-28 is kept, too. Without

@Goddesen Goddesen Jun 14, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"at or after" ensuring the week-old archive is kept isn't quite right since the interval end is compared exclusively to the archive time (and archive time is at the start of the create call). With microsecond precision this might not matter in most cases, but it's worth clearing up either this text and the example -- or maybe this is an argument to make the comparison inclusive such that this wording works.

I think that the exclusive check is technically right, but in practice it might be too much hassle for users.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed 👍

I think it's perfectly reasonable to keep the check exclusive. If the behavior doesn't match what someone expects, they can simply choose a different value for --since.

Honestly, I think --since solves all the weird edge cases we've struggled with in the past. That's why I'm a big fan of your idea to add this option.

Comment thread docs/misc/prune-example-interval.txt Outdated
Comment on lines +4 to +7
Assume today is 2026-06-04 and you always start your backups at 16:00. You have
been creating backup archives starting at 16:00 on most days going back to late
2025. Today, `create` took a little longer than usual. It's 16:12 now and you
run `prune`.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an extra intro paragraph to set up the scenario is nice. Just launching into "you start your backups" is a bit abrupt.

Suggested change
Assume today is 2026-06-04 and you always start your backups at 16:00. You have
been creating backup archives starting at 16:00 on most days going back to late
2025. Today, `create` took a little longer than usual. It's 16:12 now and you
run `prune`.
Scenario: You use borg to perform daily backups. The changes day-to-day are less
important as time goes on, so to save some storage space you have the older
archives "thin out" over time while keeping most of the recent archives. Your
backup script does `borg create ...` followed immediately by `borg prune ...`.
Assume today is 2026-06-04 and you start your backups at 16:00. You have been
creating backup archives starting at 16:00 on most days going back to late 2025.
Today, `borg create` took a little longer than usual. It's 16:12 now and you run
`borg prune`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, merged 👍

I just kept the "always", because it implies more or less consistent timing.

@Goddesen

Copy link
Copy Markdown
Owner

These are good suggestions. If you agree with my comments I'll merge it right in.

Co-Authored-By: Hugo Wallenburg <hugo@hugow.no>
@PhrozenByte

Copy link
Copy Markdown
Author

Suggestions applied, thanks 👍

However, there's one issue now following our discussion in the main PR: If we keep treating 5m as 155d for now, 2025-12-31 ends up being matched by --keep-monthly instead.

I guess we have three options:

  1. Just leave the example as-is until the follow-up PR.
  2. Update the docs to explain that 2025-12-31 is indeed matched by --keep-monthly instead.
  3. Adjust the example so that "today" is, for example, 2026-06-05 instead.

@Goddesen

Copy link
Copy Markdown
Owner

I guess we have three options:

1. Just leave the example as-is until the follow-up PR.
2. Update the docs to explain that 2025-12-31 is indeed matched by `--keep-monthly` instead.
3. Adjust the example so that "today" is, for example, `2026-06-05` instead.

I'm hesitant to knowingly commit a wrongful example even just for a little bit, in case we somehow never get around to fixing it (or we forget). Could you include a fix here? I think your no. 2 is the least work.

@PhrozenByte

PhrozenByte commented Jun 14, 2026

Copy link
Copy Markdown
Author

Done 👍

I also added a note about this behavior to the main date interval docs.

I later force-pushed another change to add a note about years as well. Users are probably less likely to run into that case, but Borg also considers 3y before 2026-06-04 to be 2023-06-05 (not 2023-06-04, because of the 2024 leap year).

@PhrozenByte PhrozenByte force-pushed the Goddesen/prune-timely-by-interval branch from 30187fb to bab58c2 Compare June 14, 2026 14:07
@Goddesen

Copy link
Copy Markdown
Owner

@PhrozenByte Thanks for the help.

@Goddesen Goddesen merged commit fd3cf57 into Goddesen:prune-timely-by-interval Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants