]> git.sur5r.net Git - bacula/bacula/commitdiff
Allow both a JobId and a filename or list of files to be
authorKern Sibbald <kern@sibbald.com>
Wed, 10 Nov 2004 21:18:14 +0000 (21:18 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 10 Nov 2004 21:18:14 +0000 (21:18 +0000)
  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
bacula/src/dird/ua_restore.c

index 10768d312d3c70fa34fd2360dd8ac3b4e7ffaf79..f66472212045e44aac9355ba1fa7e58998cc1973 100644 (file)
@@ -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";
index 72e4c0e5998336ea51c627cac4494e37164fe4ce..9f06fd33f735614ffacddd67a893dee11cb0241a 100644 (file)
@@ -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)) {