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.
6 Apply it to version 3.0.1 with:
9 patch -p0 <3.0.1-maxdiff.patch
10 ./configure <your-options>
17 Index: src/dird/fd_cmds.c
18 ===================================================================
19 --- src/dird/fd_cmds.c (revision 8911)
20 +++ src/dird/fd_cmds.c (working copy)
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) {
28 + last_full_time = str_to_utime(jcr->stime);
30 + do_full = true; /* No full, upgrade to one */
32 + /* Make sure the last diff is recent enough */
33 + if (have_full && jcr->get_JobLevel() == L_INCREMENTAL && jcr->job->MaxDiffInterval > 0) {
34 /* Lookup last diff job */
35 if (db_find_last_job_start_time(jcr, jcr->db, &jcr->jr, &stime, L_DIFFERENTIAL)) {
36 last_diff_time = str_to_utime(stime);
37 - do_diff = ((now - last_diff_time) >= jcr->job->MaxDiffInterval);
38 + /* If no Diff since Full, use Full time */
39 + if (last_diff_time < last_full_time) {
40 + last_diff_time = last_full_time;
43 + /* No last differential, so use last full time */
44 + last_diff_time = last_full_time;
46 + do_diff = ((now - last_diff_time) >= jcr->job->MaxDiffInterval);
48 - if (have_full && jcr->job->MaxFullInterval > 0 &&
49 - db_find_last_job_start_time(jcr, jcr->db, &jcr->jr, &stime, L_FULL)) {
50 - last_full_time = str_to_utime(stime);
51 + /* Note, do_full takes precedence over do_diff */
52 + if (have_full && jcr->job->MaxFullInterval > 0) {
53 do_full = ((now - last_full_time) >= jcr->job->MaxFullInterval);
55 free_pool_memory(stime);
57 - if (!have_full || do_full) {
59 /* No recent Full job found, so upgrade this one to Full */
60 Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db));
61 Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing FULL backup.\n"));
63 level_to_str(jcr->get_JobLevel()));
64 jcr->set_JobLevel(jcr->jr.JobLevel = L_FULL);
66 - /* No recent diff job found, so upgrade this one to Full */
67 + /* No recent diff job found, so upgrade this one to Diff */
68 Jmsg(jcr, M_INFO, 0, _("No prior or suitable Differential backup found in catalog. Doing Differential backup.\n"));
69 bsnprintf(since, since_len, _(" (upgraded from %s)"),
70 level_to_str(jcr->get_JobLevel()));