#3067 Issue closed: Trying to build rescue ISO for Bacula backup

Labels: support / question, fixed / solved / done

ZENAdmin-Ops opened issue at 2023-11-06 05:44:

  • ReaR version ("/usr/sbin/rear -V"): 2.7

  • If your ReaR version is not the current version, explain why you can't upgrade:

  • OS version ("cat /etc/os-release" or "lsb_release -a" or "cat /etc/rear/os.conf"): Debian 11

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

OUTPUT=ISO
OUTPUT_URL=file:///home/zen/debian11-recovery.iso
BACKUP=BACULA
BACULA_CONF_DIR=”/opt/bacula/etc”
BACULA_BIN_DIR=”/opt/bacula/bin”
USE_STATIC_NETWORKING="Yes"
IP=192.168.200.41
NM=255.255.255.0
GW=192.168.200.200
  • Hardware vendor/product (PC or PowerNV BareMetal or ARM) or VM (KVM guest or PowerVM LPAR): Hyper-V VM

  • Description of the issue (ideally so that others can reproduce it):
    Hello,

Attempting to create a ReaR recovery environment to perform a restore using Bacula

Latest output from sudo rear mkrescue -v

2023-11-05 12:25:07.005672167 Including prep/BACULA/default/450_check_BACULA_client_configured.sh
2023-11-05 12:25:07.008836829 Including prep/default/490_store_write_protect_settings.sh
2023-11-05 12:25:07.011793294 Including prep/GNU/Linux/500_EFISTUB_check_kernel.sh
2023-11-05 12:25:07.015053855 Including prep/BACULA/default/500_check_BACULA_bconsole_results.sh
2023-11-05 12:25:07.029257686 ERROR: Bacula director debian11-DR6 is not responding.
===== Stack trace =====
Trace 0: /usr/sbin/rear:696 main
Trace 1: /usr/share/rear/lib/mkrescue-workflow.sh:12 WORKFLOW_mkrescue
Trace 2: /usr/share/rear/lib/framework-functions.sh:129 SourceStage
Trace 3: /usr/share/rear/lib/framework-functions.sh:59 Source
Trace 4: /usr/share/rear/prep/BACULA/default/500_check_BACULA_bconsole_results.sh:21 source

I think this is likely to be a configuration error as this system has Bacula installed and operational.

After troubleshooting suggestions.

Thank you.

ZENAdmin-Ops commented at 2023-11-06 05:50:

Hello,

Possibly the issue might be that I need to define a 'client' that the ReaR recovery environment will use when performing the restore.

I must admit that I'm not entirely clear on this aspect of the configuration at present.

ZENAdmin-Ops commented at 2023-11-07 23:12:

Hello,

I've attempted some troubleshooting and this error appears to be a bug

sudo rear mkrescue -v
Relax-and-Recover 2.7 / 2022-07-13
Running rear mkrescue (PID 405169 date 2023-11-08 10:07:54)
Using log file: /var/log/rear/rear-debian11-DR6.log
Running workflow mkrescue on the normal/original system
Using UEFI Boot Loader for Linux (USING_UEFI_BOOTLOADER=1)
Using autodetected kernel '/boot/vmlinuz-5.10.0-26-amd64' as kernel in the recovery system
ERROR: Bacula director debian11-DR6 is not responding.

2023-11-08 10:07:55.104444475 Including prep/BACULA/default/500_check_BACULA_bconsole_results.sh
2023-11-08 10:07:55.134400311 ERROR: Bacula director debian11-DR6 is not responding.

Here is the relevant code

# is the director server present? Fetch from $BACULA_CONF_DIR/bconsole.conf file
BACULA_DIRECTOR=$(grep -i address $BACULA_CONF_DIR/bconsole.conf | awk '{ print $3 }')
[ "${BACULA_DIRECTOR}" ] || Error "Director not defined in $BACULA_CONF_DIR/bconsole.conf"

