]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
add bVarEstimate to let the FD knows this is an estimate and not a real backup
authorAlain Spineux <alain@baculasystems.com>
Wed, 14 Feb 2024 10:10:30 +0000 (11:10 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 21 Mar 2024 16:30:47 +0000 (17:30 +0100)
- some plugin need to know that this is an "estimate" command and not
  a "run" to not activate snapshot, mount, .......
- the winbmr plugin can avoid the collection of information and
  the mount of recovery operation.

bacula/src/dird/fd_cmds.c
bacula/src/dird/ua_cmds.c
bacula/src/filed/fd_plugins.c
bacula/src/filed/fd_plugins.h
bacula/src/filed/job.c
bacula/src/jcr.h

index e57e117b9497c22d00a5b385b9f608d75f360989..6b2df0671935931d53fb2cfaf559f2f19320adfb 100644 (file)
@@ -456,24 +456,25 @@ bool send_level_command(JCR *jcr)
    const char *accurate = jcr->accurate?"accurate_":"";
    const char *not_accurate = "";
    const char *rerunning = jcr->rerunning?" rerunning ":" ";
+   const char *estimate = jcr->estimate?" estimate ": "";
    /*
     * Send Level command to File daemon
     */
    switch (jcr->getJobLevel()) {
    case L_BASE:
-      fd->fsend(levelcmd, not_accurate, "base", rerunning, 0, "", "");
+      fd->fsend(levelcmd, not_accurate, "base", rerunning, 0, estimate, "");
       break;
    /* L_NONE is the console, sending something off to the FD */
    case L_NONE:
    case L_FULL:
-      fd->fsend(levelcmd, not_accurate, "full", rerunning, 0, "", "");
+      fd->fsend(levelcmd, not_accurate, "full", rerunning, 0, estimate, "");
       break;
    case L_DIFFERENTIAL:
-      fd->fsend(levelcmd, accurate, "differential", rerunning, 0, "", "");
+      fd->fsend(levelcmd, accurate, "differential", rerunning, 0, estimate, "");
       send_since_time(jcr);
       break;
    case L_INCREMENTAL:
-      fd->fsend(levelcmd, accurate, "incremental", rerunning, 0, "", "");
+      fd->fsend(levelcmd, accurate, "incremental", rerunning, 0, estimate, "");
       send_since_time(jcr);
       break;
    case L_SINCE:
index ae814d601c91933dfd5be4cfb992f42ccec7c651..cde63a752ac3196a09434991aabfd6161d667b24 100644 (file)
@@ -1419,6 +1419,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd)
    jcr->setJobType(JT_BACKUP);
    jcr->start_time = time(NULL);
    jcr->setJobLevel(L_FULL);
+   jcr->estimate = true;
 
    for (int i=1; i<ua->argc; i++) {
       if (strcasecmp(ua->argk[i], NT_("client")) == 0 ||
index 88e13f411152c409a6a87648370dcfbf41dab546..8d17d2d1a839c1d515836613d423f5afbc2bda5c 100644 (file)
@@ -2140,6 +2140,9 @@ static bRC baculaGetValue(bpContext *ctx, bVariable var, void *value)
    case bVarMinDedupBlockSize:
       *((int*)value) = jcr->min_dedup_block_size;
       break;
+   case bVarEstimate:
+      *((int*)value) = jcr->estimate?1:0;
+      break;
    case bVarFDName:             /* get warning with g++ if we missed one */
    case bVarWorkingDir:
    case bVarPluginDir:
index 23273886450739b34a5f6ff5877a44963b637b13..2eddc1bc5a84ad4964ccf9db5499287b07aea05b 100644 (file)
@@ -433,7 +433,8 @@ typedef enum {
   bVarMaxDedupBlockSize     = 25,
   bVarMinDedupBlockSize     = 26,
   bVarIsCanceled            = 27,
-  bVarSysConfigPath         = 28
+  bVarSysConfigPath         = 28,
+  bVarEstimate              = 29,
 } bVariable;
 
 /* Events that are passed to plugin */
index ade32e1a5a8ddf647c38133b5f44b08b9435ab04..751c192a32eb3a010201c1d2024e6248b79a9da2 100644 (file)
@@ -2660,6 +2660,9 @@ static int level_cmd(JCR *jcr)
    if (strstr(dir->msg, "rerunning")) {
       jcr->rerunning = true;
    }
+   if (strstr(dir->msg, "estimate")) {
+      jcr->estimate = true;
+   }
    if (sscanf(dir->msg, "level = %s ", level) != 1) {
       goto bail_out;
    }
index 9c4798a5afe0dac7e189549182f15ce0900e0d06..43ebd5681cbe574bcfece1e46663905fd3cd7f01 100644 (file)
@@ -464,6 +464,7 @@ public:
    bool use_all_JobIds;               /* Use all jobids present in command line */
    bool sd_client;                    /* This job runs as SD client */
    bool dummy_jobmedia;               /* Dummy JobMedia written */
+   bool estimate;                     /* if the job is an estimate instead of a run */
 #endif /* DIRECTOR_DAEMON */
 
 #ifdef FILE_DAEMON
@@ -527,6 +528,7 @@ public:
    alist *plugin_verify;              /* Registered plugins that need a copy of the data in verify job */
    alist *plugin_options_list;        /* list of the options to use in a job */
    alist *fileevents;                  /* list of the current file events to record and send to the DIR */
+   bool estimate;                     /* if the job is an estimate instead of a run */
 #endif /* FILE_DAEMON */
 
 
@@ -632,6 +634,9 @@ struct s_last_job {
    char Job[MAX_NAME_LENGTH];
 };
 
+union plugin_event_level {
+
+};
 extern struct s_last_job last_job;
 extern DLL_IMP_EXP dlist *last_jobs;