Variables#
Definition#
Variables are placeholders for user-provided values. Variable values are
provided by the user when using a config with variables. When the user
applies patterns or configs that have variables in the configuration,
he/she is prompted to provide values of the variables. So, unlike constants
where values are defined in advance, the variable values are defined dynamically
at the moment of use them. Variables function is available from Bacularis
version 5.2.0
.
Variables can be useful for creating Bacula configuration both with single resources (in configs) and with complex structures such as resources that depend on each other (in patterns).
In the image below you can see an example of applying a config belonging to a pattern:

Variable consists of the following properties:
name - variable name (allowed characters:
A-Za-z0-9_
)description - (optional) explanation of the purpose of the variable
default value - (optional) the value that is used by default in the text fields if no user value is defined.
Examples#
Using variables in configs#
Administrator needs to add new paths to different FileSets
in the Bacula
configuration. These new paths use a standarized structure. Instead of adding
staticly defined paths for each FileSet
, the administrator can use variables
in the config. Once variables are created, administrator can use them as follows:
VARIABLES:
- ${product_name} - name of the company product
- ${product_part} - product part identifier
CONFIG1:
FileSet {
Include {
File = "/${product_name}/files/internal/${product_part}"
}
}
When the administrator applies this config for Bacula resources, he/she will
be prompted to provide the ${product_name}
and ${product_part}
values.
Using variables in patterns#
Administrator manually creates new Job
and FileSet
resources each
time a new employee is hired at the company and a new home directory is
created for that employee on one of the servers.
By using pattern and variables, this work can be simplified. In this case, the administrator can define variables (for the employee and for the server) and and use them in a new pattern configs as in the example below:
VARIABLES:
- ${employee} - employee name
- ${file_server} - file server name, where employee files are stored
CONFIG1:
Job {
Name = "${employee}-directory"
Description = "Home directory of the ${employee} user on ${file_server}"
JobDefs = "UsersJobDefs"
FileSet = "${employee}-files"
}
CONFIG2:
FileSet {
Name = "${employee}-files"
Include {
Options {
Compression = "Gzip4"
}
File = "/${file_server}/home/${employee}
}
}
PATTERN1:
- CONFIG1
- CONFIG2
When the administrator applies PATTERN1
to create new Bacula configuration,
each time he/she will be prompted to provide the ${file_server}
and ${employee}
values.
How to use variables?#
First, you need to define variables you want to use in configs. Variables can be created
on the Patterns
page on the Variables
tab.
[Main menu] => [Page: Patterns] => [Tab: Variables]
Once you have defined variables, you can go to configs to create a new config or edit existing one.
To see the variable picker please type the $ dollar sign in config text field. The variable picker menu should appear and you will be able to select variables.

After adding variables to config, you will now be prompted to provide the variable values whenever this config (or a pattern with this config) is applied.

Video guides#
Here you can watch two video tutorials about using variables in configs and patterns: