Skip to content

check: --max-age and --max-duration cover the archives check, fixes #10025 - #10504

Open
mr-raj12 wants to merge 3 commits into
borgbackup:masterfrom
mr-raj12:check-archives-tracking-10025
Open

mr-raj12 wants to merge 3 commits into
borgbackup:masterfrom
mr-raj12:check-archives-tracking-10025

Conversation

@mr-raj12

@mr-raj12 mr-raj12 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #10025, refs #10356. Implements what was agreed in #10025 (comment).

borg check now records the result of the archives check per archive in cache/checked-archives (archive id -> timestamp, result), in the same format and envelope as cache/checked-packs.

  • --max-age also skips archives whose ok record is younger than the timespan, and is allowed with --archives-only. --repair and --verify-data check every archive.
  • --max-duration is one time budget for the repository check and the archives check, and no longer requires --repository-only. The archives check takes the archives without an ok record first, then the least recently checked ones, and stops between two archives after it analyzed at least one.
  • All archive records are cleared when a check finds a corrupt or missing pack or salvages a pack, and when the archives check runs with --repair.

Commits:

  1. repository: split CheckTracker out of PackTracker: refactoring only, no behavior change.
  2. check: --max-age and --max-duration cover the archives check: the feature, tests and docs.

Decisions that go beyond the issue discussion, please object if you disagree:

  • An archives check stores and reuses no archive records while a pack is recorded corrupt in checked-packs, and when a run without --repair has a finding before it analyzes the archives (missing pack, dropped content, --verify-data or --find-lost-archives error).
  • If the repository check uses up --max-duration, the archives check is skipped with an info message. Without --max-age, a repository check that never finishes within the budget therefore never lets the archives check run. The help text says so and suggests --max-age or separate --repository-only / --archives-only runs.
  • Like a pack recorded corrupt, an archive recorded with a problem fails a partial archives check that does not get to it.
  • An archives check that starts analyzes at least one archive even if the budget is already used up, as the repository check verifies at least one pack. So --archives-only --max-duration makes progress in every run.
  • --max-duration is rejected with --verify-data and --find-lost-archives, as both scan the whole repository.
  • A client without write permission for cache/ (BORG_REPO_PERMISSIONS=read-only) can still run check --archives-only, it logs a warning and stores no records.

Timing, 10 archives of 100k files each, aes256-ocb, local repository:

command time
check --archives-only 12.2s
check --archives-only --max-age=1d 1.1s
check --max-age=1d 1.2s
check --repository-only 1.1s
check --archives-only --max-duration=3 4.5s, 3 of 10 archives analyzed

docs/changes.rst and the generated usage docs are not touched. This touches the same files as #10194 and #9891, I will rebase when needed.

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.13%. Comparing base (7e3d305) to head (f89809b).
⚠️ Report is 7 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/repository.py 93.61% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10504      +/-   ##
==========================================
+ Coverage   89.12%   89.13%   +0.01%     
==========================================
  Files         103      103              
  Lines       19783    19868      +85     
  Branches     3099     3115      +16     
==========================================
+ Hits        17631    17710      +79     
- Misses       1490     1497       +7     
+ Partials      662      661       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@mr-raj12
mr-raj12 force-pushed the check-archives-tracking-10025 branch from 253f5da to f0de2d7 Compare October 6, 2026 19:48

This branch has not been deployed

No deployments
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.

check: does --max-duration really need --repository-only?

1 participant