Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created February 14, 2014 02:00
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/8994532 to your computer and use it in GitHub Desktop.
Save lambdalisue/8994532 to your computer and use it in GitHub Desktop.
A script to push local changes to remote server 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 " \ \ \ PUSH files via rsync"
echo " \ \ \ "
echo " / / / Directory: $BASE"
echo " / / / Host: $HOST"
echo " / / / "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
askYesOrNo "Do you want to push files in '$BASE' to $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