How to manage separate test version of WordPress site..??

Posted on 2015-01-31
Medium Priority
Last Modified: 2015-02-17
I feel like there must be an easier way to handle testing/dev servers separately from live WordPress sites.  Here's the basic, current process I follow now.

If I have a live site at www.domain.com, I create mirror of that site at sandbox.domain.com with a separate database and separate site files, of course, but at that point they're both the same.

Then on the sandbox I can change to a new theme, make new pages, re-arrange things, and get it all setup the way I want the live site to eventually look.  Let's say that takes a week.

During that week, though, new pages/posts were created on the live site, comments, orders in WooCommerce, etc. and this data does not exist on my sandbox site.

What's the best way to get all of the changes I made on my sandbox back to my live site without losing any data or simply re-doing everything I did on the sandbox to the live site (which isn't a great option anyway because during that time the site is in a "re-arrange" mode.)

I'm thinking maybe I could use a MySQL tool like Navicat or MySQL Workbench to sync the live database and sandbox database, and then copy the sandbox site files to the live site, and in theory that should do it..??  Is there a better way?

Any information on this would be greatly appreciated.  Thanks!
Question by:Andrew Angell

Expert Comment

by:Marc Alonso
ID: 40582042
1.Under Tools there should be export.
2. Select All content
3. Download Export File (This will spit out a xml file with everything (settings, posts, pages) etc)
4. On the live site site, simply go to Tools
5. Click Import
6. Click Wordpress (install the wordpress importer plugin if asked)
7. Upload the file.

Everything should be restored on the live site.

Hope this helps :)
LVL 11

Author Comment

by:Andrew Angell
ID: 40582071
Does that add duplicates of existing pages, though, or does it update and add new records based on record IDs?

Also, it's not just a simple matter of restoring data from sandbox to live.  It's the fact that both the live site db and the sandbox db would have changes that need to be synced rather than a one-way restore.

As I mentioned, let's say I'm building in my sandbox site for a week, or even a month or more.  During that time lots of stuff is changing in the sandbox db, but also lots of stuff changing on the live site db.

When it's time to apply the new theme/content to the live site, that's where I'm getting stuck.  I'm going to need to migrate the site files, for one, so I get the theme, child theme, template files, etc. that I may have created, and I'm going to need the sandbox data so the theme functions the way I've configured it on the sandbox, but I need to keep all the content and new data from the live site that came in during that time I was building on the sandbox.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40582111

Changes to files should be no big deal.  Assuming everything is functional on test, you just upload the altered files and life goes on.

The database is a bit of a different story.  Generally speaking, theme changes shouldn't touch anything in the wp_posts, _postmeta, _users, _usermeta, etc. tables...just wp_options.  So since you only have one table to worry about you could dump both copies of the table to text and use a diff check tool to extract the differences and import those to live when ready.

A slightly fancier way to do it is via the MySQL-Diff perl module:

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

LVL 11

Author Comment

by:Andrew Angell
ID: 40582115
Many themes will use different variations of custom fields and/or page template settings, etc.  In order to get a theme working nicely you have to make adjustments to these settings in the pages/posts, which would then reflect in that data.  So then if I just migrate all the files, the theme might be in place, but the functionality and the layout of things wouldn't be right because it wouldn't have all of those details in the data migrated.  

I'll check this thing out and see if it'll suit my needs.  I was about to play with Navicat's sync tools, too, and see if that might do what i'm after.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40582119
In order to get a theme working nicely you have to make adjustments to these settings in the pages/posts, which would then reflect in that data.


My answer still applies in that case, you just have use the perl tool or something like it to merge the changes from local to live gently.  

If you are changing postmeta on a post-by-post or page-by-page basis, though...yikes. Not sure what you would do to content created since you began the process other than merge, download, alter, merge again.
LVL 11

Author Comment

by:Andrew Angell
ID: 40582121
It's pretty common for themes to use features like that, so yeah, when making a change to a new theme, if you want that new theme to actually look and function the way it's meant to, you have to make those adjustments to posts/pages accordingly.  

The perl tool (as well as what i'm seeing in navicat) looks like a one-way tool.  Seems that it would be used to keep an up-to-date copy of one database to another database.  

What I need, though, is a two-way sync.  If I simply make all of the changes on my sandbox and then migrate that back directly I would lose any posts, comments, pages, etc. that were added on the live site while I was working on the sandbox.

Unless I'm wrong about that?  Does the perl tool work with two-way sync and I'm just not seeing that?
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40582124
Mmmm.  Now that I understand better, forget that tool.  I'm thinking navicat is more what you want, possibly Toad:


There's also a ton of commercial tools for MySQL data merging but they can be pricey ($250 and up).
LVL 18

Accepted Solution

Lucas Bishop earned 2000 total points
ID: 40582733
There are a variety of tools to help you manage multiple Wordpress test environments, for example:

However these lack the ability to merge database changes/content. I'm not familiar with any plugins for Wordpress that provide this functionality, as its something that can really pose a disaster.  There are staging plugins but from what I've seen they Only provide a one-way pull

Many hosts nowadays provide staging environments for Wordpress that offer simple copy over to production:

And a middle ground option:
LVL 11

Author Comment

by:Andrew Angell
ID: 40615749
The wp stagecoach thing looks like the closest to what I'm after.  I already handle creating my own staging sites, it's just the data migration between the two that's been giving me issues.  They must doing some sort of sync, so I'll just checkout their plugin code and see if I can figure something out for myself.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
Wordpress Horizontal Drop-Down Menu In this tutorial I will show you had to add a WordPress horizontal navigation menu to your theme. I have searched and searched for a good tutorial on creating a WordPress nav menu without adding a plug-in or us…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question