Disaster recovery framework

Unwind

© Lead Image © lucato, 123RF.com

© Lead Image © lucato, 123RF.com

Article from Issue 189/2016
Author(s):

A simple Bash shell script can be a very powerful tool: Relax-and-Recover generates rescue media from running systems, takes care of backups, and helps when migrating computers to new hardware or converting to virtual machines.

If you are you looking to migrate the system and data on your sad, old laptop to a new device or you have a server that's been standing in the corner for years consuming electricity that would be better off as a virtual machine, the simple Relax-and-Recover [1] shell script can help. This disaster recovery framework for Linux licensed under GPLv2 creates rescue disks (USB sticks, CDs, PXE boot images) and saves the data – optionally in cooperation with an external backup solution.

During subsequent recovery of the data, the tool proves to be a flexible partner that also takes hardware changes into account. Relax-and-Recover is thus not just an emergency tool, it is also a useful migration tool. Physical computers thus become virtual machines through Physical-to-Virtual (P2V) migration; the way back to physical hardware with Virtual-to-Physical (V2P) migration is also possible, and you can even migrate from one virtualization solution to another through Virtual-to-Virtual (V2V).

Our test team worked on Debian 8 ("jessie") and Ubuntu 16.04 (Xenial Xerus) with Relax-and-Recover current stable version 1.17.2 and the latest version 1.18 from the GitHub repository (March 2016) [2]. We produced a rescue medium and a backup of a desktop computer. We also backed up a legacy server, combining the script with an external backup solution to do so. After this, the rescue systems and backups formed the basis for converting the physical hardware to virtual machines.

Well Prepared

Although Relax-and-Recover comes with a number of Linux distributions, the latest version is not necessarily on tap. The developers offer complete packages of the current versions on the project website [1]. You need to take care to resolve the dependencies on your system yourself. Usually, the package manager points out the missing components.

Alternatively, you can check out the program from the GitHub repository [2]. For this purpose, you need to install the git, syslinux, extlinux, and binutils packages and then execute the following commands:

git clone https://github.com/rear/rear.git
cd rear
make deb

On RPM-based systems, the package-building command is make rpm. After installing, rear resides in the /usr/sbin directory; you need to be root to start the script.

The next task is to format the backup device, which overwrites all the data. Relax-and-Recover comes with its own command to do so; to launch the process, type the command followed by device name of the removable medium, which must not be mounted (Listing 1). It is important to type Yes exactly as shown, otherwise Relax-and-Recover will quit.

Listing 1

Launching Relax-and-Recover

 

Formatting is not entirely without problems. On one of the test systems, a USB stick needed a fresh partition table before the medium was accepted. If the software quits with an error, it immediately refers you to the logfile, which contains detailed information about the problem. If all goes well, the tool formats the stick with the filesystem specified in the output and labels it REAR-000 (Figure 1).

Figure 1: Relax-and-Recover formats the USB medium and writes the label REAR-000.

Rescue the Desktop!

A backup of your own work computer would be a good first trial of the software. After formatting your USB device, go to the configuration file /etc/rear/local.conf, which only contains a few comments by the developers. Using a text editor, you can define, for example, the following requirements:

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

The rescue initramfs that contains the required startup files should end up on the USB medium. Alternative options for OUTPUT are ISO, PXE, RAMDISK, or OBDR (see the manual [3] for details). Additionally, the type of backup is defined: NETFS is the internal Relax-and-Recover method, which creates a simple tar.gz archive of all data on the system. In this case Relax-and-Recover stores the rescue image and the backup itself on the device labeled REAR-000.

The next step depends on whether you only need a bootable rescue system or a system with a full backup on top. Listing 2 shows how to create the first alternative. The -v option enables verbose message output. In this case, Relax-and-Recover only generates a bootable medium, which you can use to recover the basic environment of your system (e.g., disk layout, drivers, network card configuration), without programs and data, which are then backed up in a second step.

Listing 2

Rescue Disk

 

