Roots Discourse

How to sync databases between two Sage sites

Hi, we have a production site: and a staging site: Both are live and roughly identical, except there’s a whole bunch of settings and content that we’ve added to the staging site that we want to move over to the production site. So essentially, we’d like to push the database from staging to production but we still want the production site to retain all its URLs so that domains always match the correct environment. Both sites are also quite large. I found this tool: but noticed it’s only for Bedrock. This is a Sage site so that won’t work. I’ve also tried these plugins but without success: Database Sync, Duplicator, WPSiteSync for Content, WP Synchro, Migrate Guru, and WP Staging. Can anyone offer advice on how to do this quickly and easily?Thanks!

What do you mean “without success”? They don’t function at all, or they don’t meet your requirements in some way?

Is this database transfer something you intend to run once, or something you want to be running repeatedly?

If you have command line access to your servers, between wp db and wp search-replace you should be able to accomplish most of what you seem to need. (I think the Bedrock sync script you linked uses these internally.)

Yeah, sorry I’ve sort of lost track but some just timed out and didn’t run, some didn’t allow for domain find/replace, some seem to only work for migrating/cloning a new site, some were more about continual syncing between specific pages not a single site-wide overwrite. I sprang for WP Migrate DB Pro though so trying that now.

WP Migrate DB Pro seemed to work although their search and replace function didn’t so I had to use the plugin Better Search and Replace which did work so those two together did the job. There seem to be many ways to have done this but lots of snags too. Anyway, it’s sorted now, thanks.

If you have SSH access to your remote sites, it’s pretty convenient to run a bash script configured for your different environments.

I’ve been using a simple bash script with WP CLI that basically exports a db dump from production downloads it locally, and then uploads it to the remove dev, imports the db and runs a search replace to update the URL.

A similar script can also sync your local dev with production. There’s probably a bunch of different ways to approach this. WP-CLI also allows you to setup aliases to manage different environments from your local command line:

Honestly, I don’t really see a need for any other solution for our needs.

1 Like

Thanks for sharing. Have to check this out. Is it complicated to setup?