]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.36.0/1.36.0-jobid-restore.patch
Fix scripts/bacula.in to have awk on an environment variable
[bacula/bacula] / bacula / patches / 1.36.0 / 1.36.0-jobid-restore.patch
1
2  This patch fixes a restore to permit specifying both a JobId and
3  a filename or list of files to be restored.  Apply to 1.36.0 with:
4
5  cd <bacula-source>
6  patch -p0 <1.36.0-jobid-restore.patch
7  make
8  make install
9  ...
10
11 Index: src/dird/sql_cmds.c
12 ===================================================================
13 RCS file: /cvsroot/bacula/bacula/src/dird/sql_cmds.c,v
14 retrieving revision 1.43
15 diff -u -r1.43 sql_cmds.c
16 --- src/dird/sql_cmds.c 1 Sep 2004 19:44:28 -0000       1.43
17 +++ src/dird/sql_cmds.c 10 Nov 2004 20:38:46 -0000
18 @@ -340,4 +340,16 @@
19     "AND Path.PathId=File.PathId "
20     "AND Filename.FilenameId=File.FilenameId "
21     "ORDER BY Job.StartTime DESC LIMIT 1";
22 -     
23 +
24 +const char *uar_jobids_fileindex = 
25 +   "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
26 +   "WHERE Job.JobId IN (%s) "
27 +   "AND Job.JobId=File.JobId "
28 +   "AND Job.StartTime<'%s' "
29 +   "AND Path.Path='%s' "
30 +   "AND Filename.Name='%s' "
31 +   "AND Client.Name='%s' "
32 +   "AND Job.ClientId=Client.ClientId "
33 +   "AND Path.PathId=File.PathId "
34 +   "AND Filename.FilenameId=File.FilenameId "
35 +   "ORDER BY Job.StartTime DESC LIMIT 1";
36 Index: src/dird/ua_restore.c
37 ===================================================================
38 RCS file: /cvsroot/bacula/bacula/src/dird/ua_restore.c,v
39 retrieving revision 1.84
40 diff -u -r1.84 ua_restore.c
41 --- src/dird/ua_restore.c       15 Oct 2004 17:09:04 -0000      1.84
42 +++ src/dird/ua_restore.c       10 Nov 2004 20:38:46 -0000
43 @@ -48,7 +48,7 @@
44  extern char *uar_inc,           *uar_list_temp,   *uar_sel_jobid_temp;
45  extern char *uar_sel_all_temp1,  *uar_sel_fileset, *uar_mediatype;
46  extern char *uar_jobid_fileindex, *uar_dif,       *uar_sel_all_temp;
47 -extern char *uar_count_files;
48 +extern char *uar_count_files,    *uar_jobids_fileindex;
49  
50  
51  struct NAME_LIST {
52 @@ -632,7 +632,12 @@
53  {
54     strip_trailing_junk(file);
55     split_path_and_filename(rx, file);
56 -   Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName);
57 +   if (*rx->JobIds == 0) {
58 +      Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName);
59 +   } else {
60 +      Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, 
61 +          rx->path, rx->fname, rx->ClientName);
62 +   }
63     rx->found = false;
64     /* Find and insert jobid and File Index */
65     if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {