]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2622 About incorrect behavior of the MaxDiffInterval directive
authorEric Bollengier <eric@baculasystems.com>
Mon, 14 Jun 2021 09:23:01 +0000 (11:23 +0200)
committerEric Bollengier <eric@baculasystems.com>
Mon, 14 Jun 2021 09:59:46 +0000 (11:59 +0200)
bacula/src/dird/fd_cmds.c
bacula/src/jcr.h

index b16c5c87ac79e718a3661333f66754355dd559af..a22130dba754531cc22957d70aeb34782b37f675 100644 (file)
@@ -217,6 +217,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
    utime_t last_full_time = 0;
    utime_t last_diff_time;
    char prev_job[MAX_NAME_LENGTH], edl[50];
+   char last_full_stime[MAX_TIME_LENGTH];
    const char *reason = "";
    POOL_MEM reason2;
 
@@ -232,6 +233,8 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
       jcr->stime = get_pool_memory(PM_MESSAGE);
    }
    jcr->PrevJob[0] = jcr->stime[0] = 0;
+   last_full_stime[0] = 0;
+
    /*
     * Lookup the last FULL backup job to get the time/date for a
     * differential or incremental save.
@@ -255,6 +258,8 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
                                               &stime, prev_job, L_FULL);
       if (have_full) {
          last_full_time = str_to_utime(stime);
+         bstrncpy(last_full_stime, stime, sizeof(last_full_stime));
+
       } else {
          do_full = true;               /* No full, upgrade to one */
 
@@ -308,9 +313,8 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
          if (do_full) {
             reason = _("Max Full Interval exceeded. ");
          }
-      }
-      else
-      if (have_full && jcr->job->MaxVirtualFullInterval > 0) {
+
+      } else if (have_full && jcr->job->MaxVirtualFullInterval > 0) { /* Not used in BEE, not a real job */
          do_vfull = ((now - last_full_time) >= jcr->job->MaxVirtualFullInterval);
       }
       
@@ -325,6 +329,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
          bsnprintf(since, since_len, _(" (upgraded from %s)"),
                    level_to_str(edl , sizeof(edl), jcr->getJobLevel()));
          jcr->setJobLevel(jcr->jr.JobLevel = L_FULL);
+
       } else if (do_vfull) {
          /* No recent Full job found, and MaxVirtualFull is set so upgrade this one to Virtual Full */
          Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
@@ -332,12 +337,16 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
          bsnprintf(since, since_len, _(" (upgraded from %s)"),
                    level_to_str(edl, sizeof(edl), jcr->getJobLevel()));
          jcr->setJobLevel(jcr->jr.JobLevel = L_VIRTUAL_FULL);
+
       } else if (do_diff) {
          /* No recent diff job found, so upgrade this one to Diff */
          Jmsg(jcr, M_INFO, 0, _("%sDoing Differential backup.\n"), reason);
-         bsnprintf(since, since_len, _(" (upgraded from %s)"),
-                   level_to_str(edl, sizeof(edl), jcr->getJobLevel()));
+         pm_strcpy(jcr->stime, last_full_stime);
+         bsnprintf(since, since_len, _(", since=%s (upgraded from %s)"),
+                   jcr->stime, level_to_str(edl, sizeof(edl), jcr->getJobLevel()));
+
          jcr->setJobLevel(jcr->jr.JobLevel = L_DIFFERENTIAL);
+
       } else {
          if (jcr->job->rerun_failed_levels) {
 
index 2a4bff0c4f21f44bc9819294e8883262040f2d20..738d7842ba84376f6cf20dca9a48502f81715a7d 100644 (file)
@@ -369,7 +369,7 @@ public:
    JOB *previous_job;                 /* Job resource of migration previous job */
    JCR *wjcr;                         /* JCR for migration/copy write job */
    char FSCreateTime[MAX_TIME_LENGTH]; /* FileSet CreateTime as returned from DB */
-   char since[MAX_TIME_LENGTH];       /* since time */
+   char since[MAX_NAME_LENGTH];       /* since time */
    char PrevJob[MAX_NAME_LENGTH];     /* Previous job name assiciated with since time */
    union {
       JobId_t RestoreJobId;           /* Id specified by UA */