Linux also checks the windows system to directly back up the system for restoration in case of system problems. Next I will introduce you in detail how to back up and restore the Linux System in Linux, for more information, see.
Backup:
Specifically, we need to do this:
The first is to use the root user, which is required, and then to the/directory, that is, under the root directory, then you can use the command given below to back up one key, 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 is a brief introduction to the code. We should all know it:
Tar is a packaging command in Linux, which is similar to compressed packaging. The parameter 'cvpfz' is used to create a packaging file and has the Save permission. The following z indicates gzip compression, the street name is followed by the f parameter, and backup is used here. tgz.
The following is the backup directory. here we need to back up all the files, which is naturally the root directory :/. Later -- exclude is quite clear, that is, the directories to be excluded. We do not want to back up the files under these directories because they are useless or very large, seriously affecting the backup speed. Of course, don't be stupid enough to exclude the files you want to back up. The results will be weird. Here, I would like to remind you that if you do not want to back up/mnt, you should exclude it, and there is the/media Directory. Do not mount things, or you will back up them together, A very powerful command.
There may be a message at the end of the backup, that is, the tar command is prompted for errors due to the delay of previous errors, but it doesn't matter, pass directly.
In addition, you can also select Bzip with a high compression ratio to compress files. high compression ratio means low compression speed, which takes a long time. If you are not worried, then we can use the following command to do this. In fact, there is nothing, that is, we can replace the z parameter in the above command with the j parameter. In this case, the command will become 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 your data is unfortunately destroyed on any day, you should be glad that you have backed up the system. I hope this backup will not take too long. If you don't talk much about it, the following is recovery.
We have backed up the entire system to the backup. tgz file.
We need to confirm that you are the root user so that the operation can proceed smoothly. Otherwise, we have to struggle.
Make sure that all the backup files are in the root directory. This is required. Otherwise, unexpected errors may occur. You can imagine that the recovery file overwrites the file.
Next, I would like to publicize the benefits of Linux, that is, you do not need to use a CD boot or the like, because you are at the bottom of the operation and do not need to turn off the boot again or something, except for your system, you can't even see the shell, so let's be honest. We can restore the file and remove all other files when running Linux, this is dangerous. The question is as follows:
Run the following command:
| The Code is as follows: |
Copy code |
Tar xvpfz backup. tgz-C/ |
If bz2: is used, use the following command:
| The Code is as follows: |
Copy code |
Tar xvpfj backup.tar.bz2-C/ |
This will replace all the identical files in the partition with the files in the compressed file. All of them should be thought twice, unless your system does need to be restored.
The following command re-creates the excluded directory:
| The Code is as follows: |
Copy code |
Mkdir proc
Mkdir lost + found Mkdir mnt Mkdir sys |
■/Proc permission: file owner: root group: root owner: Read execution group: Read execution others: Read execution
■/Lost + found permission: file owner: root group: root owner: Read Write execution group: Read execution others: Read execution
■/Mnt permission: file owner: root group: root owner: Read Write execution group: Read execution others: Read execution
■/Sys permission: file owner: root group: root owner: Read Write execution group: Read execution others: Read execution