Created
May 17, 2019 00:47
-
-
Save davemac/ecfb9efd220749830cda3bd51c21fedf to your computer and use it in GitHub Desktop.
Revisions
-
davemac created this gist
May 17, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # pull a staging WP database to an existing local site # uses current directory as theme path and ssh alias pullstage() { # set -x START=$(date +%s) # get current directory name, used for database and URL # TODO: use echo get_template_directory() and get characters from right to first / current=${PWD##*/} cd ~/Sites/$current # make a backup of the current local database wp db export _db.sql wp db reset --yes # connect to remote site and export the remote database down to our local directory wp @stage db export - > $current.sql echo "rsync of remote database to $current directory complete." wp db import # database is now imported so delete it rm -rf $current.sql # update everything wp plugin update --all wp theme update --all wp core update wp core language update # activate plugins used for development wp plugin activate debug-bar query-monitor acf-theme-code-pro wp plugin deactivate passwords-evolved # get the remote site URL, remove the http:// for our search replace pull_staging_url=$(wp @stage eval '$full_url=get_site_url();$trimmed_url=str_replace("https://", "", $full_url); echo $trimmed_url;') wp search-replace "$pull_staging_url" "$current.localhost" --all-tables-with-prefix # udpate local admin user for easy access dmcweb cd ~/Sites/$current/wp-content/themes/$current # add ACF licence key, thanks @mishtershmart wp eval "acf_pro_update_license('b3JkZXJfaWQ9MzM0NDR8dHlwZT1kZXZlbG9wZXJ8ZGF0ZT0yMDE0LTA3LTA4IDAzOjAyOjI0');" END=$(date +%s) DIFF=$(( $END - $START )) echo -e "\n$pull_staging_url database now in use on $current.localhost site.\nIt took $DIFF seconds, enjoy!\n" }