# check if the director is responding?
if has_binary nc; then
   DIRECTOR_RESULT=$(nc -vz "${BACULA_DIRECTOR}" 9101 2>&1 | grep -i connected | wc -l)
   [[ $DIRECTOR_RESULT -eq 0 ]] && Error "Bacula director ${BACULA_DIRECTOR} is not responding."
fi

# does the director allow connections from this client? bconsole knows!
#
# We want these two lines to show that we can connect to the director
# and that the director can connect to the file daemon on this system.
# "Connecting to Director 'director_name-fd:9101'"
# "Connecting to Client 'bacula_client_name-fd at FQDN:9102"
BACULA_CLIENT=$(grep $(hostname -s) $BACULA_CONF_DIR/bacula-fd.conf | grep "\-fd" | awk '{print $3}' | sed -e "s/-fd//g")
[ "${BACULA_CLIENT}" ] || Error "Client $(hostname -s) not defined in $BACULA_CONF_DIR/bacula-fd.conf"

BACULA_RESULT=( $(echo -e " status client=${BACULA_CLIENT}-fd" | bconsole | grep Connect) )

director=${BACULA_RESULT[3]}
client=${BACULA_RESULT[9]}

Here is the address from bconsole.conf

address = debian11-DR6

Here is the output from the nc command

nc -vz debian11-dr6 9101
debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) opensudo

gdha commented at 2023-11-08 06:21:

What is the return code of the command:

nc -vz debian11-dr6 9101
debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) opensudo

Perhaps, we could use this instead of looking for "connected"?

ZENAdmin-Ops commented at 2023-11-08 21:33:

Hello,

Can you check the syntax of the 2nd line

nc -vz debian11-dr6 9101
debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) open
zen@debian11-DR6:~$ debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) opensudo
bash: syntax error near unexpected token `('

gdha commented at 2023-11-09 07:06:

@ZENAdmin-Ops What you need to do is:

$ nc -vz debian11-dr6 9101
debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) open
echo $?

ZENAdmin-Ops commented at 2023-11-09 09:23:

nc -vz debian11-dr6 9101 
debian11-DR6.zen.local [192.168.200.40] 9101 (bacula-dir) open
zen@debian11-DR6:~$ echo $?
0

pcahyna commented at 2023-11-16 18:17:

Hi, is the check using "nc" even needed? Isn't the subsequent check using bconsole enough?

pcahyna commented at 2023-11-16 18:20:

I mean, doesn't answering the latter question

# does the director allow connections from this client? bconsole knows!

also implicitly answer the question

# check if the director is responding?

above it? presumably, if the director allow connections from this client, it is also responding.

github-actions commented at 2024-01-16 02:10:

Stale issue message

ZENAdmin-Ops commented at 2024-01-16 02:11:

This ticket can be closed

pcahyna commented at 2024-01-16 10:42:

@ZENAdmin-Ops for future users: what was the problem? And how was it solved?

ZENAdmin-Ops commented at 2024-01-16 17:10:

I never really got that problem fixed, since I switched fairly quickly to running the restore from a bash script instead of trying to use the (very minimal) built in bacula support in rear. With that said from looking at the errors and the source code it looks like the problem is that Rear is searching for "connected" in the output of "nc" to check if the director is available, only nc doesn't ever actually say "connected". I'm guessing this code was written for an earlier version of nc that always had "connected" in its output if it was able to connect. Currently that nc command gives output like this:
Connection to localhost (127.0.0.1) 9101 port [tcp/bacula-dir] succeeded!
So it should really be searching for "succeeded" instead of "connected".

Probably the issue could be fixed by changing
DIRECTOR_RESULT=$(nc -vz "${BACULA_DIRECTOR}" 9101 2>&1 | grep -i connected | wc -l)
to
DIRECTOR_RESULT=$(nc -vz "${BACULA_DIRECTOR}" 9101 2>&1 | grep -i succeeded | wc -l)

Although if nc ever changes its output it would break again... so it would seem like there should be a better way for it to check the connection rather than trying to parse nc's output. Also, a few lines down it checks the connection again using bconsole... so the first check is kind of unnecessary.


[Export of Github issue for rear/rear.]