bundles/backup-client: actually show which rsync call produced which error

This commit is contained in:
Franzi 2021-08-01 07:57:22 +02:00
parent 1ae328d8f3
commit e596b45344
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 11 additions and 9 deletions

View file

@ -17,20 +17,22 @@ if now-mtime > 60*60*24*2:
exit(3) exit(3)
with open(statusfile, 'r') as f: 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') print('OK')
exit(0) exit(0)
elif status[0] == 'rsync_error': elif exitcode == 'rsync_error':
print('rsync produced some errors, exit codes were: {}'.format( print('rsync produced some errors, exit codes were:')
', '.join(status[1:]) for line in status[1:]:
)) print(line)
exit(2) exit(2)
elif status[0] == 'hook': elif exitcode == 'hook':
print('run-parts /etc/backup-pre-hook.d failed with exit code {}'.format(status[1])) print('run-parts /etc/backup-pre-hook.d failed with exit code {}'.format(status[1]))
exit(2) exit(2)
elif status[0] == 'abort_no_key': elif exitcode == 'abort_no_key':
print('no ssh key found in /etc/backup.priv!') print('no ssh key found in /etc/backup.priv!')
exit(1) exit(1)
else: else:

View file

@ -29,7 +29,7 @@ do_backup() {
exitcode=$? exitcode=$?
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]] if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
then then
rsync_errors+=" $exitcode" rsync_errors+="\n$1 $exitcode"
fi fi
} }