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:
- Tick all three checkboxes.
- Copy the API Key.
Step 3: Push Local Site
In your local site, go to Tools > Migrate DB and follow the steps below:
- Select “Push” and paste in the API Key.
- Setup the Find & replace. Don’t forget to replace the protocol like
http://
tohttps://
. - Tick “Media Files” if you want to sync images too.
- Save the setting so it can be reused in the future.
- Click “Migrate DB & Save”.
Done! It will open a popup showing the progress like below:
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:
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 🙂
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.
Hi James,
Yes, the abandoned repo is the one I forked. Because it has more feature than WP Migrate DB.
There are other people that is taking over the project like https://github.com/cloudverve/wp-sync-db but it doesn't support nginx last time I tested
Hi, great work, is it possible to migrate plugin and theme files? kind of like the media addon works.
Hi Nick, sorry for the late reply. For unknown reasons, I didn't receive any email notification for new comments.
Plugin and Theme are more complicated to sync. If you have SSH access to your server you can use Composer https://wptips.dev/composer-to-manage-plugins/
For custom Theme, I usually use Github Action to automatically deploy it whenever I commit my code https://github.com/sebastianpopp/git-ftp-action/
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.
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.
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.
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.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
[…] Deploying database and uploads – use WP Sync DB. […]