From e596b45344d6197cafb19edc759a065d9e68bbf3 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 1 Aug 2021 07:57:22 +0200 Subject: [PATCH] bundles/backup-client: actually show which rsync call produced which error --- .../backup-client/files/check_backup_last_run | 18 ++++++++++-------- bundles/backup-client/files/generate-backup | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bundles/backup-client/files/check_backup_last_run b/bundles/backup-client/files/check_backup_last_run index 0fa0fa6..8cc6963 100644 --- a/bundles/backup-client/files/check_backup_last_run +++ b/bundles/backup-client/files/check_backup_last_run @@ -17,20 +17,22 @@ if now-mtime > 60*60*24*2: exit(3) with open(statusfile, 'r') as f: - status = f.read().split() + status = f.read().splitlines() -if status[0] == 'ok': +exitcode = status[0].strip() + +if exitcode == 'ok': print('OK') exit(0) -elif status[0] == 'rsync_error': - print('rsync produced some errors, exit codes were: {}'.format( - ', '.join(status[1:]) - )) +elif exitcode == 'rsync_error': + print('rsync produced some errors, exit codes were:') + for line in status[1:]: + print(line) exit(2) -elif status[0] == 'hook': +elif exitcode == 'hook': print('run-parts /etc/backup-pre-hook.d failed with exit code {}'.format(status[1])) exit(2) -elif status[0] == 'abort_no_key': +elif exitcode == 'abort_no_key': print('no ssh key found in /etc/backup.priv!') exit(1) else: diff --git a/bundles/backup-client/files/generate-backup b/bundles/backup-client/files/generate-backup index ab81d30..5c39909 100644 --- a/bundles/backup-client/files/generate-backup +++ b/bundles/backup-client/files/generate-backup @@ -29,7 +29,7 @@ do_backup() { exitcode=$? if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]] then - rsync_errors+=" $exitcode" + rsync_errors+="\n$1 $exitcode" fi }