Chapter 12. Recovering and restoring a system
To back up and restore your system, Red Hat Enterprise Linux provides the Relax-and-Recover (ReaR) utility.
You can use ReaR as a disaster recovery solution and also for system migration.
By using ReaR, you can perform the following tasks:
- Produce a system backup and a bootable image, and use the image to restore the system from an existing backup.
- Replicate the original storage layout.
- Restore user and system files.
- Restore the system to different hardware.
Additionally, for disaster recovery, you can also integrate certain backup software with ReaR.
12.1. Setting up ReaR and manually creating a backup Copy linkLink copied to clipboard!
To create a rescue system, first install the packages for the Relax-and-Recover (ReaR) utility, adjust ReaR settings, and manually generate a system backup. This prepares your system for potential disaster recovery operations.
Prerequisites
The necessary configurations based on your backup restore plan are ready.
NoteThe following steps use the
NETFSbackup method in example configurations. This method is fully-integrated and built-in with ReaR, and produces a backup in a location specified by theBACKUP_URLconfiguration setting. By default it uses the systemtarutility to create a backup archive namedbackup.tar.gz.You are using the Intel 64 or AMD64 (x86-64) hardware architecture, or the IBM POWER little-endian (ppc64le) architecture.
If you are using the IBM Z architecture, see Using a ReaR rescue image on the 64-bit IBM Z architecture.
On the 64-bit ARM architecture, ReaR is currently provided only as a Technology Preview in RHEL 9.7 and later.
Procedure
Install the ReaR utility:
# dnf install rearModify the ReaR configuration file in an editor of your choice, for example:
# vi /etc/rear/local.confAdd the backup setting details to
/etc/rear/local.conf. For example, in the case of theNETFSbackup method, add the following lines:BACKUP=NETFS OUTPUT=ISO BACKUP_URL=<data-backup-location> OUTPUT_URL=<rescue-image-location>Replace <data-backup-location> with the location for the
tardata backup, and <rescue-image-location> with the location for the rescue systemISOimage. For example:BACKUP=NETFS OUTPUT=ISO # Backup is stored on an external drive BACKUP_URL=file:///run/media/user/external_drive/server_backups/ # The ISO is stored on a dedicated NFS share OUTPUT_URL=nfs://backup-server.local/exports/rear/For further information on the syntax of the
/etc/rear/local.conffile and for supported formats ofBACKUP_URLandOUTPUT_URL, see therear(8)man page.For a list of configuration variables that you can use in
/etc/rear/local.conf, as well as their default values, see the/usr/share/rear/conf/default.conffile.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=yTo make the backups incremental, meaning that only the changed files are backed up on each run, add the following line:
BACKUP_TYPE=incrementalIf you are planning to boot the ReaR rescue system on UEFI firmware, add the following line to ensure the boot does not fail:
SECURE_BOOT_BOOTLOADER=/boot/efi/EFI/redhat/shimx64.efiIf your system is using the 64-bit ARM architecture (
aarch64), use the following line instead:SECURE_BOOT_BOOTLOADER=/boot/efi/EFI/redhat/shimaa64.efi
Create a rescue system and data backup based on your restore plan. For example, when using the
NETFSbackup method, run the following command:# rear mkbackup-
If you need to create only the rescue system, use the
rear mkrescuecommand instead -
If you need to create only the data backup, use the
rear mkbackuponlycommand instead.
-
If you need to create only the rescue system, use the
Optional: Schedule regular automatic ReaR backup. You can use a variety of backup methods, based on your use case. For example:
Create a
/etc/cron.d/rearcrontab file, and add the following line:30 1 * * * /usr/sbin/rear mkbackupThis runs the the
rear mkbackupcommand at 1:30 AM every day, which creates a rescue system and a data backup in the location set up in the/etc/rear/local.conffile.- If you use an external backup method, schedule an external backup. The details depend on the backup method that you are using in ReaR.
Verification
Burn the ISO image of the rescue system to a DVD, and attempt to use the DVD to boot.
If this displays a Relax-and-Recover interface after booting, the rescue DVD works correctly.
- Use the ReaR interface to restore the system, and test that the restored system works.
12.2. Using a ReaR rescue image on the 64-bit IBM Z architecture Copy linkLink copied to clipboard!
To quickly recover and restore systems running on the IBM Z architecture, you can use the Relax-and-Recover (ReaR) rescue image.
ReaR provides basic functionality on the 64-bit IBM Z architecture and is fully supported in RHEL 9.2 and later. You can create a ReaR rescue image on IBM Z only in the z/VM environment. Backing up and recovering logical partitions (LPARs) is not supported.
ReaR on the 64-bit IBM Z architecture is supported only with the rear package version 2.6-17.el9 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.
Procedure
Install ReaR:
# dnf install rearAdd the following variables to the
/etc/rear/local.conffile to configure ReaR for producing a rescue image on the 64-bit IBM Z architecture:-
To configure the
IPLoutput method, add the`OUTPUT=IPL` line to the configuration. To configure the backup method and destination, add
BACKUPandBACKUP_URLvariables. For example:BACKUP=NETFS BACKUP_URL=nfs://<nfsserver name>/<share path>ImportantLocal backup storage is currently not supported on the 64-bit IBM Z architecture.
-
Optional: You can also configure the
OUTPUT_URLvariable to save the kernel andinitrdfiles. By default, theOUTPUT_URLis aligned withBACKUP_URL.
-
To configure the
To perform backup and rescue image creation:
# rear mkbackupThis creates the kernel and initrd files at the location specified by the
BACKUP_URLorOUTPUT_URL(if set) variable, and a backup using the specified backup method.-
To recover the system, use the ReaR kernel and initrd files created in the previous step, and boot from a Direct Attached Storage Device (DASD) or a Fibre Channel Protocol (FCP)-attached SCSI device prepared with the
ziplboot loader, kernel, andinitrd. For more information, see Booting the RHEL installation by using a prepared DASD. -
When the rescue kernel and
initrdare booted, the ReaR rescue environment starts. Proceed with the system recovery.
Next steps
12.3. Recovering your system by using ReaR Copy linkLink copied to clipboard!
To recover your RHEL system on new hardware after a failure of the current hardware, use the Relax-and-Recover (ReaR) utility.
Prerequisites
- You have set up ReaR and created a backup. For instructions, see Setting up ReaR and manually creating a backup.
- You have a set of working hardware on which you want to run the system after you recover it.
The hard disk on which you plan to recover your system does not contain any critical data.
ImportantRecovering a system on a hard disk by using ReaR erases all data currently stored on the disk.
Procedure
- Boot the rescue system on the new hardware. For example, you can burn the ISO image of the rescue system to a DVD, and boot from the DVD.
- In the Relax-and-Recover boot menu, select the option to boot to the recovery environment.
In the
RESCUEprompt, run therear recovercommand.The rescue system recreates the partition layout and file systems.
Restore user and system files from the data backup into the
/mnt/local/directory.For example, if you used the
NETFSmethod to create the backup, ReaR automatically performs the restoration process. However, based on your backup settings, ReaR might still require your confirmation in certain points of the restoration.
12.4. Modifying the content of the ReaR backup Copy linkLink copied to clipboard!
When creating a rescue system and data backup by using the Relax-and-Recover (ReaR) utility, certain files and storage components are not included in the backups. To adjust what data and devices are excluded from the backups, modify ReaR configuration.
When creating the rescue image, ReaR creates the /var/lib/rear/layout/disklayout.conf layout file, and embeds the file in the rescue image.
During the recovery process, ReaR uses the layout file to recreate the storage layout of the original system, where the rescue image has been produced, on the disks of the recovered system. The storage layout includes partitions, volume groups, logical volumes, file systems, and other storage components.
Prerequisites
- You have set up ReaR on your system. For instructions, see Setting up ReaR and manually creating a backup.
Procedure
Generate the current layout file.
# rear savelayoutOpen the layout file to examine its configuration. For example:
# vi /var/lib/rear/layout/disklayout.confTo exclude specific files or storage devices from the backup, you can configure ReaR to ignore them when creating the rescue image.
Open the ReaR local configuration file for editing. For example:
# vi /etc/rear/local.confAdjust which storage devices will be excluded from the layout file. You can use a variety of
excludevariables in the/etc/rear/local.conffile, including the following:-
AUTOEXCLUDE_DISKS -
AUTOEXCLUDE_MULTIPATH -
AUTOEXCLUDE_PATH -
EXCLUDE_RECREATE
For information on the functions and syntax of these variables, as well as of the layout file, see the
Layout configurationchapter in the ReaR user guide. This guide is installed with therearpackage, and is available at/usr/share/doc/rear/relax-and-recover-user-guide.html.-
By default, when a local disk-based file system is included in the layout file, all files on that file system are backed up when you use the
rear mkbackuporrear mkbackuponlycommands.To configure specific files or a directory tree to be excluded from the backup, use the
BACKUP_PROG_EXCLUDEvariable.The value of
BACKUP_PROG_EXCLUDEmust be an array of glob(3)-style wildcard patterns that tar or rsync uses. Note that you must quote the patterns 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.conffile. The default value contains, for example, the/tmp/*pattern that excludes all the files and directories under the/tmpdirectory, but not the/tmpdirectory itself.If you need to exclude other files and directories, append further patterns to the variable. To ensure that the default values are preserved, do not override the variable.
For example, to exclude all files and directories under the directory
/data/temp, use:BACKUP_PROG_EXCLUDE+=( '/data/temp/*' )NoteWhen you exclude all files and directories in a single mounted file system this way, ReaR recreates the file system during recovery, but it will be empty. You can use this for file systems that contain temporary data and do not require preserving, or for data that is backed up by using methods independent of ReaR.
Verification
To ensure that the layout file includes only the required storage components, do the following:
Re-generate the layout file.
# rear savelayoutOpen the new layout file and make sure that your configuration changes had the intended effect.
# vi /var/lib/rear/layout/disklayout.conf
To ensure that the backup excludes specific files, use the
rear mkbackupcommand. This lists the backup exclude patterns in the log.You can find the log file in the
/var/log/reardirectory. Use this to verify the exclude 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/*In this example, the entire root file system is included in the backup, with the exception of all files and directories under the
/tmp,/dev/shmand/var/lib/rear/outputdirectories.