Skip to content

Instantly share code, notes, and snippets.

@davidmfoley
Created May 4, 2018 18:26
Show Gist options
  • Save davidmfoley/9ce9d60c583918a50a97e945777c58be to your computer and use it in GitHub Desktop.
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
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');"
#! /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