I come from a Laravel background which means I am used to using database migrations and seedings to keep content on dev / staging sites in sync with my local environment.

I'm starting my first project in WordPress and was wondering how to go about doing the same. Essentially I'm building the site on my local environment and through the use of plugins such as Advanced Custom Fields I will create the content for the site. I need an easy was of ensuring the dev / staging sites have the same content as my local environment. I only want to sync content such as posts, pages, custom post types, and any associated media.

Deployment of code itself is not an issue as the code is kept under version control and I can create a webhook to auto deploy the code.

I have read up on plugins such as WP Migrate DB but I'm not sure this is the tool for the job.

Can anyone advise the best way to accomplish this?

  • Can vouch for WP Migrate DB, great plugin that does about the same as answered below. Definitely a little bit more of a hassle with WP vs Laravel but if you have experience with databases you should be fine. Just make sure you don't run a straight search/replace in the database as this will mess up the serialized arrays WP uses for a lot of things... use a tool specifically designed to work with WP or at least serialized strings Jul 11, 2017 at 21:07
  • If you need to do a simple single immigration, then check out "Duplicator". Awesome plugin to create install packages etc. Jul 12, 2017 at 7:36

3 Answers 3



That's the one main caveat of WordPress development, that even a seasoned WordPress developer still wonders what's the perfect automation for syncing database content from local environment to live server.

You can't just upload your database dump from your local development environment to the server and be happy with the results.

WordPress actually stores the resulting URLs in the database.

So let's say your local development URL is http://localhost/awesome. Your posts as it stored in the database has also stored your development URL(i.e. http://localhost/awesome) in every post. The URL is also stored in the wp_options table. So when you import your local database dump to the server you need to replace the existing URL to the server URL in order for the post links to work.

A not so elegant solution:

One of the solutions that I personally use is Search Replace DB by interconnect/it.

To use the script, download the zip file from below, extract the folder called search-replace-db-master (assuming you are using the 3.1.0 version), renaming it to something secret of your choosing, upload it via FTP, SFTP or SCP to your web server’s public facing directory, then navigate to that folder in your browser. The script will automatically attempt to find and populate the database field but you must check that the details are correct and that it is for the database you wish to carry out a search/replace operation on.

A typical WP install with this script would have the folders as follows:

  • /your-secret-search-replace-folder
  • /wp-admin
  • /wp-content
  • /wp-includes

NOTE: Please read the Installation and Usage of the tool in their website, and make sure the details are correct upon proceeding with the replacement.

How does it work?


Development URL: http://localhost/awesome
Live Server URL: http://awesome.com

You provide the development URL to the Replace Textbox and the live server URL to the With Textbox. Make sure to have a backup of your database, then hit the button dry run or live run to perform the action.


Does it work all the time? Well, not so quick, it actually depends on your requirements, but so far in all my WordPress projects and its varying requirements it works as expected.

There's a lots of solutions out there and one of them is mentioned in your question(i.e. WP Migrate DB). You just got to bare the tedious workflow of WordPress development, as great as CMS WordPress has been throughout its existence there's still this one main caveat that lets us want to be freed.

  • Search Replace DB has not been updated in two years, so I'd consider it an unmaintained project. As I recall, it does not update URLs in serialized data.
    – Dan Knauss
    Jul 11, 2017 at 21:52
  • Wp-cli works fine with the option "search-replace" wp search-replace old_url new_url. Even the serialized data is updated (Search/replace intelligently handles PHP serialized data, and does not change primary key values.)
    – Mike
    Jul 15, 2017 at 9:53

For our site, we've written a Perl script that copies the database then uses wp-cli commands to tweak certain settings that are local to a given site. The script also fires off a UNIX line command to sync up the uploads directories.

We use that when we need to copy the entire database, which gets plugin settings in addition to all content.

However, we also have a content staging site for our users, and we use RAMP to migrate individual content items (or batches of them) from the content staging site to the live site. This will bring all dependencies with a given post/page such as media attachments, taxonomy terms, users, etc. RAMP is geared toward the end user who is updating and creating content. It does require some customization to work with sites that have been customized using something like ACF.

Our typical workflow is to use RAMP to go between content staging and live, and then to use our copy script to refresh our dev and test sites with content at the content staging site.

Finally, since you're already using version control, you may wish to have a look at VersionPress which allows you to version the database. I've not used it but have been keeping an eye on development for a while and it's intriguing.


Code changes should go into GIT and pulled (or use some more elaborate script that does a build from the code pulled). Content changes should only be done on production or a "content staging" server on which no code development is being done, and therefor you can safely transfer the DB.

You should not mix code development and content changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.