Skip to content

Instantly share code, notes, and snippets.

@dannygsmith
Last active December 13, 2017 03:47
Show Gist options
  • Save dannygsmith/084b9b77ffe6ddeddb2d568b30278f96 to your computer and use it in GitHub Desktop.
Save dannygsmith/084b9b77ffe6ddeddb2d568b30278f96 to your computer and use it in GitHub Desktop.
Restore all WordPress databases in laravel valet
#!/usr/bin/env bash
SUFFIX=`date "+%w"`
#styles
VP_NONE='\033[00m'
VP_RED='\033[01;31m'
VP_GREEN='\033[01;32m'
VP_YELLOW='\033[01;33m'
VP_PURPLE='\033[01;35m'
VP_CYAN='\033[01;36m'
VP_WHITE='\033[01;37m'
VP_BOLD='\033[1m'
VP_UNDERLINE='\033[4m'
readarray arr < ${HOME}/bin/hosts.txt
## now loop through the above array
for k in "${arr[@]}"
do
echo " "
echo " "
cd "${HOME}/Sites/${k}"
echo -e "${VP_GREEN}Creating $k${VP_NONE}"
wp db drop --yes
wp db create
printf -v x "%s%s-%s.sql" "${HOME}/Dropbox/backups/" $k $SUFFIX
wp db import $x
done
#brew postinstall mysql
#mysql_secure_installation
#mysql.server start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment