-Chris-

On Wed, 25 Feb 2026, 00:22 Rob Gerber, <[email protected]> wrote:

> > I also get an email saying "24-Feb 21:46 bacula-dir JobId 0: Loaded
> plugin: ldap-dir.so”.
>
> If a runscript stanza runs as 'console' instead of using 'command' to run
> an actual script file, the resulting bacula log entries will be associated
> with 'jobid 0'. I'd check your bacula director configuration for any
> instance of the word 'console'.
> 'grep -i console /opt/bacula/etc/bacula-dir.conf'
> Look for lines like 'console = some bconsole command'
>

I use command= <script.sh> in all the Runscript blocks, so not that.

>
> Bill A previously had these words to say about why it's better to put your
> bconsole commands in a script that echos the command to bconsole, vs using
> 'console ='.
>
> From Bill A's previous emails on this list:
> "
> *NOTE: I don't recommend using the `Console =` option in RunsScript{}
> stanzas for a few reasons.
>
> - If you use `Console =`, any output from them appears mixed into your
> bacula.log file, identified as `JobID: 0` so you never
> know what job actually caused the outputs
> - Using `Command =` you are able to fully control everything in a script.
> - Any stdout in your script is printed in the Admin joblog that called it.
> So you can add any output you like so your Admin
> job log is quite verbose and you know everything that happened, and when.
> (bconsole: ll joblog jobid=xxxx)
> - If you use `Console =` you cannot get the outputs from the above bconsole
>  command
> "
>
> The alternative to 'console = some bconsole command' is to echo the
> desired command to bconsole.
>
> In some cases you can get away with `echo "this is my command" | bconsole`
> though for a script you should define things like the bconsole binary path,
> and the bconsole config location.
>
> Additionally, you can use echo to pass newlines through to bconsole, and
> thus step through an interactive bconsole menu.
>
> See example from Bill A below:
> "
> Example script to call with the `Command =` setting in your RunScript:
> ----8<----
> #!/bin/bash
>
> bcbin="/opt/bacula/bin/bconsole"
> bccfg="/opt/bacula/etc/bconsole.conf"
>
> echo "Whatever you want to appear in Admin joblog"
> echo -e "your bconsole command\nquit\n" | ${bcbin} -c ${bccfg}   # All
> output will be in your Admin Job's joblog
> echo "Whatever else you want to appear in Admin joblog"
> ----8<----
> "
>
> I THINK Bill has previously asserted that it's better to 'quit' your
> bconsole sessions after entering commands. I'm fuzzy on the reason, but I
> think it was something like 'if you don't quit your bconsole sessions,
> they'll stay resident in the background', or something like that. I could
> be hallucinating all of this. Don't blame Bill if I'm misremembering. IIRC,
> others asserted that this wasn't current bacula behavior. Either way, you
> can see how this could be useful, especially if you needed to provide
> multiple stages of input.
>
> Martin S has warned that echo commands and shell behavior varies,
> particularly around handling of newlines. Some echo's don't have -e. Some
> shells directly handle \n, others don't. Test the echo command I gave and
> make sure it works for you. Or try printf (I have no experience there, but
> martin suggested it).
>
> >chrisw@m910q:~$ bacula-dir -t
> >24-Feb 21:46  Message delivery ERROR: Msg delivery error: fopen
> /opt/bacula/working/bacula-dir.bacula-dir.-1616568216.mail failed:
> ERR=Permission denied
> >24-Feb 21:46  Message delivery ERROR: fopen /var/log/bacula/bacula.log
> failed: ERR=Permission denied
>
> Those errors make sense, at least.
> Only user bacula can write to /opt/bacula/working. User chrisw is not user
> bacula.
> Members of group bacula, or 'others' cannot write to the
> /opt/bacula/working directory.
> > chrisw@m910q:~$ ls -l /opt/bacula/
> ...
> > drwxr-xr-x 2 bacula bacula 12288 Feb 24 06:15 working
>
> I'd guess similarly, user chrisw doesn't have write permission for logfile
> /var/log/bacula/log/bacula.log.
> On my systems, file bacula.log only allowes user bacula to write to the
> log.
> example:
> [gerber@td-bacula ~]$ ls -l /opt/bacula/log/bacula.log
> -rw-r--r--. 1 bacula bacula 51378289 Feb 24 16:01
> /opt/bacula/log/bacula.log
>
> # I am curious to see the output of
> id chrisw
> # and
> ls -l /var/log/bacula/log/bacula.log
>

chrisw@m910q:~$ id chrisw
uid=1000(chrisw) gid=1000(chrisw)
groups=1000(chrisw),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev),111(bluetooth),113(lpadmin),116(scanner),993(docker)

chrisw@m910q:~$ ls -l /var/log/bacula
lrwxrwxrwx 1 root root 15 Mar 25 2024 /var/log/bacula -> /opt/bacula/log

chrisw@m910q:~$ ls -l /opt/bacula/log/
total 1032
-rw-r--r-- 1 bacula bacula 357472 Feb 25 06:15 bacula.log
-rw-r--r-- 1 bacula bacula 471377 Jan 31 06:15 bacula.log.1
-rw-r--r-- 1 bacula bacula 185679 Dec 31 06:15 bacula.log.2
-rw-r--r-- 1 bacula bacula 6211 Dec 22 22:45 bacula.log.3
-rw-r--r-- 1 bacula bacula 246 Nov 25 13:48 bacula.log.4
-rw-r--r-- 1 bacula bacula 7055 Feb 8 2025 bacula.log

Ok so far I think

>
>
> What happens if you either:
>
> # As root, order bacula-dir to run itself with user bacula, and group
> bacula
> sudo bacula-dir -t -u bacula -g bacula
>

