-
-
Save vanquishregret/725f72b762b4c0d0b77a46bda8f20da5 to your computer and use it in GitHub Desktop.
rsync with retries
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 | |
### ABOUT | |
### Runs rsync, retrying on errors up to a maximum number of tries. | |
### Simply edit the rsync line in the script to whatever parameters you need. | |
# Trap interrupts and exit instead of continuing the loop | |
trap "echo Exited!; exit;" SIGINT SIGTERM | |
MAX_RETRIES=50 | |
i=0 | |
# Set the initial return value to failure | |
false | |
while [ $? -ne 0 -a $i -lt $MAX_RETRIES ] | |
do | |
i=$(($i+1)) | |
rsync -avz --progress --partial -e "ssh -i /home/youngian/my_ssh_key" /mnt/storage/duplicity_backups [email protected]:. | |
done | |
if [ $i -eq $MAX_RETRIES ] | |
then | |
echo "Hit maximum number of retries, giving up." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment