Backup and restore of Ubuntu

Source: Internet
Author: User
Tags bz2

One of the great things about Linux is that you can back up your system or restore your system in a running system without having to use BOOT-CD to boot specifically.

Of course, if your system has been hung up and cannot be started, you can use the live CD to start, the effect is the same. In fact LiveCD is you install Ubuntu,try

Uuntu options to enter a virtual Ubuntu, detailed tutorials are detailed in ...

here's how to back up your Ubuntu system:

After entering Ubuntu, open the terminal and enter the following command:

1. Become the root user: sudo su
2. Go to the root directory: CD/

Then, here's the complete command I used to back up my system:

Tar-cvpzf/media/sda7/backup.tgz--exclude=/proc--exclude=/lost+found--exclude=/mnt--exclude=/sys--exclude=/ Media/

Next, let's explain a little bit:
Tar is the program used to back up
C-Create a new backup document
V-verbose mode, the TAR program will output all the information in real time on the screen.
P-Save permissions and apply to all files.
Z-compress backup files with ' gzip ' to reduce the volume of backup files.
F-Indicates the path where the backup file is stored,/media/sda7/backup.tgz is the file name in this example. This backup file is backed up by a different partition, which is the

His hard disk partition, equivalent to the non-system partition under Windows, check the storage location here.

--excloude-Exclude the specified directory from being backed up

To take a look at the directories we want to include, we don't have to back up everything because some directories are not very useful. Confirm that you do not want to include the files, otherwise you will have to

To a very strange result. You also don't have to back up anything under the/MNT directory unless you have other partitions hanging under it or you insist on backing it up. You must also make sure that no

Any resource hangs in the/media directory (for example, any CD or Removable storage media). Otherwise, remove the/media. If you choose to back up media, you will be loading CDs,

hard disks, USB drives, etc. are also backed up.

The last parameter is the directory we want to save. We want to save everything, using/as the root directory.

You can also use BZIP2 to compress files, BZIP2 is higher than gzip compression rate, but slower. If the compression ratio is important to you, then you should use BZIP2, "J" instead of "Z" in the command, and give the file a correct extension "bz2". The complete command is as follows:
# tar CVPJF backup.tar.bz2–exclude=/proc–exclude=/lost+found–exclude=/backup.tar.bz2–exclude=/mnt–exclude=/sys/

Then restore the system

Use the following command to restore the system:

# tar Xvpfz backup.tgz-c/


If your profile is compressed using BZIP2, you should use:
# tar XVPFJ backup.tar.bz2-c/


Note: The above command overwrites all files of the same name on the partition with the files in the archive, and the backup system has added new files before the system is restored, which is not affected.

If you want to go back to the remote point of Backup, please delete all the files in the root directory, in the native Ubentu do not recommend this, see LiveCD version of Ubuntu Backup and recovery.

Backup and restore of Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.