Skip to content

check: detect missing packs referenced by the index (#9898) - #10069

Open
mr-raj12 wants to merge 1 commit into
borgbackup:masterfrom
mr-raj12:vanished-packs-detection-9898
Open

check: detect missing packs referenced by the index (#9898)#10069
mr-raj12 wants to merge 1 commit into
borgbackup:masterfrom
mr-raj12:vanished-packs-detection-9898

Conversation

@mr-raj12

Copy link
Copy Markdown
Contributor

Fixes #9898.

A read-only check verified pack and index integrity separately but never compared them, so a pack that the chunk index still referenced while missing from packs/ passed clean. The loss only showed up later, on extract.

With an intact index, check now loads the chunk index, collects the pack ids it references, and reports any absent from packs/ as errors, failing the check. It is skipped for a corrupt or invalid index, which gets rebuilt from the packs on next use.

Tests cover the detection, the clean case, and the invalid-index skip.

With an intact index, load the chunk index and report any referenced
pack id that is absent from packs/. Such packs are counted as errors so
the check fails. Skipped for a corrupt or invalid index, which is rebuilt
from the packs on next use.
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10069   +/-   ##
=======================================
  Coverage   86.77%   86.78%           
=======================================
  Files          98       98           
  Lines       17109    17124   +15     
  Branches     2591     2595    +4     
=======================================
+ Hits        14847    14861   +14     
  Misses       1570     1570           
- Partials      692      693    +1     

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

Comment thread src/borg/repository.py
Comment on lines +1045 to 1046
if index_invalid:
logger.warning("chunk index is invalid (interrupted operation); it will be rebuilt on next use.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does it makes sense to continue after this warning?

Comment thread src/borg/repository.py
logger.info(summary)
if missing_pack_ids:
# one id per line (the list can be long).
logger.error(f"Found {len(missing_pack_ids)} missing pack(s) referenced by the index:")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Found 42 missing packs ..." can be misunderstood.

Use the same msg as above: "{len(missing_pack_ids)} pack(s) referenced by the index are missing."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also think about the opposite case:

Could it be that we have packs that should be in the index, but aren't?

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.

borg2 check: vanished packs?

2 participants