From: Eric Bollengier Date: Mon, 10 Jan 2011 15:24:58 +0000 (+0100) Subject: Add restore_job= option to restore command X-Git-Tag: Release-7.0.0~1231 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c231db347a67b9f72b8a0cb0aa3e5dbc29f319d6;p=bacula%2Fbacula Add restore_job= option to restore command --- diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index ca1ee1b1dd..ab3b750fd7 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -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" }, diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index ae358fd92a..f3aade05d3 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -266,6 +266,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); CLIENT *get_client_resource(UAContext *ua); int get_job_dbr(UAContext *ua, JOB_DBR *jr); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 16c9e8200c..48a73af7d7 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -156,7 +156,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= client= storage= bootstrap=" + NT_("where= client= storage= bootstrap= " + "restore_job=" "\n\tcomment= jobid= done select all"), false}, { NT_("relabel"), relabel_cmd, _("Relabel a tape"), diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index a02ff7f0e7..1df4960b17 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -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 }; diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 1ff4f27fb4..0a8b68c024 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -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 */