check: support custom archive formatting, #9411#9910
Conversation
Add --format and BORG_CHECK_FORMAT to control the archive part of the "Analyzing archive ..." output, like repo-list and prune already do. Archives with damaged or missing metadata fall back to the plain description.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9910 +/- ##
==========================================
+ Coverage 85.13% 85.22% +0.09%
==========================================
Files 93 93
Lines 15899 15921 +22
Branches 2428 2430 +2
==========================================
+ Hits 13535 13569 +34
+ Misses 1654 1648 -6
+ Partials 710 704 -6 ☔ View full report in Codecov by Harness. |
|
@mr-raj12 I am in google meet now. |
ReviewOverviewAdds Verification done: ran the full What's correct (verified, not just read)
Issues / suggestions
RisksLow. The behavior change is cosmetic (log-line formatting), the default stays close to the old output, error paths degrade gracefully, and the feature is opt-in beyond that. The two pre-existing bugs described in the PR text (uncaught Verdict: solid, well-tested contribution; points 1–2 are both two-line changes and worth doing here. 🤖 Review generated with Claude Code |
Fixes #9411.
repo-listandpruneboth let you format the archive part of their output.checkhad it hardcoded, so the format env vars did nothing there.This adds
--formatandBORG_CHECK_FORMAT, same pattern as those two. Default is{archive} {time} {id}, which stays close to the old output.The format gets checked in
do_check(), before the repository check starts. That check can run for hours on a big repo and it would be annoying to only find out about a typo afterwards.Keys like
{comment}need the archive metadata. When it cannot be loaded, formatting falls back to the plain description from the archive directory entry and the checks report the problem as usual. The fallback formats the timestamp the same way the formatter would, so a damaged archive lines up with an intact one.--formatonly affects the archives check, so passing it together with--repository-onlynow raises the same contradiction error as--verify-dataand friends. A setBORG_CHECK_FORMATdoes not, since an env var sitting in a shell profile is a default rather than a request.One behaviour change worth noting: the default
{time}now prints asSun, 2026-02-22 17:01:01 +0000. The old hardcoded line printed2026-02-22 17:01:01.359832+00:00.No changelog entry yet.
Two pre-existing issues found on the way
Both are on master already, not from this PR.
repo-listdies with an uncaughtArchive.DoesNotExistif an archive metadata block is missing, because its default format resolves{username}/{hostname}/{comment}/{tags}andArchiveFormatter.get_metanever catches it.prunehits the same thing with a custom format.A lost archive shows up as
archive-does-not-existwith a 1970 timestamp, which looks like a bug in borg. The name is simply gone: the archives directory entry is stored with empty content, so name and timestamp only exist inside the missing metadata block.Can file both separately if that is useful.