From 386901a26a4a4234584f16616fa90161f05e9089 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 13 Mar 2008 12:51:51 +0000 Subject: [PATCH] ebl Add AfterVSS option to RunsWhen runscript option git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6597 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/dird_conf.c | 4 +++- bacula/src/filed/job.c | 1 + bacula/src/lib/runscript.c | 14 ++++++++++++++ bacula/src/lib/runscript.h | 1 + bacula/technotes-2.3 | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 03d5933979..f5ff79e367 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -1729,10 +1729,12 @@ static void store_runscript_when(LEX *lc, RES_ITEM *item, int index, int pass) *(int *)(item->value) = SCRIPT_Before ; } else if (strcasecmp(lc->str, "after") == 0) { *(int *)(item->value) = SCRIPT_After; + } else if (strcasecmp(lc->str, "aftervss") == 0) { + *(int *)(item->value) = SCRIPT_AfterVSS; } else if (strcasecmp(lc->str, "always") == 0) { *(int *)(item->value) = SCRIPT_Any; } else { - scan_err2(lc, _("Expect %s, got: %s"), "Before, After or Always", lc->str); + scan_err2(lc, _("Expect %s, got: %s"), "Before, After, AfterVSS or Always", lc->str); } scan_to_eol(lc); } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index d8ee96eacc..345d1841d7 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1483,6 +1483,7 @@ static int backup_cmd(JCR *jcr) berrno be; Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror()); } + run_scripts(jcr, jcr->RunScripts, "ClientAfterVSS"); } #endif diff --git a/bacula/src/lib/runscript.c b/bacula/src/lib/runscript.c index 7eaae64e55..bac10eb985 100644 --- a/bacula/src/lib/runscript.c +++ b/bacula/src/lib/runscript.c @@ -116,6 +116,8 @@ int run_scripts(JCR *jcr, alist *runscripts, const char *label) if (strstr(label, NT_("Before"))) { when = SCRIPT_Before; + } else if (bstrcmp(label, NT_("ClientAfterVSS"))) { + when = SCRIPT_AfterVSS; } else { when = SCRIPT_After; } @@ -142,6 +144,18 @@ int run_scripts(JCR *jcr, alist *runscripts, const char *label) } } + if ((script->when & SCRIPT_AfterVSS) && (when & SCRIPT_AfterVSS)) { + if ((script->on_success && (jcr->JobStatus == JS_Blocked)) + || (script->on_failure && job_canceled(jcr)) + ) + { + Dmsg4(200, "runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n", + script->command, script->on_success, script->on_failure, + jcr->JobStatus ); + runit = true; + } + } + if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) { if ((script->on_success && (jcr->JobStatus == JS_Terminated)) || (script->on_failure && job_canceled(jcr)) diff --git a/bacula/src/lib/runscript.h b/bacula/src/lib/runscript.h index 921fc11ef2..3659246c7c 100644 --- a/bacula/src/lib/runscript.h +++ b/bacula/src/lib/runscript.h @@ -58,6 +58,7 @@ enum { SCRIPT_Never = 0, SCRIPT_After = (1<<0), /* AfterJob */ SCRIPT_Before = (1<<1), /* BeforeJob */ + SCRIPT_AfterVSS = (1<<2), /* BeforeJob and After VSS */ SCRIPT_Any = SCRIPT_Before | SCRIPT_After }; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index fa346df8f0..8b1916c299 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,8 @@ General: 13Mar08 +ebl Add RunsWhen = AfterVSS to runscript. You can execute a command + (restart an application) just after the VSS snapshot on windows. kes Don't zap dcr values during release_volume() as they might have the next Volume to be mounted. kes Fix AIX prototype. -- 2.39.5