Latest Stories

Featured Stories

Filter By Categories
Ramesh Vishveshwar
By
April 26, 2019

Relax & Recover

We have talked about backups in previous articles. Recovery from backups is often easy, but in case of hardware failures, you will need to go through the entire process of re-installing the OS, retweaking the configurations to suit your needs and then begin the recovery process. What if it were possible to restore the entire operating system, configuration and all? This is where Relax and Recover comes in.

Introduction

Relax and Recover is an open source modular recovery tool that creates bootable ISO images in the system’s original storage layout. There are various ready-to-use workflows built in that ease the process of recovery. Since the storage layout can be modified prior to recovery, and disimilar hardware and virtualization is supported, Relax-and-Recover offers the flexibility to be used for complex system migrations.

A wide variety of hardware is supported to store the recovery boot media (ISO, PXE USB, eSATA storage or OBDR tape) and a variety of network protocols are supported to store the image to an offsite location (sftp, ftp, http, nfs, cifs).

Relax and Recover, also known as rear has few external dependencies as it uses a lot of bash and Unix tools. It is platform independent and is known to work with all flavors of Linux.

Installation & Initial Usage

Relax and Recover is available as rpm or deb packages from http://relax-and-recover.org/download/. Depending on your Linux flavor, grab the latest version and install it as follows (in the folder where the package is downloaded)

From RPM packages

# rpm -Uhv rear-2.4-1.el7.x86_64.rpm

From DEB packages

# dpkg -i rear*.deb

To install missing dependencies

# apt-get -f install

To confirm successful installation, execute rear dump to get details like below

Relax-and-Recover 1.12.0svn497 / 2011-07-11
Dumping out configuration and system information
System definition:
ARCH = Linux-x86_64
OS = GNU/Linux
OS_VENDOR = RedHatEnterpriseServer
OS_VERSION = 5.6

You can also install from source available on GitHub

# git clone git@github.com:rear/rear.git

You can then proceed to make the installation package through

# make rpm

or

# make deb

based on your OS

Options

The general configuration file is located at /usr/share/rear/conf/default.conf and contains the list of all the variables used by rear. Do not modify any of these variables, redefine them in /etc/rear/site.conf or /etc/rear/local.conf files.

Example when rear creates a resuce/recovery system image, it needs a temporary storage location. This is defaulted to /tmp/rear.XXXXXXXXXXXXXXX. If you do not wish to change the temporary storage location, create an entry like this in your /etc/rear/local.conf file

export TMPDIR="/mnt/media/temp"

You can choose to make similar changes such as default output, backup URL etc in your local.conf file

Usage

Let’s explore a simple use case of backing up the device on to an USB device

First we need to format the USB (assuming it is mounted as /dev/sdc)

# usr/sbin/rear format /dev/sdc 

You will be asked to confirm formatting the device. Answer Yes and the device will be formatted. The device is named REAR-000 as per the format workflow. You will need to enter this information in your local.conf file.

Edit the /etc/rear/local.conf file using nano (or your favorite editor) and add the following details

### write the rescue initramfs to USB and update the USB bootloader
OUTPUT=USB

### create a backup using the internal NETFS method, using 'tar'
BACKUP=NETFS

### write both rescue image and backup to the device labeled REAR-000
BACKUP_URL=usb:///dev/disk/by-label/REAR-000

Now, we are ready to create a rescue image

# usr/sbin/rear -v mkrescue

You will get an output similar to this

Relax-and-Recover 2.2 / Git
Using log file: /root/rear.master/var/log/rear/rear-fireflash.log
Creating disk layout
Creating root filesystem layout
WARNING: To login as root via ssh you need to
setup an authorized_keys file in /root/.ssh

Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Writing MBR to /dev/sdc
Copying resulting files to usb location

Also check the log file to see if there are any errors that need to be fixed. You are now ready to start creating full backups. Assuming your USB device has sufficient space, you can do a full backup like so

# usr/sbin/rear -v mkbackup

The output is then written into your USB drive under the folder rear/{hostname}/YYYYMMDD.HHMM/backup. The data is not encrypted so keep the USB drive safe.

You can also use rsync as the backup program to store the information. You will need to create the /etc/rear/site.conf with the following details

BACKUP=NETFS
OUTPUT=USB
BACKUP_PROG=rsync
BACKUP_URL=usb:///dev/disk/by-label/REAR-000

Once your backup is complete, it is possible to recover from this ISO image. You will need to boot from the USB (remember we created a bootable image in the first step). Once you boot, you will be presented with a Relax and Recover menu. You can recover automatically or recover manually. To manually recover

# rear -d -v recover

rear will attempt to check the system and see if things have changed. For e.g., from the time you created the backup and the recover, your hard disk has changed. rear will try to remap the backup disk details to the new available disk. Once recovery is complete, you can restart the system and it will be back to the recovered state.

Conclusion

Relax and Recover is useful not only in maintaining backups, but in setting up a predefined image that can be copied over and over to new machines without having to manually configure each server.

Subscribe Email