]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
Correct pool source setting
[bacula/bacula] / bacula / src / dird / ua_run.c
index e544817cf032c7d7112bea36bfed361648ee9c38..52315f69762ffa505d858c3c85fe6c5b8b3da9c5 100644 (file)
@@ -7,7 +7,7 @@
  *   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
@@ -34,7 +34,7 @@ extern struct s_kw ReplaceOptions[];
  *     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
@@ -47,6 +47,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    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;
@@ -55,6 +56,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    bool kw_ok;
    JOB *job = NULL;
    JOB *verify_job = NULL;
+   JOB *previous_job = NULL;
    STORE *store = NULL;
    CLIENT *client = NULL;
    FILESET *fileset = NULL;
@@ -81,6 +83,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       "since",                        /* 18 since */
       "cloned",                       /* 19 cloned */
       "verifylist",                   /* 20 verify output list */
+      "migrationjob",                 /* 21 migration job name */
       NULL};
 
 #define YES_POS 14
@@ -101,6 +104,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    bootstrap = NULL;
    replace = NULL;
    verify_job_name = NULL;
+   previous_job_name = NULL;
    catalog_name = NULL;
    verify_list = NULL;
 
@@ -109,8 +113,8 @@ int run_cmd(UAContext *ua, const char *cmd)
       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;
@@ -254,6 +258,15 @@ int run_cmd(UAContext *ua, const char *cmd)
                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;
@@ -401,6 +414,17 @@ int run_cmd(UAContext *ua, const char *cmd)
       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.
@@ -409,6 +433,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    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;
@@ -469,7 +494,7 @@ int run_cmd(UAContext *ua, const char *cmd)
 
    jcr->cloned = cloned;
 
-   if (find_arg(ua, N_("fdcalled")) > 0) {
+   if (find_arg(ua, NT_("fdcalled")) > 0) {
       jcr->file_bsock = dup_bsock(ua->UA_sock);
       ua->quit = true;
    }
@@ -488,11 +513,12 @@ try_again:
       }
    }
    if (jid) {
+      /* Note, this is also MigrateJobId */
       jcr->RestoreJobId = str_to_int64(jid);
    }
 
    /* Run without prompting? */
-   if (ua->batch || find_arg(ua, N_("yes")) > 0) {
+   if (ua->batch || find_arg(ua, NT_("yes")) > 0) {
       goto start_job;
    }
 
@@ -638,6 +664,32 @@ try_again:
               jcr->JobPriority);
       }
       break;
+   case JT_MIGRATE:
+      jcr->JobLevel = L_FULL;      /* default level */
+      bsendmsg(ua, _("Run Restore job\n"
+                     "JobName:       %s\n"
+                     "Bootstrap:     %s\n"
+                     "Where:         %s\n"
+                     "Replace:       %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->where?jcr->where:NPRT(job->RestoreWhere),
+           replace,
+           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;
@@ -879,6 +931,12 @@ 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"));