Last active
May 27, 2016 14:45
-
-
Save MiquelAdell/3ed61d43db3c8c7e0708e6b3a31a1cd2 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
#!/usr/bin/env bash | |
SERVER=vps282893.ovh.net | |
EXCLUDE_LIST=false; | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; | |
if [ "$#" -ne 2 ]; then | |
printf "Usage: upload.sh \e[33;1mname_of_the_directory_on_local_machine\033[0m \e[33;1mname_of_the_directory_on_remote_machine\033[0m\n" 1>&2; | |
exit 1 | |
fi | |
FROM_FOLDER=$1 | |
TO_FOLDER=$2 | |
FROM="/Users/miqueladell/code/vagrant-local/www/$FROM_FOLDER/htdocs/wp-content" | |
TO="/home/miqueladell/websites/$TO_FOLDER" | |
if (test -f "exclude-list.txt"); then | |
# use local exclude list file | |
EXCLUDE_LIST="exclude-list.txt"; | |
else | |
if (test -f "$DIR/exclude-list.txt"); then | |
EXCLUDE_LIST="$DIR/exclude-list.txt"; | |
else | |
printf " \e[31;1mmissing exclude file\033[0m\n" 1>&2; | |
exit 2 | |
fi | |
fi | |
printf " \e[33;1mNOTICE:\033[0m using $EXCLUDE_LIST as exclude file\n" | |
if [ ! -d "$FROM" ]; then | |
printf " \e[31;1m$FROM does not exist\033[0m\n" 1>&2; | |
exit 1 | |
fi | |
if (ssh $SERVER "[ ! -d $TO ]"); then | |
printf " \e[31;1m$TO does not exist\033[0m\n" 1>&2; | |
exit 1 | |
fi | |
read -p "Copiar de $FROM_FOLDER a $TO_FOLDER?" -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
# do dangerous stuff | |
rsync -aphvP --delete --exclude-from $EXCLUDE_LIST $FROM $SERVER:$TO | |
ssh -t vps282893.ovh.net "sudo /home/miqueladell/websites/$TO_FOLDER/post-upload.sh" | |
fi | |
# rsync -aphvP /Users/miqueladell/code/vagrant-local/www/memoriaviva/htdocs/wp-content vps282893.ovh.net:/home/miqueladell/websites/memoriaviva |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment