]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/3.0.1-maxdiff.patch
143334e287bae88d9f9a73e481e58a50dc2cefaa
[bacula/bacula] / bacula / patches / 3.0.1-maxdiff.patch
1
2  This patch can be applied to version 3.0.1 and ensures that
3  if maxdiffinterval is set, it will be done even if no prior
4  Diff job ran.  This should fix bug #1311.
5
6  Apply it to version 3.0.1 with:
7
8  cd <bacula-source>
9  patch -p0 <3.0.1-maxdiff.patch
10  ./configure <your-options>
11  make
12  ...
13  make install
14
15
16
17 Index: src/dird/fd_cmds.c
18 ===================================================================
19 --- src/dird/fd_cmds.c  (revision 8902)
20 +++ src/dird/fd_cmds.c  (working copy)
21 @@ -198,22 +198,29 @@
22        now = (utime_t)time(NULL);
23        jcr->jr.JobId = 0;     /* flag to return since time */
24        have_full = db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime);
25 -      /* If there was a successful job, make sure it is recent enough */
26 -      if (jcr->get_JobLevel() == L_INCREMENTAL && have_full && jcr->job->MaxDiffInterval > 0) {
27 +      if (have_full) {
28 +         last_full_time = str_to_utime(jcr->stime);
29 +      }
30 +      /* Make sure the last diff is recent enough */
31 +      if (have_full && jcr->get_JobLevel() == L_INCREMENTAL && jcr->job->MaxDiffInterval > 0) {
32           /* Lookup last diff job */
33           if (db_find_last_job_start_time(jcr, jcr->db, &jcr->jr, &stime, L_DIFFERENTIAL)) {
34              last_diff_time = str_to_utime(stime);
35 -            do_diff = ((now - last_diff_time) >= jcr->job->MaxDiffInterval);
36 +         } else {
37 +            /* No last differential, so use last full time */
38 +            last_diff_time = last_full_time;
39           }
40 +         do_diff = ((now - last_diff_time) >= jcr->job->MaxDiffInterval);
41        }
42 -      if (have_full && jcr->job->MaxFullInterval > 0 &&
43 -         db_find_last_job_start_time(jcr, jcr->db, &jcr->jr, &stime, L_FULL)) {
44 -         last_full_time = str_to_utime(stime);
45 +      /* Note, do_full takes precedence over do_diff */
46 +      if (have_full && jcr->job->MaxFullInterval > 0) {
47           do_full = ((now - last_full_time) >= jcr->job->MaxFullInterval);
48 +      } else {
49 +         do_full = true;
50        }
51        free_pool_memory(stime);
52  
53 -      if (!have_full || do_full) {
54 +      if (do_full) {
55           /* No recent Full job found, so upgrade this one to Full */
56           Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
57           Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing FULL backup.\n"));
58 @@ -221,7 +228,7 @@
59              level_to_str(jcr->get_JobLevel()));
60           jcr->set_JobLevel(jcr->jr.JobLevel = L_FULL);
61         } else if (do_diff) {
62 -         /* No recent diff job found, so upgrade this one to Full */
63 +         /* No recent diff job found, so upgrade this one to Diff */
64           Jmsg(jcr, M_INFO, 0, _("No prior or suitable Differential backup found in catalog. Doing Differential backup.\n"));
65           bsnprintf(since, since_len, _(" (upgraded from %s)"),
66              level_to_str(jcr->get_JobLevel()));