]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/backup.c
Fix hourly scheduling problem
[bacula/bacula] / bacula / src / dird / backup.c
index 6fe03e85507db022e8f9575ed25dc8a5240d1058..f6db260141c8577f23d6b6b9e831bd758137d4f2 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -120,10 +120,28 @@ int do_backup(JCR *jcr)
        jcr->JobId, jcr->Job);
 
    /* 
-    * Get the Pool record  
+    * Get the Pool record -- first apply any level defined pools  
     */
+   switch (jcr->JobLevel) {
+   case L_FULL:
+      if (jcr->full_pool) {
+        jcr->pool = jcr->full_pool;   
+      }
+      break;
+   case L_INCREMENTAL:
+      if (jcr->inc_pool) {
+        jcr->pool = jcr->inc_pool;   
+      }
+      break;
+   case L_DIFFERENTIAL:
+      if (jcr->dif_pool) {
+        jcr->pool = jcr->dif_pool;   
+      }
+      break;
+   }
    memset(&pr, 0, sizeof(pr));
    bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name));
+
    while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */
       /* Try to create the pool */
       if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) {
@@ -228,7 +246,7 @@ int wait_for_job_termination(JCR *jcr)
 {
    int32_t n = 0;
    BSOCK *fd = jcr->file_bsock;
-   int fd_ok = FALSE;
+   bool fd_ok = false;
    uint32_t JobFiles, Errors;
    uint64_t ReadBytes, JobBytes;
 
@@ -237,7 +255,7 @@ int wait_for_job_termination(JCR *jcr)
    while ((n = bget_dirmsg(fd)) >= 0) {
       if (!fd_ok && sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles,
          &ReadBytes, &JobBytes, &Errors) == 5) {
-        fd_ok = TRUE;
+        fd_ok = true;
         set_jcr_job_status(jcr, jcr->FDJobStatus);
          Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
       } else {
@@ -264,9 +282,11 @@ int wait_for_job_termination(JCR *jcr)
       jcr->Errors = Errors;
       jcr->ReadBytes = ReadBytes;
       jcr->JobBytes = JobBytes;
+   } else {
+      Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n"));
    }
 
-// Dmsg4(000, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus,
+// Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus,
 //   jcr->JobStatus, jcr->SDJobStatus);
 
    /* Return the first error status we find Dir, FD, or SD */
@@ -375,7 +395,11 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
    msg_type = M_INFO;                /* by default INFO message */
    switch (jcr->JobStatus) {
       case JS_Terminated:
-         term_msg = _("Backup OK");
+        if (jcr->Errors || jcr->SDErrors) {
+            term_msg = _("Backup OK -- with warnings");
+        } else {
+            term_msg = _("Backup OK");
+        }
         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
@@ -383,14 +407,18 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
         msg_type = M_ERROR;          /* Generate error message */
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
-           pthread_cancel(jcr->SD_msg_chan);
+           if (jcr->SD_msg_chan) {
+              pthread_cancel(jcr->SD_msg_chan);
+           }
         }
         break;
       case JS_Canceled:
          term_msg = _("Backup Canceled");
         if (jcr->store_bsock) {
            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
-           pthread_cancel(jcr->SD_msg_chan);
+           if (jcr->SD_msg_chan) {
+              pthread_cancel(jcr->SD_msg_chan);
+           }
         }
         break;
       default:
@@ -432,6 +460,8 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
    jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
 
+// bmicrosleep(15, 0);               /* for debugging SIGHUP */
+
    Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
 JobId:                  %d\n\
 Job:                    %s\n\