Skip to content

check: always require the key - #10385

Open
ThomasWaldmann wants to merge 1 commit into
borgbackup:masterfrom
ThomasWaldmann:check-requires-key
Open

ThomasWaldmann wants to merge 1 commit into
borgbackup:masterfrom
ThomasWaldmann:check-requires-key

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

borg check now loads the key before it checks anything, in every mode, and aborts if it can not.

Before

  • borg check --repository-only (without --repair) needed no key at all.
  • A check without --repair swallowed RepositoryKeyInfoMissing and carried on without a key: the archives check then rebuilt the chunk index without an object validator and only failed at its second attempt to load the key.
  • Only --repair really required the key (borg2: index rebuild trusts pack headers #9901).

Now

User-visible consequences

  • borg check --repository-only can not be run without the key / passphrase any more, e.g. on a repository server that does not have them.
  • A repository without key info in its config (created via the Python API, Repository(..., create=True)) fails every check with rc 54 (RepositoryKeyInfoMissing); a wrong passphrase fails with rc 52, before anything is checked.

Tests

  • test_check_without_key_aborts_on_a_corrupt_pack_header is removed: a check without the key does not exist any more.
  • New: test_check_aborts_on_wrong_passphrase and test_check_aborts_without_key_info, each for the full, the --repository-only and the --archives-only check. The --repository-only cases fail on master.

Docs

  • The check epilog says that check always needs the key, --repository-only included; the repair-only sentence about it is gone.
  • docs/internals/packs.rst no longer describes a repair that walks the packs without the key (stale since borg2: index rebuild trusts pack headers #9901).
  • Usage docs / man pages are not regenerated.

🤖 Generated with Claude Code

borg check loads the key right after the argument validation, in every
mode: a --repository-only check without --repair needed no key until now,
and a check without --repair let a repository config without key info
through. Every borg 2 repository has a borg key and the key class comes
from the repository config, so loading the key reads no repository object.

The passphrase is still asked for before the repository check starts
(borgbackup#1931). Repository.check() always gets the object validator (it uses it
for the index rebuild, which only a repair does) and ArchiveChecker.check()
has no path without a key any more, so its chunk index rebuild always
validates the object headers it walks.

A check without the key is gone, so the test for it is replaced by tests
that a wrong passphrase and a repository config without key info abort
the full, the --repository-only and the --archives-only check.

Docs: the check epilog says that check always needs the key, packs.rst
no longer describes a repair walking the packs without the key.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ThomasWaldmann

Copy link
Copy Markdown
Member Author

@mr-raj12 please check.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.14%. Comparing base (4a687b5) to head (aabcb1e).
⚠️ Report is 12 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10385      +/-   ##
==========================================
- Coverage   88.15%   88.14%   -0.02%     
==========================================
  Files         103      103              
  Lines       18822    18810      -12     
  Branches     2919     2915       -4     
==========================================
- Hits        16593    16580      -13     
- Misses       1552     1554       +2     
+ Partials      677      676       -1     

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

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.

1 participant