Skip to content

check: --find-lost-archives reuses the archive metadata ids found by --verify-data, fixes #8478 - #10447

Open
mr-raj12 wants to merge 3 commits into
borgbackup:masterfrom
mr-raj12:check-find-lost-archives-verify-data-8478
Open

mr-raj12 wants to merge 3 commits into
borgbackup:masterfrom
mr-raj12:check-find-lost-archives-verify-data-8478

Conversation

@mr-raj12

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

Copy link
Copy Markdown
Contributor

Description

borg check --verify-data --find-lost-archives read every object twice: once in verify_data and once in rebuild_archives_directory to find the archive metadata objects.

verify_data now records the ids of the archive metadata objects it parses, including chunks that succeed on the --repair retry, in ArchiveChecker.archive_meta_ids. If the pass is interrupted, the ids stay None.

If archive_meta_ids is not None, rebuild_archives_directory reads only those objects. Otherwise it reads the meta dict (ro_type, without the data) of every object to find them.

Behavior change: with --verify-data and without --repair, an archive metadata object that fails in verify_data (corrupted, or a transient read error) is reported only by verify_data and not read again. The full scan no longer runs, so the extra "Skipping corrupted chunk" message is gone. error_found is the same.

Tests:

  • test_check_undelete_archives and test_spoofed_archive run with and without --verify-data.
  • New tests cover id collection (including a soft-deleted archive), an interrupted verify_data, and chunks kept by the --repair retry.
  • test_check_find_lost_archives_corrupt_archive_meta checks which step reports a corrupt archive metadata object, with and without --verify-data.
  • rebuild_archives_directory tests cover an interrupted rebuild on both paths and skipping a corrupt, non-archive or invalid msgpack object from archive_meta_ids.

fixes #8478

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.86%. Comparing base (8274470) to head (a4c459b).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10447      +/-   ##
==========================================
+ Coverage   88.73%   88.86%   +0.12%     
==========================================
  Files         103      103              
  Lines       19387    19405      +18     
  Branches     3023     3028       +5     
==========================================
+ Hits        17204    17244      +40     
+ Misses       1514     1495      -19     
+ Partials      669      666       -3     

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

@mr-raj12

Copy link
Copy Markdown
Contributor Author

Best merged after the stack (#10443 → #10445 → #10455 → #10464). This and #10458 change the same import line in check_cmd_test.py, so whichever goes in second needs a one-line fixup — I will push it as soon as the first one lands.

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.

borg2: check --verify-data --find-lost-archives can be made faster

1 participant