* Version $Id$
*/
/*
- Copyright (C) 2001-2005 Kern Sibbald
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
- version 2 as ammended with additional clauses defined in the
+ version 2 as amended with additional clauses defined in the
file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
* run [job=]<job-name> level=<level-name>
*
* For Restore Jobs
- * run <job-name> jobid=nn
+ * run <job-name>
*
* Returns: 0 on error
* JobId if OK
char *where, *fileset_name, *client_name, *bootstrap;
const char *replace;
char *when, *verify_job_name, *catalog_name;
+ char *previous_job_name;
char *since = NULL;
+ char *verify_list;
bool cloned = false;
int Priority = 0;
int i, j, opt, files = 0;
bool kw_ok;
JOB *job = NULL;
JOB *verify_job = NULL;
+ JOB *previous_job = NULL;
STORE *store = NULL;
CLIENT *client = NULL;
FILESET *fileset = NULL;
"catalog", /* 17 override catalog */
"since", /* 18 since */
"cloned", /* 19 cloned */
+ "verifylist", /* 20 verify output list */
+ "migrationjob", /* 21 migration job name */
NULL};
#define YES_POS 14
bootstrap = NULL;
replace = NULL;
verify_job_name = NULL;
+ previous_job_name = NULL;
catalog_name = NULL;
+ verify_list = NULL;
for (i=1; i<ua->argc; i++) {
Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]);
kw_ok = false;
/* Keep looking until we find a good keyword */
for (j=0; !kw_ok && kw[j]; j++) {
- if (strcasecmp(ua->argk[i], _(kw[j])) == 0) {
- /* Note, yes and run have no value, so do not err */
+ if (strcasecmp(ua->argk[i], kw[j]) == 0) {
+ /* Note, yes and run have no value, so do not fail */
if (!ua->argv[i] && j != YES_POS /*yes*/) {
bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
return 1;
kw_ok = true;
break;
+ case 20: /* write verify list output */
+ verify_list = ua->argv[i];
+ kw_ok = true;
+ break;
+ case 21: /* Migration Job */
+ if (previous_job_name) {
+ bsendmsg(ua, _("Migration Job specified twice.\n"));
+ return 0;
+ }
+ previous_job_name = ua->argv[i];
+ kw_ok = true;
+ break;
+
+
default:
break;
}
verify_job = job->verify_job;
}
+ if (previous_job_name) {
+ previous_job = (JOB *)GetResWithName(R_JOB, previous_job_name);
+ if (!previous_job) {
+ bsendmsg(ua, _("Migration Job \"%s\" not found.\n"), previous_job_name);
+ previous_job = select_job_resource(ua);
+ }
+ } else {
+ previous_job = job->verify_job;
+ }
+
+
/*
* Create JCR to run job. NOTE!!! after this point, free_jcr()
* before returning.
set_jcr_defaults(jcr, job);
jcr->verify_job = verify_job;
+ jcr->previous_job = previous_job;
set_storage(jcr, store);
jcr->client = client;
jcr->fileset = fileset;
jcr->cloned = cloned;
- if (find_arg(ua, _("fdcalled")) > 0) {
+ if (find_arg(ua, NT_("fdcalled")) > 0) {
jcr->file_bsock = dup_bsock(ua->UA_sock);
ua->quit = true;
}
}
}
if (jid) {
+ /* Note, this is also MigrateJobId */
jcr->RestoreJobId = str_to_int64(jid);
}
/* Run without prompting? */
- if (ua->batch || find_arg(ua, _("yes")) > 0) {
+ if (ua->batch || find_arg(ua, NT_("yes")) > 0) {
goto start_job;
}
} else {
Name = "";
}
+ if (!verify_list) {
+ verify_list = job->WriteVerifyList;
+ }
+ if (!verify_list) {
+ verify_list = "";
+ }
bsendmsg(ua, _("Run %s job\n"
"JobName: %s\n"
"FileSet: %s\n"
"Storage: %s\n"
"Pool: %s\n"
"Verify Job: %s\n"
+"Verify List: %s\n"
"When: %s\n"
"Priority: %d\n"),
_("Verify"),
jcr->store->hdr.name,
NPRT(jcr->pool->hdr.name),
Name,
+ verify_list,
bstrutime(dt, sizeof(dt), jcr->sched_time),
jcr->JobPriority);
}
jcr->JobPriority);
}
break;
+ case JT_MIGRATE:
+ jcr->JobLevel = L_FULL; /* default level */
+ bsendmsg(ua, _("Run Migration job\n"
+ "JobName: %s\n"
+ "Bootstrap: %s\n"
+ "FileSet: %s\n"
+ "Client: %s\n"
+ "Storage: %s\n"
+ "JobId: %s\n"
+ "When: %s\n"
+ "Catalog: %s\n"
+ "Priority: %d\n"),
+ job->hdr.name,
+ NPRT(jcr->RestoreBootstrap),
+ jcr->fileset->hdr.name,
+ jcr->client->hdr.name,
+ jcr->store->hdr.name,
+ jcr->MigrateJobId==0?"*None*":edit_uint64(jcr->MigrateJobId, ec1),
+ bstrutime(dt, sizeof(dt), jcr->sched_time),
+ jcr->catalog->hdr.name,
+ jcr->JobPriority);
+ break;
default:
bsendmsg(ua, _("Unknown Job Type=%d\n"), jcr->JobType);
goto bail_out;
}
-
if (!get_cmd(ua, _("OK to run? (yes/mod/no): "))) {
goto bail_out;
}
}
if (ua->cmd[0] != 0) {
jcr->RestoreBootstrap = bstrdup(ua->cmd);
- fd = fopen(jcr->RestoreBootstrap, "r");
+ fd = fopen(jcr->RestoreBootstrap, "rb");
if (!fd) {
bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"),
jcr->RestoreBootstrap, strerror(errno));
bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
}
goto try_again;
+ case -1: /* error or cancel */
+ goto bail_out;
default:
goto try_again;
}
Dmsg1(800, "Calling run_job job=%x\n", jcr->job);
start_job:
JobId = run_job(jcr);
+#if 0
+ bsendmsg(ua, "<job director=\"console\" time=\"%u\" status=\"%c\" type=\"%c\" "
+ "jobid=\"%u\" job=\"%s\" level=\"%c\" finished=\"false\" priority=\"%u\"/>\n",
+ time(NULL), jcr->JobStatus, jcr->JobType, jcr->JobId,
+ jcr->Job, jcr->JobLevel, jcr->JobPriority);
+#endif
free_jcr(jcr); /* release jcr */
if (JobId == 0) {
bsendmsg(ua, _("Job failed.\n"));