It is much more convenient to let Relax-and-Recover perform the backup task, too. If the USB removable drive is large enough, the command rear mkbackup backs up everything to a single medium. If you don't have not enough space there, external hard drives or network drives can be used. The location for the backup is defined by the BACKUP_URL variable in the /etc/rear/local.conf configuration file. It expects values that begin with file://, nfs://, tape://, or cifs://. You can enter authentication information for Samba shares in the /etc/rear/.cifs file (again, take a look at the manual  [3] for a sample configuration).

After starting the rescue system, a selection menu (Figure 2) appears listing available rescue images and, in a second step, existing backups. You can also decide whether Relax-and-Recover should do everything automatically or if you want to intervene, in which case you log in as root without a password. The recovery process is launched by rear recover. Again, the -v switch ensures detailed output.

Figure 2: The Relax-and-Recover boot menu showing the available images (e.g., silberfisch here ) and alternative boot methods.

In the course of the restore, the program creates the partitions and reformats them with the original filesystem. The swap space ends up at the same location, and the script mounts the device and then restores the data. Finally, Relax-and-Recover installs the GRUB bootloader. Before rebooting the computer, you can see the results of your work in /mnt/local, as the script reveals (Figure 3).

Figure 3: If you want to check the results of your recover operation before rebooting, look in /mnt/local.

Teamwork

After the reboot, the system will be in the same state it was before calling rear mkrescue or rear mkbackup. Interaction is possible and necessary if the disk size has changed; you need to edit the /var/lib/rear/layout/diskrestore.sh script generated by the restore in a text editor. Thanks to detailed logfiles and the ability to change scripts on the fly during the recover process, you can even move systems to larger or smaller hard disks, although you can run into problems if you move to an enhanced IDE (EIDE) disk.

Relax-and-Recover is also at home in data centers, where it can back up or migrate servers with a significantly larger amount of data storage, compared with a desktop PC. You can even integrate an existing backup solution. Relax-and-Recover works with, among others, Bacula, Bareos, HP Data Protector, CommVault Galaxy (versions 5 to  7, and possibly later versions), Symantec NetBackup, EMC (formerly Legato) NetWorker, and IBM Tivoli Storage Manager.

Teamwork with an external backup program is not just an elegant way to combine the recovery and restore process, it also offers other benefits. The NETFS backup method, with its simple .tar.gz archive, does not take into account running databases and lock files. If you do not want to create a database dump manually and stop processes before running Relax-and-Recover, you will probably prefer a complete solution that takes care of exactly such problems.

The test team combined Bareos [4], a Bacula fork, with Relax-and-Recover and added the following information to the /etc/rear/local.conf configuration file:

OUTPUT=ISO
OUTPUT_URL=nfs://<IP>/<Share>/<Hostname>
BACKUP=BAREOS
BAREOS_CLIENT=<Bareosclient-fd>

The ISO image as a rescue system resides on a computer accessible via NFS. After a server crash, or when migrating to a virtual machine, the ISO boots via PXE – given an appropriately configured TFTP server. BAREOS_CLIENT defines the name of the Bareos file daemon, which is responsible for backing up the client data.

The file daemon itself and its configuration are stored in the ISO image; it then autonomously takes care of restoring the data later on. A mandatory requirement, however, is that it access the backup server via bconsole, which is the tool that communicates with the Bareos Director.

One other consideration in this scenario is that everything beyond a minimum rescue system is best stored in the backup, including directories such as /etc, /usr, and /var, but not /tmp, /proc, and the like. This will ensure that the system administrator finds everything again as expected.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Mondo and Mindi

    Mondo shows that backups don’t need to be time consuming or difficult. This amazingly simple tool backs up complete hard disks or individual directories.

  • Data Recovery Services

    Nothing protects your data like a well-conceived system of backups. However, no one is perfect, and mistakes happen. In most cases, you can recover data you thought was lost by sending your disk to a data recovery service.

  • Bacula

    When backup jobs become too challenging for a script, the daemon-based free backup tool Bacula may be the answer.

  • Data Reconstruction

    One false click can quickly delete important data, or even an entire partition. If a backup tool is missing, only a rescue specialist can help.

  • SystemRescueCd

    The SystemRescueCd live system contains numerous tools that you can use to recover deleted files or a defective system.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News