Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repair count to borg check --repair output #8260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1870,9 +1870,14 @@ def check(
match=match, first=first, last=last, sort_by=sort_by, older=older, oldest=oldest, newer=newer, newest=newest
)
self.orphan_chunks_check()
self.repair_count = 0
self.orphan_chunks_check()
Comment on lines 1872 to +1874
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you accidentally duplicated the call to orphan_chunks_check.

self.finish()
if self.error_found:
logger.error("Archive consistency check complete, problems found.")
if self.repair_count > 0:
logger.error(f"Archive consistency check complete, problems found and {self.repair_count} problem(s) repaired.")
else:
logger.error("Archive consistency check complete, problems found.")
else:
logger.info("Archive consistency check complete, no problems found.")
return self.repair or not self.error_found
Expand Down Expand Up @@ -2338,7 +2343,9 @@ def orphan_chunks_check(self):
)
for id_ in unused:
self.repository.delete(id_)
self.repair_count += 1
Copy link
Member

Choose a reason for hiding this comment

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

Guess it is least important to count the fixed orphaned objects - while they should not occur in the ideal case, there can be conditions producing them.

But, orphans (chunks that are not referenced by any archive) are only a cosmetic issue and we could also just silently remove them (that's why the log message is on INFO level, not WARNING or ERROR).

It would be more important to count the severe "repaired" issues, e.g. if a referenced chunk is missing from the repo and was replaced by an all-zero replacement chunk. That's data loss and the repair is only bringing back consistency, but it's not bringing back the data.

If such a lost chunk reappears later, borg check can also heal it, that's a real repair then.

logger.info("Finished deleting orphaned/superseded objects.")

else:
logger.info("Orphaned objects check skipped (needs all archives checked).")

Expand Down
Loading