Overview
ReaR (Relax-and-Recover) is an open-source bare metal disaster recovery solution. ReaR produces a bootable recovery image which can recreate the system’s original storage layout and provide an environment in which to restore a backup of the system. ReaR supports several different image types, but the simplest is an ISO image, which can be written to physical media, or used directly in a VM.
ReaR has a modular design supporting many different methods of data backup and recovery. Here we are using Bacula as the data recovery method / backup system. While ReaR does have some built-in support for Bacula, it is currently quite limited and has some bugs, so the approach here is to simply configure ReaR to use a generic backup method, and then manually include Bacula in the ReaR environment. This guide assumes that the system is already configured as a Bacula client.
The ReaR environment must be configured to use the same IP address as the original system so the Bacula director will see it as the same client during the restore. Alternatively a second client could be defined in the Bacula config and specified as the restore client when launching the Bacula restore job, to allow restoring to a different IP address.
Note: If you want to perform a test restore to a different destination, rather than the original system, say a VM. If you’re going to use the same IP address as the original system for the test restore, then the original system will need to be shutdown (or be “offline” from the network while the restore is being performed). Or you can define a second “test restore” client in your Bacula Director, and then specify that restore client when launching the Bacula restore job.
ReaR is configured via /etc/rear/local.conf. See ReaR Config below for an example config and explanation of the essential options. For a list of all possible options, you can take a look at /usr/share/rear/conf/default.conf.
The restore process is fairly straight-forward:
- Boot the ISO
- Type:
- ‘rear recover’
- to setup the disks, mount points
- make the destination system accessible on the network
- ‘rear recover’
- Start the bacula file daemon in the rear recovery environment.
- Then launch a restore job from the Bacula director.
- When the restore is finished, exit the ReaR shell and reboot into the recovered system.
See below for step-by-step instructions.
Step by Step How-to ReaR Setup
- Install ReaR, either from your distro’s software repositories as shown below, or download a package from http://relax-and-recover.org/download/
- Distros using .deb packages (Debian, Ubuntu, etc)
sudo apt-get install rear
- Distros using .rpm packages (RHEL, Fedora, etc)
sudo dnf install rear
- Distros using .deb packages (Debian, Ubuntu, etc)
- Open /etc/rear/local.conf in a text editor and modify it to fit your needs. See ReaR Config below for a working config example and explanation of the options.
sudo nano /etc/rear/local.conf
-
Create the ISO.
sudo rear -v mkrescue
-
Test the ISO, and perform a test restore.
Performing a Restore
- Boot the ISO and login with root. It should login without requesting a password.
- Start the recovery process.
The recovery process will automatically setup items like disk partitions and mount points, getting everything ready for the data restore, and will then launch a shell when its ready for you to do the data restore.
rear recover
- Manually perform the data recovery.
- Start the bacula file daemon using the “-c” option to specify the bacula config file to use. Both the bacula-fd binary and the bacula-fd.conf config file should have been included in the ReaR system with the COPY_AS_IS option.
/opt/bacula/bin/bacula-fd -c /opt/bacula/etc/bacula-fd.conf
-
- Start a restore job on the Bacula Director.
This should automatically send the data to the file daemon started in the previous step. The restore must be set to restore all files to /mnt/local, where the disks were mounted during ‘rear recover’. Following is an example bconsole command for launching the restore:
restore client=MyClient pool=MyPool where=/mnt/local select current all done
- Start a restore job on the Bacula Director.
This should automatically send the data to the file daemon started in the previous step. The restore must be set to restore all files to /mnt/local, where the disks were mounted during ‘rear recover’. Following is an example bconsole command for launching the restore:
Depending on your configuration, you may also be asked to select which restore job to use.
Review the options and then type ‘yes’ to start the restore.
Wait for the restore job to finish with the following bconsole command:
wait jobid=1279
-
- After the restore job finishes, exit the rear shell, and when it asks if you are ready to continue recovery type yes, and it will finish up the recovery and install the boot loader.
exit yes
- After the restore job finishes, exit the rear shell, and when it asks if you are ready to continue recovery type yes, and it will finish up the recovery and install the boot loader.
- Reboot into the restored system
reboot now
ReaR Config
Example Config
Highlighted text should be replaced with values relevant to your setup / environment.
OUTPUT=ISO
ISO_DIR="/home/myuser"
ISO_PREFIX="rear_recovery"
BACKUP=REQUESTRESTORE
USE_DHCLIENT="No"
USE_STATIC_NETWORKING="Yes"
KERNEL_CMDLINE="ip=10.0.0.15 nm=255.255.255.0 netdev=eth0 gw=10.0.0.1"
GRUB2_DEFAULT_BOOT="rear"
GRUB2_TIMEOUT="5"
COPY_AS_IS+=(
/opt/bacula
)
Config Breakdown
Lines 1-3 configure the output image. OUTPUT defines what type of image to create, which in this case an ISO image. ISO_DIR sets the directory in which to save the ISO image.
ISO_PREFIX sets the ISO image’s file name. This is called “prefix” because “.iso” will be added to the end of it. This name should probably include this machine’s hostname, so it won’t get confused with ISOs from other machines.
Line 5 defines the backup method to be used. REQUESTRESTORE is a generic method that will simply request for the user to perform the restore after rear has setup the disks and gotten everything ready for the data restore.
Lines 7-9 configure the network settings to be used in the rear environment. Be sure to change the IP address, netmask, network device, and gateway address to values relevant to your setup.
Lines 11-12 configure the grub bootloader that will be used to boot the rear ISO. The first line sets it to boot the rear environment by default and the second sets it to auto boot in 5 seconds.
Lines 14-16 set what files and directories to include in the ISO, other than the basic system. In this case we are only including Bacula, which is in /opt/bacula in most cases. To include other things, such as a custom bash script, simply add its path in COPY_AS_IS+=() and it will be included in the image.
Further Reference
/usr/share/rear/conf/default.conf
Related articles:

How to Protect Your Backups from Ransomware





