Skip to content

Instantly share code, notes, and snippets.

@aflyhorse

aflyhorse/rrsync

Last active Sep 22, 2016
Embed
What would you like to do?
A script to spur on rsync
#!/bin/bash
# A script to spur on rsync.
# Released under GPLv3, copyright LunarShaddow
# retry cap
MAXTRY=10
# safety-keep sleep interval
SLEEPSEC=600
RVALUE=0
i=0
while [[ i -lt $MAXTRY ]] ; do
echo "[Started] at $(date)"
rsync --partial "$@"
RVALUE=$?
echo "[Exited] at $(date) with code $RVALUE"
if [[ $RVALUE -lt 10 || $RVALUE -eq 20 ]] ; then
break
fi
(( i += 1 ))
echo "Something went wrong. Retry count: $i/$MAXTRY"
echo "For God's sake, rest for a while."
sleep $SLEEPSEC
done
exit $RVALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment