Created
February 14, 2014 01:59
-
-
Save lambdalisue/8994526 to your computer and use it in GitHub Desktop.
A script to pull remote changes to local via rsync
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
#!/usr/bin/env bash | |
BASE=$(pwd) | |
HOST=$1 | |
if [[ "$HOST" = "" ]]; then | |
echo "usage: rsync_pull HOST_ADDRESS" | |
exit 1 | |
fi | |
askYesOrNo() { | |
while true ; do | |
read -p "$1 (y/n)?" answer | |
case $answer in | |
[yY] | [yY]es | YES ) | |
return 0;; | |
[nN] | [nN]o | NO ) | |
return 1;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
} | |
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | |
echo " / / / " | |
echo " / / / PULL files via rsync" | |
echo " / / / " | |
echo " \ \ \ Directory: $BASE" | |
echo " \ \ \ Host: $HOST" | |
echo " \ \ \ " | |
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | |
askYesOrNo "Do you want to pull files in '$BASE' from $HOST?" | |
if [[ $? -eq 0 ]]; then | |
rsync -az --progress $HOST:$BASE/ . | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment