Skip to content

check, repo-compress: read packs from the repository, not from the store cache, fixes #10397 - #10467

Open
mr-raj12 wants to merge 2 commits into
borgbackup:masterfrom
mr-raj12:store-cache-check-10397
Open

mr-raj12 wants to merge 2 commits into
borgbackup:masterfrom
mr-raj12:store-cache-check-10397

Conversation

@mr-raj12

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

Copy link
Copy Markdown
Contributor

Description

borg check and borg repo-compress read the packs from the repository, also if BORG_STORE_CACHE is set. This implements idea 1 of #10397, fixes #10397.

The cached packs are not verified against the repository. With the cache:

  • borg check --verify-data reported an integrity error for a damaged cache file, and borg check --repair --verify-data deleted the intact object from the repository.
  • borg check --archives-only --verify-data did not find damage in the repository while an intact copy of the pack was cached.
  • borg repo-compress copies objects that already use the target compression into the new pack without authenticating them, then deletes the old pack. A damaged cache file ended up in the repository.

Changes:

  • Repository(store_cache=True): store_cache=False ignores BORG_STORE_CACHE, all packs are read from the repository.
  • with_repository and get_repository pass store_cache through. check and repo-compress use store_cache=False.
  • Help text of borg check, borg repo-compress and BORG_STORE_CACHE updated.

Tests:

  • test_store_cache_argument: store_cache True/False, local and ssh://.
  • test_store_cache_default_directory: BORG_STORE_CACHE=1 caches the packs in <cache_dir>/storecache.
  • test_check_verify_data_ignores_a_corrupt_store_cache: damaged cached packs, check --verify-data and check --repair --verify-data report no error, no pack is removed.
  • test_check_archives_only_verify_data_ignores_an_intact_store_cache: damaged repository pack, intact cached copy, check --archives-only --verify-data reports the integrity error.
  • test_repo_compress_ignores_a_corrupt_store_cache: damaged cached packs, repo-compress -C none rewrites packs, check --verify-data is clean afterwards.

The three check / repo-compress tests fail if check and repo-compress use the cache.

Not in this PR: other readers (extract, mount, ...) still fail on a damaged cache file until the cache directory is deleted (ideas 2 to 4 of #10397).

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 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.11%. Comparing base (7e3d305) to head (c28db79).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10467      +/-   ##
==========================================
- Coverage   89.12%   89.11%   -0.01%     
==========================================
  Files         103      103              
  Lines       19783    19783              
  Branches     3099     3099              
==========================================
- Hits        17631    17630       -1     
- Misses       1490     1492       +2     
+ Partials      662      661       -1     

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

@mr-raj12

mr-raj12 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on current master, one conflict in the borg check help text resolved by keeping master's --find-lost-archives paragraph.

…ore cache, fixes borgbackup#10397

The cached packs (BORG_STORE_CACHE) are not verified against the repository.
With the cache, check verified the cached copies instead of the repository:
a damaged cache file was reported as an integrity error and check --repair
deleted the intact object from the repository, while damage in the repository
was not found as long as an intact copy was cached. repo-compress copies
objects that already use the target compression into the new pack without
authenticating them, so a damaged cache file ended up in the repository.

Repository(store_cache=False) ignores BORG_STORE_CACHE. with_repository and
get_repository pass it through; check and repo-compress use it.
@mr-raj12

mr-raj12 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on current master, the only conflict was the borg check help text, kept both paragraphs (the --repair one from #10493 first, then the BORG_STORE_CACHE one).

@mr-raj12
mr-raj12 force-pushed the store-cache-check-10397 branch from 32213b9 to c28db79 Compare October 6, 2026 18:25

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.

store cache: a corrupt cache entry is treated as repository corruption, check --repair deletes the healthy chunk

1 participant