Mergebot: Simple Database Merging for WordPress?
So you’ve wrapped up a WordPress website overhaul and you’re ready to deploy. There’s only one problem. How do you deploy your development site without losing all of the updates and new content added to the production site while you were developing?
What you need is some way to compare your development database to the production database, merge the two databases, and resolve any conflicts one by one. The only problem is, there is no such tool. Or is there?
In this post, we’ll check out Mergebot, take it for a spin, consider the pros and cons of using Mergebot, and highlight interesting alternatives for database merging.
Ready? Let’s get to it.
Disclaimer: I joined Mergebot’s beta program as a paying program member to get access to Mergebot. Delicious Brains did not know about this review — as a matter of fact, they’ll find out about it the same time you do: when the article is published.
How Does Mergebot Work
Let’s walk through the development workflow for working with Mergebot.
- You clone a production site to a development environment.
- You install Mergebot on both the development and production sites.
- As you make changes to your development site, Mergebot records these changes.
- Periodically, you pull down a new copy of the production database and use it to refresh the development database.
- Each time you refresh your development database you use Mergebot to reapply the changes made to your development site. That way, you development site has your latest production data and all of your development work.
- Once you’re ready to deploy work to the production site, just head to Tools > Mergebot and hit the button to Apply Changeset and all of your development changes will be applied to the production site database.
In the end, you’ll be able to deploy changes from the development database to the production database without causing any loss of data.
Sounds great right? Let’s see how things play out in practice.
Mergebot in Action
The first thing to do when getting started with Mergebot is to clone your production site to a development environment. Then, once you have your development site set up, install the Mergebot plugin on both sites.
With the plugin installed and activated, an admin notice appears letting you know that you need to complete installation by adding an API key to each site’s wp-config.php file.
Once the Mergebot API key has been defined on both the development and production sites, a visit to the Tools > Mergebot menu on the development site will allow you to link the sites.
Mergebot is now set up. However, it isn’t tracking any changes. To start keeping track of changes to the development site, you have to click the button in the top right corner of the admin bar.
Now it’s time to make some changes. To test things out, I turned on recording and created a new post on the development site. Then I created a new page on the production site.
Let’s see what Mergebot tracked.
The wording of the message in the Mergebot page of the WordPress admin (Tools > Mergebot) is a bit cryptic — at least to my ears. However, clicking the View Queries button launches a new browser tab where you can see the actual queries recorded by Mergebot.
Looking through the changeset that Mergebot recorded reveals that the changes to the development site have been stored to the Mergebot server. Now we can update our development site database with a fresh copy of the production database and then apply this changeset.
So, let’s do that next.
Refreshing the Development Database
Mergebot is designed to work with WP Migrate DB Pro — which enables simple database cloning between two connected sites. Using WP Migrate DB Pro makes refreshing the development database a very easy process. However, the developer has said that using WP Migrate DB Pro is not required — a claim that I can confirm is true.
I don’t have access to WP Migrate DB Pro. Instead, I used the free version, WP Migrate DB, to export the production database, and then imported the database into my development database using phpMyAdmin.
After refreshing the development database, I logged back into the development site and was greeted by a message from Mergebot.
In retrospect, I should have expected this behavior. But I admit that at the time I was a bit puzzled by this message. I selected the option to record the queries and then checked the Mergebot server for details.
As it turns out, the queries that were captured represented a massive batch of WordPress security keys being saved to the WordPress database. The generation of these queries appears to have occurred when WordPress connected to the manually-refreshed database. Clearly, I should’ve opted to ignore those changes.
The tutorial videos included in the Mergebot documentation make the merging process appear to be completely seamless when using WP Migrate DB Pro. In that scenario, Mergebot recognizes what you’re doing when you refresh the development database and ignores the changes applied by the refreshing of the database.
In any case, this created a changeset that was annoyingly oversized, but still, it worked just fine. I re-refreshed the database, this time opting to ignore the new changes, and then went to Tools > Mergebot to apply the changeset. The result was that the development site included all of the changes made to both the production and development databases.
Deploying a Changeset
Deploying your development work to the production database is the really impressive part of using Mergebot. It couldn’t be simpler.
Just log into the production site, go to Tools > Mergebot and click the button to Apply Changeset. Then sit back and wait while Mergebot pulls all of the development queries from the Mergebot server and applies them to your production database.
Mergebot Limitations and Observations
While Mergebot did perform as advertised — and I have to admit, deploying changes to production is about as simple as it could possibly be — that doesn’t mean that it’s a perfect solution for every WordPress developer. In my testing and review of Mergebot, the following issues and limitations came up.
Changesets aren’t editable, and they should be.
When I inadvertently recorded the original database refresh I realized something: there is no way to delete part of a changeset. Each changeset is an all-or-nothing proposition.
In my test, the changeset included two things: the post created on my development site and the database refresh action. I had the option to either delete the entire changeset or just live with the fact that it was tracking a lot of queries needlessly. A nicer third option would have been to have the ability to drop just part of the changeset.
Mergebot works great with WP Migrate DB Pro, but only OK without it.
Technically, yes, you can use Mergebot without WP Migrate DB Pro. However, having completed the migration process manually and also having seen the demonstration videos showing how to complete the migration with WP Migrate DB Pro, it’s crystal clear that Mergebot and WP Migrate DB Pro are intended to be paired.
Mergebot is a SaaS product, not a plugin.
The biggest complaint found in the comments section of the blog post announcing Mergebot is that Mergebot is a SaaS product. In other words, Mergebot is really a web-based service that you get access to by installing a plugin.
Changes are saved to Delicious Brains’ Mergebot servers — actually, AWS servers managed by Delicious Brains, but you know what I mean. So you can’t use Mergebot without an active subscription our without sending data to their server
We don’t have any philosophical problems with this model. Heck, we have a product or two that employ a similar model. However, this may be a deal breaker for developers working with clients who do not allow the storage of their data on third-party servers.
Mergebot Beta-Stage Limitations
There are also several limitations currently imposed on Mergebot due to its beta status. You can expect to see some or most of these limitations addressed by the time Mergebot reaches stable status, but it’s worth keeping an eye out for these factors if you’re interested in this plugin and service.
- Mergebot currently only tracks changes to core WordPress database tables, but you can add additional tables manually. Future versions of the plugin will also watch for custom tables used by the most popular WordPress plugins such as WooCommerce.
- Mergebot does not support multisite.
- Mergebot will track changes to media, but applying the changeset won’t actually upload the media files. For now, you’ll have to upload or remove media files manually. Mergebot will help ensure you don’t miss any uploads by providing a list of files that need to be uploaded.
- Mergebot currently only supports two environments: production and development. The plan is to support additional environments such as staging sites and multiple development environments in the future.
- The Mergebot documentation indicates that each changeset will be capped at 1000 queries during beta (although, my changeset was actually capped at 2000 queries). Reach the cap and you have to deploy the changeset to record any additional changes.
- Currently, Mergebot doesn’t effectively handle operations that depend on deploy-time data. This can cause issues with permissions — such as customers losing access to digital products they’ve purchased. In addition, it means that plugin and theme activation, deletion, update, and uninstall actions aren’t handled properly. In short, the plugin is in beta, use with care.
Who is Mergebot Right For?
In its current beta state, Mergebot will be particularly interesting to freelance developers working on relatively simple sites who can live with the beta limitations: one production and development site, data stored to the Mergebot server, and only 1000 (or 2000) queries per changeset.
However, it isn’t quite ready for agencies or developers working with complex projects that involve plugins and operations that Mergebot can’t handle at this time.
Having said that, when paired with WP Migrate DB Pro, Mergebot provides a very smooth and quick process for merging databases between development and production environments without losing any data. Once most of the beta program limitations have been addressed, it has the potential to be a very useful tool that will save WordPress developers a lot of time and headaches.
WordPress Database Merging Alternatives
If you aren’t sold on Mergebot, and are looking for a tool that allows you to merge WordPress databases without losing any data, you do have a few others options.
First, you could write a custom script. This option will be limited to fairly experienced and knowledgeable developers, but it bears mentioning and the linked article will help you get started.
Second, you could check out VersionPress. This git-powered plugin will allow you to create a staging site, edit it, and then merge the staging site back with the production site without data loss. However, you’ll need to be comfortable with git and the command line to use these features. Unlike Mergebot, Versionpress is free and you can use it without saving your data to a third-party server.
Third, WP Stagecoach is a premium, hosted, staging site service. The service allows you to create WordPress staging sites, host them on WP Stagecoach’s servers, and then merge your staging site with your production site. Like Mergebot, this is a premium service and your data will end up hosted on a third-party server. However, of all of the available options, WP Stagecoach appears to be the most beginner friendly.
Merging databases between development and production sites without losing any data has long been a challenge for WordPress developers. However, there are at least three solutions on the market today (at least in beta form) that can help solve this problem.
While no product or service has fully solved the problem yet, Mergebot, VersionPress, and WP Stagecoach all provide tools that solve at least part of the problem while they continue to add new features to solve an every-growing part of this puzzle.