]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/vbackup.c
kes Ensure that job report is always printed even if job is failed
[bacula/bacula] / bacula / src / dird / vbackup.c
index d41aae599e213fca2b3407e1f73313979acc510a..18eb34c332744eea0bbb58ca3010c8996f694481 100644 (file)
@@ -61,7 +61,6 @@ void vbackup_cleanup(JCR *jcr, int TermCode);
  */
 bool do_vbackup_init(JCR *jcr)
 {
-   char *p;
 
    if (!get_or_create_fileset_record(jcr)) {
       Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
@@ -101,43 +100,6 @@ bool do_vbackup_init(JCR *jcr)
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
    }
 
-   POOLMEM *jobids = get_pool_memory(PM_FNAME);
-   jcr->jr.JobLevel = L_VIRTUAL_FULL;
-   db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
-   jcr->jr.JobLevel = L_FULL;
-   Dmsg1(10, "Accurate jobids=%s\n", jobids);
-   if (*jobids == 0) {
-      free_pool_memory(jobids);
-      Jmsg(jcr, M_FATAL, 0, _("Cannot find previous JobIds.\n"));
-      return false;
-   }
-
-   /*
-    * Now we find the last job that ran and store it's info in
-    *  the previous_jr record.  We will set our times to the
-    *  values from that job so that anything changed after that
-    *  time will be picked up on the next backup.
-    */
-   p = strrchr(jobids, ',');              /* find last jobid */
-   if (p != NULL) {
-      p++;
-   } else {
-      p = jobids;
-   }
-   memset(&jcr->previous_jr, 0, sizeof(jcr->previous_jr));
-   jcr->previous_jr.JobId = str_to_int64(p);
-   if (!db_get_job_record(jcr, jcr->db, &jcr->previous_jr)) {
-      Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for previous Job: ERR=%s"),
-               db_strerror(jcr->db));
-      return false;
-   }
-
-   if (!create_bootstrap_file(jcr, jobids)) {
-      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
-      free_pool_memory(jobids);
-      return false;
-   }
-   free_pool_memory(jobids);
 
    /*
     * If the original backup pool has a NextPool, make sure a 
@@ -153,6 +115,7 @@ bool do_vbackup_init(JCR *jcr)
    if (!set_migration_wstorage(jcr, jcr->pool)) {
       return false;
    }
+   jcr->pool = jcr->pool->NextPool;
    pm_strcpy(jcr->pool_source, _("Job Pool's NextPool resource"));
 
    Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n", jcr->pool->name(), jcr->rpool->name());
@@ -173,17 +136,20 @@ bool do_vbackup(JCR *jcr)
 {
    char ed1[100];
    BSOCK *sd;
+   char *p;
 
    Dmsg2(100, "rstorage=%p wstorage=%p\n", jcr->rstorage, jcr->wstorage);
    Dmsg2(100, "Read store=%s, write store=%s\n", 
       ((STORE *)jcr->rstorage->first())->name(),
       ((STORE *)jcr->wstorage->first())->name());
    /* ***FIXME***  we really should simply verify that the pools are different */
+#ifdef xxx
    if (((STORE *)jcr->rstorage->first())->name() == ((STORE *)jcr->wstorage->first())->name()) {
       Jmsg(jcr, M_FATAL, 0, _("Read storage \"%s\" same as write storage.\n"),
            ((STORE *)jcr->rstorage->first())->name());
       return false;
    }
+#endif
 
    /* Print Job Start message */
    Jmsg(jcr, M_INFO, 0, _("Start Virtual Backup JobId %s, Job=%s\n"),
@@ -193,6 +159,45 @@ bool do_vbackup(JCR *jcr)
 _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n"));
    }
 
+   POOLMEM *jobids = get_pool_memory(PM_FNAME);
+   jcr->jr.JobLevel = L_VIRTUAL_FULL;
+   db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
+   jcr->jr.JobLevel = L_FULL;
+   Dmsg1(10, "Accurate jobids=%s\n", jobids);
+   if (*jobids == 0) {
+      free_pool_memory(jobids);
+      Jmsg(jcr, M_FATAL, 0, _("No previous Jobs found.\n"));
+      return false;
+   }
+
+   /*
+    * Now we find the last job that ran and store it's info in
+    *  the previous_jr record.  We will set our times to the
+    *  values from that job so that anything changed after that
+    *  time will be picked up on the next backup.
+    */
+   p = strrchr(jobids, ',');              /* find last jobid */
+   if (p != NULL) {
+      p++;
+   } else {
+      p = jobids;
+   }
+   memset(&jcr->previous_jr, 0, sizeof(jcr->previous_jr));
+   jcr->previous_jr.JobId = str_to_int64(p);
+   Dmsg1(10, "Previous JobId=%s\n", p);
+   if (!db_get_job_record(jcr, jcr->db, &jcr->previous_jr)) {
+      Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for previous Job: ERR=%s"),
+               db_strerror(jcr->db));
+      return false;
+   }
+
+   if (!create_bootstrap_file(jcr, jobids)) {
+      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
+      free_pool_memory(jobids);
+      return false;
+   }
+   free_pool_memory(jobids);
+
    /*
     * Open a message channel connection with the Storage
     * daemon. This is to let him know that our client
@@ -310,6 +315,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
       edit_uint64(jcr->JobId, ec3));
    db_sql_query(jcr->db, query.c_str(), NULL, NULL);
 
+   /* Get the fully updated job record */
    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"),
          db_strerror(jcr->db));
@@ -398,7 +404,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
    }
    jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
 
-   Jmsg(jcr, msg_type, 0, _("Bacula %s %s (%s): %s\n"
+   Jmsg(jcr, msg_type, 0, _("%s %s %s (%s): %s\n"
 "  Build OS:               %s %s %s\n"
 "  JobId:                  %d\n"
 "  Job:                    %s\n"
@@ -416,8 +422,6 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
 "  SD Files Written:       %s\n"
 "  SD Bytes Written:       %s (%sB)\n"
 "  Rate:                   %.1f KB/s\n"
-"  Encryption:             %s\n"
-"  Accurate:               %s\n"
 "  Volume name(s):         %s\n"
 "  Volume Session Id:      %d\n"
 "  Volume Session Time:    %d\n"
@@ -425,7 +429,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
 "  SD Errors:              %d\n"
 "  SD termination status:  %s\n"
 "  Termination:            %s\n\n"),
-        my_name, VERSION, LSMDATE, edt,
+        BACULA, my_name, VERSION, LSMDATE, edt,
         HOST_OS, DISTNAME, DISTVER,
         jcr->jr.JobId,
         jcr->jr.Job,
@@ -443,8 +447,6 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
         edit_uint64_with_commas(jcr->jr.JobBytes, ec3),
         edit_uint64_with_suffix(jcr->jr.JobBytes, ec4),
         kbps,
-        jcr->Encrypt?_("yes"):_("no"),
-        jcr->accurate?_("yes"):_("no"),
         jcr->VolumeName,
         jcr->VolSessionId,
         jcr->VolSessionTime,