{"id":5766,"date":"2024-01-18T11:26:45","date_gmt":"2024-01-18T11:26:45","guid":{"rendered":"https:\/\/natsav.com\/blog\/?p=5766"},"modified":"2024-01-19T07:45:20","modified_gmt":"2024-01-19T07:45:20","slug":"backup-on-ubuntu-server-with-tar-command","status":"publish","type":"post","link":"https:\/\/natsav.com\/blog\/backup-on-ubuntu-server-with-tar-command\/","title":{"rendered":"How to Create a Full Backup on Ubuntu Server Using the TAR Command"},"content":{"rendered":"<p><span style=\"color: #000000;\">Creating a full backup of an Ubuntu server using the tar command involves compressing the entire file system into an archive. Follow these steps to create a full backup using the tar command:<\/span><\/p>\n<p data-nodeid=\"93\"><strong>1.Open a Terminal:<\/strong><br \/>\nOpen a terminal on your Ubuntu server either by logging in via SSH or directly on the server.<\/p>\n<p data-nodeid=\"95\"><strong>2.Run the tar Command:<\/strong><br \/>\nUse the tar command to create a compressed archive of the entire file system. Adjust the paths and filenames as per your preferences.<\/p>\n<p data-nodeid=\"96\"><span style=\"color: #000080;\">sudo tar -cvpzf \/path\/to\/backup.tar.gz &#8211;directory=\/ &#8211;exclude=proc &#8211;exclude=sys &#8211;exclude=dev &#8211;exclude=run &#8211;exclude=tmp \/<\/span><br \/>\n-c: Create a new archive.<br \/>\n-v: Verbose mode (show the progress).<br \/>\n-p: Preserve permissions.<br \/>\n-z: Compress the archive using gzip.<br \/>\n-f: Specify the archive file name.<br \/>\n&#8211;directory=\/: Change to the root directory before archiving.<br \/>\n&#8211;exclude: Exclude specific directories from the archive.<\/p>\n<p data-nodeid=\"97\">In this example, the proc, sys, dev, run, and tmp directories are excluded to avoid unnecessary files and improve backup efficiency.<\/p>\n<p data-nodeid=\"99\"><strong>3.Monitor the Progress:<\/strong><br \/>\nThe tar command will display the progress in the terminal. Once it completes, you&#8217;ll have a compressed archive at the specified location.<\/p>\n<p data-nodeid=\"101\"><strong>4.Verify the Backup:<\/strong><br \/>\nTo verify the contents of the backup, use the following command:<\/p>\n<p data-nodeid=\"102\"><span style=\"color: #000080;\">tar -tvzf \/path\/to\/backup.tar.gz<\/span><\/p>\n<p data-nodeid=\"103\">This command lists the contents of the compressed archive.<\/p>\n<p data-nodeid=\"105\"><strong>5.Secure the Backup:<\/strong><br \/>\nIf your backup contains sensitive information, consider securing it. You can use encryption tools like gpg to encrypt the backup file.<\/p>\n<p data-nodeid=\"106\"><span style=\"color: #000080;\">gpg -c \/path\/to\/backup.tar.gz<\/span><\/p>\n<p data-nodeid=\"107\">Follow the prompts to set a passphrase for encryption.<\/p>\n<p data-nodeid=\"108\">Now, you&#8217;ve successfully created a full backup of your Ubuntu server using the tar command. Remember to store the backup in a secure location and consider automating the backup process using tools like cron for regular backups.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a full backup of an Ubuntu server using the tar command involves compressing the entire file system into an archive. Follow these steps to create a full backup using the tar command: 1.Open a Terminal: Open a terminal on your Ubuntu server either by logging in via SSH or directly on the server. 2.Run [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[255],"tags":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/natsav.com\/blog\/wp-content\/uploads\/2024\/01\/tar-ubuntu-222.png?fit=478%2C244&ssl=1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5766"}],"collection":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/comments?post=5766"}],"version-history":[{"count":3,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5766\/revisions"}],"predecessor-version":[{"id":5770,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5766\/revisions\/5770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media\/5772"}],"wp:attachment":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media?parent=5766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/categories?post=5766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/tags?post=5766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}