Skip to content

check: a full --repair rebuilds a corrupt index once, in the archives phase, fixes #10434 - #10445

Open
mr-raj12 wants to merge 2 commits into
borgbackup:masterfrom
mr-raj12:check-repair-single-rebuild-10434
Open

mr-raj12 wants to merge 2 commits into
borgbackup:masterfrom
mr-raj12:check-repair-single-rebuild-10434

Conversation

@mr-raj12

@mr-raj12 mr-raj12 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Merge after #10443. This branch is rebased on it and includes its commit; the first commit here is #10443's, the second is this PR's.

With a corrupt index, a full borg check --repair rebuilt the index twice: once in Repository.check and again in ArchiveChecker.check, which rebuilds it from the packs on every --repair run. Each pack was walked and each object decrypted twice, and an object failing validation was reported twice.

Now:

  • A full --repair still verifies every pack by its store hash, then leaves the corrupt index to the archives phase, which rebuilds and stores it. The repository check logs this and does not fail for it, unless it was interrupted (then the archives phase does not run and the check fails).
  • --repository-only --repair is unchanged: it rebuilds the index if every pack is intact.
  • Repository.check requires repo_only to be passed when repair=True, like validate.
  • The interrupted rebuild message said the index "is rebuilt on next use"; most commands abort on a corrupt index instead, so it now says to run borg check --repair.

Guard question from the issue: the "no rebuild if a pack is corrupt" guard now applies to --repository-only only, which is intended. A full --repair may rebuild over a corrupt pack because its archives phase then repairs the archives that reference the dropped chunks. --repository-only has no such step, so it leaves the index for a full repair (refs #8572). Left as is: under --repository-only, an object failing validation inside a pack whose store hash matches still gets a rebuild that skips it. That can be a follow-up if wanted.

The total count of skipped pack byte ranges was not moved to the archives phase: each skip is logged with its pack and offset, and the archives check ends with "problems found".

Tests:

  • a full --repair walks each pack once (fails on master with 51 extra walks)
  • the tampered object is reported once (reported twice on master)
  • Repository.check(repair=True, repo_only=False) verifies all packs, walks no pack objects, stores no index and succeeds
  • a Ctrl-C during the archives phase rebuild stores nothing, repo-list aborts with CorruptChunkIndexFragment, and a second --repair completes
  • the existing rebuild and validation tests run in both full and --repository-only mode

fixes #10434

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 Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (8274470) to head (468df82).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10445   +/-   ##
=======================================
  Coverage   88.73%   88.74%           
=======================================
  Files         103      103           
  Lines       19387    19392    +5     
  Branches     3023     3025    +2     
=======================================
+ Hits        17204    17209    +5     
  Misses       1514     1514           
  Partials      669      669           

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

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 --repair: a full check rebuilds a corrupt chunks index from all packs twice

1 participant