{"id":437,"date":"2024-12-29T11:56:05","date_gmt":"2024-12-29T03:56:05","guid":{"rendered":"https:\/\/www.tunerli.com\/?p=437"},"modified":"2024-12-29T11:56:05","modified_gmt":"2024-12-29T03:56:05","slug":"preparation-for-migrating-blog-host-to-on-premise-part-2","status":"publish","type":"post","link":"https:\/\/www.tunerli.com\/index.php\/2024\/12\/29\/preparation-for-migrating-blog-host-to-on-premise-part-2\/","title":{"rendered":"Preparation for migrating blog host to on-premise \u2013 Part 2"},"content":{"rendered":"\n<p>So I finally decided to start the backing up and migration work from the cloud server.<\/p>\n\n\n\n<p>It&#8217;s been quite some time since the website was set up, more than 4 years. There were also many changes to the settings compared with the very initial ones and because I was lazy to keep the notes up to date, I was lost on the current configurations, including the database the website is using, the connection account and password, and also some other manual configurations, etc. Literally, I am facing a website I have not much knowledge of how it&#8217;s set up. Ok, then, let&#8217;s refresh the memories by checking the settings one by one, and also updating the notes or even create a more formal documentation for future reference. Fortunately, I still have the admin credentials of the cloud server, both the local host and MySQL, which makes things a little bit easier.<\/p>\n\n\n\n<p>First, let&#8217;s see the website configuration from <code>wp-config.php<\/code> file under the website root directory by <code>sudo cat \/var\/www\/site\/wp-config.php<\/code> <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"353\" src=\"https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/image.png\" alt=\"\" class=\"wp-image-438\" srcset=\"https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/image.png 735w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/image-300x144.png 300w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/image-640x307.png 640w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/image-100x48.png 100w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/figure>\n\n\n\n<p>Ok, now there are four main tasks <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Back up the database used by the site and also the site files;<\/li>\n\n\n\n<li>Copy the database and site file backups to the on-premise server;<\/li>\n\n\n\n<li>Install necessary software and Create a new database on the on-premise server and import the data to the new database;<\/li>\n\n\n\n<li>Configure the site to use the new database;<\/li>\n<\/ul>\n\n\n\n<p><strong>Task 1<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Archive the site files using tar <code>tar -czvf wordpress_backup.tar.gz \/var\/www\/tunerli.com<\/code> <\/li>\n\n\n\n<li>Back up the database <code>mysqldump -u root -p database &gt; wpdata_backup_20241228.sql<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>Task 2<\/strong> <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I have limited the SSH access to the cloud server only from my home workstation, so I will need to copy the backups from the cloud server to my home workstation and then copy them to the on-premise server.<\/li>\n\n\n\n<li>Copy the backups from the cloud server to my workstation\n<ul class=\"wp-block-list\">\n<li><code>scp user@cloudserver:\/home\/user\/wordpress_backup.tar.gz . <\/code><\/li>\n\n\n\n<li><code>scp user@cloudserver:\/home\/user\/wpdata_backup_20241228.sql .<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Now copy them to the new server\n<ul class=\"wp-block-list\">\n<li><code>scp wordpress_backup.tar.gz user@localserver:\/home\/user\/<\/code><\/li>\n\n\n\n<li><code>scp wpdata_backup_20241228.sql user@localserver:\/home\/user\/<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Task 3<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install the necessary software on the new server\n<ul class=\"wp-block-list\">\n<li><code>sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Put the site files to the corresponding place\n<ul class=\"wp-block-list\">\n<li><code>sudo tar -xzvf  \/home\/user\/wordpress_backup.tar.gz -C \/var\/www\/<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create a new database and user for the site connection\n<ul class=\"wp-block-list\">\n<li>CREATE DATABASE NEWDATABASE;<\/li>\n\n\n\n<li>CREATE USER &#8216;NEWUSER&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;PASSWORD&#8217;;<\/li>\n\n\n\n<li>GRANT ALL PRIVILEGES ON NEWDATABASE.* TO &#8216;NEWUSER&#8217;@&#8217;localhost&#8217;;<\/li>\n\n\n\n<li>FLUSH PRIVILEGES;<\/li>\n\n\n\n<li>EXIT;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Import the data from the backup to the new database\n<ul class=\"wp-block-list\">\n<li>mysql -u NEWUSER -p NEWDATABASE &lt; \/home\/user\/wpdata_backup_20241228.sql<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Task 4<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Update the wp-config.php file with the new database and user credentials<\/li>\n\n\n\n<li>create a new conf file for this new site under \/etc\/apache2\/sites-available\/\n<ul class=\"wp-block-list\">\n<li><code>sudo nano \/etc\/apache2\/sites-available\/site.conf<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Check the syntax error \n<ul class=\"wp-block-list\">\n<li><code>sudo apache2ctl configtest<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Enable the new site and rewrite module\n<ul class=\"wp-block-list\">\n<li><code>sudo a2ensite site.conf<\/code><\/li>\n\n\n\n<li><code>sudo a2enmod rewrite<\/code><\/li>\n\n\n\n<li><code>sudo systemctl restart apache2<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Disable the default site\n<ul class=\"wp-block-list\">\n<li><code>sudo a2dissite 000-default.conf<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Now it&#8217;s time to confirm! As I haven&#8217;t figured out the DDNS solution\/vendor, I can only test with the IP information for now and I have done that in the conf file for the site. So now access it from IP <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"534\" src=\"https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr.png\" alt=\"\" class=\"wp-image-440\" srcset=\"https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr.png 1000w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr-300x160.png 300w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr-768x410.png 768w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr-640x342.png 640w, https:\/\/www.tunerli.com\/wp-content\/uploads\/2024\/12\/2024-12-29-11_43_42-MrSuns-Website-\u2013-A-Site-to-Record-and-Share-and-11-more-pages-Personal-Micr-100x53.png 100w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>Bingo! Works. Ok, now I am going to update the documentation for this part before I start working on the next step of DDNS setup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I finally decided to start the backing up and migration work from the cloud server. It&#8217;s been quite some time since the website was set up, more than 4<a href=\"https:\/\/www.tunerli.com\/index.php\/2024\/12\/29\/preparation-for-migrating-blog-host-to-on-premise-part-2\/\" class=\"more-link\"><span class=\"more-button\">Continue reading<span class=\"screen-reader-text\">Preparation for migrating blog host to on-premise \u2013 Part 2<\/span><\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":442,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,5],"tags":[10,7],"class_list":["post-437","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-random-words","category-technical-issues-and-resolutions","tag-project","tag-technology"],"_links":{"self":[{"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/posts\/437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/comments?post=437"}],"version-history":[{"count":2,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"predecessor-version":[{"id":441,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/posts\/437\/revisions\/441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/media\/442"}],"wp:attachment":[{"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tunerli.com\/index.php\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}