Chapter 17. Recovering and restoring a system


To recover and restore a system using an existing backup, Red Hat Enterprise Linux provides the Relax-and-Recover (ReaR) utility.

You can use the utility as a disaster recovery solution and also for system migration.

The utility enables you to perform the following tasks:

  • Produce a bootable image and restore the system from an existing backup, using the image.
  • Replicate the original storage layout.
  • Restore user and system files.
  • Restore the system to a different hardware.

Additionally, for disaster recovery, you can also integrate certain backup software with ReaR.

17.1. Setting up ReaR and manually creating a backup

Use the following steps to install the package for using the Relax-and-Recover (ReaR) utility, create a rescue system, configure and generate a backup.

Prerequisites

  • Necessary configurations as per the backup restore plan are ready.

    Note that you can use the NETFS backup method, a fully-integrated and built-in method with ReaR.

Procedure

  1. Install the ReaR utility:

    # yum install rear
    Copy to Clipboard
  2. Modify the ReaR configuration file in an editor of your choice, for example:

    # vi /etc/rear/local.conf
    Copy to Clipboard
  3. Add the backup setting details to /etc/rear/local.conf. For example, in the case of the NETFS backup method, add the following lines:

    BACKUP=NETFS
    BACKUP_URL=backup.location
    Copy to Clipboard

    Replace backup.location by the URL of your backup location.

  4. To configure ReaR to keep the previous backup archive when the new one is created, also add the following line to the configuration file:

    NETFS_KEEP_OLD_BACKUP_COPY=y
    Copy to Clipboard
  5. To make the backups incremental, meaning that only the changed files are backed up on each run, add the following line:

    BACKUP_TYPE=incremental
    Copy to Clipboard
  6. Create a rescue system:

    # rear mkrescue
    Copy to Clipboard
  7. Create a backup as per the restore plan. For example, in the case of the NETFS backup method, run the following command:

    # rear mkbackuponly
    Copy to Clipboard

    Alternatively, you can create the rescue system and the backup in a single step by running the following command:

    # rear mkbackup
    Copy to Clipboard

    This command combines the functionality of the rear mkrescue and rear mkbackuponly commands.

17.2. Scheduling ReaR

The /etc/cron.d/rear crontab file in the rear package runs the rear mkrescue command automatically at 1:30 AM everyday to schedule the Relax-and-Recover (ReaR) utility for regularly creating a rescue system. The command only creates a rescue system and not the backup of the data. You still need to schedule a periodic backup of data by yourself. For example:

Procedure

  • You can add another crontab that will schedule the rear mkbackuponly command.
  • You can also change the existing crontab to run the rear mkbackup command instead of the default /usr/sbin/rear checklayout || /usr/sbin/rear mkrescure command.
  • You can schedule an external backup, if an external backup method is in use. The details depend on the backup method that you are using in ReaR.
Note

The /etc/cron.d/rear crontab file provided in the rear package is considered deprecated, see Deprecated functionality shell and command line, because it is not sufficient by default to perform a backup.

17.3. Using a ReaR rescue image on the 64-bit IBM Z architecture

Basic Relax and Recover (ReaR) functionality is now available on the 64-bit IBM Z architecture and is fully supported since RHEL 8.8. You can create a ReaR rescue image on IBM Z only in the z/VM environment. Backing up and recovering logical partitions (LPARs) has not been tested.

Important

ReaR on the 64-bit IBM Z architecture is supported only with the rear package version 2.6-9.el8 or later. Earlier versions are available as a Technology Preview feature only. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview.

The only output method currently available is Initial Program Load (IPL). IPL produces a kernel and an initial RAM disk (initrd) that can be used with the zIPL boot loader.

Prerequisites

  • ReaR is installed.

    • To install ReaR, run the yum install rear command

Procedure

Add the following variables to the /etc/rear/local.conf to configure ReaR for producing a rescue image on the 64-bit IBM Z architecture:

  1. To configure the IPL output method, add OUTPUT=IPL.
  2. To configure the backup method and destination, add BACKUP and BACKUP_URL variables. For example:

    BACKUP=NETFS
    
    BACKUP_URL=nfs://<nfsserver name>/<share path>
    Copy to Clipboard
    Important

    The local backup storage is currently not supported on the 64-bit IBM Z architecture.

  3. Optional: You can also configure the OUTPUT_URL variable to save the kernel and initrd files. By default, the OUTPUT_URL is aligned with BACKUP_URL.
  4. To perform backup and rescue image creation:

    # rear mkbackup
    Copy to Clipboard
  5. This creates the kernel and initrd files at the location specified by the BACKUP_URL or OUTPUT_URL (if set) variable, and a backup using the specified backup method.
  6. To recover the system, use the ReaR kernel and initrd files created in step 3, and boot from a Direct Attached Storage Device (DASD) or a Fibre Channel Protocol (FCP)-attached SCSI device prepared with the zipl boot loader, kernel, and initrd. For more information, see Using a Prepared DASD.
  7. When the rescue kernel and initrd get booted, it starts the ReaR rescue environment. Proceed with system recovery.