This gives error 'sudo: bacula-dir: command not found'

Or with full path

chrisw@m910q:~$ sudo /opt/bacula/bin/bacula-dir -t -u bacula -g bacula
bacula-dir: bsys.c:161-0 Safe_unlink excluded:
/opt/bacula/working/bacula-dir.bacula-dir.1605382264.mail
bacula-dir: smartall.c:418-0 Orphaned buffer: bacula-dir 32 bytes at
55d35fb707d8 from watchdog.c:90
bacula-dir: smartall.c:418-0 Orphaned buffer: bacula-dir 32 bytes at
55d35fb7cc08 from watchdog.c:91

>
> # Or, as any user besides bacula, run:
> sudo su bacula
> # then as user bacula, run:
> bacula-dir -t
>

chrisw@m910q:~$ sudo su bacula

bacula@m910q:/home/chrisw$ /opt/bacula/bin/bacula-dir -t
bacula-dir: bsys.c:161-0 Safe_unlink excluded:
/opt/bacula/working/bacula-dir.bacula-dir.-150400904.mail
bacula-dir: smartall.c:418-0 Orphaned buffer: bacula-dir 32 bytes at
560cf70c0eb8 from watchdog.c:90
bacula-dir: smartall.c:418-0 Orphaned buffer: bacula-dir 32 bytes at
560cf70c0518 from watchdog.c:91

So much the same as before. However the log write doesn't error since the
user is now bacula.

I suspect there's something wrong in my mail config but can't find it.
Thanks for those suggestions, I'll keep digging. Mail is sent to
root@localhost which Postfix picks up and relays to Gmail.



> (for this second option, you might have to set a shell for user bacula, if
> you've never become bacula before)
>
> As a reminder, *never run the director or SD as root* (or any other user
> besides bacula) to avoid messing up permissions on PID and state files
> The FD already runs as root. So 'sudo bacula-fd -t' is correct for it.
>
>
> Robert Gerber
> 402-237-8692
> [email protected]
>
> On Tue, Feb 24, 2026, 4:20 PM Chris Wilkinson <[email protected]>
> wrote:
>
>> Just recently I’ve been getting the following error in response to the
>> check config command bacula-dir -t. I also get an email saying "24-Feb
>> 21:46 bacula-dir JobId 0: Loaded plugin: ldap-dir.so”. Backups are running
>> normally with no errors and normal completion emails
>> (Bacula-v15/Debian-Bookworm compiled from source).
>>
>> <
>> chrisw@m910q:~$ bacula-dir -t
>> 24-Feb 21:46  Message delivery ERROR: Msg delivery error: fopen
>> /opt/bacula/working/bacula-dir.bacula-dir.-1616568216.mail failed:
>> ERR=Permission denied
>> 24-Feb 21:46  Message delivery ERROR: fopen /var/log/bacula/bacula.log
>> failed: ERR=Permission denied
>> >
>>
>> DIR runs as bacula:bacula
>>
>> chrisw@m910q:~$ ls -l /opt/bacula/
>> total 44
>> drwxr-xr-x 2 root   root    4096 Nov  7  2024 bin
>> drwxr-x--- 2 bacula bacula  4096 Dec 24 18:32 bsr
>> drwxr-xr-x 7 bacula tape    4096 Feb 21 00:16 cache
>> drwxr-xr-x 2 bacula bacula  4096 Feb 23 19:44 etc
>> drwxr-xr-x 2 root   root    4096 Nov  9  2024 lib
>> drwxr-xr-x 2 bacula bacula  4096 Feb  1 00:00 log
>> drwxr-xr-x 2 root   root    4096 Nov  9  2024 plugins
>> drwxr-xr-x 3 root   root    4096 Nov  7  2024 scripts
>> drwxr-xr-x 2 bacula bacula 12288 Feb 24 06:15 working
>>
>> chrisw@m910q:~$ ls -l /opt/bacula/working/
>> total 40
>> -rw-r--r-- 1 bacula bacula   857 Jan  1 08:59 bacula.3513.traceback
>> -rw-r----- 1 bacula bacula  2196 Feb 24 06:15 bacula-dir.9101.state
>> -rw-r--r-- 1 bacula bacula    60 Feb 23 20:30
>> bacula-dir.bacula-dir.1914724472.mail
>> -rw-r----- 1 root   root    2196 Feb 24 06:15 bacula-fd.9102.state
>> -rw-r----- 1 bacula tape       8 Feb 23 17:39 bacula-sd.9103.pid
>> -rw-r----- 1 bacula tape    2196 Feb 24 06:15 bacula-sd.9103.state
>> -rw------- 1 bacula bacula 13309 Feb 24 06:15 m910q-dir.conmsg
>>
>> The messages resource is more or less per manual.
>>
>> <
>> Messages {
>>   Name = "Standard"
>>   MailCommand = "/opt/bacula/bin/bsmtp -h localhost -s \"Bacula %n\" %r"
>>   OperatorCommand = "/opt/bacula/bin/bsmtp -h localhost -f \"\(Bacula\)
>> %r\" -s \"Bacula: Intervention needed for Job:%n %j\" %r"
>>   Syslog = All, !Skipped
>>   Mail = root@localhost = All, !Skipped
>>   Append = /var/log/bacula/bacula.log = All, !Skipped
>>   Console = All, !Skipped
>>   Operator = root@localhost = All, !Skipped
>>   Catalog = All, !Skipped
>> }
>> >
>>
>> Similar commands for FD and SD run without error.
>>
>> I’m guessing that there is a permissions issue somewhere but I’m
>> struggling to know where to look. Any suggestions would be great.
>>
>> Best
>> -Chris-
>>
>>
>>
>>
>> _______________________________________________
>> Bacula-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/bacula-users
>>
>
_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to