Database sync between local and production

I was watching Mark Jaquith’s presentation at WCSF 2013 recently and in the Q&A Mark mentioned something about rsync – after a quick Google I can see this is done via SSH – my question is this: is this something that can be done to a local development environment? Do you still need to copy the database and change configuration, url references etc? For a local setup should I just stick to using a script to change the references?

1 Answer
1

If you have databases reachable from the outside ie: mysql1.example.com you can work on a local development environment connected to that the whole time.

I just found a nice thing to put in wp-config.php to be able to change the host depending on your environment

$host = $_SERVER['HTTP_HOST'];
define( 'WP_HOME', 'http://' . $host );
define( 'WP_SITEURL', 'http://' . $host );

Then there are setups like:

  • Varying Vagrant: https://github.com/10up/varying-vagrant-vagrants
  • WP-Stack: https://github.com/markjaquith/WP-Stack

Leave a Comment