Relax-and-Recover – Backup and Recover a Linux System

Relax-and-Recover (ReaR in short) is a simple yet powerful, easy-to-setup, full-featured and leading open-source bare metal disaster recovery and system migration solution, written in Bash. It is a modular and configurable framework with numerous ready-to-use workflows for common situations.

ReaR creates a bootable rescue system and/or system backup in various formats. You can boot your bare metal server using the rescue system image and initiate a system restore from the backup. It can restore to different hardware where necessary, hence it can also be employed as a system migration tool.

Relax-and-Recover Key Features:

  1. It has a modular design written in Bash and can be extended using custom functionality.
  2. Supports various boot media including ISO, PXE, OBDR tape, USB or eSATA storage.
  3. Supports a variety of network protocols including FTP, SFTP, HTTP, NFS, and CIFS for storage and backup.
  4. Supports disk layout implementation such as LVM, DRBD, iSCSI, HWRAID (HP SmartArray), SWRAID, multipathing, and LUKS (encrypted partitions and filesystems).
  5. Supports both third-party and internal backup tools including IBM TSM, HP DataProtector, Symantec NetBackup, Bacula; tar and rsync.
  6. Supports booting via PXE, DVD/CD, bootable tape or virtual provisioning.
  7. Supports a simulation model that shows what scripts are run without executing them.
  8. Supports consistent logging and advanced debugging options for troubleshooting purposes.
  9. It can be integrated with monitoring tools such as Nagios and Opsview.
  10. It can also be integrated with job schedulers such as cron.
  11. It also supports various virtualization technologies supported (KVM, Xen, VMware).

In this article, you will learn how to install and configure ReaR to create a rescue system and/or system backup using a USB stick and rescue or restore a bare-metal Linux system after a disaster.

Step 1: Installing ReaR in Linux Bare Metal Server

1. To install the rear package on Debian and Ubuntu Linux distributions, use the following command.

$ sudo apt-get install rear extlinux

On RHEL and CentOS, you need to enable the EPEL 8 repository, then install the rear package as shown.

# yum install rear syslinux-extlinux grub2-efi-x64-modules
# dnf install rear syslinux-extlinux	#Fedora 22+

2. Once the installation is complete, rear’s main configuration directory is /etc/rear/ and the key configuration files are:

  • /etc/rear/local.conf – used to set system-specific configuration; it’s intended for manual configuration.
  • /etc/rear/site.conf – used to set site-specific configuration, should be created by the user.
  • /usr/share/rear/conf/default.conf – contains possible/default configuration values.
  • /var/log/rear/ – this directory stores the log files.

3. First, prepare the rescue media, a USB stick in this case by formatting using the rear command-line utility as follows. Once the formatting is complete, the media will be labeled as REAR-000.

# rear format /dev/sdb
Prepare Rescue Media
Prepare Rescue Media

4. To configure the output format, use the OUTPUT and OUTPUT_URL variables, enter it in the /etc/rear/local.conf configuration file.


4. Also, ReaR comes with a built-in backup method (called NETFS) which allows you to create both a rescue system and a full-system backup. It creates a simple backup as a tar archive by default.

To enable a full-system backup, add the BACKUP=NETFS and BACKUP_URL variables in the /etc/rear/local.conf configuration file. To create a bootable USB device, combine OUTPUT=USB and BACKUP_URL=”usb:///dev/disk/by-label/REAR-000” as shown.


5. After configuring the rear, run the following command to print out its current configuration for BACKUP and OUTPUT methods and some system information.

# rear dump
Rear Backup Configuration Settings
Rear Backup Configuration Settings

Step 2: Creating a Rescue System and a Full-System Backup

6. If all the settings are fine, you can create a rescue system using the mkrecue command as follows, where the -v option enables verbose mode.

# rear -v  mkrescue
Make Rescue System
Make Rescue System

Note: If you encounter the following error after running a rescue or backup operation, as shown in this screenshot.

