Created
June 18, 2013 19:04
-
-
Save nateflink/5808260 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
WPPATH=$1 | |
REMOTE_WPPATH=$2 | |
SSH_USER=$3 | |
SSH_URL=$4 | |
LOCAL_HOSTNAME=$5 | |
REMOTE_HOSTNAME=$6 | |
# | |
# copy the remote wp installation to the remote tmp directory | |
# | |
REMOTE_TMPPATH=$(ssh ${SSH_USER}@${SSH_URL} '\ | |
VAR=$(curl -s https://gist.github.com/nateflink/5798915/raw/copywp.sh | bash -s '${REMOTE_WPPATH}' );\ | |
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 1; };\ | |
echo $VAR\ | |
') | |
#echo $REMOTE_TMPPATH | |
# | |
# copy local wp installation to a tmp location | |
# | |
TMPPATH=$(curl -s https://gist.github.com/nateflink/5798915/raw/copywp.sh | bash -s ${WPPATH} ) | |
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 1; } | |
#echo $TMPPATH | |
# | |
# find and replace urls in the temp path location | |
# | |
VAR=$(curl -s https://gist.github.com/nateflink/5793139/raw/findreplace.sh | bash -s ${TMPPATH} ${LOCAL_HOSTNAME} ${REMOTE_HOSTNAME}) | |
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 1; } | |
# | |
# copy the tmp local wordpress to the remote location | |
# | |
rsync -r -v -l --exclude ".*" --include=".htaccess" ${TMPPATH}/ ${SSH_USER}@${SSH_URL}:"${REMOTE_TMPPATH}" | |
# | |
# switch the old wp with the new wp and import mysql database | |
# | |
DATE=`date +%Y-%m-%d_%H:%M:%S` | |
DIRS=(${REMOTE_WPPATH//\// }) | |
REMOTE_BACKUPPATH="./"${DIRS[${#DIRS[@]} - 1]}"_$DATE" | |
RMVAR=$(ssh ${SSH_USER}@${SSH_URL} '\ | |
mv '${REMOTE_WPPATH}' '${REMOTE_BACKUPPATH}';\ | |
mv '${REMOTE_TMPPATH}' '${REMOTE_WPPATH}';\ | |
VAR=$(curl -s https://gist.github.com/nateflink/06c5f5f99002374fe628/raw/readwpconfig.sh | bash -s "'${REMOTE_WPPATH}'/wp-config.php");\ | |
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 1; };\ | |
IFS=" " read -a ARR <<< "${VAR}";\ | |
WPDBNAME=${ARR[0]};\ | |
WPDBUSER=${ARR[1]};\ | |
WPDBPASS=${ARR[2]};\ | |
WPDBHOST=${ARR[3]};\ | |
mysql -u ${WPDBUSER} -p${WPDBPASS} -h ${WPDBHOST} ${WPDBNAME} < '${REMOTE_WPPATH}'/backup.sql;\ | |
') | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment