Last active
November 16, 2019 17:51
-
-
Save hmartiniano/ad4e37bd99f5935e69057fb291ba88a0 to your computer and use it in GitHub Desktop.
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 | |
# 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