CentOS system backup and Recovery tutorial

Source: Internet
Author: User

Unlike Windows, Linux does not restrict access to anything by the root user, so you can put each file in a tar file in a single partition.

To switch to the root directory using the root user

Then, use the following command to back up the complete system:

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

Description

The tar part is the software we're going to use.

' Cvpfz ' is our option for tar, like "Create a zipped document" (which is obvious), "Save Permissions" (so that each of the same files has the same permissions), as well as "gzip" (reduced size). Next, the name of the compressed document will be obtained, in our example is backup.tgz.
followed by the root directory that we want to back up. Since we want to back everything up:/. And then there's the directory we're going to remove: we don't want to back up everything because it's not very useful to include some directories. Also make sure you don't add the backup file itself, otherwise you'll get weird results. You may also not want to include the/mnt folder-if you mount other partitions there-you will end up backing up those as well. Also make sure you don't have anything attached to the/media (that is, no CD or removable media is mounted). Otherwise, remove the/media.

At the end of the process, you might get a message that says "tar: There's a mistake due to a previous error" or something, but in most cases you can just ignore it.

As a choice, you can use bZIP to compress your backups. This means a higher compression ratio but also means a lower speed. If the compression ratio is important to you, simply replace the "z" in the command with "J" and give the backup a corresponding extension. These will make the command this way:

Tar cvpjf backup.tar.bz2/--exclude=/proc--exclude=/lost+found--exclude=/backup.tar.bz2--exclude=/mnt--exclude=/ Sys

Recovery:

If the system is destroyed, then we can restore it with a backup of the tar package.

Backup.tgz file in the root directory of the partition

Once again make sure that you are the root user and the root directory of the backup files in the file system.

One of the wonderful things about Linux is that this work can even be done on a running system, and there's no need to get the boot CD or anything to get dizzy. Of course, if you make your system unable to be booted. You may have no choice but to use only one live-cd, but the result is the same. You can even remove all of the files in the Linux system while it is running. But I'm not telling you that order!

This is the command I want to use:

Tar Xvpfz backup.tgz-c/

If you use bz2:

Tar xvpfj backup.tar.bz2-c/

Warning: This will replace all the files in your partition with the files in the compressed document!

Make sure to recreate the directory you excluded before you do anything else:

mkdir procmkdir lost+foundmkdir Mntmkdir sys
    • /proc Permissions: File owner: Root group: Root owner: Read execution group: Read execute other: Read execute
    • /lost+found Permissions: File owner: Root group: Root owner: Read Write execution group: Read execute other: Read execute
    • /MNT Permissions: File owner: Root group: Root owner: Read Write execution group: Read execute other: Read execute
    • /sys Permissions: File owner: Root group: Root owner: Read Write execution group: Read execute other: Read execute

When you reboot, everything will be exactly the same as when you backed up.

CentOS system backup and Recovery tutorial

Related Article

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.