Relax-and-Recover(简称ReaR)是一个简单但功能强大、易于设置、功能齐全且领先的开源裸机灾难恢复和系统迁移解决方案,使用Bash编写。它是一个模块化且可配置的框架,具有许多适用于常见情况的即用型工作流程。
ReaR创建各种格式的可启动救援系统和/或系统备份。您可以使用救援系统映像启动裸机服务器并从备份启动系统还原。它可以在必要时恢复到不同的硬件,因此它也可以用作系统迁移工具。
放松和恢复的主要特点:
- 它采用用 Bash 编写的模块化设计,可以使用自定义功能进行扩展。
- 支持各种启动介质,包括 ISO、PXE、OBDR 磁带、USB 或 eSATA 存储。
- 支持FTP、SFTP、HTTP、NFS、CIFS等多种网络协议进行存储和备份。
- 支持磁盘布局实施,例如 LVM、DRBD、iSCSI、HWRAID (HP SmartArray)、SWRAID、多路径和 LUKS(加密分区和文件系统)。
- 支持第三方和内部备份工具,包括IBM TSM、HP DataProtector、Symantec NetBackup、Bacula;tar和rsync。
- 支持通过 PXE、DVD/CD、可启动磁带或虚拟配置启动。
- 支持模拟模型,显示哪些脚本正在运行而不执行它们。
- 支持一致的日志记录和高级调试选项以进行故障排除。
- 它可以与Nagios和Opsview等监控工具集成。
- 它还可以与作业调度程序(例如cron )集成。
- 它还支持所支持的各种虚拟化技术(KVM、Xen、VMware)。
在本文中,您将了解如何安装和配置ReaR以使用 USB 记忆棒创建救援系统和/或系统备份,并在灾难后救援或恢复裸机 Linux 系统。
步骤1:在Linux裸机服务器中安装ReaR
1.要在Debian和Ubuntu Linux 发行版上安装后部软件包,请使用以下命令。
$ sudo apt-get install 后 extlinux
在RHEL和CentOS上,您需要启用 EPEL 8 存储库,然后安装后部软件包,如图所示。
# yum 安装后部 syslinux-extlinux grub2-efi-x64-modules # dnf 安装后 syslinux-extlinux #Fedora 22+
2、安装完成后,rear的主配置目录为/etc/rear/
: 关键配置文件为:
- /etc/rear/local.conf – used to set system-specific configuration; it’s intended for manual configuration.
- /etc/rear/site.conf – used to set site-specific configuration, should be created by the user.
- /usr/share/rear/conf/default.conf – contains possible/default configuration values.
- /var/log/rear/ – this directory stores the log files.
3. First, prepare the rescue media, a USB stick in this case by formatting using the rear command-line utility as follows. Once the formatting is complete, the media will be labeled as REAR-000.
# rear format /dev/sdb
![](https://www.alaica.com/wp-content/uploads/linux-786.png)
4. To configure the output format, use the OUTPUT and OUTPUT_URL variables, enter it in the /etc/rear/local.conf configuration file.
OUTPUT=USB
4. Also, ReaR comes with a built-in backup method (called NETFS) which allows you to create both a rescue system and a full-system backup. It creates a simple backup as a tar archive by default.
To enable a full-system backup, add the BACKUP=NETFS and BACKUP_URL variables in the /etc/rear/local.conf configuration file. To create a bootable USB device, combine OUTPUT=USB and BACKUP_URL=”usb:///dev/disk/by-label/REAR-000” as shown.
OUTPUT=USB BACKUP=NETFS BACKUP_URL=”usb:///dev/disk/by-label/REAR-000”
5. After configuring the rear, run the following command to print out its current configuration for BACKUP and OUTPUT methods and some system information.
# rear dump
![](https://www.alaica.com/wp-content/uploads/linux-787.png)
Step 2: Creating a Rescue System and a Full-System Backup
6. If all the settings are fine, you can create a rescue system using the mkrecue command as follows, where the -v
option enables verbose mode.
# rear -v mkrescue
![](https://www.alaica.com/wp-content/uploads/linux-788.png)
Note: If you encounter the following error after running a rescue or backup operation, as shown in this screenshot.
UEFI systems: “ERROR: /dev/disk/by-label/REAR-EFI is not block device. Use `rear format -- --efi ' for correct format”
![](https://www.alaica.com/wp-content/uploads/linux-789.png)
Format the USB stick using this command and redo the operation.
# rear format -- --efi /dev/sdb
![](https://www.alaica.com/wp-content/uploads/linux-790.png)
7. To create a rescue system and backup the system as well, use the mkbackup command as shown.
# rear -v mkbackup
8. To create a full-system backup only, use the mkbackuponly command as follows.
# rear -v mkbackuponly
Optional: Scheduling Rear Operations Using Cron
8.您可以通过在/etc/crontab文件中添加适当的条目来安排 ReaR 使用 cron 作业调度程序定期创建救援系统。
分钟 小时 day_of_month 月 day_of_week root /usr/sbin/rear mkrescue
以下配置将创建救援系统或在每个午夜进行全系统备份。确保您的 USB 记忆棒已连接到它。
0 0 * * root /usr/sbin/rear mkrescue 或者 0 0 * * root /usr/sbin/rear mkbackup
步骤 3:执行系统救援/恢复
9.要在灾难后恢复系统,请将可启动 USB 记忆棒连接到裸机系统并从其启动。在控制台界面中,选择选项一(恢复主机名)并单击 Enter。
![](https://www.alaica.com/wp-content/uploads/linux-791.png)
10.接下来,将配置ReaR救援系统,系统可能会提示您提供原始网络接口的替代品,如屏幕截图所示。完成后,单击 Enter。
![](https://www.alaica.com/wp-content/uploads/linux-792.png)
11.然后以 root 身份登录(只需输入用户名 root 并单击 Enter)即可运行实际恢复。
![](https://www.alaica.com/wp-content/uploads/linux-793.png)
11.接下来,运行以下命令启动恢复过程。救援系统将比较磁盘,检查其配置并提示您选择磁盘布局配置。按 Enter 继续自动磁盘配置。
然后它将开始系统布局恢复,一旦创建了磁盘布局,它将恢复备份,如下图所示。
# 后恢复
![](https://www.alaica.com/wp-content/uploads/linux-794.png)
12.备份恢复完成后,救援系统将运行mkinitrd来创建用于预加载模块的初始 ramdisk 映像,然后安装引导加载程序并退出。系统恢复完成后,恢复后的系统会挂载/mnt/local/
到该目录下,进入该目录进行查看。
最后,重新启动系统:
# cd /mnt/本地 # 重新启动
![](https://www.alaica.com/wp-content/uploads/linux-795.png)
13.重新启动后,SELinux 将尝试根据/mnt/local/.autorelabel文件重新标记已恢复系统上的文件和文件系统,如以下屏幕截图所示。
![](https://www.alaica.com/wp-content/uploads/linux-796.png)
有关更多使用选项,请阅读ReaR手册页。
# 男子后方
ReaR 主页:http://relax-and-recover.org/。
ReaR是领先的、易于使用(设置即忘记)的开源裸机灾难恢复和系统迁移框架。在本文中,我们解释了如何使用 ReaR 创建 Linux 裸机救援系统和备份以及如何在灾难后恢复系统。使用下面的评论表与我们分享您的想法。