{"id":1476,"date":"2020-05-23T22:34:39","date_gmt":"2020-05-23T15:34:39","guid":{"rendered":"https:\/\/lab.wptips.dev\/?p=1476"},"modified":"2020-06-21T09:27:44","modified_gmt":"2020-06-21T02:27:44","slug":"wp-sync-db","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/wp-sync-db\/","title":{"rendered":"How to Synchronize Live and Local Database?"},"content":{"rendered":"\n<p>How do you push a local database to your live one? Have you been manually exporting then importing the SQL files?<\/p>\n\n\n\n<p>I&#8217;ve been doing that for years until I found this plugin called <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/hrsetyono\/wp-sync-db\" target=\"_blank\">WP Sync DB<\/a>.<\/p>\n\n\n\n<p>Follow the guide below for installation process:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Download and Activate it in BOTH Local and Live sites.<\/h2>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-background has-orange-background-color\" href=\"https:\/\/github.com\/hrsetyono\/wp-sync-db\" target=\"_blank\" rel=\"noreferrer noopener\">Download <strong>WP Sync DB<\/strong> from Github<\/a><\/div>\n<\/div>\n\n\n\n<details class=\"wp-block-h-faq\" style=\"--faqTitleBg:var(--orange-light)\"><summary class=\"h-faq-question\">Why is the plugin not in WordPress.org repository?<\/summary><div class=\"h-faq-answer\"><p>Because the creator forked it from another plugin called WP Migrate DB which is already in wordpress.org.<\/p><\/div><\/details>\n\n\n\n<details class=\"wp-block-h-faq\" style=\"--faqTitleBg:var(--orange-light)\"><summary class=\"h-faq-question\">Is the link above your own forked version?<\/summary><div class=\"h-faq-answer\"><p>Yes, the creator abandoned the plugin and I need to add nginx support to it.<\/p><\/div><\/details>\n\n\n\n<details class=\"wp-block-h-faq\" style=\"--faqTitleBg:var(--orange-light)\"><summary class=\"h-faq-question\">Is it safe to use?<\/summary><div class=\"h-faq-answer\"><p>From my 3 years of experience using it, I&#8217;ve never got any fatal error.<\/p><p>The way it works is it creates temporary tables and only replace your real table if the migration is a 100% success.<\/p><p>So the worst it could do is adding some unused tables in your database that you can easily drop.<\/p><p>Having said that, it&#8217;s never a bad idea to <strong>have a periodic backup of your website<\/strong>, in case of human error.<\/p><\/div><\/details>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Get the API Key from Live Site<\/h2>\n\n\n\n<p>In your live site, go to Tools &gt; Migrate DB, click &#8220;Settings&#8221; tab and follow the steps below:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"691\" height=\"422\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-api-key-live.jpg\" alt=\"\" class=\"wp-image-1479\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-api-key-live.jpg 691w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-api-key-live-480x293.jpg 480w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><figcaption>WP Sync DB setting in live site<\/figcaption><\/figure><\/div>\n\n\n\n<ol><li>Tick all three checkboxes.<\/li><li>Copy the API Key.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Push Local Site<\/h2>\n\n\n\n<p>In your local site, go to Tools &gt; Migrate DB and follow the steps below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"747\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-setup-local.jpg\" alt=\"\" class=\"wp-image-1480\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-setup-local.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-setup-local-480x478.jpg 480w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-setup-local-150x150.jpg 150w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>WP Sync DB preparing local site<\/figcaption><\/figure>\n\n\n\n<ol><li>Select &#8220;Push&#8221; and paste in the API Key.<\/li><li>Setup the Find &amp; replace. Don&#8217;t forget to replace the protocol like <code>http:\/\/<\/code> to <code>https:\/\/<\/code>.<\/li><li>Tick &#8220;Media Files&#8221; if you want to sync images too.<\/li><li>Save the setting so it can be reused in the future.<\/li><li>Click &#8220;Migrate DB &amp; Save&#8221;.<\/li><\/ol>\n\n\n\n<p><strong>Done!<\/strong> It will open a popup showing the progress like below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"183\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/thumb-pushing.jpg\" alt=\"\" class=\"wp-image-1481\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/thumb-pushing.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/thumb-pushing-480x117.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption>WP Sync DB push progress<\/figcaption><\/figure>\n\n\n\n<h2 class=\"has-red-color has-text-color wp-block-heading\">Common Error: transfer_chunk<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">The connection failed, an unexpected error occurred,\nplease contact support. (#121 - scope: transfer_chunk)<\/code><\/pre>\n\n\n\n<p>This error is caused by an <strong>unstable internet connection<\/strong>. Even a slight disturbance can break the progress of your push or pull.<\/p>\n\n\n\n<p>This is the biggest weakness of this plugin.<\/p>\n\n\n\n<p>If you can&#8217;t get better internet, what you can do is to migrate few tables at a time by selecting it in the setting like below:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"432\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-table-filter-select.jpg\" alt=\"\" class=\"wp-image-1484\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-table-filter-select.jpg 631w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2020\/05\/wpsync-table-filter-select-480x329.jpg 480w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><figcaption>Selecting few tables at a time if your internet connection is unstable<\/figcaption><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator is-style-dots\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>I have tried many migration plugin and this is the best free plugin you can get. Another promising plugin is <a rel=\"noreferrer noopener\" href=\"https:\/\/versionpress.com\/\" target=\"_blank\">VersionPress<\/a>, but it hasn&#8217;t been production-ready for like 2 years.<\/p>\n\n\n\n<p>For migrating theme files, I&#8217;m using <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/features\/actions\" target=\"_blank\">Github Action<\/a> that automatically uploads changed files on commit. I will create a tutorial about that in the future.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Let me know if you trouble setting up WP Sync DB plugin in the comment below \ud83d\ude42<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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<\/p>\n","protected":false},"author":1,"featured_media":1485,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[28],"class_list":["post-1476","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugin","tag-database"],"blocksy_meta":"","_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=1476"}],"version-history":[{"count":9,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1476\/revisions"}],"predecessor-version":[{"id":1639,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/1476\/revisions\/1639"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/1485"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=1476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=1476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=1476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}