Using ReaR with Bacula to perform a Bare-Metal-Restore


Using ReaR with Bacula to perform a Bare-Metal-Restore


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:

  1. Boot the ISO
  2. Type:
    1. ‘rear recover’
      1. to setup the disks, mount points
      2. make the destination system accessible on the network
  3. Start the bacula file daemon in the rear recovery environment.
  4. Then launch a restore job from the Bacula director.
  5. 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

  1. Install ReaR, either from your distro’s software repositories as shown below, or download a package from
    1. Distros using .deb packages (Debian, Ubuntu, etc)
      sudo apt-get install rear
    2. Distros using .rpm packages (RHEL, Fedora, etc)
      sudo dnf install rear
  2. 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
using nano to edit /etc/rear/local.conf
  1. Create the ISO.

    sudo rear -v mkrescue
creating the ReaR iso image using command: sudo rear -v mkrescue
  1. Test the ISO, and perform a test restore.

Performing a Restore

  1. Boot the ISO and login with root. It should login without requesting a password.
boot the ReaR iso
  1. 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
enter the command: rear recover
enter the command: rear recover
  1. Manually perform the data recovery.
    1. 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 the Bacula file daemon
enter the command: /opt/bacula/bin/bacula-fd -c /opt/bacula/etc/bacula-fd.conf to start the Bacula file daemon
    1. 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
use bconsole to start a restore job
use bconsole to start a restore job on the Bacula Director

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.

bconsole running the restore job
bconsole running the restore job

Wait for the restore job to finish with the following bconsole command:

wait jobid=1279
bconsole wait for the restore job to finish
bconsole wait for the restore job to finish.
    1. 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 the rear shell
after the restore job finishes, exit the rear shell.
  1. Reboot into the restored system
    reboot now

ReaR Config

Example Config

Highlighted text should be replaced with values relevant to your setup / environment.



KERNEL_CMDLINE="ip= nm= netdev=eth0 gw="




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

The default ReaR config file containing all possible options with lots of helpful comments:

Share it on social networks

You may also like...

Leave a Comment

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

Get In Touch

Have a question?

Are you 100% sure that your backup is safe from the latest ransomware attacks?

Video Guide