[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bacula-devel] exclude files by touching special file on client


Hello,

Well, totally by accident, I just now stumbled across the patch file for this 
feature, which I had not yet deleted.  So I have attached it to this email 
message.

Best regards,

Kern

On Tuesday 02 September 2008 17:54:30 Ulrich Leodolter wrote:
> Hello,
>
> i remember a patch on this (or users) list which
> allows exclude on client side by touching special
> files. e.g
>
> touch /private/.nobackup
>
> will exclude all files under /private
>
> the filename ".nobackup" could be specified by
> server side config option.
>
>
> anyone remembers this patch?
> is it in svn?
>
> ul


Index: src/dird/fd_cmds.c
===================================================================
--- src/dird/fd_cmds.c	(revision 6814)
+++ src/dird/fd_cmds.c	(working copy)
@@ -369,6 +369,9 @@
             if (fo->plugin) {
                fd->fsend("G %s\n", fo->plugin);
             }
+            if (fo->ignoredir) {
+               bnet_fsend(fd, "Z %s\n", fo->ignoredir);
+            }
             if (fo->reader) {
                fd->fsend("D %s\n", fo->reader);
             }
Index: src/dird/inc_conf.c
===================================================================
--- src/dird/inc_conf.c	(revision 6814)
+++ src/dird/inc_conf.c	(working copy)
@@ -58,6 +58,7 @@
 static void store_base(LEX *lc, RES_ITEM *item, int index, int pass);
 static void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass);
 static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass);
+static void store_ignoredir(LEX *lc, RES_ITEM *item, int index, int pass);
 static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass);
 static void setup_current_opts(void);
 
@@ -84,9 +85,10 @@
  *   name             handler     value    code flags default_value
  */
 static RES_ITEM newinc_items[] = {
-   {"file",            store_fname,   {0},      0, 0, 0},
-   {"plugin",          store_plugin_name,   {0},      0, 0, 0},
-   {"options",         options_res,   {0},      0, 0, 0},
+   {"file",            store_fname,       {0},      0, 0, 0},
+   {"plugin",          store_plugin_name, {0},      0, 0, 0},
+   {"ignoredir",       store_ignoredir,   {0},      0, 0, 0},
+   {"options",         options_res,       {0},      0, 0, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -604,6 +606,21 @@
    scan_to_eol(lc);
 }
 
+/* Store ignoredir info */
+static void store_ignoredir(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+   int token;
+
+   token = lex_get_token(lc, T_NAME);
+   if (pass == 1) {
+      /*
+       * Pickup reader command
+       */
+      res_incexe.current_opts->ignoredir = bstrdup(lc->str);
+   }
+   scan_to_eol(lc);
+}
+
 /* Store drivetype info */
 static void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass)
 {
Index: src/dird/dird_conf.h
===================================================================
--- src/dird/dird_conf.h	(revision 6814)
+++ src/dird/dird_conf.h	(working copy)
@@ -459,6 +459,7 @@
    alist drivetype;                   /* drive type limitation */
    char *reader;                      /* reader program */
    char *writer;                      /* writer program */
+   char *ignoredir;                   /* ignoredir string */
    char *plugin;                      /* plugin program */
 };
 
Index: src/filed/job.c
===================================================================
--- src/filed/job.c	(revision 6814)
+++ src/filed/job.c	(working copy)
@@ -321,6 +321,9 @@
             fo->base.destroy();
             fo->fstype.destroy();
             fo->drivetype.destroy();
+            if (fo->ignoredir != NULL) {
+               free(fo->ignoredir);
+            }
          }
          incexe->opts_list.destroy();
          incexe->name_list.destroy();
@@ -680,7 +683,7 @@
       }
       break;
    case '<':
-      Dmsg0(100, "Doing < include on client.\n");
+      Dmsg1(100, "Doing < of '%s' include on client.\n", p + 1);
       p++;                      /* skip over < */
       if ((ffd = fopen(p, "rb")) == NULL) {
          berrno be;
@@ -846,6 +849,11 @@
       set_options(current_opts, item);
       state = state_options;
       break;
+   case 'Z':
+      current_opts = start_options(ff);
+      current_opts->ignoredir = bstrdup(item);
+      state = state_options;
+      break;
    case 'D':
       current_opts = start_options(ff);
 //    current_opts->reader = bstrdup(item);
@@ -907,6 +915,9 @@
          for (k=0; k<fo->drivetype.size(); k++) {
             Dmsg1(400, "XD %s\n", (char *)fo->drivetype.get(k));
          }
+         if (fo->ignoredir) {
+            Dmsg1(400, "Z %s\n", fo->ignoredir);
+         }
       }
       dlistString *node;
       foreach_dlist(node, &incexe->name_list) {
Index: src/findlib/find.c
===================================================================
--- src/findlib/find.c	(revision 6814)
+++ src/findlib/find.c	(working copy)
@@ -280,6 +280,7 @@
       findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
       ff->flags = fo->flags;
       ff->GZIP_level = fo->GZIP_level;
+      ff->ignoredir = fo->ignoredir;
       ff->fstypes = fo->fstype;
       ff->drivetypes = fo->drivetype;
 
Index: src/findlib/find_one.c
===================================================================
--- src/findlib/find_one.c	(revision 6814)
+++ src/findlib/find_one.c	(working copy)
@@ -513,6 +513,28 @@
          }
       }
 
+      /*
+       * Ignore this directory and everything below if the file .nobackup
+       * (or what is defined for IgnoreDir in this fileset) exists
+       */
+      if (ff_pkt->ignoredir != NULL) {
+	 struct stat sb;
+	 char fname[MAXPATHLEN];
+
+	 if (strlen(ff_pkt->fname) + strlen("/") +
+	    strlen(ff_pkt->ignoredir) + 1 > MAXPATHLEN)
+	    return 1;	/* Is this wisdom? */
+
+	 strcpy(fname, ff_pkt->fname);
+	 strcat(fname, "/");
+	 strcat(fname, ff_pkt->ignoredir);
+	 if (stat(fname, &sb) == 0) {
+            Dmsg2(100, "Directory '%s' ignored (found %s)\n",
+	       ff_pkt->fname, ff_pkt->ignoredir);
+            return 1;      /* Just ignore this directory */
+	 }
+      }
+
       /* Build a canonical directory name with a trailing slash in link var */
       len = strlen(fname);
       link_len = len + 200;
Index: src/findlib/find.h
===================================================================
--- src/findlib/find.h	(revision 6814)
+++ src/findlib/find.h	(working copy)
@@ -44,6 +44,7 @@
 #endif
 
 #include <sys/file.h>
+#include <sys/param.h>
 #if HAVE_UTIME_H
 #include <utime.h>
 #else
@@ -158,6 +159,7 @@
    alist base;                        /* list of base names */
    alist fstype;                      /* file system type limitation */
    alist drivetype;                   /* drive type limitation */
+   char *ignoredir;                   /* ignore directories with this file */
 };
 
 
@@ -223,6 +225,7 @@
    uint32_t flags;                    /* backup options */
    int GZIP_level;                    /* compression level */
    int strip_path;                    /* strip path count */
+   char *ignoredir;                   /* ignore directories with this file */
    bool cmd_plugin;                   /* set if we have a command plugin */
    alist fstypes;                     /* allowed file system types */
    alist drivetypes;                  /* allowed drive types */
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilot Consulting.