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.

As with most other software it's safer to try new plugins, configuration options or template changes in a separate testing environment, see e.g. WordPress local development environment.

Most questions and answers I've seen about this is the simpler case: doing the initial development locally and then deploy everything to the live site. That is easy. However, what if I need to test some change in the middle of site's life cycle? I guess the steps should be:

  1. Replicate a current state of the site to the testing environment
  2. Test the changes in the testing environment
  3. When done, merge the changes back to live

I know how to do 1+2 but am not sure about 3. This steps breaks down to 2 parts:

  1. Files
  2. Database

Again, 1 is easy so for example template updates are easily migrated from test to live. But 2 is tricky. Copying test db to live is not always possible (there might have been content changes in the meantime etc.), comparing schemas is also not a trivial task, theoretically there could be a plugin that would help with test <-> live synchronization but I'm not sure if it exists.

How do you people deal with this? Any tips & tricks or procedures?

share|improve this question
    
I don't think you're going to get a definitive answer on this. Because what you're asking is so subjective, it seems more fitting that this becomes a community wiki because there is no right or wrong answer for this. –  DigitalSea Mar 1 '12 at 7:27
    
Maybe there's no good answer to this questions, which would be very strange to me as thousands of WP admins need to deal with test/live migration every now and then. –  Borek Mar 1 '12 at 10:44

2 Answers 2

I don't think you will find any comprehensive or easy answer for this. I think the way you already broke down the various aspects of your installation is the key - i.e., thinking of changes to files as different from changes to the database.

Most of the changes I make are at the file level - e.g., CSS, adding code for a hook, stuff like that. They are isolated in files, as you said.

For the changes I make which affect the database, they tend to be compartmentalized as plugins, so they are also easy to isolate and deploy or rollback as long as I keep track of what steps I am taking.

Since you seem more concerned about your database changes, do you have a particular change or type of change that you want to discuss? You could consider doing a MySql dump of both the test and live database and then using a file diff tool to find the differences. In many cases this would probably let you extract a few SQL commands that could be packaged into a deployment script (but this could involve a fair amount of understanding about the underlying database to be sure to get the script right).

share|improve this answer
    
Syncing at the DB level is probably the "ultimate" way but also relatively hard to get (you need to transfer only the right changes and understand what you are doing). I was looking for some simpler way but maybe there isn't. –  Borek Feb 29 '12 at 10:39
    
I agree. In general you'd have to get your hands dirty finding differences between the databases. There is a lengthy discussion of some tools that people have found helpful in finding MySql database diffs here: Compare two MySQL databases –  Shannon Wagner Feb 29 '12 at 14:30

It might sound counterproductive, but to transfer changes locally I usually just delete the database on my local environment, dump a copy of the live database and then open it up in a text editor and do a find and replace of the live url to be that of my local url.

So for example if my live site is: http://www.awesomewidgets.com and my local test url is: http://localhost/awesomewidgets - I'd do a search and replace of "http://www.awesomewidgets.com" and make it "http://localhost/awesomewidgets"

You just then have to remember to copy over any plugins you might have installed on the live site and of course, any uploaded files like images, videos or audio files which are usually inside of your wp-content/uploads folder (unless you changed it).

share|improve this answer
    
I'd agree with this... I've used this method in the past with a local copy of the live database - search and replace urls and all works great. –  Vince Pettit Feb 29 '12 at 9:16
    
You are describing step 1 which is not a problem. Step 3 is. –  Borek Feb 29 '12 at 10:24
    
I don't think there is a simple solution for step 3. If you develop on a unix based machine like a Mac or Linux, then I'm sure there is a way of syncing everything using Git. But to be honest, I don't think there is a definitive solution for this and even setting up some kind of Git based syncing would in itself be time consuming and not worth the effort of just copying things over manually. –  DigitalSea Feb 29 '12 at 12:51
    
How could Git be used with MySQL database? What do you mean? –  Borek Feb 29 '12 at 17:12
    
Git can be used with anything. It's highly configurable. Using Git hooks you can make it do anything like run wrapper scripts every time you commit, push and update. You can essentially use it to keep databases and files synced with one another across different machines, like I said this would be a lot of work but it would work. This link might interest you: stackoverflow.com/questions/4764304/… - there isn't a definitive answer to this, I don't see how there can be one right answer to your question. –  DigitalSea Mar 1 '12 at 1:33

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.