Linux Backups using Relax and Recover (ReaR)

Relax-and-Recover allows you to back up a Linux server by creating a bare-metal image of the system. This can be stored any number of places such as on the network, tape, USB, etc. It can also be used to migrate a Linux installation to another host.

ReaR is not for file-level recovery and cannot be used for that purpose. It is meant for disaster recovery but also allows for incremental backups to be done. For file-level backup and recovery, I recommend using FWBackups.

ReaR creates backups in a compressed TAR.GZ, and also creates a bootable recovery image (.iso) for each Linux server that is backed up. ReaR is able to integrate with other backup solutions such as Bacula, Bareos, etc.

Prerequisites

You may need to install the following packages:
dnf install syslinux syslinux-extlinux

Installing and Configuring ReaR

  1. On Fedora, install ReaR by entering the following command:
    dnf install rear
  2. Create and edit the following file to match below: vi /etc/rear/site.conf
    OUTPUT=ISO
    BACKUP=NETFS
    BACKUP_PROG=tar
    BACKUP_URL="nfs://<IP ADDRESS>/LinuxBackups/"
    BACKUP_TYPE=incremental
    FULLBACKUPDAY="Sun"

Creating a Backup

  1. Run the following command to create a backup of the Linux system as well as a bootable .iso for recovery:
    rear -v mkbackup

Scheduling Backups

Create a cronjob as root to run the command: rear mkbackup as often as you like.

Example Cron:

0 6 * * 0 /usr/sbin/rear mkbackup

Recovery

To recover a system, you first need to boot to the .ISO that was created with the backup. You may use your favorite method for booting to the .ISO whether it’s creating a bootable USB sick, burning it to a CD, mounting it in iDRAC, etc. Just boot to it on the server in which you want to restore to.

  1. When the recovery screen loads, select the top option to recover.
  2. Type root to log in.
  3. To start recovery, enter rear -v recover
    1. If recovery fails, see below.

Fixing Recovery

THIS SECTION STILL IN PROGRESS

# Create missing directory:
mkdir /run/rpcbind

# Manually start networking:
chmod a+x /etc/scripts/system-setup.d/60-network-devices.sh
/etc/scripts/system-setup.d/60-network-devices.sh

# Navigate to and list files in /var/lib/rear/layout/xfs
# Edit each file ending in .xfs with vi and remove “sunit=0 blks” from the “log” section.
# In my case, the following files, then save them:
vi /var/lib/rear/layout/xfs/fedora_serv–build-root.xfs
vi /var/lib/rear/layout/xfs/sda1.xfs
vi /var/lib/rear/layout/xfs/sdb2.xfs

# Run the following commands to get a list of LVs and VGs:
lvdisplay
vgdisplay

# Run the following commands to remove the above listed LVs and VGs:
lvremove
vgremove

# Now run recovery again:
rear recover

References

Configuration options: https://github.com/rear/rear/blob/master/doc/user-guide/03-configuration.adoc

Documentation: http://relax-and-recover.org/documentation/

Resolved recovery issue: https://github.com/rear/rear/issues/1575#issuecomment-344732487

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *