Automatic Bacula Console Commands During Backup
  • Post category:Uncategorized
  • Post comments:0 Comments

Run Bacula console commands is another way to automate any Bacula operation (e.g.: tape libraries update slots, if you forget to do it when changing tapes); or increase the logs information level (show fileset=%f), since its practical for troubleshooting and maybe useful to face more strict security auditing policies.

The definition of the console-script command is performed within the Job resource (sub-resource) for a specific job; or for all Jobs at the JobDefs

1. Example of update slots, normally set for a first higher priority backup job:

RunScript {
RunsWhen = Before
RunsOnClient = no
Console = "update slots storage=storage_name"
}

2. Example of show fileset=f%, to always display at the beginning of your backup job folders and settings in your FileSet (at JobDefs):

RunScript {
RunsWhen = Before
RunsOnClient = no
Console = "show fileset=%f"
}

Obs .: does not work if the fileset have spaces in its name.

2.1. The output added to the log would look like this:

17-Set 17:27 hfaria-K46CB-dir JobId 767: shell command: run BeforeJob “/etc/bacula/scripts/make_catalog_backup.pl MyCatalog”
17-Set 17:27 hfaria-K46CB-dir JobId 767: console command: run BeforeJob “show fileset=Catalog”
17-Set 17:27 hfaria-K46CB-dir JobId 0: FileSet: name=Catalog
17-Set 17:27 hfaria-K46CB-dir JobId 0: O M
17-Set 17:27 hfaria-K46CB-dir JobId 0: N
17-Set 17:27 hfaria-K46CB-dir JobId 0: I /var/lib/bacula/bacula.sql
17-Set 17:27 hfaria-K46CB-dir JobId 0:
N

3. The %f (fileset) is one of Bacula replacement characters, which can be used as a variable in the execution of any script. Check the full table:

%% = %
%b = Job Bytes
%c = Client’s name
%d = Daemon’s name (Such as host-dir or host-fd)
%D = Director’s name (Also valid on file daemon)
%e = Job Exit Status
%f = Job FileSet (Only on director side)
%F = Job Files
%h = Client address
%i = JobId
%j = Unique Job id
%l = Job Level
%n = Job name
%p = Pool name (Only on director side)
%s = Since time
%t = Job type (Backup, …)
%v = Volume name (Only on director side)
%w = Storage name (Only on director side)
%x = Spooling enabled? (“yes” or “no”)

Disponível em: pt-brPortuguês (Portuguese (Brazil))enEnglish

Leave a Reply