Skip to content

Instantly share code, notes, and snippets.

@DArcMattr
Last active October 8, 2015 23:48
Show Gist options
  • Save DArcMattr/3406732 to your computer and use it in GitHub Desktop.
Save DArcMattr/3406732 to your computer and use it in GitHub Desktop.
WordPress development install sync script
#!/bin/sh
# Assumptions:
# 1) The machine environment variable is set, WEB_ENVIRONMENT, either 'test' or 'demo'
# 2) The development site URL is $WEB_ENVIRONMENT.$SITE
# 3) The following 3 lines are in wp-config.php
# if ( isset( $_GET[ 'relocate' ] ) && ( $_GET[ 'relocate' ] === $_ENV[ 'WEB_ENVIRONMENT' ] ) ):
# define( 'RELOCATE', TRUE );
# endif;
# 4) https://github.com/interconnectit/Search-Replace-DB is installed, with `replace_db` symlinked to `searchreplacedb2cli.php`
SITE="AAAA"
DB="BBBB"
ssh XXXX@YYYY.ZZZ "mysqldump -C --database $DB" | mysql
replace_db -h localhost -u {wp db user} -d $db -p {wp db user password} -c {db character set} -s "http://$site" -r "http://$WEB_ENVIRONMENT.$site"
curl http://$WEB_ENVIRONMENT.$SITE/wp-login.php?relocate=$WEB_ENVIRONMENT
rsync -rv cor:/var/www/vhosts/$SITE/wp-content/uploads/* /var/www/vhosts/$SITE/wp-content/uploads/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment