#2891 Issue closed: Attempting to Automate Relax and Recovery (ReaR)

Labels: support / question, fixed / solved / done

keredf opened issue at 2022-11-29 22:09:

  • ReaR version: 2.6 / 2020-06-17

  • OS version: RHEL 8.6

  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):

  • Hardware vendor/product: Laptop

  • System architecture: x86

  • Firmware: BIOS R2.01, UEFI 2.7

  • Storage (local disk or SSD): image saved onto local laptop SSD then image copied to a DVD

  • Storage layout ("lsblk -ip"):

/dev/nvme0n1           477G  disk
/dev/nvme0n1p1         600M  part  /boot/eft
/dev/nvme0n1p2         1G    part  /boot
/dev/nvme0n1p3         475G  part
/dev/mapper/rhel-root  70G   lvm   /
/dev/mapper/rhel-swap  7.7G  lvm   [SWAP]
/dev/mapper/rhel-home  397G  lvm   /home
  • Description of the issue (ideally so that others can reproduce it):

I am attempting to create a backup recovery image of a RedHat (RHEL) machine.
I am attempting to create a Relax and Recovery (ReaR) image to restore the machine.
I would like to fully automate the restoration process as much as possible
by simply booting from REAR rescue image with little user intervention.
After creating an image, we attempted to manually add the "unattended" parameter
in the kernel while booting the system from REAR rescue image.
This works but does not fully automate (e.g., no manual typing is required to recover the image) the restoration process.

In the kernel:

grubby --update-kernel=ALL --args="unattended"
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Does anyone know if this can be done?
Ideally, we are looking for consultation as soon as possible.
Thank you.

  • Workaround, if any: none

  • Attachments, as applicable ("rear -D mkrescue/mkbackup/recover" debug log files): none

pcahyna commented at 2022-11-29 22:25:

For me this (unattended) works. What is the thing that does not get automated this way?

Note that prompts that require manual input time out and select the default option if you ignore them long enough. You can shorten the timeout by setting the USER_INPUT_TIMEOUT variable. There are also USER_INPUT_user_input_ID variables for fine-grained customizations. See the description of the variables in /usr/share/rear/conf/default.conf .

keredf commented at 2022-11-30 11:49:

We have to manually enter the kernel command line to enter the unattended option. Is it possible to update the grub menu/boot sequence with this unattended option.

To clarify, we attempted to update the grub menu with the following options, but it did not work:
grubby --update-kernel=ALL --args="unattended"
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

I have not tried to use the USER_INPUT_TIMEOUT variable.

the /etc/rear/local.conf is set with the following settings:

OUTPUT=ISO
OUTPUT_URL=null
BACKUP=NETFS
BACKUP_URL=iso:///BACKUP/
ISO_MAX_SIZE=4400
BACKUP_PROG_EXCLUDE=("${BACKUP_PROG_EXCLUDE[@]}" '/media' '/var/tmp' '/var/crash' '/RHEL_8.6' '/mnt')

jsmeix commented at 2022-11-30 11:55:

@keredf
see KERNEL_CMDLINE in usr/share/rear/conf/default.conf
e.g. for ReaR 2.6 online at
https://github.com/rear/rear/blob/rear-2.6/usr/share/rear/conf/default.conf#L81
and see "RESCUE IMAGE KERNEL COMMAND LINE OPTIONS"
in "man rear" e.g. for ReaR 2.6 online at
https://github.com/rear/rear/blob/rear-2.6/doc/rear.8.adoc
so something like

KERNEL_CMDLINE+=" unattended"

in /etc/rear/local.conf should do it.

keredf commented at 2022-11-30 22:15:

setting KERNEL_CMDLINE="unattended" & USER_INPUT_TIMEOUT=1 in /etc/rear/local.conf did work.

Is it possible to remove options we from the grub menu? Is it possible to set decrease the time out in the grub menu from 5s to 1s/0s?

In Grub menu, options are:
Relax-and-Recover (no Secure Boot)
Relax-and-Recover (Secure Boot)
Boot original system
Reboot

Also, after the "‘rear recover’ finished successfully" line, the machine waits 30 seconds before rebooting. Is it possible to decrease the time to 1s/0s?

Thank you so much!

jsmeix commented at 2022-12-01 06:58:

The 30 seconds waiting
after "‘rear recover’ finished successfully"
is hardcoded in
usr/share/rear/skel/default/etc/scripts/system-setup

if unattended_recovery ; then
    choices=( "View Relax-and-Recover log file(s)"
              "Go to Relax-and-Recover shell"
            )
    echo -e "\nLaunching 'rear recover' automatically in unattended mode\n"
    # The recover workflow is always verbose (see usr/sbin/rear):
    if rear $rear_debug_options recover ; then
        echo -e "\n'rear recover' finished successfully\n"
        echo -e "\nRebooting in 30 seconds (Ctrl-C to interrupt)\n"
        sleep 30
        reboot

