Skip to content

check: summarize findings and repairs - #9891

Open
charmikadi wants to merge 3 commits into
borgbackup:masterfrom
charmikadi:fix/check-repair-summary
Open

check: summarize findings and repairs#9891
charmikadi wants to merge 3 commits into
borgbackup:masterfrom
charmikadi:fix/check-repair-summary

Conversation

@charmikadi

@charmikadi charmikadi commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

borg check already reports individual problems as it finds them, but it was hard to tell at a glance how many issues there were overall, or how many --repair actually fixed.
This adds a short summary at the end of the check:

  • for archive consistency checks, count problems found and repairs done
  • for repository checks, include the error count in the finish message (repo repair still isn't implemented)
    Also updated a few repair tests to cover the new summary lines.

Fixes #2397

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 Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.77%. Comparing base (30194fb) to head (4b7e2a6).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/archive.py 89.28% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9891      +/-   ##
==========================================
- Coverage   86.95%   84.77%   -2.18%     
==========================================
  Files         101      101              
  Lines       17983    18013      +30     
  Branches     2737     2743       +6     
==========================================
- Hits        15637    15271     -366     
- Misses       1639     2045     +406     
+ Partials      707      697      -10     

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

@ThomasWaldmann

Copy link
Copy Markdown
Member

@charmikadi Thanks for helping with this!

Just be aware that @mr-raj12 is currently working on packs and that might need bigger changes in borg check also.

@ThomasWaldmann

Copy link
Copy Markdown
Member

@mr-raj12 Check this, please.

@mr-raj12

Copy link
Copy Markdown
Contributor

Thanks for working on this, @charmikadi! My repo repair PR #10048 is landing soon and it rewrites this same check() finish region in repository.py (the "repository repair not implemented" line goes away) and also ArchiveChecker.finish(), so this PR currently conflicts with master there and it's around 330 commits behind. Would suggest rebasing onto latest master and narrowing this to only the archive-side summary for now, and we can add the repository-side repairs count once #10048 is merged. I'll reuse your counting approach and credit you when I do the follow-up.

@charmikadi
charmikadi force-pushed the fix/check-repair-summary branch from 14337fe to 4b7e2a6 Compare August 20, 2026 04:33

@ThomasWaldmann ThomasWaldmann left a comment

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.

thanks for working on this, some feedback.

please note that @mr-raj12 should be still working on borg check --repair, so this is a potentially ongoing merge conflict.

Comment thread src/borg/archive.py
Comment on lines +1957 to +1960
if self.repair:
self._note_problem(repaired=True)
else:
self._note_problem()

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.

could be just 1 line, using repaired=self.repair.

but there is a bigger problem here: it already assumes that the manifest could be rebuilt (repaired), before even calling rebuild_manifest.

Comment thread src/borg/archive.py
Comment on lines +1986 to +1990
logger.error(
"Archive consistency check complete, %d problem(s) found, %d repaired.",
self.problems_found,
self.repairs_done,
)

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.

this doesn't work for the case that problems were found, but 0 repairs were done.

Comment thread src/borg/archive.py
self.chunks_modified = True
# drop it from our own index too, so rebuild_archives reports the file it belongs to.
del self.chunks[defect_chunk]
self._note_problem(repaired=True)

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.

hmm, guess we need to think more about what "repaired" means. it just deleted a defective chunk. if that chunk is referenced, this means data loss. so, we do not have the defect chunk anymore, but we also lost the data it originally contained.

Comment thread src/borg/archive.py
# longer matches the packs.
self.chunks_modified = False

def _note_problem(self, *, repaired=False):

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.

guess this is important enough to not use a default for repaired, but to require the caller to be always explicit about whether something was repaired or not.

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: summarize findings, --repair: summarize repairs

3 participants