Last active
December 18, 2015 14:39
-
-
Save nateflink/5798915 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 | |
#By Nate Flink | |
# | |
# get the wp-config mysql variables | |
# | |
DIRPATH=$1 | |
VAR=$(curl -s https://gist.github.com/nateflink/06c5f5f99002374fe628/raw/readwpconfig.sh | bash -s "${DIRPATH}/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]} | |
# | |
# export mysql database | |
# | |
VAR=$(curl -s https://gist.github.com/nateflink/5790798/raw/mysqldump.sh | bash -s $WPDBNAME $WPDBUSER $WPDBPASS $WPDBHOST "${DIRPATH}/backup.sql") | |
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 2; } | |
# | |
# make a copy of wordpress files to /tmp directory | |
# | |
DATE=`date +%Y-%m-%d_%H:%M:%S` | |
DIRS=(${DIRPATH//\// }) | |
TMPPATH="/tmp/"${DIRS[${#DIRS[@]} - 1]}"_$DATE" | |
cp -rp ${DIRPATH} ${TMPPATH} | |
echo "${TMPPATH}"; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment