#2535 PR merged: #2152: make bacula aware of different location of config files

Labels: enhancement, fixed / solved / done, minor bug, external tool

gdha opened issue at 2020-12-08 16:35:

Signed-off-by: Gratien Dhaese gratien.dhaese@gmail.com

Pull Request Details:
  • Type: Bug Fix

  • Impact: Normal

  • Reference to related issue (URL): #2152

  • How was this pull request tested? Not yet tested - waiting on Bacula user to do that for us

  • Brief description of the changes in this pull request: The Enterprise Bacula uses different locations for keeping the configuration files than the community version of Bacula, hence, the enhancement to detect the correct location via preparation flow.

gdha commented at 2020-12-09 08:11:

I used this PR as an example for https://relax-and-recover.org/rear-user-guide/development/github-pr.html

jsmeix commented at 2020-12-09 10:07:

I noticed many StopIfError calls in the code.

I recommend to never use StopIfError, see the explanation about
"Using the ...IfError functions can result unexpected behaviour in certain cases"
in usr/share/rear/lib/_input-output-functions.sh

Better use

ERROR_CONDITION && Error "..."



as needed.

The ...IfError functions are only there for backward compatibility in old code.

jsmeix commented at 2020-12-09 10:14:

I can feel your pain with getting that old style code reasonably well...

jsmeix commented at 2020-12-09 13:26:

if you like you may have a look at
for a possible further improvement.

gdha commented at 2020-12-09 13:34:

@jsmeix Thank you for your endless patience and clear view on good practice of the bash language. I asked the 2 Bacula users for their advice on the ping matter - we will see what comes back...

VN1977 commented at 2020-12-09 14:11:

To my mind using ping is worse than checking if the service is really accessible. So I'd have listened to @jsmeix

jsmeix commented at 2020-12-09 14:15:

since IPv6 'ping' has become even worser than worse ;-)
One must try both IPv4 and IPv6 and guess what it could mean if one fails :-(

gdha commented at 2020-12-09 14:19:

@VN1977 Ok, how can we test if the BACULA_DIRECTOR is responding if we don't use ping? I need your advise here.

VN1977 commented at 2020-12-09 14:39:

I think we can use something like this

nc -vz BACULA_DIRECTOR 9101 2>&1 | grep -i connected | wc -l

But not every system has netcat installed. You can add it to dependencies.

jsmeix commented at 2020-12-09 14:44:

I know nothing at all how Bacula works but I think the final testing in

# 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" ] || Error "Bacula director not reachable."

[ "$client" ] || Error "Bacula client status unknown on director."

looks as if it tests both the Bacula director (implicitly) and the Bacula client.
This was the reason why I was wondering what that 'ping' test is actually good for
when also the Bacula director gets implicitly tested by the final testing.

VN1977 commented at 2020-12-09 15:16:

@jsmeix this is two steps check. Firstly we check if director accesible at network level then connect to it and look for config of designated client.
If step #1 failed we excplicitily understand what caused it and we don't need to connect with bconsole.

linuxdan commented at 2020-12-09 21:41:

Where did this get sidetracked about ping testing ?
The original issue I opened a year and a half ago is about how the Enterprise Bacula client is in a different location than the open source client.

jsmeix commented at 2020-12-10 10:18:

I set you as the assignee here so you can fix your things as you want it.
Please follow our coding style https://github.com/rear/rear/wiki/Coding-Style
Perhaps best is when you submit a completely new pull request
so we can decide better about your changes.

gdha commented at 2020-12-16 16:22:

@linuxdan @VN1977 Please verify if the Bacula director check works or not?

VN1977 commented at 2020-12-16 19:49:

I can check on Friday only

gdha commented at 2021-01-15 15:08:

@VN1977 today is Friday ;-) possible to have a quick check please?

VN1977 commented at 2021-01-22 10:09:

we had a huge holiday.... so sorry for the delay.
I don't really know how to compile the new version to check quickly. Could you please help?

gdha commented at 2021-01-22 10:31:

@VN1977 You can download the latest ReaR snapshot packages (of today) from http://download.opensuse.org/repositories/Archiving:/Backup:/Rear:/Snapshot/CentOS_7/x86_64/ (for CentOS 7), or otherwise use the link http://download.opensuse.org/repositories/Archiving:/Backup:/Rear:/Snapshot/ to select the OS version you need.

VN1977 commented at 2021-01-22 10:47:

2021-01-22 13:42:14.644359166 Including prep/BACULA/default/450_check_BACULA_client_configured.sh
2021-01-22 13:42:14.655556702 ERROR: Bacula File Daemon is missing

Should I add some parameters to site.conf or not?

gdha commented at 2021-01-22 12:50:


2021-01-22 13:42:14.644359166 Including prep/BACULA/default/450_check_BACULA_client_configured.sh
2021-01-22 13:42:14.655556702 ERROR: Bacula File Daemon is missing

The script says bacula-fd is missing (or it couldn't find it in the default PATH). Could you verify this? And, while you're busy check also if bconsole responds correctly.

VN1977 commented at 2021-01-22 13:03:

My bacula config files are placed at /opt/bacula/etc so script can not find them.What concerns bconsole the config file also placed there.I thought that you made changes to scripts for supporting non-default config files.--

gdha commented at 2021-01-22 13:18:

@VN1977 Yes, of course it is the purpose to test this PR - first git clone https://github.com/rear/rear/tree/issue2152-prep-bacula and then use this newly branch to test out if the PR would make sense or not. Therefore, go into this branch and copy your /etc/rear/local.conf to this branch your_cloned_rear_path/etc/rear/ and also start rear from within this cloned PR (use relative path to rear script: your_cloned_rear_path/usr/sbin/rear -v mkrescue

VN1977 commented at 2021-01-22 15:39:

@gdha everything works great!

[Export of Github issue for rear/rear.]