This patch fixes a restore to permit specifying both a JobId and a filename or list of files to be restored. Apply to 1.36.0 with: cd patch -p0 <1.36.0-jobid-restore.patch make make install ... Index: src/dird/sql_cmds.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/dird/sql_cmds.c,v retrieving revision 1.43 diff -u -r1.43 sql_cmds.c --- src/dird/sql_cmds.c 1 Sep 2004 19:44:28 -0000 1.43 +++ src/dird/sql_cmds.c 10 Nov 2004 20:38:46 -0000 @@ -340,4 +340,16 @@ "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: src/dird/ua_restore.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/dird/ua_restore.c,v retrieving revision 1.84 diff -u -r1.84 ua_restore.c --- src/dird/ua_restore.c 15 Oct 2004 17:09:04 -0000 1.84 +++ src/dird/ua_restore.c 10 Nov 2004 20:38:46 -0000 @@ -48,7 +48,7 @@ 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 @@ { 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)) {