bundles/backup-client: use a bash function to do backups instead of repeating the same code over and over
This commit is contained in:
parent
adeb8eff88
commit
65e6b8d053
1 changed files with 16 additions and 10 deletions
|
@ -17,18 +17,24 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
do_backup() {
|
||||
rsync -zaAP --numeric-ids --delete --relative \
|
||||
--rsync-path="/usr/bin/rsync --fake-super" \
|
||||
-e "ssh -o IdentityFile=/etc/backup.priv -o StrictHostKeyChecking=accept-new -p ${port}" \
|
||||
"$1" "$ssh_login":backups/
|
||||
|
||||
# Exit code 24 means some files have vanished during rsync.
|
||||
# I don't know why, but this is very common, apparently?
|
||||
exitcode=$?
|
||||
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
|
||||
then
|
||||
rsync_errors+=" $exitcode"
|
||||
fi
|
||||
}
|
||||
|
||||
rsync_errors=""
|
||||
% for path in sorted(paths):
|
||||
rsync -zaAP --numeric-ids --delete --relative \
|
||||
--rsync-path="/usr/bin/rsync --fake-super" \
|
||||
-e "ssh -o IdentityFile=/etc/backup.priv -o StrictHostKeyChecking=accept-new -p ${port}" \
|
||||
"${path}" "$ssh_login":backups/
|
||||
|
||||
exitcode=$?
|
||||
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
|
||||
then
|
||||
rsync_errors+=" $exitcode"
|
||||
fi
|
||||
do_backup "${path}"
|
||||
% endfor
|
||||
|
||||
if [[ -n "$rsync_errors" ]]
|
||||
|
|
Loading…
Reference in a new issue