Created
May 4, 2018 18:26
-
-
Save davidmfoley/9ce9d60c583918a50a97e945777c58be to your computer and use it in GitHub Desktop.
Fetch data from remote WP mysql instance to local, companion of https://gist.github.com/davidmfoley/74586660d7cb70165b8196b54973543d
This file contains 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
mysqldump \ | |
-u $REMOTE_USER \ | |
-p$REMOTE_PASS \ | |
-h $REMOTE_HOST \ | |
-P $REMOTE_PORT $REMOTE_DB > ./test-dump | |
mysql -h host.docker.internal -P 3306 --password=wordpress -u wordpress wordpress < ./test-dump | |
# Make local-dev-specific modifications | |
mysql -h host.docker.internal -P 3306 --password=wordpress -u wordpress wordpress \ | |
-e "update wp_options set option_value='http://localhost:8080' where option_name in ('siteurl', 'home');" |
This file contains 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 | |
DIR=$( cd "$( dirname "$0" )" && pwd ) | |
# Set all of these env vars based on your remote server | |
docker run --rm -it \ | |
-e REMOTE_HOST \ | |
-e REMOTE_PASS \ | |
-e REMOTE_PORT \ | |
-e REMOTE_DB \ | |
-e REMOTE_USER \ | |
-v $DIR/fetch-data.sh:/fetch-data.sh mysql:5.7 \ | |
/bin/bash /fetch-data.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment