{"id":1340,"date":"2019-03-20T15:27:20","date_gmt":"2019-03-20T07:27:20","guid":{"rendered":"http:\/\/tommykwan.com\/blog\/?p=1340"},"modified":"2019-03-20T16:56:43","modified_gmt":"2019-03-20T08:56:43","slug":"wordpress-cone-migration-and-backup-from-server-a-to-server-b","status":"publish","type":"post","link":"https:\/\/tommykwan.com\/blog\/my-diaries\/wordpress-cone-migration-and-backup-from-server-a-to-server-b\/","title":{"rendered":"WordPress Cone\/migration and Backup (from Server A to Server B)"},"content":{"rendered":"<p>Today, I am trying to <strong>back up my WordPress on Server A to Server B.<\/strong> To assist my future operations, I would like to open a post to record the procedures briefly.<\/p>\n<p>Firstly, you need to backup all the wordpress folder as well as the SQL. If you can, just use the export function of phpMyAdmin on Server A.<\/p>\n<p>However, there is some tricky point is that you have to click two boxes: 1)\u00a0\u58d3\u7e2e: zip and 2)\u00a0\u532f\u51fa\u8cc7\u6599\u5eab\u70ba\u5404\u5225\u6a94\u6848 in order to zip the .sql by using phpMyAdmin function.<\/p>\n<blockquote><p>Copy the whole folder from Server A<\/p>\n<p>MUST export<strong> xxx.<span style=\"text-decoration: underline;\">sql.zip<\/span><\/strong> (one of the phpMyAdmin Export Function)<\/p><\/blockquote>\n<p>Then, just copy and paste the whole folder to Server B<\/p>\n<p>And import the\u00a0<strong>xxx.<span style=\"text-decoration: underline;\">sql.zip<\/span><\/strong>\u00a0to Server B by using phpMyAdmin<\/p>\n<p>If you have problem during import &#8211; please pay attention on the limitation on upload setting in <strong>php.ini<\/strong><br \/>\nReference:\u00a0<a href=\"http:\/\/tech.smallya.net\/2017\/11\/21\/phpmyadmin%E7%84%A1%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%8C%AF%E5%85%A5%E4%B8%8A%E5%82%B3%E5%A4%A7%E5%AE%B9%E9%87%8Fsql%E6%AA%94%E6%A1%88%E5%95%8F%E9%A1%8C%E8%A7%A3%E6%B1%BA\/\" target=\"_blank\" rel=\"noopener\">http:\/\/tech.smallya.net\/2017\/11\/21\/phpmyadmin%E7%84%A1%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%8C%AF%E5%85%A5%E4%B8%8A%E5%82%B3%E5%A4%A7%E5%AE%B9%E9%87%8Fsql%E6%AA%94%E6%A1%88%E5%95%8F%E9%A1%8C%E8%A7%A3%E6%B1%BA\/<\/a><\/p>\n<blockquote>\n<div class=\"line number1 index0 alt2\"><code class=\"bash plain\">upload_max_filesize = 100M;<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"bash plain\">post_max_size = 100M;<\/code><\/div>\n<\/blockquote>\n<p>Then follow instruction of the link :\u00a0<a href=\"https:\/\/www.wpbeginner.com\/wp-tutorials\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.wpbeginner.com\/wp-tutorials\/how-to-fix-the-error-establishing-a-database-connection-in-wordpress\/<\/a>\u00a0to edit the\u00a0<strong>WP-Config.php\u00a0<\/strong><\/p>\n<p>Of course, you can test the connection by using another php<\/p>\n<p><strong>testconnection.php<\/strong><\/p>\n<blockquote><p><code>&lt;?php<br \/>\n$link = mysqli_connect('localhost', 'username', 'password');<br \/>\nif (!$link) {<br \/>\ndie('Could not connect: ' . mysqli_error());<br \/>\n}<br \/>\necho 'Connected successfully';<br \/>\nmysqli_close($link);<br \/>\n?&gt;<\/code><\/p>\n<div><\/div>\n<\/blockquote>\n<div>After that, in <strong>phpMyAdmin of Server B,<\/strong> <strong>use the command below to update all the old path<\/strong>(URL, root path&#8230;whatever you name it)<\/div>\n<div>Reference link:\u00a0<a href=\"https:\/\/www.hostinger.com\/tutorials\/wordpress\/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin\" target=\"_blank\" rel=\"noopener\">https:\/\/www.hostinger.com\/tutorials\/wordpress\/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin<\/a><\/div>\n<div><\/div>\n<div>\n<blockquote>\n<pre class=\"crayon:false\">UPDATE wp_options SET option_value = replace(option_value, '<strong>http:\/\/www.oldurl<\/strong>', '<strong>http:\/\/www.newurl<\/strong>') WHERE option_name = 'home' OR option_name = 'siteurl';\r\n\r\nUPDATE wp_posts SET guid = replace(guid, 'http:\/\/www.oldurl','http:\/\/www.newurl');\r\n\r\nUPDATE wp_posts SET post_content = replace(post_content, 'http:\/\/www.oldurl', 'http:\/\/www.newurl');\r\n\r\nUPDATE wp_postmeta SET meta_value = replace(meta_value,'http:\/\/www.oldurl','http:\/\/www.newurl');<\/pre>\n<\/blockquote>\n<\/div>\n<div><\/div>\n<div>Finally, follow this link:\u00a0<a href=\"https:\/\/codex.wordpress.org\/Changing_The_Site_URL\" target=\"_blank\" rel=\"noopener\">https:\/\/codex.wordpress.org\/Changing_The_Site_URL<\/a><\/div>\n<div>\n<blockquote>\n<h3><span id=\"Edit_wp-config.php\" class=\"mw-headline\">Edit wp-config.php<\/span><\/h3>\n<p>It is possible to set the site URL manually in the wp-config.php file.<\/p>\n<p>Add these two lines to your wp-config.php, where &#8220;example.com&#8221; is the correct location of your site.<\/p>\n<pre>define( 'WP_HOME', 'http:\/\/www.newurl' );\r\ndefine( 'WP_SITEURL', 'http:\/\/www.newurl' );<\/pre>\n<\/blockquote>\n<p>Also, please change the &#8220;define(&#8216;WP_DEBUG&#8217;, false);&#8221; to &#8220;define(&#8216;WP_DEBUG&#8217;, true);&#8221;<\/p>\n<\/div>\n<blockquote><p>&#8220;define(&#8216;WP_DEBUG&#8217;, false);&#8221; \u21d2 &#8220;define(&#8216;WP_DEBUG&#8217;, <strong>true<\/strong>);&#8221;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<div><\/div>\n<div>However, there is still some problem after doing these steps &#8211; for example, you cannot enter the admin login page directly by using : &#8216;http:\/\/www.newurl\/admin&#8217;<\/div>\n<div><\/div>\n<div>to solve this problem, I am still looking for solution. But you can still <strong>login directly<\/strong> through\u00a0<strong>http:\/\/www.newurl\/wp-login.php<\/strong><\/div>\n<div><\/div>\n<div>Indeed, there are few reasons leading to the probelm:<\/div>\n<ol>\n<li>After log onto admin page of your wordpress &gt;&gt; Setting &gt;&gt; Permalinks: there are various options, please make sure you have choose the correct setting, if you are not sure, try-and-errors method could help.. just click every one to try it.<\/li>\n<li>You may need to set up the Virtual Host if you have various WordPress in your Server B<\/li>\n<\/ol>\n<div><\/div>\n<div>To set up virtual host &#8211; link FYI:<\/div>\n<div><a href=\"https:\/\/www.cloudways.com\/blog\/configure-virtual-host-on-windows-10-for-wordpress\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.cloudways.com\/blog\/configure-virtual-host-on-windows-10-for-wordpress\/<\/a><\/div>\n<div><\/div>\n<div>One more important concept is that if you have more than one wordpress in your Server B, you need to set the virtual host as below:<\/div>\n<div><\/div>\n<div>\n<p><code>&lt;VirtualHost *:80&gt;<br \/>\nDocumentRoot \"C:\/xampp\/htdocs\/\"<br \/>\nServerName <strong>localhost<\/strong><br \/>\n&lt;Directory \"\/\"&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/code><\/p>\n<div>\n<p><code>&lt;VirtualHost *:80&gt;<br \/>\nDocumentRoot \"C:\/xampp\/htdocs\/<strong>host1<\/strong>\"<br \/>\nServerName <strong>host1.localhost<\/strong><br \/>\n&lt;Directory \"C:\/xampp\/htdocs\/<strong>host1<\/strong>\"&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/code><\/p>\n<div>\n<p><code>&lt;VirtualHost *:80&gt;<br \/>\nDocumentRoot \"C:\/xampp\/htdocs\/<strong>host2<\/strong>\"<br \/>\nServerName <strong>host2.localhost<\/strong><br \/>\n&lt;Directory \"C:\/xampp\/htdocs\/<strong>host2<\/strong>\"&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/code><\/p>\n<\/div>\n<\/div>\n<div><code>&lt;VirtualHost *:80&gt;<br \/>\nDocumentRoot \"C:\/xampp\/htdocs\/<strong>host3<\/strong>\"<br \/>\nServerName <strong>host3.localhost<\/strong><br \/>\n&lt;Directory \"C:\/xampp\/htdocs\/<strong>host3<\/strong>\"&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/code><\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>Finally, I have done this trouble task<\/div>\n<div>Good Luck!<\/div>\n<div><\/div>\n<div>End of report @ Tommy.K<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I am trying to back up my WordPress on Server A to Server B. To assist my future operations, I would like to open a post to record the procedures briefly. Firstly, you need to backup all the wordpress folder as well as the SQL. If you can, just use the export function of<a class=\"read-more \" href=\"https:\/\/tommykwan.com\/blog\/my-diaries\/wordpress-cone-migration-and-backup-from-server-a-to-server-b\/\" title=\"Read More\"> <span class=\"button default\">Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1340","post","type-post","status-publish","format-standard","hentry","category-my-diaries"],"_links":{"self":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/1340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/comments?post=1340"}],"version-history":[{"count":11,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/1340\/revisions"}],"predecessor-version":[{"id":1351,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/posts\/1340\/revisions\/1351"}],"wp:attachment":[{"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/media?parent=1340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/categories?post=1340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommykwan.com\/blog\/wp-json\/wp\/v2\/tags?post=1340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}