From: Alain Spineux Date: Wed, 14 Feb 2024 10:10:30 +0000 (+0100) Subject: add bVarEstimate to let the FD knows this is an estimate and not a real backup X-Git-Tag: Release-15.0.2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64298cd56ca9d5d2b1b8cd7d5b11ab03c9ad80f5;p=thirdparty%2Fbacula.git add bVarEstimate to let the FD knows this is an estimate and not a real backup - 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. --- diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index e57e117b9..6b2df0671 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -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: diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index ae814d601..cde63a752 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -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; iargc; i++) { if (strcasecmp(ua->argk[i], NT_("client")) == 0 || diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 88e13f411..8d17d2d1a 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -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: diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 232738864..2eddc1bc5 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -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 */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index ade32e1a5..751c192a3 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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; } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 9c4798a5a..43ebd5681 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -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;