Created
February 14, 2014 02:00
-
-
Save lambdalisue/8994532 to your computer and use it in GitHub Desktop.
A script to push local changes to remote server 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 " \ \ \ 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