Warning

Currently, the rescue process reformats all the DASDs (Direct Attached Storage Devices) connected to the system. Do not attempt a system recovery if there is any valuable data present on the system storage devices. This also includes the device prepared with the zipl boot loader, ReaR kernel, and initrd that were used to boot into the rescue environment. Ensure to keep a copy.

17.4. ReaR exclusions

The ReaR utility recreates the storage layout of the original system, where the rescue image has been produced, on the disks of the recovered system according to the description in the /var/lib/rear/layout/disklayout.conf layout file during the recovery process. The storage layout includes partitions, volume groups, logical volumes, file systems, and other storage components.

ReaR creates the layout file when creating the rescue image and embeds this file in the image. You can also create the layout file by using the rear savelayout command. This allows you to quickly create the layout file and examine it, without creating the entire rescue image.

The layout file describes the entire storage layout of the original system with certain exceptions, as ReaR excludes some storage components from the layout file and from being recreated during recovery. The exclusion of storage components from layout is controlled by the following configuration variables:

  • AUTOEXCLUDE_DISKS
  • AUTOEXCLUDE_MULTIPATH
  • AUTOEXCLUDE_PATH
  • EXCLUDE_RECREATE

You can view the default values for the configuration variables in the /usr/share/rear/conf/default.conf file and can change these values in the local /etc/rear/local.conf configuration file.

For more information about the syntax of the layout file and the configuration variables that you can use to exclude some storage components, see the Layout configuration chapter in the ReaR user guide, which is installed with the ReaR package as /usr/share/doc/rear/relax-and-recover-user-guide.html.

You can also configure which files are backed up by the internal NETFS and RSYNC backup methods. By default, files on all mounted local (disk-based) file systems are backed up by the rear mkbackup or rear mkbackuponly commands, if the file systems are included in the layout file. Excluding some file systems from the layout file, which is controlled by variables such as AUTOEXCLUDE_DISKS, AUTOEXCLUDE_MULTIPATH, AUTOEXCLUDE_PATH, and EXCLUDE_RECREATE, also excludes their content from the backup. You can also exclude some files or a directory tree from the backup without excluding a file system from the layout file by using the BACKUP_PROG_EXCLUDE configuration variable. When all files and directories in a file system are excluded in this way, the file system is recreated during recovery, but it will be empty, because the backup does not contain any data to restore into it. This is useful for file systems that contain temporary data and are not required to be preserved, or for data that is backed up by using methods independent of ReaR.

The BACKUP_PROG_EXCLUDE variable is an array of glob(3)-style wildcard patterns that are passed to tar or rsync. Note that the patterns are required to be quoted in order to prevent their expansion by the shell when it reads the configuration file. The default value of this variable is set in the /usr/share/rear/conf/default.conf file. The default value contains, for example, the /tmp/* pattern that excludes all the files and directories under the /tmp directory, but not the /tmp directory itself.

If you need to exclude other files and directories, append further patterns to the variable instead of overriding it in order to preserve the default values. For example, to exclude all files and directories under the directory /data/temp, use:

# BACKUP_PROG_EXCLUDE+=( '/data/temp/*' )
Copy to Clipboard

The rear mkbackup command lists the backup exclude patterns in the log. You can find the log file in the /var/log/rear directory. This can be used to verify the excluded rules before performing a full system recovery. For example, the log can contain the following entries:

2025-04-29 10:17:41.312431050 Making backup (using backup method NETFS)
2025-04-29 10:17:41.314369109 Backup include list (backup-include.txt contents):
2025-04-29 10:17:41.316197323   /
2025-04-29 10:17:41.318052001 Backup exclude list (backup-exclude.txt contents):
2025-04-29 10:17:41.319857125   /tmp/*
2025-04-29 10:17:41.321644442   /dev/shm/*
2025-04-29 10:17:41.323436363   /var/lib/rear/output/*
Copy to Clipboard

Here, the whole root file system is included in the backup, with the exception of all files and directories under the /tmp, /dev/shm and /var/lib/rear/output directories.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat, Inc.