Skip to content

Instantly share code, notes, and snippets.

@spicecadet
Created November 17, 2018 10:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spicecadet/71d65fab0480812bc66b09b69d056253 to your computer and use it in GitHub Desktop.
Save spicecadet/71d65fab0480812bc66b09b69d056253 to your computer and use it in GitHub Desktop.
WP-CLI Get Production DB
#!/bin/bash
#get siteurl option from prod and dev
PROD_SITEURL=$(wp @prod option get siteurl);
DEV_SITEURL=$(wp @dev option get siteurl);
#Export database from prod and import to dev
wp @prod db export - > prod.sql
wp @dev db import /srv/www/edmund/prod.sql
#Update siteurl
wp @dev search-replace $PROD_SITEURL $DEV_SITEURL
#Remove .sql file
rm prod.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment