]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/verify.c
Turn off debug
[bacula/bacula] / bacula / src / dird / verify.c
index aa67aebf07c0482ae7066bf522ba9fca166e4f6a..192cbbc2c1fc607c4cfff2c5707fbe0e98cf4db4 100644 (file)
@@ -1,22 +1,7 @@
-/*
- *
- *   Bacula Director -- verify.c -- responsible for running file verification
- *
- *     Kern Sibbald, October MM
- *
- *  Basic tasks done here:
- *     Open DB
- *     Open connection with File daemon and pass him commands
- *       to do the verify.
- *     When the File daemon sends the attributes, compare them to
- *       what is in the DB.
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark ofJohn Walker.
+   Bacula® is a registered trademark of John Walker.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *   Bacula Director -- verify.c -- responsible for running file verification
+ *
+ *     Kern Sibbald, October MM
+ *
+ *  Basic tasks done here:
+ *     Open DB
+ *     Open connection with File daemon and pass him commands
+ *       to do the verify.
+ *     When the File daemon sends the attributes, compare them to
+ *       what is in the DB.
+ *
+ *   Version $Id$
+ */
 
 
 #include "bacula.h"
@@ -66,6 +66,22 @@ static int missing_handler(void *ctx, int num_fields, char **row);
  */
 bool do_verify_init(JCR *jcr) 
 {
+   return true;
+}
+
+
+/*
+ * Do a verification of the specified files against the Catlaog
+ *
+ *  Returns:  false on failure
+ *            true  on success
+ */
+bool do_verify(JCR *jcr)
+{
+   const char *level;
+   BSOCK   *fd;
+   int stat;
+   char ed1[100];
    JOB_DBR jr;
    JobId_t verify_jobid = 0;
    const char *Name;
@@ -74,12 +90,16 @@ bool do_verify_init(JCR *jcr)
 
    memset(&jcr->previous_jr, 0, sizeof(jcr->previous_jr));
 
-   Dmsg1(9, "bdird: created client %s record\n", jcr->client->hdr.name);
-
    /*
-    * Find JobId of last job that ran.  E.g.
-    *   for VERIFY_CATALOG we want the JobId of the last INIT.
-    *   for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the
+    * Find JobId of last job that ran. Note, we do this when
+    *   the job actually starts running, not at schedule time,
+    *   so that we find the last job that terminated before
+    *   this job runs rather than before it is scheduled. This
+    *   permits scheduling a Backup and Verify at the same time,
+    *   but with the Verify at a lower priority.
+    *
+    *   For VERIFY_CATALOG we want the JobId of the last INIT.
+    *   For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the
     *       last backup Job.
     */
    if (jcr->JobLevel == L_VERIFY_CATALOG ||
@@ -89,7 +109,7 @@ bool do_verify_init(JCR *jcr)
       if (jcr->verify_job &&
           (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ||
            jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG)) {
-         Name = jcr->verify_job->hdr.name;
+         Name = jcr->verify_job->name();  
       } else {
          Name = NULL;
       }
@@ -149,22 +169,6 @@ bool do_verify_init(JCR *jcr)
       jcr->fileset = jcr->verify_job->fileset;
    }
    Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, jcr->JobLevel);
-   return true;
-}
-
-
-/*
- * Do a verification of the specified files against the Catlaog
- *
- *  Returns:  false on failure
- *            true  on success
- */
-bool do_verify(JCR *jcr)
-{
-   const char *level;
-   BSOCK   *fd;
-   int stat;
-   char ed1[100];
 
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
@@ -318,6 +322,8 @@ bool do_verify(JCR *jcr)
       jcr->sd_msg_thread_done = true;   /* no SD msg thread, so it is done */
       jcr->SDJobStatus = JS_Terminated;
       get_attributes_and_put_in_catalog(jcr);
+      db_end_transaction(jcr, jcr->db);   /* terminate any open transaction */
+      db_write_batch_file_records(jcr);
       break;
 
    default:
@@ -349,7 +355,6 @@ void verify_cleanup(JCR *jcr, int TermCode)
    const char *Name;
 
 // Dmsg1(100, "Enter verify_cleanup() TermCod=%d\n", TermCode);
-   dequeue_messages(jcr);             /* display any queued messages */
 
    Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", jcr->JobLevel,
       jcr->ExpectedFiles, jcr->JobFiles);
@@ -365,9 +370,9 @@ void verify_cleanup(JCR *jcr, int TermCode)
    }
 
    JobId = jcr->jr.JobId;
-   set_jcr_job_status(jcr, TermCode);
 
-   update_job_end_record(jcr);
+   update_job_end(jcr, TermCode);
+
    if (jcr->unlink_bsr && jcr->RestoreBootstrap) {
       unlink(jcr->RestoreBootstrap);
       jcr->unlink_bsr = false;
@@ -409,7 +414,8 @@ void verify_cleanup(JCR *jcr, int TermCode)
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
    if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) {
       jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
-      Jmsg(jcr, msg_type, 0, _("Bacula %s (%s): %s\n"
+   Jmsg(jcr, msg_type, 0, _("Bacula %s %s (%s): %s\n"
+"  Build OS:               %s %s %s\n"
 "  JobId:                  %d\n"
 "  Job:                    %s\n"
 "  FileSet:                %s\n"
@@ -425,9 +431,8 @@ void verify_cleanup(JCR *jcr, int TermCode)
 "  FD termination status:  %s\n"
 "  SD termination status:  %s\n"
 "  Termination:            %s\n\n"),
-         VERSION,
-         LSMDATE,
-         edt,
+        my_name, VERSION, LSMDATE, edt,
+        HOST_OS, DISTNAME, DISTVER,
          jcr->jr.JobId,
          jcr->jr.Job,
          jcr->fileset->hdr.name,
@@ -444,7 +449,8 @@ void verify_cleanup(JCR *jcr, int TermCode)
          sd_term_msg,
          term_msg);
    } else {
-      Jmsg(jcr, msg_type, 0, _("Bacula %s (%s): %s\n"
+   Jmsg(jcr, msg_type, 0, _("Bacula %s %s (%s): %s\n"
+"  Build:                  %s %s %s\n"
 "  JobId:                  %d\n"
 "  Job:                    %s\n"
 "  FileSet:                %s\n"
@@ -458,9 +464,8 @@ void verify_cleanup(JCR *jcr, int TermCode)
 "  Non-fatal FD errors:    %d\n"
 "  FD termination status:  %s\n"
 "  Termination:            %s\n\n"),
-         VERSION,
-         LSMDATE,
-         edt,
+        my_name, VERSION, LSMDATE, edt,
+        HOST_OS, DISTNAME, DISTVER,
          jcr->jr.JobId,
          jcr->jr.Job,
          jcr->fileset->hdr.name,
@@ -718,7 +723,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
    if (is_bnet_error(fd)) {
       berrno be;
       Jmsg2(jcr, M_FATAL, 0, _("bdird<filed: bad attributes from filed n=%d : %s\n"),
-                        n, be.strerror());
+                        n, be.bstrerror());
       return false;
    }
 
@@ -757,7 +762,7 @@ static int missing_handler(void *ctx, int num_fields, char **row)
    }
    if (!jcr->fn_printed) {
       Jmsg(jcr, M_INFO, 0, "\n");
-      Jmsg(jcr, M_INFO, 0, _("The following files are missing:\n"));
+      Jmsg(jcr, M_INFO, 0, _("The following files are in the Catalog but not on disk:\n"));
       jcr->fn_printed = true;
    }
    Jmsg(jcr, M_INFO, 0, "      %s%s\n", row[0]?row[0]:"", row[1]?row[1]:"");