]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/dird/vbackup.c
authorEric Bollengier <eric@baculasystems.com>
Fri, 24 Apr 2020 16:08:27 +0000 (18:08 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:17 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed Feb 20 12:07:53 2019 +0100

    Allow to run a VirtualFull on a single Job

    A VirtualFull on a single Job is similar to a Copy job, except that we use
    the File list to generate the BSR instead of using the JobMedia table.

    It enables to skip files in the job copy.

Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Nov 22 12:11:18 2016 +0100

    Add run when option that permits duration or existing long date/time specification

Author: Thomas Lohman <thomasl@mtl.mit.edu>
Date:   Thu Jan 14 11:27:24 2016 +0100

    Implement MaxVirtualFullInterval

bacula/src/dird/vbackup.c

index c467840ccd1f0bd09d56f78013a32a5e7afc470c..0dc72db5599fd4e454c460fdf36220ad53d3b3ae 100644 (file)
@@ -48,23 +48,13 @@ void vbackup_cleanup(JCR *jcr, int TermCode);
 bool do_vbackup_init(JCR *jcr)
 {
 
-   if (!get_or_create_fileset_record(jcr)) {
-      Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
-      return false;
-   }
+  /* 
+   * if the read pool has not been allocated yet due to the job 
+   * being upgraded to a virtual full then allocate it now 
+   */
+  if (!jcr->rpool_source)
+    jcr->rpool_source = get_pool_memory(PM_MESSAGE);
 
-   apply_pool_overrides(jcr);
-
-   if (!allow_duplicate_job(jcr)) {
-      return false;
-   }
-
-   jcr->jr.PoolId = get_or_create_pool_record(jcr, jcr->pool->name());
-   if (jcr->jr.PoolId == 0) {
-      Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId);
-      Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n"));
-      return false;
-   }
    /*
     * Note, at this point, pool is the pool for this job.  We
     *  transfer it to rpool (read pool), and a bit later,
@@ -150,6 +140,12 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n")
          jr.JobLevel = L_INCREMENTAL; /* Take Full+Diff+Incr */
          db_get_accurate_jobids(jcr, jcr->db, &jr, &jobids);
 
+         if (jobids.count == 1) {
+            /* It's better to keep the input, we might already have copy/vf jobs */
+            jobids.reset();
+            jobids.add(jcr->JobIds);
+         }
+
       } else if (sel.set_string(jcr->JobIds, true)) {
          /* Found alljobid keyword */
          if (jcr->use_all_JobIds) {
@@ -222,8 +218,13 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n")
       return false;
    }
    if (jobids.count == 1) {
-      Jmsg(jcr, M_WARNING, 0, _("Only one Job found. Consolidation not needed.\n"));
-      return false;
+      if (jcr->JobIds && strcmp(jcr->JobIds, jobids.list) == 0) {
+         Jmsg(jcr, M_INFO, 0, _("Only one Job found in argument. Consolidation forced.\n"));
+
+      } else {
+         Jmsg(jcr, M_WARNING, 0, _("Only one Job found. Consolidation not needed.\n"));
+         return false;
+      }
    }
 
    /* Remove number of JobIds we want to keep */