Skip to content

Instantly share code, notes, and snippets.

@hmartiniano
Last active November 16, 2019 17:51
Show Gist options
  • Save hmartiniano/ad4e37bd99f5935e69057fb291ba88a0 to your computer and use it in GitHub Desktop.
Save hmartiniano/ad4e37bd99f5935e69057fb291ba88a0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# script to transfer the contents of a remote directory to a local machine
# the script use a brute force approach where the transfer is repeated if
# the return code of the rsync command is anything other than 0 (e.g. if an error occurs)
USERNAME=root
REMOTE_HOST=192.168.1.1
REMOTE_DIR=/home/example
LOCAL_DIR=.
while true
do
rsync -avz ${USERNAME}@${REMOTE_HOST}:${DIR} ${LOCAL_DIR}
if [ $? -eq 0 ] ; then
exit 0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment