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

2 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.