6be8d09
This patch should fix the problem reported in bug #803 where a Verify 
6be8d09
job select the JobId to verified at schedule time rather than at runtime.
6be8d09
This makes it difficult or impossible to schedule a verify just after
6be8d09
a backup.
6be8d09
6be8d09
Apply this patch to Bacula version 2.0.3 (probably 2.0.2 as well) with:
6be8d09
6be8d09
  cd <bacula-source>
6be8d09
  patch -p0 <2.0.3-verify.patch
6be8d09
  make
6be8d09
  ...
6be8d09
  make install
6be8d09
6be8d09
Index: src/dird/verify.c
6be8d09
===================================================================
6be8d09
--- src/dird/verify.c	(revision 4353)
6be8d09
+++ src/dird/verify.c	(working copy)
6be8d09
@@ -40,6 +25,21 @@
6be8d09
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Z├╝rich,
6be8d09
    Switzerland, email:ftf@fsfeurope.org.
6be8d09
 */
6be8d09
+/*
6be8d09
+ *
6be8d09
+ *   Bacula Director -- verify.c -- responsible for running file verification
6be8d09
+ *
6be8d09
+ *     Kern Sibbald, October MM
6be8d09
+ *
6be8d09
+ *  Basic tasks done here:
6be8d09
+ *     Open DB
6be8d09
+ *     Open connection with File daemon and pass him commands
6be8d09
+ *       to do the verify.
6be8d09
+ *     When the File daemon sends the attributes, compare them to
6be8d09
+ *       what is in the DB.
6be8d09
+ *
6be8d09
+ *   Version $Id: 2.0.3-verify.patch,v 1.1 2007/07/24 20:11:04 ixs Exp $
6be8d09
+ */
6be8d09
 
6be8d09
 
6be8d09
 #include "bacula.h"
6be8d09
@@ -66,6 +66,22 @@
6be8d09
  */
6be8d09
 bool do_verify_init(JCR *jcr) 
6be8d09
 {
6be8d09
+   return true;
6be8d09
+}
6be8d09
+
6be8d09
+
6be8d09
+/*
6be8d09
+ * Do a verification of the specified files against the Catlaog
6be8d09
+ *
6be8d09
+ *  Returns:  false on failure
6be8d09
+ *            true  on success
6be8d09
+ */
6be8d09
+bool do_verify(JCR *jcr)
6be8d09
+{
6be8d09
+   const char *level;
6be8d09
+   BSOCK   *fd;
6be8d09
+   int stat;
6be8d09
+   char ed1[100];
6be8d09
    JOB_DBR jr;
6be8d09
    JobId_t verify_jobid = 0;
6be8d09
    const char *Name;
6be8d09
@@ -74,12 +90,16 @@
6be8d09
 
6be8d09
    memset(&jcr->previous_jr, 0, sizeof(jcr->previous_jr));
6be8d09
 
6be8d09
-   Dmsg1(9, "bdird: created client %s record\n", jcr->client->hdr.name);
6be8d09
-
6be8d09
    /*
6be8d09
-    * Find JobId of last job that ran.  E.g.
6be8d09
-    *   for VERIFY_CATALOG we want the JobId of the last INIT.
6be8d09
-    *   for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the
6be8d09
+    * Find JobId of last job that ran. Note, we do this when
6be8d09
+    *   the job actually starts running, not at schedule time,
6be8d09
+    *   so that we find the last job that terminated before
6be8d09
+    *   this job runs rather than before it is scheduled. This
6be8d09
+    *   permits scheduling a Backup and Verify at the same time,
6be8d09
+    *   but with the Verify at a lower priority.
6be8d09
+    *
6be8d09
+    *   For VERIFY_CATALOG we want the JobId of the last INIT.
6be8d09
+    *   For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the
6be8d09
     *       last backup Job.
6be8d09
     */
6be8d09
    if (jcr->JobLevel == L_VERIFY_CATALOG ||
6be8d09
@@ -89,7 +109,7 @@
6be8d09
       if (jcr->verify_job &&
6be8d09
           (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ||
6be8d09
            jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG)) {
6be8d09
-         Name = jcr->verify_job->hdr.name;
6be8d09
+         Name = jcr->verify_job->name();  
6be8d09
       } else {
6be8d09
          Name = NULL;
6be8d09
       }
6be8d09
@@ -149,23 +169,7 @@
6be8d09
       jcr->fileset = jcr->verify_job->fileset;
6be8d09
    }
6be8d09
    Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, jcr->JobLevel);
6be8d09
-   return true;
6be8d09
-}
6be8d09
 
6be8d09
-
6be8d09
-/*
6be8d09
- * Do a verification of the specified files against the Catlaog
6be8d09
- *
6be8d09
- *  Returns:  false on failure
6be8d09
- *            true  on success
6be8d09
- */
6be8d09
-bool do_verify(JCR *jcr)
6be8d09
-{
6be8d09
-   const char *level;
6be8d09
-   BSOCK   *fd;
6be8d09
-   int stat;
6be8d09
-   char ed1[100];
6be8d09
-
6be8d09
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
6be8d09
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
6be8d09
       return false;