Skip to content

Instantly share code, notes, and snippets.

@aflyhorse
Last active September 22, 2016 08:47
Show Gist options
  • Save aflyhorse/1becec640af335be7f5f3c9307779a80 to your computer and use it in GitHub Desktop.
Save aflyhorse/1becec640af335be7f5f3c9307779a80 to your computer and use it in GitHub Desktop.
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