Home > Operation and Maintenance > CentOS > How to backup centos system

How to backup centos system

WJ
Release: 2020-06-05 15:56:05
Original
4660 people have browsed it

How to backup centos system

How to backup centos system?

When software or hardware failure causes a system to crash, the system administrator is faced with three tasks to restore it to a fully operational state in the new hardware environment:

1 .Start the rescue system on new hardware.

2. Copy the original storage structure.

3.Restore system and user files.

Regarding the third point, you can use tar to back up and restore files. The first two points can be accomplished using ReaR.

1. Experimental environment

System version: centos 7

Backup software: ReaR (Relax-and -Recover )

Virtual platform: vmware workstation 15.5

2. Configure ReaR

1. Installation related Software package

# yum install rear genisoimage syslinux
Copy after login

2. Configure ReaR

The ReaR configuration file is /etc/rear/local.conf. The main parameters are the following two:

OUTPUT=Output format //First aid system format, such as ISO or USB OUTPUT_URL=Output path //Can be local or SFTP, such as file:/ //mnt/rescue/ represents the local /mnt/rescue/ directory, sftp://backup:password@192.168.0.1/ represents the sftp directory

The system emergency system produced by default is an ISO image file, which is saved in the /var/lib/rear/output/ directory. When the OUTPUT parameter is configured, a copy will be copied to the path set by OUTPUT_URL. Under normal circumstances, we only need one image file, so we can make the following settings to save the file in the /mnt/ directory:

ISO_DIR="/mnt"
Copy after login

3. Backup system

1 .Use tar to back up user and system files, with the -p parameter retaining permissions, the -z parameter using gzip for compression, and --exclude to exclude some directories that do not need to be backed up

# tar -cpzf backup.tar.gz / --exclude=/proc --exclude=/lost+found --exclude=./backup.tgz --exclude=/mnt --exclude=/sys
Copy after login

2. Package the backed up files Save it to other places, such as the host 192.168.0.1

# scp backup.tar.gz root@192.168.0.1:/backup/backup.tar.gz
Copy after login

3. Use ReaR to make an image of the emergency system, and save the image file to other places for recovery use.

# rear -v mkrescue
Copy after login

4. Restore the system

1. Burn the ISO image to a CD and boot from the CD. (Use the ISO image directly in the virtual machine environment)

2. Select the "Recover" recovery option in the menu and enter the command line

3. Run the command to restore the system. (Restore partition and file system)

# rear recover
Copy after login

4. Restore system and user data to the /mnt/local/ directory.

# scp root@192.168.0.1:/backup/backup.tar.gz /mnt/local/    //假设备份的文件在192.168.0.1的主机上,复制到本地# tar xf /mnt/local/backup.tar.gz -C /mnt/local/    //恢复数据# rm -f /mnt/local/backup.tar.gz    //删除备份文件
Copy after login

5. Set the SELinux information to be updated when the system starts.

# touch /mnt/local/.autorelabel
Copy after login

6. Restart the system

# exit    //退出恢复模式,选择yes,安装boot loader# reboot    //重启系统
Copy after login

Related references:centOS tutorial

The above is the detailed content of How to backup centos system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template