Link to home
Start Free TrialLog in
Avatar of Andrew Angell
Andrew AngellFlag for United States of America

asked on

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

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!
Avatar of Marc Alonso
Marc Alonso
Flag of Australia image

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 :)
Avatar of Andrew Angell

ASKER

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.
Andrew,

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:

http://adamspiers.org/computing/mysqldiff/
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.
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.

<shrug>

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.
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?
Mmmm.  Now that I understand better, forget that tool.  I'm thinking navicat is more what you want, possibly Toad:

http://software.dell.com/products/toad-for-mysql

There's also a ton of commercial tools for MySQL data merging but they can be pricey ($250 and up).
ASKER CERTIFIED SOLUTION
Avatar of Lucas Bishop
Lucas Bishop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

Thanks!