so you have to change that script as you need it.

jsmeix commented at 2022-12-01 07:20:

@keredf
I cannot imagine how you boot your ReaR recovery system
(i.e. what the bootloader setup of your ReaR recovery system is).

The string "Boot original system" only appears in
usr/share/rear/output/default/940_grub2_rescue.sh
but this is only run when GRUB_RESCUE is explicitly
set to a true value which you don't have
according to your /etc/rear/local.conf in
https://github.com/rear/rear/issues/2891#issuecomment-1332028592

As far as I know normally
with OUTPUT=ISO and BIOS
SYSLINUX is used as bootloader for the ReaR recovery system
via the make_syslinux_config function call in
usr/share/rear/output/ISO/Linux-i386/300_create_isolinux.sh)
and
with OUTPUT=ISO and UEFI
GRUB2 is used as bootloader for the ReaR recovery system
via the create_grub2_cfg function call in
usr/share/rear/output/ISO/Linux-i386/250_populate_efibootimg.sh

Our ReaR recovery system bootloader setup
are long grown rather complicated pieces of code
that behave different depending on what there is
on the original system.

As far as I see on first glance the
ReaR recovery system bootloader timeout values
are hardcoded at the various places of our
ReaR recovery system bootloader setup code.

keredf commented at 2022-12-01 17:54:

@jsmeix
I was able to set sleep to 0 in usr/share/rear/skel/default/etc/scripts/system-setup. That worked great.

It is strange that I am seeing the "Boot original system" option in the Grub menu.

There is another timeout I would like to decrease. During the recovery process, there is another 30 second timeout:
"Disk Configuration looks identical
Proceed with ‘recover’ (yes) otherwise manual disk layout configuration is enforced
(Default ‘yes’ timeout 30 seconds)"

I looked for this string in some of the files/scripts but I can't find it. Do you know which file I can change this timeout?

I really appreciate your help! Thank you.

jsmeix commented at 2022-12-02 07:28:

@keredf
that it is strange for you seeing "Boot original system" in the Grub menu
helped me to see why you see it but I couldn't find it in the code.
I had searched the current master code (basically the ReaR 2.7 code)
where I myself had changed

- menuentry "Boot original system" {
+ menuentry "Boot next EFI" --id=chainloader {

in the create_grub2_cfg function in lib/bootloader-functions.sh via
https://github.com/rear/rear/commit/25f86d4f9cb320db637e65550830cb19a7fd2b02
and https://github.com/rear/rear/pull/2662
which contains in particular
https://github.com/rear/rear/pull/2662#issuecomment-888470901
so in ReaR 2.7 we have a new config variable GRUB2_TIMEOUT
that should (hopefully) do what you need.

For a test you can try out ReaR 2.7
or our current ReaR upstream GitHub master code
without conflicts with your normally installed ReaR version.
See the section
"Testing current ReaR upstream GitHub master code" in
https://en.opensuse.org/SDB:Disaster_Recovery
A 'git clone' of our upstream GitHub master code repository
contains all our released ReaR versions as commits
so you can 'git checkout' all released ReaR versions
e.g.:

a5f78a60089fae811f867a37a409e5d6e2d2aa68
Thu Jul 14 10:47:57 2022 +0200
ReaR 2.7 release
...
c40fd8efdc2b9822c05ba17b0ad219ffad5c19b0
Wed Jun 17 18:41:46 2020 +0200
ReaR 2.6 release

The code for "Disk configuration looks identical" is in
usr/share/rear/layout/prepare/default/250_compare_disks.sh
online at
https://github.com/rear/rear/blob/rear-2.6/usr/share/rear/layout/prepare/default/250_compare_disks.sh#L135

So either you change the default local timeout=30 in that code
or you specify the USER_INPUT_TIMEOUT variable
which you already set to 1 according to your
https://github.com/rear/rear/issues/2891#issuecomment-1332801879

Currently I cannot explain why you get 30 seconds timeout regardless of

test "$timeout" -gt "$USER_INPUT_TIMEOUT" && timeout="$USER_INPUT_TIMEOUT"

in the code.

Alternatively specify an automated input for the UserInput() call
with its matching user_input_ID value DISK_LAYOUT_PROCEED_RECOVERY
so in this case you may specify in your etc/rear/local.conf

USER_INPUT_DISK_LAYOUT_PROCEED_RECOVERY="yes"

see the section
"Relax-and-Recover UserInput function default behaviour"
in default.conf e.g. online for ReaR 2.6 in particular at
https://github.com/rear/rear/blob/rear-2.6/usr/share/rear/conf/default.conf#L280

github-actions commented at 2023-02-01 02:46:

Stale issue message


[Export of Github issue for rear/rear.]