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