]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/clientrunaftervss.patch
ebl First version of this patch, we need to handle VSS failure
[bacula/bacula] / bacula / patches / testing / clientrunaftervss.patch
1  Add a new runswhen directive ClientRunAfterVSS 
2  "Run After VSS snapshot, but before backup"
3
4  It can be applied to Bacula trunk (and probably earlier
5  2.2.x versions) with:
6
7  cd <bacula-source>
8  ./configure <your options>
9  patch -p0 <clientrunaftervss.patch
10  make
11  ...
12  make install
13
14
15
16 Index: src/lib/runscript.c
17 ===================================================================
18 --- src/lib/runscript.c (révision 5993)
19 +++ src/lib/runscript.c (copie de travail)
20 @@ -108,6 +108,8 @@
21  
22     if (strstr(label, NT_("Before"))) {
23        when = SCRIPT_Before;
24 +   } else if (bstrcmp(label, NT_("ClientRunAfterVSS"))) {
25 +      when = SCRIPT_AfterVSS;
26     } else {
27        when = SCRIPT_After;
28     }
29 @@ -134,6 +136,19 @@
30           }
31        }
32  
33 +      if ((script->when & SCRIPT_AfterVSS) && (when & SCRIPT_AfterVSS)) {
34 +         if ((script->on_success 
35 +            && (jcr->JobStatus == JS_Running || jcr->JobStatus == JS_Created))
36 +            || (script->on_failure && job_canceled(jcr))
37 +            )
38 +         {
39 +            Dmsg4(200, "runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n", 
40 +                  script->command, script->on_success, script->on_failure,
41 +                  jcr->JobStatus );
42 +            runit = true;
43 +         }
44 +      }
45 +
46        if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) {
47           if ((script->on_success && (jcr->JobStatus == JS_Terminated))
48               || (script->on_failure && job_canceled(jcr))
49 Index: src/lib/runscript.h
50 ===================================================================
51 --- src/lib/runscript.h (révision 5993)
52 +++ src/lib/runscript.h (copie de travail)
53 @@ -56,6 +56,7 @@
54     SCRIPT_Never  = 0,
55     SCRIPT_After  = (1<<0),      /* AfterJob */
56     SCRIPT_Before = (1<<1),      /* BeforeJob */
57 +   SCRIPT_AfterVSS = (1<<2),   /* BeforeJob and After VSS */
58     SCRIPT_Any    = SCRIPT_Before | SCRIPT_After
59  };
60  
61 Index: src/filed/job.c
62 ===================================================================
63 --- src/filed/job.c     (révision 5993)
64 +++ src/filed/job.c     (copie de travail)
65 @@ -1427,6 +1435,7 @@
66           berrno be;
67           Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror());
68        } 
69 +      script->run(jcr, "ClientRunAfterVSS");
70     }
71  #endif
72  
73 Index: src/dird/dird_conf.c
74 ===================================================================
75 --- src/dird/dird_conf.c        (révision 5993)
76 +++ src/dird/dird_conf.c        (copie de travail)
77 @@ -1682,10 +1682,12 @@
78        *(int *)(item->value) = SCRIPT_Before ;
79     } else if (strcasecmp(lc->str, "after") == 0) {
80        *(int *)(item->value) = SCRIPT_After;
81 +   } else if (strcasecmp(lc->str, "aftervss") == 0) {
82 +      *(int *)(item->value) = SCRIPT_AfterVSS;
83     } else if (strcasecmp(lc->str, "always") == 0) {
84        *(int *)(item->value) = SCRIPT_Any;
85     } else {
86 -      scan_err2(lc, _("Expect %s, got: %s"), "Before, After or Always", lc->str);
87 +      scan_err2(lc, _("Expect %s, got: %s"), "Before, After, AfterVSS or Always", lc->str);
88     }
89     scan_to_eol(lc);
90  }