From f1ed101480d67837b04cbf05dbcca18558d1f9c6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 10 Nov 2004 21:18:14 +0000 Subject: [PATCH] Allow both a JobId and a filename or list of files to be specified on a restore command line. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1681 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/sql_cmds.c | 14 +++++++++++++- bacula/src/dird/ua_restore.c | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index 10768d312d..f664722120 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -340,4 +340,16 @@ const char *uar_jobid_fileindex = "AND Path.PathId=File.PathId " "AND Filename.FilenameId=File.FilenameId " "ORDER BY Job.StartTime DESC LIMIT 1"; - + +const char *uar_jobids_fileindex = + "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client " + "WHERE Job.JobId IN (%s) " + "AND Job.JobId=File.JobId " + "AND Job.StartTime<'%s' " + "AND Path.Path='%s' " + "AND Filename.Name='%s' " + "AND Client.Name='%s' " + "AND Job.ClientId=Client.ClientId " + "AND Path.PathId=File.PathId " + "AND Filename.FilenameId=File.FilenameId " + "ORDER BY Job.StartTime DESC LIMIT 1"; diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 72e4c0e599..9f06fd33f7 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -48,7 +48,7 @@ extern char *uar_create_temp1, *uar_last_full, *uar_full; extern char *uar_inc, *uar_list_temp, *uar_sel_jobid_temp; extern char *uar_sel_all_temp1, *uar_sel_fileset, *uar_mediatype; extern char *uar_jobid_fileindex, *uar_dif, *uar_sel_all_temp; -extern char *uar_count_files; +extern char *uar_count_files, *uar_jobids_fileindex; struct NAME_LIST { @@ -632,7 +632,12 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi { strip_trailing_junk(file); split_path_and_filename(rx, file); - Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); + if (*rx->JobIds == 0) { + Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); + } else { + Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, + rx->path, rx->fname, rx->ClientName); + } rx->found = false; /* Find and insert jobid and File Index */ if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) { -- 2.39.5