Skip to content

Instantly share code, notes, and snippets.

@mklasen
Created August 9, 2019 11:09
Show Gist options
  • Save mklasen/096979b37d300b16202e75da0351f8dd to your computer and use it in GitHub Desktop.
Save mklasen/096979b37d300b16202e75da0351f8dd to your computer and use it in GitHub Desktop.
Migrate a database from local to staging/production with WP CLI and SSH
##
# This assumes the following folder structure
# Local environment:
# ./app/
# ./app/www/
# ./_db_dumps/
#
# Production/staging environment:
# ./wordpress/current/
# ./_db_dumps/
###
# Local, in: ./app/www/ folder
wp db export latest.sql && mv *.sql ../../_db_dumps/
# Local, in: ./
scp _db_dumps/latest.sql user@host:_db_dumps/
# Server, in: ./wordpress/current/:
wp db import ~/_db_dumps/latest.sql && wp search-replace "localdomain.test" "productdomain.com" --all-tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment