Relax and Recover (ReaR) | 1 Easy Guide

Introduction

Relax and Recover is an opensource disaster recovery solution available for both the home and enterprise users.

Create a NFS, FTP, HTTP, RSYNC, CIFS or Local to start with the backup.

Where to save the Backup?

We are about to use NFS in this guide. If you need to setup a NFS server please follow this guide.

How to setup NFS server on CentOS 8.x, For your information the same steps are applicable to setup in a Rocky Linux 8.x

I have created a dedicated NFS share to perform the ReaR Backups.

# vim /etc/exports.d/rear-backup.exports

/backup 192.168.56.0/24(rw,no_root_squash)

Installing Relax and Recover

Install the required packages

# yum install rear genisoimage syslinux grub2-efi-x64-modules -y
Installed:
  attr-2.4.48-3.el8.x86_64            bc-1.07.1-5.el8.x86_64               bind-export-libs-32:9.11.26-6.el8.x86_64  binutils-2.30-108.el8_5.1.x86_64  dhcp-client-12:4.3.6-45.el8.x86_64
  dhcp-common-12:4.3.6-45.el8.noarch  dhcp-libs-12:4.3.6-45.el8.x86_64     genisoimage-1.1.11-39.el8.x86_64          ipcalc-0.2.4-4.el8.x86_64         libburn-1.4.8-3.el8.x86_64
  libisoburn-1.4.8-4.el8.x86_64       libisofs-1.4.8-3.el8.x86_64          libusal-1.1.11-39.el8.x86_64              mtools-4.0.18-14.el8.x86_64       rear-2.6-3.el8.x86_64
  syslinux-6.04-5.el8.x86_64          syslinux-nonlinux-6.04-5.el8.noarch  tar-2:1.30-5.el8.x86_64                   xorriso-1.4.8-4.el8.x86_64

Complete!
[root@production-app1 ~]#

Available Examples

Just read this file to know all the available options in ReaR

# more /usr/share/rear/conf/default.conf

Few of configuration examples can be found under /usr/share/rear/conf/examples/

[root@production-app1 ~]# ls -lthr /usr/share/rear/conf/examples/
total 56K
-rw-r--r--. 1 root root 1013 Jan  4  2017 PXE-booting-example-with-URL-style.conf
-rw-r--r--. 1 root root  755 Mar  3  2017 USB-and-Samba-example.conf
-rw-r--r--. 1 root root 2.7K Feb  2  2018 SLE12-btrfs-example.conf
-rw-r--r--. 1 root root 2.1K Sep 11  2019 RHEL7-PPC64LE-Multipath-PXE-GRUB.conf
-rw-r--r--. 1 root root 2.7K Apr 27  2020 SLE11-SLE12-SAP-HANA-UEFI-example.conf
-rw-r--r--. 1 root root 2.8K Apr 27  2020 RHEL7-ISO-Oracle-example.conf
-rw-r--r--. 1 root root  838 Apr 27  2020 RHEL6-NETFS-of-NBU-master-example.conf
-rw-r--r--. 1 root root  667 Apr 27  2020 rescue-and-backup-on-same-ISO-image-example.conf
-rw-r--r--. 1 root root 5.0K Jun 16  2020 SLE12-SP2-btrfs-example.conf
-rw-r--r--. 1 root root 4.3K Jun 16  2020 SLE12-SP1-btrfs-example.conf
-rw-r--r--. 1 root root 1.5K Jun 16  2020 SLE11-ext3-example.conf
-rw-r--r--. 1 root root  912 Jun 16  2020 borg-example.conf
[root@production-app1 ~]#

Configuring Relax and Recover

Instead of making changes to /etc/rear/local.conf it advise to create site.conf.

# vim /etc/rear/site.conf
OUTPUT=ISO
OUTPUT URL=nfs://192.168.56.104/backup/
BACKUP=NETFS
BACKUP_URL=nfs://192.168.56.104/backup/
BACKUP_PROG_EXCLUDE=("${BACKUP_PROG_EXCLUDE[@]}" '/media' '/vat/tmp' '/var/crash' '/kdump')
LOGFILE="$LOG_DIR/rear-$HOSTNAME.log"

Supported Backup locations are

# nfs://host.domain/path/path/path
# cifs://server.domain/share
# usb:///dev/sdb1
# sftp://backup:password@192.168.0.0/
# rsync://[USER@]HOST[:PORT]::/PATH

Starting with the Backup

Start the Backup by running the rear command with options and arguments

# rear -v -d mkbackup
[root@production-app1 ~]# rear -v -d mkbackup
Relax-and-Recover 2.6 / 2020-06-17
Running rear mkbackup (PID 80058)
Using log file: /var/log/rear/rear-production-app1.log
Running workflow mkbackup on the normal/original system
Using backup archive '/tmp/rear.V75opqHiz97Wz6F/outputfs/production-app1/backup.tar.gz'
Found EFI system partition /dev/sda1 on /boot/efi type vfat
Using UEFI Boot Loader for Linux (USING_UEFI_BOOTLOADER=1)
Using autodetected kernel '/boot/vmlinuz-4.18.0-348.el8.0.2.x86_64' as kernel in the recovery system
Creating disk layout
Overwriting existing disk layout file /var/lib/rear/layout/disklayout.conf
Using guessed bootloader 'EFI' (found in first bytes on /dev/sda)
Verifying that the entries in /var/lib/rear/layout/disklayout.conf are correct ...
Creating recovery system root filesystem skeleton layout
Handling network interface 'enp0s3'
enp0s3 is a physical device
Handled network interface 'enp0s3'
Handling network interface 'enp0s8'
enp0s8 is a physical device
Handled network interface 'enp0s8'
To log into the recovery system via ssh set up /root/.ssh/authorized_keys or specify SSH_ROOT_PASSWORD
Trying to find what to use as UEFI bootloader...
Trying to find a 'well known file' to be used as UEFI bootloader...
Using '/boot/efi/EFI/rocky/grubx64.efi' as UEFI bootloader file
Copying logfile /var/log/rear/rear-production-app1.log into initramfs as '/tmp/rear-production-app1-partial-2022-01-16T11:57:01+04:00.log'
Copying files and directories
Copying binaries and libraries
Copying all kernel modules in /lib/modules/4.18.0-348.el8.0.2.x86_64 (MODULES contains 'all_modules')
Copying all files in /lib*/firmware/
Skip copying broken symlink '/etc/mtab' target '/proc/89694/mounts' on /proc/ /sys/ /dev/ or /run/
Broken symlink '/usr/lib/modules/4.18.0-348.el8.0.2.x86_64/build' in recovery system because 'readlink' cannot determine its link target
Broken symlink '/usr/lib/modules/4.18.0-348.el8.0.2.x86_64/source' in recovery system because 'readlink' cannot determine its link target
Testing that the recovery system in /tmp/rear.V75opqHiz97Wz6F/rootfs contains a usable system
Creating recovery/rescue system initramfs/initrd initrd.cgz with gzip default compression
Created initrd.cgz with gzip default compression (421415374 bytes) in 43 seconds
GRUB2 modules to load: fat part_gpt xfs
Did not find /boot/grub2/locale files (minor issue for UEFI ISO boot)
Making ISO image
Wrote ISO image: /var/lib/rear/output/rear-production-app1.iso (453M)
Copying resulting files to nfs location
Saving /var/log/rear/rear-production-app1.log as rear-production-app1.log to nfs location
Copying result files '/var/lib/rear/output/rear-production-app1.iso /tmp/rear.V75opqHiz97Wz6F/tmp/VERSION /tmp/rear.V75opqHiz97Wz6F/tmp/README /tmp/rear.V75opqHiz97Wz6F/tmp/rear-production-app1.log' to /tmp/rear.V75opqHiz97Wz6F/outputfs/production-app1 at nfs location
Making backup (using backup method NETFS)
Creating tar archive '/tmp/rear.V75opqHiz97Wz6F/outputfs/production-app1/backup.tar.gz'
Archived 858 MiB [avg 8530 KiB/sec] OK
Archived 858 MiB in 104 seconds [avg 8448 KiB/sec]
Exiting rear mkbackup (PID 80058) and its descendant processes ...
Running exit tasks
You should also rm -Rf --one-file-system /tmp/rear.V75opqHiz97Wz6F
[root@production-app1 ~]#

As shown in the last line, run rm command to release the space.

# rm -Rf --one-file-system /tmp/rear.V75opqHiz97Wz6F

We are done with Relax and Recover Backups.

Starting with Recovery

Copy the ISO from the NFS server where is saved, and boot the server you need to recover.

ReaR recovery ISO
ReaR recovery ISO

Only get the CLI to do the recovery

Relax and Recover Booted
Relax and Recover Booted
# rear -v -d recover
Relax and Recover Resuce completed
Relax and Recover Rescue completed

Unattach the ISO and start using the recovered server, Once the server stared booting it will relabel the enter server.

Completely recovered server with ReaR
Completely recovered server with ReaR

That’s it, we have completed with recovering.

Conclusion:

A complete Open Source solution Relax and Recover helps to recover a Physical server and this can be a quick and easiest disaster recovery for you home lab or for a production setup.