From: Eric Bollengier Date: Fri, 1 Oct 2010 07:46:20 +0000 (+0200) Subject: Add .bvfs_get_jobids to return jobids needed by a job to restore X-Git-Tag: Release-5.2.1~1069 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=55b084cf2cd265113c10d17fd8d24fbbc40b0209;p=bacula%2Fbacula Add .bvfs_get_jobids to return jobids needed by a job to restore --- diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index aa04186ec3..3d62a843ba 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -73,6 +73,7 @@ static bool aopcmd(UAContext *ua, const char *cmd); static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd); static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd); static bool dot_bvfs_update(UAContext *ua, const char *cmd); +static bool dot_bvfs_get_jobids(UAContext *ua, const char *cmd); static bool api_cmd(UAContext *ua, const char *cmd); static bool sql_cmd(UAContext *ua, const char *cmd); @@ -107,6 +108,7 @@ static struct cmdstruct commands[] = { /* help */ /* can be used in runscript * { NT_(".bvfs_lsdirs"), dot_bvfs_lsdirs, NULL, true}, { NT_(".bvfs_lsfiles"),dot_bvfs_lsfiles,NULL, true}, { NT_(".bvfs_update"), dot_bvfs_update, NULL, true}, + { NT_(".bvfs_get_jobids"), dot_bvfs_get_jobids,NULL,true}, { NT_(".types"), typescmd, NULL, false} }; #define comsize ((int)(sizeof(commands)/sizeof(struct cmdstruct))) @@ -343,6 +345,34 @@ static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd) return true; } +static bool dot_bvfs_get_jobids(UAContext *ua, const char *cmd) +{ + JOB_DBR jr; + db_list_ctx jobids; + int pos; + + if (!open_client_db(ua)) { + return true; + } + + memset(&jr, 0, sizeof(JOB_DBR)); + if ((pos = find_arg_with_value(ua, "jobid")) >= 0) { + jr.JobId = str_to_int64(ua->argv[pos]); + } + + if (!db_get_job_record(ua->jcr, ua->db, &jr)) { + ua->error_msg(_("Unable to get Job record for JobId=%s: ERR=%s\n"), + ua->cmd, db_strerror(ua->db)); + return true; + } + jr.JobLevel = L_INCREMENTAL; /* Take Full+Diff+Incr */ + if (!db_accurate_get_jobids(ua->jcr, ua->db, &jr, &jobids)) { + return true; + } + ua->send_msg("%s\n", jobids.list); + return true; +} + static bool dot_quit_cmd(UAContext *ua, const char *cmd) { quit_cmd(ua, cmd);