UEFI systems: “ERROR: /dev/disk/by-label/REAR-EFI is not block device. Use `rear format -- --efi ' for correct format” 
USB Stick Format Error
USB Stick Format Error

Format the USB stick using this command and redo the operation.

# rear format  -- --efi /dev/sdb
Format USB
Format USB

7. To create a rescue system and backup the system as well, use the mkbackup command as shown.

# rear -v mkbackup

8. To create a full-system backup only, use the mkbackuponly command as follows.

# rear -v mkbackuponly

Optional: Scheduling Rear Operations Using Cron

8. You can schedule ReaR to regularly create a rescue system using the cron job scheduler by adding the appropriate entry in the /etc/crontab file.

minute hour day_of_month month day_of_week root /usr/sbin/rear mkrescue

The following configurations will create a rescue system or take a full-system backup every midnight. Ensure that your USB stick is attached to it.

0 		0   		*  		* 		root /usr/sbin/rear mkrescue
0 		0   		*  		* 		root /usr/sbin/rear mkbackup

Step 3: Performing a System Rescue/Restoration

9. To restore/recover your system after a disaster, connect the bootable USB stick to your bare metal system and boot from it. In the console interface, select option one (Recover hostname) and click Enter.

ReaR Main Boot Menu
ReaR Main Boot Menu

10. Next, the ReaR rescue system will be configured, you may be prompted to provide replacements for the original network interfaces as shown in the screenshot. Once you are done, click Enter.

Select Network Interface
Select Network Interface

11. Then login as root (just type username root and click Enter) to run the actual recovery.

Run System Recovery
Run System Recovery

11. Next, run the following command to launch the recovery process. The rescue system will compare the disks, examine their configurations and prompt you to choose disk layout configuration. Press Enter to proceed with auto disk configuration.

Then it will start the system layout restoration, once the disk layout is created, it will restore the backup as shown in the following screenshot.

# rear recover
ReaR Recover Method
ReaR Recover Method

12. When the backup restoration is complete, the rescue system will run mkinitrd to create initial ramdisk images for preloading modules, then install the boot loader and exits. One the system recovery is done, the restored system will be mounted under /mnt/local/, move into this directory to examine it.

Finally, reboot the system:

# cd /mnt/local
# rebooot
Explore Restored System
Explore Restored System

13. After a reboot, the SELinux will try to relabel files and file systems on the recovered system based on /mnt/local/.autorelabel file, as shown in the following screenshot.

Relabeling File System
Relabeling File System

For more usage options, read the ReaR manual page.

# man rear

ReaR Homepage:

The ReaR is the leading, easy-to-use (setup-and-forget) and open source bare metal disaster recovery and system migration framework. In this article, we explained how to use ReaR to create a Linux bare metal rescue system and backup and how to restore a system after a disaster. Use the comment form below share your thoughts with us.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “Relax-and-Recover – Backup and Recover a Linux System”

  1. Hi Guys,

    I’m hoping that one of you guys may have a solution for me. I used ReaR to create a backup of my CentOS7 system. Tested regularly… no probs. My system, a laptop, was stolen now, and I just have this backup. When I use it on any other computer, I either don’t see it or when I do and select it as my boot option in BIOS, it says no bootable disk found.

    I have tried this in both UEFI and legacy BIOS. I have used other recovery tools like Testdisk and Photorec to recover files from this disk, but, unrecognizable formats. My backup was made with the USB option. Any help and advice will be appreciated. Am running into dead ends on the internet. I have tried the recovery on assorted computers, that have Windows on, Mint, Arch, luck.

    I know, it doesn’t matter the OS, as it should boot from recovery USB. But, I have tried to see if any different, in a GRUB setup, or BCDStore. In BIOS / UEFI, I have tested various options, incl secure boot, and fast boot.

    Is there any way a person can use the files recovered with Testdisk?

    Any other options. I was reading about putting GRUB_RESCUE = 1, but, do not have ReaR on the current two Linux machines that I have. Even still, I would need to put it in local.conf file, in ReaR, if I did install it. But, considering that USB drive keeps saying “no bootable disk found”?



Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.