]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/clientrunaftervss.patch
ebl Use old LStat fields for deleted files (more simple)
[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 Index: src/dird/dird_conf.c
15 ===================================================================
16 --- src/dird/dird_conf.c        (révision 6325)
17 +++ src/dird/dird_conf.c        (copie de travail)
18 @@ -1688,10 +1688,12 @@
19        *(int *)(item->value) = SCRIPT_Before ;
20     } else if (strcasecmp(lc->str, "after") == 0) {
21        *(int *)(item->value) = SCRIPT_After;
22 +   } else if (strcasecmp(lc->str, "aftervss") == 0) {
23 +      *(int *)(item->value) = SCRIPT_AfterVSS;
24     } else if (strcasecmp(lc->str, "always") == 0) {
25        *(int *)(item->value) = SCRIPT_Any;
26     } else {
27 -      scan_err2(lc, _("Expect %s, got: %s"), "Before, After or Always", lc->str);
28 +      scan_err2(lc, _("Expect %s, got: %s"), "Before, After, AfterVSS or Always", lc->str);
29     }
30     scan_to_eol(lc);
31  }
32 Index: src/filed/job.c
33 ===================================================================
34 --- src/filed/job.c     (révision 6325)
35 +++ src/filed/job.c     (copie de travail)
36 @@ -1445,6 +1445,7 @@
37           berrno be;
38           Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror());
39        } 
40 +      run_scripts(jcr, jcr->RunScripts, "ClientAfterVSS");
41     }
42  #endif
43  
44 Index: src/lib/runscript.h
45 ===================================================================
46 --- src/lib/runscript.h (révision 6325)
47 +++ src/lib/runscript.h (copie de travail)
48 @@ -58,6 +58,7 @@
49     SCRIPT_Never  = 0,
50     SCRIPT_After  = (1<<0),      /* AfterJob */
51     SCRIPT_Before = (1<<1),      /* BeforeJob */
52 +   SCRIPT_AfterVSS = (1<<2),   /* BeforeJob and After VSS */
53     SCRIPT_Any    = SCRIPT_Before | SCRIPT_After
54  };
55  
56 Index: src/lib/runscript.c
57 ===================================================================
58 --- src/lib/runscript.c (révision 6325)
59 +++ src/lib/runscript.c (copie de travail)
60 @@ -116,6 +116,8 @@
61  
62     if (strstr(label, NT_("Before"))) {
63        when = SCRIPT_Before;
64 +   } else if (bstrcmp(label, NT_("ClientAfterVSS"))) {
65 +      when = SCRIPT_AfterVSS;
66     } else {
67        when = SCRIPT_After;
68     }
69 @@ -142,6 +144,18 @@
70           }
71        }
72  
73 +      if ((script->when & SCRIPT_AfterVSS) && (when & SCRIPT_AfterVSS)) {
74 +         if ((script->on_success && (jcr->JobStatus == JS_Blocked))
75 +            || (script->on_failure && job_canceled(jcr))
76 +            )
77 +         {
78 +            Dmsg4(200, "runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n", 
79 +                  script->command, script->on_success, script->on_failure,
80 +                  jcr->JobStatus );
81 +            runit = true;
82 +         }
83 +      }
84 +
85        if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) {
86           if ((script->on_success && (jcr->JobStatus == JS_Terminated))
87               || (script->on_failure && job_canceled(jcr))