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