Skip to content

Instantly share code, notes, and snippets.

@iRhonin
Created June 3, 2020 09:36
Show Gist options
  • Save iRhonin/5aa84c101c15998fc7562aa17f8b1056 to your computer and use it in GitHub Desktop.
Save iRhonin/5aa84c101c15998fc7562aa17f8b1056 to your computer and use it in GitHub Desktop.
Auto Reconnect Rsync
#!/bin/bash
echo -e "Please enter the full (escaped) file path:"
read -r path
echo "Path: $path"
echo -e "Enter the destination:"
read -r dst
echo "Destination: $dst"
while [ 1 ]
do
rsync --progress --partial --delete -az -e ssh "USER@HOST:$path" $dst
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "rsync failure. Retrying in a minute..."
sleep 60
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment