2020-11-13 11:36:52 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
statusfile=/var/tmp/backup.monitoring
|
|
|
|
ssh_login="${username}@${server}"
|
|
|
|
|
|
|
|
if ! [[ -f /etc/backup.priv ]]
|
|
|
|
then
|
|
|
|
echo "abort_no_key" > "$statusfile"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-07 19:47:22 +00:00
|
|
|
run-parts --exit-on-error -- /etc/backup-pre-hooks.d
|
|
|
|
exitcode=$?
|
|
|
|
if [[ $exitcode != 0]]
|
|
|
|
then
|
|
|
|
echo "hook $exitcode" > "$statusfile"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-13 11:36:52 +00:00
|
|
|
rsync_errors=""
|
|
|
|
% for path in sorted(paths):
|
|
|
|
rsync -zaAP --numeric-ids --delete --relative \
|
|
|
|
--rsync-path="/usr/bin/rsync --fake-super" \
|
2020-11-14 11:49:57 +00:00
|
|
|
-e "ssh -o IdentityFile=/etc/backup.priv -o StrictHostKeyChecking=accept-new -p ${port}" \
|
2020-11-13 11:36:52 +00:00
|
|
|
"${path}" "$ssh_login":backups/
|
|
|
|
|
|
|
|
exitcode=$?
|
2020-11-13 12:23:57 +00:00
|
|
|
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
|
2020-11-13 11:36:52 +00:00
|
|
|
then
|
2020-11-13 12:23:57 +00:00
|
|
|
rsync_errors+=" $exitcode"
|
2020-11-13 11:36:52 +00:00
|
|
|
fi
|
|
|
|
% endfor
|
|
|
|
|
|
|
|
if [[ -n "$rsync_errors" ]]
|
|
|
|
then
|
|
|
|
echo "rsync_error$rsync_errors" > "$statusfile"
|
2020-11-13 12:23:57 +00:00
|
|
|
else
|
|
|
|
echo "ok" > "$statusfile"
|
2020-11-13 11:36:52 +00:00
|
|
|
fi
|