{"id":211,"date":"2026-01-03T16:26:09","date_gmt":"2026-01-03T16:26:09","guid":{"rendered":"https:\/\/sunserver.in\/blog\/?p=211"},"modified":"2026-04-10T07:57:13","modified_gmt":"2026-04-10T07:57:13","slug":"backup-and-restore-full-backup-vps-migrate-vps","status":"publish","type":"post","link":"https:\/\/sunserver.in\/blog\/backup-and-restore-full-backup-vps-migrate-vps\/","title":{"rendered":"Backup and restore full backup VPS (migrate VPS)"},"content":{"rendered":"\n<p>First step was backup your Linux VPS directly on the server and then download it into your machine. Here\u2019s how to create a compressed backup and download it afterward.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/sunserver.in\/blog\/backup-and-restore-full-backup-vps-migrate-vps\/#Creating_and_Downloading_a_Compressed_Backup\" >Creating and Downloading a Compressed Backup<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/sunserver.in\/blog\/backup-and-restore-full-backup-vps-migrate-vps\/#Restoring_the_Backup_on_a_New_VPS\" >Restoring the Backup on a New VPS<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_and_Downloading_a_Compressed_Backup\"><\/span>Creating and Downloading a Compressed Backup<a href=\"https:\/\/gist.github.com\/muhammadardie\/0cd786089e61a886418cced138a8f3fa#creating-and-downloading-a-compressed-backup\"><\/a><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a Compressed Archive on the VPS<\/strong>:\n<ul class=\"wp-block-list\">\n<li>You can use\u00a0<code>tar<\/code>\u00a0to create a compressed archive of the entire root filesystem while excluding directories that don\u2019t need to be backed up (such as\u00a0<code>\/dev<\/code>,\u00a0<code>\/proc<\/code>,\u00a0<code>\/sys<\/code>, etc.).<\/li>\n\n\n\n<li>Run the following command on your VPS:                                                                                       <em><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-vivid-purple-color\">sudo tar -czvf \/root\/vps-backup.tar.gz &#8211;exclude={&#8220;\/dev\/*&#8221;,&#8221;\/proc\/*&#8221;,&#8221;\/sys\/*&#8221;,&#8221;\/tmp\/*&#8221;,&#8221;\/run\/*&#8221;,&#8221;\/mnt\/*&#8221;,&#8221;\/media\/*&#8221;,&#8221;\/lost+found&#8221;} \/<\/mark><\/em><\/li>\n\n\n\n<li>This command will create a file named\u00a0<code>vps-backup.tar.gz<\/code>\u00a0in the\u00a0<code>\/root<\/code>\u00a0directory.<\/li>\n\n\n\n<li><strong>Explanation<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong><code>tar -czvf<\/code><\/strong>:\n<ul class=\"wp-block-list\">\n<li><code>-c<\/code>: Creates a new archive.<\/li>\n\n\n\n<li><code>-z<\/code>: Compresses the archive with gzip.<\/li>\n\n\n\n<li><code>-v<\/code>: Verbose mode to show progress.<\/li>\n\n\n\n<li><code>-f<\/code>: Specifies the filename.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>--exclude<\/code><\/strong>: Excludes directories that shouldn\u2019t be part of the backup (as explained previously).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Download the Backup File to Your Local Machine<\/strong>:\n<ul class=\"wp-block-list\">\n<li>After creating the compressed file, you can transfer it to your Windows machine using an\u00a0<code>scp<\/code>\u00a0tool like\u00a0<strong>WinSCP<\/strong>\u00a0or a terminal with\u00a0<strong>SSH<\/strong>\u00a0(e.g., PowerShell or a WSL terminal).<\/li>\n\n\n\n<li><strong>Option 1: Using WinSCP<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open WinSCP and connect to your VPS using SFTP.<\/li>\n\n\n\n<li>Navigate to the\u00a0<code>\/root<\/code>\u00a0directory and locate\u00a0<code>vps-backup.tar.gz<\/code>.<\/li>\n\n\n\n<li>Download the file by dragging it to your local directory on Windows.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Option 2: Using scp in PowerShell or WSL<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open PowerShell or WSL on your Windows machine.<\/li>\n\n\n\n<li>Use the following command to copy the file:                                                                       <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">scp user@vps_ip:\/root\/vps-backup.tar.gz C:\\path\\to\\local\\directory<\/mark><\/li>\n\n\n\n<li>Replace\u00a0<code>user<\/code>\u00a0and\u00a0<code>vps_ip<\/code>\u00a0with your VPS username and IP address, and specify the local path where you want to save the file.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Verify the Backup File on your local machine<\/strong>:\n<ul class=\"wp-block-list\">\n<li>After downloading, you can use tools like\u00a0<strong>7-Zip<\/strong>\u00a0or\u00a0<strong>WinRAR<\/strong>\u00a0on Windows to inspect the contents of\u00a0<code>vps-backup.tar.gz<\/code>\u00a0and ensure the backup was successful.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Clean Up (Optional)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If you need to free up space on the VPS, you can delete the backup file from\u00a0<code>\/root<\/code>\u00a0after confirming it\u2019s safely downloaded:sudo rm \/root\/vps-backup.tar.gz<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This method will give you a full, compressed backup of your Linux system that you can easily store or move. To restore it to another Linux server, you can transfer the archive back to the new server and extract it.<\/p>\n\n\n\n<p>To restore the&nbsp;<code>vps-backup.tar.gz<\/code>&nbsp;file to a new VPS, you can follow these steps. This process will extract all files and configurations, effectively replicating your original system on the new VPS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Restoring_the_Backup_on_a_New_VPS\"><\/span>Restoring the Backup on a New VPS<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/muhammadardie\/0cd786089e61a886418cced138a8f3fa#restoring-the-backup-on-a-new-vps\"><\/a><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Transfer the Backup File to the New VPS<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If the backup file is on your local machine, upload it to the new VPS using\u00a0<code>scp<\/code>\u00a0or a tool like WinSCP.<\/li>\n\n\n\n<li><strong>Example using\u00a0<code>scp<\/code><\/strong>: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">scp C:\\path\\to\\vps-backup.tar.gz user@new_vps_ip:\/root<\/mark><\/li>\n\n\n\n<li>Replace\u00a0<code>user@new_vps_ip<\/code>\u00a0with your new VPS username and IP address, and specify the local path to the backup file.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Prepare the New VPS<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Connect to the new VPS via SSH: ssh <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">user@new_vps_ip<\/mark><\/li>\n\n\n\n<li>Make sure you are logged in as\u00a0<code>root<\/code>\u00a0or have\u00a0<code>sudo<\/code>\u00a0privileges since restoring the backup will need access to system files and directories.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Extract the Backup Archive<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Go to the directory where you transferred the backup file, e.g.,\u00a0<code>\/root<\/code>.<\/li>\n\n\n\n<li>Run the following command to extract the backup archive:sudo tar -xzvf \/root\/vps-backup.tar.gz -C \/<\/li>\n\n\n\n<li><strong>Explanation<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong><code>-x<\/code><\/strong>: Extracts the archive.<\/li>\n\n\n\n<li><strong><code>-z<\/code><\/strong>: Decompresses the file (since it\u2019s gzip compressed).<\/li>\n\n\n\n<li><strong><code>-v<\/code><\/strong>: Verbose mode to show progress.<\/li>\n\n\n\n<li><strong><code>-f<\/code><\/strong>: Specifies the file.<\/li>\n\n\n\n<li><strong><code>-C \/<\/code><\/strong>: Extracts everything to the root directory.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Adjust System Configurations<\/strong>:\n<ul class=\"wp-block-list\">\n<li>After restoring, some configurations may need adjustment based on the new VPS environment. For example:\n<ul class=\"wp-block-list\">\n<li><strong>Network Configurations<\/strong>: Ensure any network or IP-specific settings in\u00a0<code>\/etc\/network\/interfaces<\/code>\u00a0or\u00a0<code>\/etc\/netplan<\/code>\u00a0are correct.<\/li>\n\n\n\n<li><strong>Hostname<\/strong>: Update the hostname if needed by editing\u00a0<code>\/etc\/hostname<\/code>\u00a0and\u00a0<code>\/etc\/hosts<\/code>.<\/li>\n\n\n\n<li><strong>SSH Keys<\/strong>: If your SSH keys differ, update them in\u00a0<code>\/root\/.ssh<\/code>\u00a0or\u00a0<code>\/home\/username\/.ssh<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Reinstall GRUB (Optional)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If your VPS uses a different bootloader or disk layout, you may need to reinstall GRUB or another bootloader.<\/li>\n\n\n\n<li>To reinstall GRUB, you can use the following command:sudo grub-install sudo update-grub<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Reboot the New VPS<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Restart the VPS to apply changes and ensure all services are running with the restored configurations:sudo reboot<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Verify the Restoration<\/strong>:\n<ul class=\"wp-block-list\">\n<li>After rebooting, check that key services like Apache, Docker, and other applications are running correctly.<\/li>\n\n\n\n<li>Run\u00a0<code>systemctl<\/code>\u00a0to see the status of services:sudo systemctl status apache2 sudo systemctl status docker<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This process should restore all your original files, configurations, and installed applications, effectively cloning your previous setup on the new VPS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First step was backup your Linux VPS directly on the server and then download it into your machine. Here\u2019s how to create a compressed backup and download it afterward. Creating and Downloading a Compressed Backup This method will give you a full, compressed backup of your Linux system that you can easily store or move. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":221,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hosting"],"_links":{"self":[{"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":1,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions\/212"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/media\/221"}],"wp:attachment":[{"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunserver.in\/blog\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}