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