{"id":2289,"date":"2016-10-13T23:29:10","date_gmt":"2016-10-13T20:29:10","guid":{"rendered":"https:\/\/afaghhosting.net\/blog\/backup-any-linux-box-on-softlayer\/"},"modified":"2016-10-13T23:29:10","modified_gmt":"2016-10-13T20:29:10","slug":"backup-any-linux-box-on-softlayer","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/backup-any-linux-box-on-softlayer\/","title":{"rendered":"Backup any Linux box on SoftLayer"},"content":{"rendered":"<p>The safest copy is an offline copy. In this article, we\u2019ll cover how to backup entire partitions in Linux systems. It&#8217;ll utilize the tar command in Softlayer&#8217;s unique rescue environment and showcase the simplicity and flexibility of the process.<\/p>\n<p>We begin by quickly identifying and becoming familiar with our filesystems.<\/p>\n<p>1. Log into your server as the root user type: df -h<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"Log into your server as the root user type: df -h\" title=\"Log into your server as the root user type: df -h\" height=\"317\" width=\"713\" class=\"media-element file-default; centered file-default\" typeof=\"foaf:Image\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2017\/12\/backup-any-linux-box-on-softlayer.png\"\/><\/p>\n<p>2. Take note of the filesystem column and note the \/ mount has the filesystem \/dev\/sda2.<\/p>\n<p>This is our root partition. Make note of it as it&#8217;ll be needed once our system is in the rescue layer. Our rescue layer is our diagnostic layer where customers can troubleshoot and backup files.<\/p>\n<p>3. Once you are sure you want to make backups of files, initiate the rescue layer. It will not wipe your data but it will reboot your server and unmount your existing partitions.<\/p>\n<p>Follow these steps to initiate the rescue layer:<\/p>\n<p><a href=\"http:\/\/knowledgelayer.softlayer.com\/procedure\/launch-rescue-kernel\" target=\"_blank\" rel=\"noopener\">http:\/\/knowledgelayer.softlayer.com\/procedure\/launch-rescue-kernel<\/a><\/p>\n<p>4. After you initiate rescue layer, wait five to six minutes for the rescue layer to finish loading. Then login to the server using SSH. You can find the rescue layer password by going into your Customer Portal (<u><a href=\"http:\/\/control.softlayer.com)\">http:\/\/control.softlayer.com)<\/a><\/u>. Navigate from the Device tab to the Devices List. Select and click on your device name. Click the Passwords tab. Click on the asterisks to reveal your password.<\/p>\n<p>5. Once you\u2019re logged into the rescue layer, you\u2019ll need to mount your partitions.<\/p>\n<p>6. Now mount the root (\/) partition in the rescue layer:<\/p>\n<p>\u00a0\u00a0\u00a0 mount \/dev\/sda2 \/mnt<\/p>\n<p>7. Then we\u2019ll need to quickly mount the rest of the partitions under \/mnt. You can do this by running the command below:<\/p>\n<p>cat \/mnt\/etc\/fstab | grep UUID | egrep -v &#8216;swap|\/ *ext&#8217; | awk -F= &#8216;{print $2&#8243; \/mnt&#8221;$3}&#8217; | awk &#8216;{print $1&#8243; \/mnt&#8221;$2}&#8217; | xargs -I {} echo mount -U {}<\/p>\n<p>This results in mount commands to mount the rest of the filesystems. Simple, right? Be sure to save that command; it&#8217;ll expedite your rescue layer troubleshooting next time.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"This results in mount commands to mount the rest of the filesystems. Simple, right? Be sure to save that command; it'll expedite your rescue layer troubleshooting next time.\" title=\"This results in mount commands to mount the rest of the filesystems. Simple, right? Be sure to save that command; it'll expedite your rescue layer troubleshooting next time.\" height=\"186\" width=\"844\" class=\"media-element file-default; centered file-default\" typeof=\"foaf:Image\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2017\/12\/backup-any-linux-box-on-softlayer-1.png\"\/><\/p>\n<p>8. Triple left-click each line to select the full line, then right-click to paste and run that command to mount each partition.<\/p>\n<p>9. If you want to see all your previously mounted filesystems, we can access them by chrooting as follows: chroot \/mnt<\/p>\n<ol>\n<li value=\"10\">Browse to the main folder (aka root folder \/):\n<p>cd \/<\/p>\n<\/li>\n<li value=\"11\">Before we finish, make a backups folder to contain your backups:\n<p>mkdir backups<\/p>\n<\/li>\n<\/ol>\n<p>Now make backups using the tar command in the compressed format tar.gz. To make backups using tar.gz, we\u2019ll make a backup of a very common and important partition: \/home<\/p>\n<p>1. Browse to root:<\/p>\n<p>\u00a0\u00a0\u00a0 cd \/<\/p>\n<p>2. Run the following<\/p>\n<p>\u00a0\u00a0\u00a0 tar -pzcvf \/backups\/fullbackup.tar.gz &#8211;directory=\/home &#8211;exclude=backups .<\/p>\n<p>A quick explanation of the flags:<\/p>\n<ul>\n<li>-p tells us to preserve file permissions<\/li>\n<li>-z tells us to compress the files<\/li>\n<li>-c tells us to create the tar.gz file<\/li>\n<li>-v gives us visible output<\/li>\n<li>-f lets us know the filename we&#8217;re working with<\/li>\n<li>-directory=\/ tells us where the backups should start. Be sure to include the &#8220;.&#8221; In the tar command as shown above.<\/li>\n<\/ul>\n<p>It is always recommended that you test your backups to make sure they have the files you need and data&#8217;s integrity is preserved. Once you&#8217;ve made the backup file, you can reboot the machine and download the file to restore it on another server.<\/p>\n<p>3. To restore that file, upload it via SFTP to your root directory, then in SSH run the following:<\/p>\n<p>\u00a0\u00a0\u00a0 tar -pzxvf fullbackup.tar.gz -C \/home<\/p>\n<p>A quick explanation of the flags: \u00a0-c \/home tells us to first browse to the \/home directory and then begin to extract the .tar.gz file. By default, the restoration will overwrite any file with the same name. There are flags such as &#8220;&#8211;keep-old-files,&#8221; which prevent you from replacing existing files on the disk, and &#8220;&#8211;keep-newer-files&#8221; when you don&#8217;t want to replace newer existing files, e.g. tar -pzxvf fullbackup.tar.gz -C \/home &#8211;keep-newer-files.<\/p>\n<p>-Stanley<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The safest copy is an offline copy. In this article, we\u2019ll cover how to backup entire partitions in Linux systems. It&#8217;ll utilize the tar command in Softlayer&#8217;s unique rescue environment and showcase the simplicity and flexibility of the process. We begin by quickly identifying and becoming familiar with our filesystems. 1. Log into your server &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-2289","post","type-post","status-publish","format-standard","hentry","category-softlayer"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2289"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2289\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}