Chapter 26. Relax-and-Recover (ReaR)
- booting a rescue system on the new hardware
- replicating the original storage layout
- restoring user and system files
rear recovercommand, which starts the recovery process. During this process, ReaR replicates the partition layout and filesystems, prompts for restoring user and system files from the backup created by backup software, and finally installs the boot loader. By default, the rescue system created by ReaR only restores the storage layout and the boot loader, but not the actual user and system files.
26.1. Basic ReaR Usage
26.1.1. Installing ReaR
yum install rear genisoimage syslinux
26.1.2. Configuring ReaR
/etc/rear/local.conffile. Specify the rescue system configuration by adding these lines:
OUTPUT=output format OUTPUT_URL=output location
ISOfor an ISO disk image or
USBfor a bootable USB.
file:///mnt/rescue_system/for a local filesystem directory or
sftp://backup:firstname.lastname@example.org/for an SFTP directory.
Example 26.1. Configuring Rescue System Format and Location
/mnt/rescue_system/directory, add these lines to the
rear's default output location
/mnt/rescue_system/HOSTNAME/rear-localhost.iso- output location specified in
OUTPUT=ISO BACKUP=NETFS OUTPUT_URL=null BACKUP_URL="iso:///backup" ISO_DIR="output location"
26.1.3. Creating a Rescue System
rear -v mkrescueRelax-and-Recover 1.17.2 / Git Using log file: /var/log/rear/rear-rhel7.log mkdir: created directory '/var/lib/rear/output' Creating disk layout Creating root filesystem layout TIP: To login as root via ssh you need to set up /root/.ssh/authorized_keys or SSH_ROOT_PASSWORD in your configuration file Copying files and directories Copying binaries and libraries Copying kernel modules Creating initramfs Making ISO image Wrote ISO image: /var/lib/rear/output/rear-rhel7.iso (124M) Copying resulting files to file location
/mnt/rescue_system/. Because the system's host name is
rhel7, the backup location now contains directory
rhel7/with the rescue system and auxiliary files:
ls -lh /mnt/rescue_system/rhel7/total 124M -rw-------. 1 root root 202 Jun 10 15:27 README -rw-------. 1 root root 166K Jun 10 15:27 rear.log -rw-------. 1 root root 124M Jun 10 15:27 rear-rhel7.iso -rw-------. 1 root root 274 Jun 10 15:27 VERSION
26.1.4. Scheduling ReaR
minute hour day_of_month month day_of_week root /usr/sbin/rear mkrescue
Example 26.2. Scheduling ReaR
0 22 * * 1-5 root /usr/sbin/rear mkrescue
26.1.5. Performing a System Rescue
- Boot the rescue system on the new hardware. For example, burn the ISO image to a DVD and boot from the DVD.
- In the console interface, select the "Recover" option:
- You are taken to the prompt:
Figure 26.2. Rescue system: prompt
WarningOnce you have started recovery in the next step, it probably cannot be undone and you may lose anything stored on the physical disks of the system.
- Run the
rear recovercommand to perform the restore or migration. The rescue system then recreates the partition layout and filesystems:
Figure 26.3. Rescue system: running "rear recover"
- Restore user and system files from the backup into the
Example 26.3. Restoring User and System FilesIn this example, the backup file is a tar archive created per instructions in Section 22.214.171.124, “Configuring the Internal Backup Method”. First, copy the archive from its storage, then unpack the files into
/mnt/local/, then delete the archive:
scp email@example.com:/srv/backup/rhel7/backup.tar.gz /mnt/local/~]#
tar xf /mnt/local/backup.tar.gz -C /mnt/local/~]#
rm -f /mnt/local/backup.tar.gzThe new storage has to have enough space both for the archive and the extracted files.
- Verify that the files have been restored:
Figure 26.4. Rescue system: restoring user and system files from the backup
- Ensure that SELinux relabels the files on the next boot:
touch /mnt/local/.autorelabelOtherwise you may be unable to log in the system, because the
/etc/passwdfile may have the incorrect SELinux context.
- Finish the recovery by entering
exit. ReaR will then reinstall the boot loader. After that, reboot the system:
Figure 26.5. Rescue system: finishing recoveryUpon reboot, SELinux will relabel the whole filesystem. Then you will be able to log in to the recovered system.