|
|
@@ -304,6 +304,9 @@ def main(argv: list[str]): |
|
|
|
if borg.stdin is None: |
|
|
|
raise Exception("no pipe") |
|
|
|
|
|
|
|
borg_saw_warnings = 0 |
|
|
|
borg_saw_errors = 0 |
|
|
|
|
|
|
|
# Use a thread to capture output |
|
|
|
def reader_thread(fh): |
|
|
|
last_progress = 0 |
|
|
@@ -313,7 +316,20 @@ def main(argv: list[str]): |
|
|
|
if ((data['type'] == 'log_message' or |
|
|
|
data['type'] == 'progress_message') |
|
|
|
and 'message' in data): |
|
|
|
line = (data['message'] + '\n').encode() |
|
|
|
|
|
|
|
# Count warnings and errors, but ignore some. |
|
|
|
changed_msg = "file changed while we backed it up" |
|
|
|
if data['levelname'] == 'WARNING': |
|
|
|
prefix = "warning: " |
|
|
|
if changed_msg not in data['message']: |
|
|
|
borg_saw_warnings += 1 |
|
|
|
elif data['levelname'] not in ('DEBUG', 'INFO'): |
|
|
|
prefix = "error: " |
|
|
|
borg_saw_errors += 1 |
|
|
|
else: |
|
|
|
prefix = "" |
|
|
|
|
|
|
|
line = (prefix + data['message'] + '\n').encode() |
|
|
|
elif data['type'] == 'archive_progress': |
|
|
|
now = time.time() |
|
|
|
if now - last_progress > 10: |
|
|
@@ -359,8 +375,12 @@ def main(argv: list[str]): |
|
|
|
ret = borg.returncode |
|
|
|
if ret < 0: |
|
|
|
backup.log('E', f"borg exited with signal {-ret}") |
|
|
|
elif ret != 0: |
|
|
|
backup.log('E', f"borg exited with return code {ret}") |
|
|
|
elif ret == 2 or borg_saw_errors: |
|
|
|
backup.log('E', f"borg exited with errors (ret={ret})") |
|
|
|
elif ret == 1 or borg_saw_warnings: |
|
|
|
backup.log('W', f"borg exited with warnings (ret={ret})") |
|
|
|
else: |
|
|
|
backup.log('E', f"borg exited with unknown error code {ret}") |
|
|
|
|
|
|
|
# See if we had any errors |
|
|
|
warnings = sum(1 for (letter, msg) in backup.logs if letter == 'W') |
|
|
|