Backup and restoration in Linux

Source: Internet
Author: User
Recently, we have been configuring centos servers. we all know that the configuration process may be complicated and sometimes there may be errors. if the configuration fails and cannot be recovered, reload the system, therefore, it is very important to back up the system. Linux backup is actually to store all files in a uniform package. it will be fine to overwrite the original files with these files when recovery is required. Backup: switch to the root directory (/) of the root user, which must be the root directory. otherwise, some files will be missed. Use the following command to package: ta

Recently, we have been configuring centos servers. we all know that the configuration process may be complicated and sometimes there may be errors. if the configuration fails and cannot be recovered, reload the system, therefore, it is very important to back up the system.

Linux backup is actually to store all files in a uniform package. it will be fine to overwrite the original files with these files when recovery is required.

Backup:

Switch to the root directory (/) of the root user, which must be the root directory. otherwise, some files will be missed. Use the following command to package:

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

Among them, backup. tgz is the backup name, followed by the root directory we want to back up. Next, we want to remove the directory: We don't want to back up everything, because some directories are not very useful, and make sure you haven't added the backup file itself. otherwise, you will get a weird result. You may not include the/mnt folder-if you mount other partitions there-otherwise you will back up those files. At the same time, make sure that you have nothing to attach to/media (that is, no cd or removable media is mounted ). Otherwise, remove/media.

 

Recovery:

 

Run the following command to enter the root directory/as the root user:

tar xvpfz backup.tgz -C /

Make sure that you re-create the directory you excluded before you do anything else:

mkdir procmkdir lost+foundmkdir mntmkdir 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 and write execution group: Read execution Other: Read execution/mnt permission: file owner: root group: root owner: read and write execution group: Read execution Other: Read execution/sys permission: file owner: root group: root owner: read and write execution group: read and execute others: read and execute

After you restart, everything will be exactly the same as what you back up.

Reference: http://blog.sina.com.cn/s/blog_628c3f9e0102v24j.html

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.