#3500 PR merged
: In sbin/rear error out if '-c' is used in recovery system¶
Labels: enhancement
, fixed / solved / done
jsmeix opened issue at 2025-07-30 14:55:¶
-
Type: Enhancement
-
Impact: Normal
-
Reference to related issue (URL):
https://github.com/rear/rear/issues/2942#issuecomment-3132425914
https://github.com/rear/rear/issues/512#issuecomment-68051604 -
How was this pull request tested?
I tested it on my SLES15-SP6 test VM in a Git clone.
On the original test system VM:
# usr/sbin/rear -D -c /foor/bar mkbackup
ERROR: The '-c' option argument '/foor/bar' is not a directory
# mkdir /etc/myrear
# cp -av etc/rear/* /etc/myrear
'etc/rear/local.conf' -> '/etc/myrear/local.conf'
# usr/sbin/rear -D -c /etc/myrear mkbackup
Relax-and-Recover 2.9 / 2025-01-31
Running rear mkbackup (PID 3681 date 2025-07-30 16:43:01)
Command line options: usr/sbin/rear -D -c /etc/myrear mkbackup
Using config directory '/etc/myrear'
...
In the ReaR recovery system on a replacement VM:
RESCUE localhost:~ # rear -D -c /etc/myrear recover
ERROR: The '-c' option is not supported within the ReaR rescue/recovery system (its config directory is always /etc/rear)
RESCUE localhost:~ # find / -xdev | grep myrear
[no output]
RESCUE localhost:~ # rear -D recover
...
The recovery "just worked" for me
and the recreated system boots and works normally.
- Description of the changes in this pull request:
In sbin/rear error out
when '-c' is used inside the ReaR recovery system
because the '-c' option is not supported within
the ReaR recovery system because
its config directory is always /etc/rear
jsmeix commented at 2025-07-31 12:40:¶
@rear/contributors
I would like to merge it tomorrow (Friday) afternoon
unless there are objections.
jsmeix commented at 2025-07-31 13:10:¶
@schlomo
I was already wondering how to deal with portable mode
when I developed the changes for this pull request
(which was the most time consuming part of this pull request)
because I have no practical experience with portable mode
and I don't know how it should behave in practice.
So I followed what the existing code
which sets RECOVERY_MODE tells:
# PORTABLE mode is meant to be used only to run 'rear recover' within a foreign rescue system,
# see https://github.com/rear/rear/pull/3206#issuecomment-2122173021
if test -e "/etc/rear-release" || test "$PORTABLE" ; then
RECOVERY_MODE=1
fi
Because "rear recover" does not work with '-c'
(see my comment in this pull request code)
also '-c' cannot work for what portable mode
is meant to be used.
I had a look how portable mode makes its ReaR tar archive
in output/PORTABLE/default/450_create_portable_archive.sh
and at first glance it seems there is nothing special
which would include an alternative config directory
so I concluded '-c' can also not work in portable mode
because also in portable mode there is only etc/rear
schlomo commented at 2025-07-31 13:14:¶
@jsmeix yes, I agree. Let's leave it as you wrote it.
jsmeix commented at 2025-08-01 09:59:¶
The current implementation does a hardcoded error exit
when '-c /config/dir' is used within the ReaR recovery system
even when /config/dir exists within the ReaR recovery system
because the user had specified to get it included via
COPY_AS_IS+=( /config/dir )
So I investigated what could be done here.
I tested with my above SLES15-SP6 test VMs
how things are in the ReaR recovery system with
COPY_AS_IS+=( /etc/myrear/ )
In the ReaR recovery system this results:
RESCUE localhost:~ # find /etc/rear
/etc/rear
/etc/rear/mappings
/etc/rear/mappings/mac
/etc/rear/os.conf
/etc/rear/local.conf
/etc/rear/rescue.conf
RESCUE localhost:~ # find /etc/myrear
/etc/myrear
/etc/myrear/local.conf
So certain additional config files are missing
(mappings/mac
os.conf
rescue.conf
)
when '-c /etc/myrear' is used within the ReaR recovery system.
I tried nevertheless rear -c /etc/myrear recover
(with modified /bin/rear to not error out)
and in my simple test case it even finished
without an explicit error.
BUT
in general we cannot know how far or if at all
# rear -c /alternative/config/dir recover
will work because only /etc/rear/ contains all config files
which are normally expected and used by "rear recover".
Therefore the '-c' option is not supported
within the ReaR recovery system because therein
the only supported config directory is /etc/rear/
Nevertheless the user can specify
COPY_AS_IS+=( /alternative/config/dir )
but then he must manually setup things properly within
his ReaR recovery system before calling "rear recover"
i.e. he must provide the right config files in /etc/rear/
lzaoral commented at 2025-08-20 14:05:¶
Unfortunately, a2fe977d3cac54e1dcdad49146f822217c2b83d1 broke parsing of
workflow arguments, e.g. rear format -- -y /dev/sda
no longer works:
# rear format -- /dev/sdb
ERROR: Argument 'format' not accepted. Use 'rear format -- --help' for more information.
The format
argument gets passed to the workflow as well which was not
the case before.
[Export of Github issue for rear/rear.]