Each of the daemons normally has debug messages compiled into the program, but these are disabled by default.
There are two ways to enable the debug output:
1st Method
The first way of getting debug output is to dynamically turn it on with the bconsole using the setdebug level=nnn command.
This is generally answered in the documentation: https://docs.bareos.org/TasksAndConcepts/BareosConsole.html#bcommandsetdebug
Examples:
Log into bconsole, then run the following commands:
- To enable debug for a storage called 'File' (use your own storage name here, with 'tab' after storage=, you will get a list:
setdebug level=150 trace=1 timestamp=1 storage=File
- To enable debug for the director:
setdebug level=150 trace=1 timestamp=1 dir
- To enable debug for a client (in this example for client named 'centos-fd'
setdebug level=150 trace=1 timestamp=1 client=centos-fd
In all cases you get an answer, which contains the file names, where the debug is written to:
2000 OK setdebug=150 trace=1 hangup=0 timestamp=1 tracefile=/var/lib/bareos/centos-fd
The file will be written on the machine, where the respective daemon runs in the working directory.
Be aware that debug-files might get quite large.
To deactivate the debug messages, use the same command as above but with 'level=0 trace=0'
setdebug level=0 trace=0 client=centos-fd
In rare cases, when you want to debug all daemons (including remote clients and storages) you can use the special keyword all.
setdebug level=100 trace=1 timestamp=1 all
2nd Method
The second one is to add the '-d nnn' option on the command line when starting the daemon.
This is more used in conjunction with the -t for debugging configuration trouble.
How to automatically set and unset debug levels with scheduled admin jobs
Tracing the daemon with a high debug level can generate very large trace file. When you need to track down a problem that occurs only at a certain times, it might be interesting to automatically set the debug level at a certain time and stop the collect after a specific time period.
For example, if we want to debug the Tape storage from 10 minutes before normal start of jobs (21:00) and we know that if the problem occurs it will be in the first 20 minutes, so we stop the trace at 21:20. What we also add is a call to a script that will rotate and compress the collected date, to avoid filling up the /var/lib/bareos/ partition.
on the director, storage, filedaemon
We start by defining 2 schedules to set and unset the debug tracing.
Schedule {Name = "admin_setdebug_2050"Description = "Run every day at 20:50"Enabled = YesRun = at 20:50}Schedule {Name = "admin_unsetdebug_2120" Description = "Run every day at 21:20" Enabled = Yes Run = at 21:20 }
Now we define the 2 jobs
Job {Name = "admin-setdebug"Description = "admin job setdebug level"Type = AdminPriority = 10Level = FullClient = bareos-fdFileSet = "Catalog"Schedule = "admin_setdebug_2050"Pool = "Full"Storage = "Tape-0"Allow Duplicate Jobs = noMessages = StandardRunScript {Runs When = BeforeRuns On Client = noConsole = "setdebug level=1000 trace=1 timestamp=1 storage=Tape-0"}}Job {Name = "admin-unsetdebug" Description = "admin job setdebug level 0"Type = AdminPriority = 10Level = FullClient = bareos-fdFileSet = "Catalog" Schedule = "admin_unsetdebug_2120" Pool = "Full"Storage = "Tape-0"Allow Duplicate Jobs = noMessages = StandardRunScript { Runs When = Before Runs On Client = no Console = "setdebug level=0 trace=0 timestamp=0 storage=Tape-0" } RunScript { Runs When = after Runs On Client = no Command = "bash -c '/var/lib/bareos/trace_rotate.sh'" }}
Example of script that can do a trace rotation
trace_rotate.sh
#!/bin/sh# Rotate bareos-sd trace fileD=$(date "+%Y%m%d_%H%M%S")for F in dir sd fd; doif [ -f /var/lib/bareos/bareos-${F}.trace ]; thenmv -v /var/lib/bareos/bareos-${F}.trace /var/lib/bareos/bareos-${F}.trace.${D}xz -9 -v /var/lib/bareos/bareos-${F}.trace.${D}fidonechown bareos:bareos /var/lib/bareos/trace_rotate.shchmod 0750 /var/lib/bareos/trace_rotate.sh
for remote storage or fd
- In case of remote client, you need to copy the trace_rotate.sh script and also change `Runs On Client = yes`
- In case of remote storage, you need to copy the trace_rotate.sh script over and schedule its execution by an external program (e.g. systemd timers, cron, at)