bundles/backup-client: more logging, fix wrong variable name

This commit is contained in:
Franzi 2021-08-08 07:47:07 +02:00
parent c14bb43993
commit bb519adb2c
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -7,6 +7,7 @@ NL=$'\n'
if ! [[ -f /etc/backup.priv ]]
then
echo "/etc/backup.priv does not exist" | logger -t backup-client -p user.error
echo "abort_no_key" > "$statusfile"
exit 1
fi
@ -15,6 +16,7 @@ run-parts --exit-on-error -- /etc/backup-pre-hooks.d
exitcode=$?
if [[ $exitcode != 0 ]]
then
echo "run-parts /etc/backup-pre-hooks.d exited $exitcode" | logger -t backup-client -p user.error
echo "hook $exitcode" > "$statusfile"
exit 1
fi
@ -25,7 +27,7 @@ do_backup() {
for try in {1..5}
do
echo "Running Backup for $1, try $try ..." >&2
echo "Backup for '$1', try $try ..." | logger -t backup-client -p user.info
# Compress level 1 is a good compromise between speed and cpu usage.
rsync --compress-level=1 -aAP --numeric-ids --delete --relative \
@ -36,6 +38,7 @@ do_backup() {
# Exit code 24 means some files have vanished during rsync.
# I don't know why, but this is very common, apparently?
exitcode=$?
echo "Backup for '$1' try $try exited $exitcode" | logger -t backup-client -p user.info
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
then
rsync_errorcodes_for_this_path+=" $exitcode"
@ -48,8 +51,9 @@ do_backup() {
if [[ "$backup_has_successfully_run" != "yes" ]]
then
echo "Backup for '$1' did not succeed!" | logger -t backup-client -p user.error
<%text>
rsync_errors+="${NL}${1}${rsync_errors_for_this_path}"
rsync_errors+="${NL}${1}${rsync_errorcodes_for_this_path}"
</%text>
fi
}