Hi,
we have the need to initiate run scripts during the execution of restore jobs.
These run scripts need to vary depending on the target machines, so we
configured multiple restore jobs. Due to that, the "restore" command needs to
know which restore job to run.
At this time, bacula allows the configuration of multiple restore jobs. When
the "restore" command is used, these jobs are checked: if none exists, an
error is issued, and the restore is aborted. If exactly one exists, this one
is used. If multiple are used, a dialog is initiated where the user needs to
select the respective job interactively.
With the attached patch, it is possible to specify the restore job to use on
the bacula command line via a "job=xxx" attribute, such as
restore job=RestoreFiles fileset=myFileset client=client-fd
restoreclient=client-fd where=/mypath select current all done yes
Have fun and do what you'd like to with the patch; you do have my FLA.
Best regards
Bastian
--
Collax GmbH . Basler Str. 115a . 79115 Freiburg . Germany
p: +49 (0) 89-990 157-28 www.collax.com
Geschäftsführer: Falk Birkner, Ralf Elias
AG München HRB 173695. Ust.-IdNr: DE270819312
\ What has four legs and an arm? A happy pitbull.
--- bacula-5.2.12.ori/src/dird/ua_restore.c 2012-09-13 10:51:19.000000000 +0200
+++ bacula-5.2.12/src/dird/ua_restore.c 2012-11-26 16:41:32.000000000 +0100
@@ -82,8 +82,8 @@
JCR *jcr = ua->jcr;
char *escaped_bsr_name = NULL;
char *escaped_where_name = NULL;
- char *strip_prefix, *add_prefix, *add_suffix, *regexp;
- strip_prefix = add_prefix = add_suffix = regexp = NULL;
+ char *strip_prefix, *add_prefix, *add_suffix, *regexp, *cli_restore_job;
+ strip_prefix = add_prefix = add_suffix = regexp = cli_restore_job = NULL;
memset(&rx, 0, sizeof(rx));
rx.path = get_pool_memory(PM_FNAME);
@@ -133,6 +133,11 @@
rx.RegexWhere = ua->argv[i];
}
+ i = find_arg_with_value(ua, "job");
+ if (i >= 0) {
+ cli_restore_job = ua->argv[i];
+ }
+
if (strip_prefix || add_suffix || add_prefix) {
int len = bregexp_get_build_where_size(strip_prefix, add_prefix, add_suffix);
regexp = (char *)bmalloc(len * sizeof(char));
@@ -162,16 +167,29 @@
}
/* Ensure there is at least one Restore Job */
- LockRes();
- foreach_res(job, R_JOB) {
- if (job->JobType == JT_RESTORE) {
- if (!rx.restore_job) {
- rx.restore_job = job;
+ if (cli_restore_job) {
+ rx.restore_job = (JOB *)GetResWithName(R_JOB, cli_restore_job);
+ if (!rx.restore_job) {
+ ua->error_msg(_("The given job name \"%s\" was not found in bacula-dir.conf.\n"), cli_restore_job);
+ goto bail_out;
+ }
+ if (rx.restore_job->JobType != JT_RESTORE) {
+ ua->error_msg(_("The given job \"%s\" is not a restore job.\n"), cli_restore_job);
+ goto bail_out;
+ }
+ rx.restore_jobs = 1;
+ } else {
+ LockRes();
+ foreach_res(job, R_JOB) {
+ if (job->JobType == JT_RESTORE) {
+ if (!rx.restore_job) {
+ rx.restore_job = job;
+ }
+ rx.restore_jobs++;
}
- rx.restore_jobs++;
}
+ UnlockRes();
}
- UnlockRes();
if (!rx.restore_jobs) {
ua->error_msg(_(
"No Restore Job Resource found in bacula-dir.conf.\n"
@@ -474,6 +492,7 @@
"comment", /* 21 */
"restorejob", /* 22 */
"replace", /* 23 */
+ "job", /* 24 */
NULL
};
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
BUILD Helping you discover the best ways to construct your parallel projects.
http://goparallel.sourceforge.net
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel