Last active
September 22, 2016 08:47
-
-
Save aflyhorse/1becec640af335be7f5f3c9307779a80 to your computer and use it in GitHub Desktop.
A script to spur on rsync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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