Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been working away at a medium-size WordPress site. So far I've just been hosting the site on my local machine and showing it to internal consultants over our local network. Things are working well, and now it's time to show it off to the client. I've been using git all along, so pushing it to the dev server was a breeze. I duplicated the local DB and pushed it to the dev server manually, which was fairly easy except that I had to manually change a few URL entries.

Now my question is: what's the best way to keep two instances of WordPress synced? I still have more work to do locally and the DB is going to need to get pushed up again. How do other people manage this in an automated way?

One thought I had was to write a git hook to pull the MySQL data down when I push from my local machine and have a hook on the other end to import the data when the dev server pulls. However, if I do this I'll have to worry about changes to the wp_options table.

Does anyone have any strategies for making this sort of thing easy?

Thanks!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Assuming your wp-config.php is already in place and in order:

  • Step 1. Mysqldump your development database
  • Step 2. Replace all instances of development.domain.com to production.domain.com^^
  • Step 3. Login to MySQL, run a SOURCE command to import data e.g. source /path/to/file

^^ How to replace all instances of old domain with new: (1) Copy the script below. (2) chmod +x it. (3) Run it.

Usage: ./script.sh development-dump.sql > production-dump.sql

#!/bin/sed -f
s/'\([^\\']*\)development.domain.com\([^\\']*\)'/'\1production.domain.com\2'/g
share|improve this answer
2  
I guess this is probably my best option, then. I was hoping to avoid doing something like this, but it's what I'm reading everywhere else as well. The only thing I would change about this is step 3, where I would use mysqlimport so that I could tie all the steps into git hook and have it happen automatically on a pull. Thank you for your help! –  Gavin Anderegg Mar 16 '11 at 23:49

This has been discussed a few times so I'd suggest going over these threads then asking about any gaps you still see.

What process do you use for WordPress development?

Easily Move a WordPress Install from Development to Production?

Ultimately keeping the database in sync is the issue most struggle with. I simply don't really worry about it. I'll import some posts/CPT's if we have a new content type but that's about it the rest I do manually.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.