Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created February 14, 2014 01:59
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 lambdalisue/8994526 to your computer and use it in GitHub Desktop.
Save lambdalisue/8994526 to your computer and use it in GitHub Desktop.
A script to pull remote changes to local via rsync
#!/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