]> git.sur5r.net Git - bacula/bacula/commitdiff
Add restore_job= option to restore command
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 10 Jan 2011 15:24:58 +0000 (16:24 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 10 Jan 2011 15:31:26 +0000 (16:31 +0100)
bacula/src/console/console.c
bacula/src/dird/protos.h
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_select.c

index ca1ee1b1dda909953aa0ddcab3ae56eb1d89aa4c..ab3b750fd7c246cfef166c28eca5d5c14e450b6a 100644 (file)
@@ -522,7 +522,7 @@ void get_items(const char *what)
 
 typedef enum 
 {
-   ITEM_ARG,       /* item with simple list like .job */
+   ITEM_ARG,       /* item with simple list like .jobs */
    ITEM_HELP       /* use help item=xxx and detect all arguments */
 } cpl_item_t;
 
@@ -597,7 +597,8 @@ static struct cpl_keywords_t cpl_keywords[] = {
    {"pool=",      ".pool"          },
    {"fileset=",   ".fileset"       },
    {"client=",    ".client"        },
-   {"job=",       ".job"           },
+   {"job=",       ".jobs"          },
+   {"restore_job=",".jobs type=R"  },
    {"level=",     ".level"         },
    {"storage=",   ".storage"       },
    {"schedule=",  ".schedule"      },
index f0ae1822a955ff98ee6d49afdc0f7087d46133b4..127fa10352ca14d8e1d61e002a938c1283b87a57 100644 (file)
@@ -267,6 +267,7 @@ int     get_media_type(UAContext *ua, char *MediaType, int max_media);
 bool    get_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk="pool");
 bool    get_client_dbr(UAContext *ua, CLIENT_DBR *cr);
 POOL   *get_pool_resource(UAContext *ua);
+JOB    *get_restore_job(UAContext *ua);
 POOL   *select_pool_resource(UAContext *ua);
 JCR *select_running_job(UAContext *ua, const char *reason);
 CLIENT *get_client_resource(UAContext *ua);
index 51b7727bf623f61ca8934c1cbccba88ac6c7985a..d6fd44461d968d1b3a674e3f8af188a95a3872e5 100644 (file)
@@ -157,7 +157,8 @@ static struct cmdstruct commands[] = {                                      /* C
  { NT_("quit"),       quit_cmd,      _("Terminate Bconsole session"), NT_(""),              false},
  { NT_("query"),      querycmd,      _("Query catalog"),              NT_(""),              false},
  { NT_("restore"),    restore_cmd,   _("Restore files"), 
-   NT_("where=</path> client=<client> storage=<storage> bootstrap=<file>"
+   NT_("where=</path> client=<client> storage=<storage> bootstrap=<file> "
+       "restore_job=<job>"
        "\n\tcomment=<text> jobid=<jobid> done select all"), false},
 
  { NT_("relabel"),    relabel_cmd,   _("Relabel a tape"), 
index a02ff7f0e7e8abaa835ed8deda81a2be2e7fc483..1df4960b1719084a34b7db2ac807bf30f4ed0711 100644 (file)
@@ -220,7 +220,7 @@ int restore_cmd(UAContext *ua, const char *cmd)
    if (rx.restore_jobs == 1) {
       job = rx.restore_job;
    } else {
-      job = select_restore_job_resource(ua);
+      job = get_restore_job(ua);
    }
    if (!job) {
       goto bail_out;
@@ -458,6 +458,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
       "restoreclient", /* 19 */
       "copies",        /* 20 */
       "comment",       /* 21 */
+      "restore_job",   /* 22 */
       NULL
    };
 
index 2e427b0a93087154ae2fbef1fa6da96c6e6873fa..5ee912696d5ca2a078f8ad784099f319beb8f588 100644 (file)
@@ -293,6 +293,24 @@ JOB *select_job_resource(UAContext *ua)
    return job;
 }
 
+/* 
+ * Select a Restore Job resource from argument or prompt
+ */
+JOB *get_restore_job(UAContext *ua)
+{
+   JOB *job;
+   int i = find_arg_with_value(ua, "restore_job");
+   if (i >= 0 && acl_access_ok(ua, Job_ACL, ua->argv[i])) {
+      job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+      if (job && job->JobType == JT_RESTORE) {
+         return job;
+      }
+      ua->error_msg(_("Error: Restore Job resource \"%s\" does not exist.\n"),
+                    ua->argv[i]);
+   }
+   return select_restore_job_resource(ua);
+}
+
 /*
  * Select a Restore Job resource from prompt list
  */