Skip to content

Instantly share code, notes, and snippets.

@bivald
Forked from iangreenleaf/rsync-retry.sh
Last active August 2, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bivald/09dd7ad29db8f6970033b8d44d2a9921 to your computer and use it in GitHub Desktop.
Save bivald/09dd7ad29db8f6970033b8d44d2a9921 to your computer and use it in GitHub Desktop.
rsync with retries
#!/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=30
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 -e 'ssh -T -c aes128-ctr -o Compression=no -x' . enplore@enplore+singaporeair+ingestion-sftp:/enplore-data/upload/
sleep 10
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