Linux backup and restore Linux system

Source: Internet
Author: User
Tags bz2 mkdir

Backup:

Specifically to do this:

The first is to use the root user, must, then to/directory, is the root directory, and then you can use the command given below a key backup, easy:

The code is as follows Copy Code

Tar cvpzf backup.tgz/--exclude=/proc--exclude=/lost+found--exclude=/backup.tgz--

Exclude=/mnt--exclude=/sys

Here a little bit about the code, should have known it:

Tar is the Linux Packaging command, is similar to the compression of packaging, plus the parameter ' CVPFZ ' used to indicate the creation of a packaging file, and have the right to save, the following z indicates the use of gzip compression, F parameters behind the street name, here is the backup.tgz.

followed by the backup of the directory, here to back up all the files, nature is the root directory:/. Back--exclude very clear, is to exclude the directory, the files in these directories we do not want to back up, because there is no use, or very large, seriously affect the speed of backup. Of course, don't be stupid enough to rule out the files you want to back up, and the results will be weird. Here to remind, if you do not want to back up the/mnt, then the exclusion of it, there is the/media directory, do not mount things, or together back up, or a more powerful command.

There may be a message at the end of the backup that prompts the tar command for an error due to a previous error, but that doesn't matter, direct pass.

In addition, you can also choose to have a higher compression ratio of bzip to compress the file, high compression ratio means low compression speed, it will take a long time, if not very anxious, then you can use the following command to do, in fact, it is nothing, is the above command of the z parameter to replace the J parameter, it is OK, In that case, the command would be like this:

The code is as follows Copy Code


Tar cvpzf backup.tgz/--exclude=/proc--exclude=/lost+found--exclude=/backup.tgz--

Exclude=/mnt--exclude=/sys

Recovery:

If it's unfortunate that your data has been destroyed, you should be thankful that you've backed up the system and hopefully it won't take too long. Don't say much nonsense, the following is recovery.

We've backed up the entire system to the backup.tgz file.

The following is still to make sure you are root users, so as to smooth, otherwise have to tangle.

Make sure that the backup files you own are in the root directory. This is necessary, otherwise there will be unexpected errors, you can imagine recovery to the normal time to restore the file to cover up the situation.

Next I'm going to promote the benefits of Linux, just do not need to use CD-ROM to boot and so on, because you are at the bottom of the operation, do not need to turn off the boot or anything, the amount, here to remove your system has been you do not even see the shell, or the honest point of guidance, We can restore the file when Linux runs and remove all other files, which is dangerous. Here's the point:

You can use this command to:

The code is as follows Copy Code

Tar Xvpfz backup.tgz-c/

If you use the bz2:, you are using the following command:

The code is as follows Copy Code

Tar xvpfj backup.tar.bz2-c/

This time replace all the same files in the partition with the files in the compressed file, and think twice before you do it, unless your system does need to be restored.

The following command is used to recreate the excluded directory:

The code is as follows Copy Code


mkdir proc

mkdir Lost+found

mkdir MNT

mkdir SYS

/proc Permissions: File owner: Root group: Root owner: Read execution group: Read execution other: Read execution
/lost+found Permissions: File owner: Root group: Root owner: Read Write execution group: Read execution other: Read execution
/MNT Permissions: File owner: Root group: Root owner: Read Write execution group: Read execution other: Read execution
/sys Permissions: File owner: Root group: Root owner: Read Write execution group: Read execution other: Read execution

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.