Advanced Restore Options
Some plugins can be configured at the restore time with “Plugin Restore Objects” stored in the catalog. It is possible to list these objects and display them for a list job jobids with the following command:
# /opt/bacula/bin/bconsole
*.bvfs_get_jobids client=127.0.0.1-fd
10,11,12
*llist pluginrestoreconf jobid=10,11,12
jobid: 10
restoreobjectid: 15
objectname: RestoreOptions
pluginname: bpipe:/@bpipe@/encrypt-bug.jpg:cat /tmp/encrypt-bug.jpg:cat >/tmp/encrypt-bug.jpg
objecttype: 27
*list pluginrestoreconf jobid=10,11,12 id=15
# Plugin configuration file
# Version 1
OptPrompt="Restore command to use"
restore_command=@STR@
In this example, the bpipe plugin can be configured at restore time to overwrite the default restore command with a string (@STR@).
From a script it is possible to use the “Plugin Restore Option” menu at
the restore step, or to submit a file with the appropriate
configuration. For the bpipe
plugin, the “restore_command” can be
configured at the restore time. With the bpipe
plugin, the “Plugin
Restore Option” file would look like:
# cat /tmp/restore.opts
restore_command="cat > /tmp/a.jpg"
The file should be uploaded to the director during the restore session
and used in the restore command via the pluginrestoreconf
option.
The file transfer and the restore command should be done in the same
bconsole session.
# /opt/bacula/bin/bconsole
*@putfile akey /tmp/restore.opts
OK
*restore pluginrestoreconf="15:akey"
The “pluginrestoreconf” option of the restore command needs two parameters:
RestoreObjectId displayed in the “llist pluginrestoreconf” command
The Key of the file uploaded to the Director with the @putfile command
The “RestoreObjectId” is used to check the validity of the options provided by the user.
Example
In the example below, the restore process is carried out while passing the custom PostgreSQL Plugin options.
Initially, the restoreobjectid
is obtained using the following Bacula Console command:
llist pluginrestoreconf jobid=1109
jobid: 1109
restoreobjectid: 101
objectname: RestoreOptions
pluginname: postgresql:
objecttype: 27
Subsequently, it is necessary to retrieve the plugin backup settings
for the specific restoreobjectid
:
list pluginrestoreconf restoreobjectid=101 jobid=1109
# Plugin configuration file
# Version 1
OptPrompt="Drop database objects before recreating them."
OptDefault="no"
clean=@BOOL@
OptPrompt="Restore only data"
OptDefault="no"
data_only=@BOOL@
OptPrompt="New database name. Take precedence over where parameter"
database=@STR@
OptPrompt="Tables to restore"
table=@ALIST@
OptPrompt="Schema to restore"
schema=@STR@
OptPrompt="Prevent restore of triggers"
OptDefault="no"
no_triggers=@BOOL@
OptPrompt="Prevent restore of tablespaces"
OptDefault="yes"
no_tablespaces=@BOOL@
OptPrompt="Prevent restore of ownership"
OptDefault="no"
no_owner=@BOOL@
OptPrompt="Prevent restore of access privileges"
OptDefault="no"
no_privileges=@BOOL@
OptPrompt="Service defined in pg_service to use during restore"
service=@NAME@
It is possible to overwrite each of these options in the restore process.
To overwrite new option values, they must be passed in a designated text file.
This temporary file needs to be created with key=value
option items,
where key
is a plugin option and value
is a plugin option value.
In the example below, three options are overwritten:
table
database
no_triggers
echo 'table="Job"
database="database_copy1"
no_triggers="1"' > /home/john/plugin_opts.txt
Once the temporary plugin options file is prepared for passing, the restore process
involves two consecutive commands executed within the same bconsole session.
The first one informs Bacula Director that the temporary
file with plugin options should be used during the restore process. The second one is
a standard restore command that incorporates the pluginrestoreconf
option
the restoreobjectid
and the temporary file reference obj101
in the format:
restoreobjectid:file_reference
.
@putfile obj101 /home/john/plugin_opts.txt
restore pluginrestoreconf="101:obj101" select
Possible Next Steps
Go to Bacula Auth Plugin Documentation.
Go back to Bacula FD Plugin API.
Go back to Developer Guide.