How to Synchronize Live and Local Database?

Using WP Sync DB plugin we can automatically import our WordPress database from local to live installation (or vice versa) Learn how to set it up here

How do you push a local database to your live one? Have you been manually exporting then importing the SQL files?

I’ve been doing that for years until I found this plugin called WP Sync DB.

Follow the guide below for installation process:

Step 1: Download and Activate it in BOTH Local and Live sites.

Why is the plugin not in WordPress.org repository?

Because the creator forked it from another plugin called WP Migrate DB which is already in wordpress.org.

Is the link above your own forked version?

Yes, the creator abandoned the plugin and I need to add nginx support to it.

Is it safe to use?

From my 3 years of experience using it, I’ve never got any fatal error.

The way it works is it creates temporary tables and only replace your real table if the migration is a 100% success.

So the worst it could do is adding some unused tables in your database that you can easily drop.

Having said that, it’s never a bad idea to have a periodic backup of your website, in case of human error.

Step 2: Get the API Key from Live Site

In your live site, go to Tools > Migrate DB, click “Settings” tab and follow the steps below:

WP Sync DB setting in live site
  1. Tick all three checkboxes.
  2. Copy the API Key.

Step 3: Push Local Site

In your local site, go to Tools > Migrate DB and follow the steps below:

WP Sync DB preparing local site
  1. Select “Push” and paste in the API Key.
  2. Setup the Find & replace. Don’t forget to replace the protocol like http:// to https://.
  3. Tick “Media Files” if you want to sync images too.
  4. Save the setting so it can be reused in the future.
  5. Click “Migrate DB & Save”.

Done! It will open a popup showing the progress like below:

WP Sync DB push progress

Common Error: transfer_chunk

The connection failed, an unexpected error occurred,
please contact support. (#121 - scope: transfer_chunk)

This error is caused by an unstable internet connection. Even a slight disturbance can break the progress of your push or pull.

This is the biggest weakness of this plugin.

If you can’t get better internet, what you can do is to migrate few tables at a time by selecting it in the setting like below:

Selecting few tables at a time if your internet connection is unstable

Conclusion

I have tried many migration plugin and this is the best free plugin you can get. Another promising plugin is VersionPress, but it hasn’t been production-ready for like 2 years.

For migrating theme files, I’m using Github Action that automatically uploads changed files on commit. I will create a tutorial about that in the future.

Let me know if you trouble setting up WP Sync DB plugin in the comment below 🙂

Default image
Henner Setyono
A web developer who mainly build custom theme for WordPress since 2013. Young enough to never had to deal with using Table as layout.
Leave a Reply to NickCancel Reply

13 Comments

  1. I don’t understand your assertion that the original project was ‘abandoned’ – its very much alive (last update 2 months ago): https://github.com/deliciousbrains/wp-migrate-db

    It’s also the base of their (excellent) premium version: https://deliciousbrains.com/wp-migrate-db-pro/

    The version you link to, however, has not been updated in over 2 years.

    This all seems completely back to front.

  2. Hi, great work, is it possible to migrate plugin and theme files? kind of like the media addon works.

  3. Hi,

    Thanks for the article. I am noob...exuse me;)

    I have my site installed on a localhost and on a web host. I have just migrated the site using All-in-One Migration tool, which worked. Now I would like to be able to just sync the changes that I make on my local site with the live site. Question: Is the method you describe here suitable for this purpose or should I sync more than just the database?

    Thanks!

    • Hi Frank,

      This plugin only synchronizes Database and Uploads folder, not including Theme and Plugin. If that's your use case, then this will be suitable for you.

  4. Rustell Dela Cruz
    Rustell Dela Cruz

    Awesome! Is it possible to migrate local php system database to a wordpress website?

    • Hi Rustell, It's only possible to migrate WordPress database because this plugin won't be able to detect non-WP database.

  5. Thank you for doing this, after trolling all the forks it looks like your solution is the best one around. I appreciate that you've added nginx and also bundled the media files plugin.

    I would love it if your blog post went into detail about various ways to install the plugin. Especially on a live WP instance - ie. how can I install the git repo as a plugin using the UI.

    Thanks again!

    • Hi Julien,

      Thank you for reading. To install the plugin, simply download the Github as Zip and upload it via WP Admin in Plugins > Add New.

  6. Thank you for doing this, after trolling all the forks it looks like your solution is the best one around. I appreciate that you've added nginx and also bundled the media files plugin.

  7. Hallo Hr. Henner!

    Dank für die sehr gute Beschreibung.

    Nur so zur Sicherheit die Frage. Die Live-Datenbank soll auf die lokale Datenbank. Also ist die Anwendung in umgekehrter Form wie hier beschrieben zu handhaben. – funktioniert das so?

    Und Danke schon mal für die Antwort.

    Freundliche Grüße Ditmar

  8. Our WordPress Workflow with Github Action | WP Tips

    […] Deploying database and uploads – use WP Sync DB. […]