]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/fd_checkchanges.patch
ebl Add checkchanges fileset feature works with 2.1.4
[bacula/bacula] / bacula / patches / testing / fd_checkchanges.patch
1 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/dird/inc_conf.c bacula/src/dird/inc_conf.c
2 --- bacula.org/src/dird/inc_conf.c      2007-02-17 18:11:27.000000000 +0100
3 +++ bacula/src/dird/inc_conf.c  2007-02-17 17:47:16.000000000 +0100
4 @@ -120,6 +120,7 @@
5     {"noatime",         store_opts,    {0},     0, 0, 0},
6     {"enhancedwild",    store_opts,    {0},     0, 0, 0},
7     {"drivetype",       store_drivetype, {0},     0, 0, 0},
8 +   {"checkchanges",    store_opts,    {0},     0, 0, 0},
9     {NULL, NULL, {0}, 0, 0, 0}
10  };
11  
12 @@ -145,7 +146,8 @@
13     INC_KW_IGNORECASE,
14     INC_KW_HFSPLUS,
15     INC_KW_NOATIME,
16 -   INC_KW_ENHANCEDWILD
17 +   INC_KW_ENHANCEDWILD,
18 +   INC_KW_CHKCHANGES
19  };
20  
21  /*
22 @@ -174,6 +176,7 @@
23     {"hfsplussupport", INC_KW_HFSPLUS},
24     {"noatime",     INC_KW_NOATIME},
25     {"enhancedwild", INC_KW_ENHANCEDWILD},
26 +   {"checkchanges", INC_KW_CHKCHANGES},
27     {NULL,          0}
28  };
29  
30 @@ -239,6 +242,8 @@
31     {"no",       INC_KW_NOATIME,       "0"},
32     {"yes",      INC_KW_ENHANCEDWILD,  "K"},
33     {"no",       INC_KW_ENHANCEDWILD,  "0"},
34 +   {"yes",      INC_KW_CHKCHANGES,    "c"},
35 +   {"no",       INC_KW_CHKCHANGES,    "0"},
36     {NULL,       0,                      0}
37  };
38  
39 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/filed/backup.c bacula/src/filed/backup.c
40 --- bacula.org/src/filed/backup.c       2007-02-17 18:11:28.000000000 +0100
41 +++ bacula/src/filed/backup.c   2007-02-17 18:37:19.000000000 +0100
42 @@ -454,6 +454,11 @@
43  
44        stat = send_data(jcr, data_stream, ff_pkt, digest, signing_digest);
45        bclose(&ff_pkt->bfd);
46 +
47 +      if (ff_pkt->flags & FO_CHKCHANGES) {
48 +        file_have_changed(jcr, ff_pkt);
49 +      }
50 +      
51        if (!stat) {
52           return 0;
53        }
54 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/filed/job.c bacula/src/filed/job.c
55 --- bacula.org/src/filed/job.c  2007-02-17 18:11:28.000000000 +0100
56 +++ bacula/src/filed/job.c      2007-02-17 18:37:19.000000000 +0100
57 @@ -1021,6 +1021,9 @@
58        case 'K':
59           fo->flags |= FO_NOATIME;
60           break;
61 +      case 'c':
62 +         fo->flags |= FO_CHKCHANGES;
63 +         break;
64        default:
65           Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *p);
66           break;
67 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/findlib/find.h bacula/src/findlib/find.h
68 --- bacula.org/src/findlib/find.h       2007-02-17 18:11:57.000000000 +0100
69 +++ bacula/src/findlib/find.h   2007-02-17 14:07:59.000000000 +0100
70 @@ -107,6 +107,7 @@
71  #define FO_ENCRYPT      (1<<21)       /* Encrypt data stream */
72  #define FO_NOATIME      (1<<22)       /* Use O_NOATIME to prevent atime change */
73  #define FO_ENHANCEDWILD (1<<23)       /* Enhanced wild card processing */
74 +#define FO_CHKCHANGES   (1<<24)       /* Check if file have been modified during backup */
75  
76  struct s_included_file {
77     struct s_included_file *next;
78 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/findlib/find_one.c bacula/src/findlib/find_one.c
79 --- bacula.org/src/findlib/find_one.c   2007-02-17 18:11:57.000000000 +0100
80 +++ bacula/src/findlib/find_one.c       2007-02-17 18:08:37.000000000 +0100
81 @@ -181,6 +181,51 @@
82     return false;
83  }
84  
85 +/* check if a file have changed during backup and display an error */
86 +bool file_have_changed(JCR *jcr, FF_PKT *ff_pkt)
87 +{
88 +   struct stat statp;
89 +   Dmsg1(500, "file_have_changed fname=%s\n",ff_pkt->fname);
90 +
91 +   if (ff_pkt->type != FT_REG) { /* not a regular file */
92 +      return false;
93 +   }
94 +
95 +   if (lstat(ff_pkt->fname, &statp) != 0) {
96 +      berrno be;
97 +      Jmsg(jcr, M_WARNING, 0, 
98 +          _("Can't check if %s have changed ERR=%s.\n"),ff_pkt->fname,be.strerror());
99 +      return true;
100 +   }
101 +
102 +   if (statp.st_mtime != ff_pkt->statp.st_mtime) {
103 +      /* TODO: add time of changes */
104 +      Jmsg(jcr, M_ERROR, 0, _("%s have changed during backup.\n"), ff_pkt->fname);
105 +      return true;
106 +   }
107 +
108 +   if (statp.st_ctime != ff_pkt->statp.st_ctime) {
109 +      /* TODO: add time of changes */
110 +      Jmsg(jcr, M_ERROR, 0, _("%s have changed during backup.\n"), ff_pkt->fname);
111 +      return true;
112 +   }
113 +  
114 +   if (statp.st_size != ff_pkt->statp.st_size) {
115 +      /* TODO: add size change */
116 +      Jmsg(jcr, M_ERROR, 0, _("%s size have changed during backup.\n"),ff_pkt->fname);
117 +      return true;
118 +   }
119 +
120 +   if ((statp.st_blksize*statp.st_blocks) != 
121 +       (ff_pkt->statp.st_blksize*ff_pkt->statp.st_blocks)) {
122 +      /* TODO: add size change */
123 +      Jmsg(jcr, M_ERROR, 0, _("%s size have changed during backup.\n"),ff_pkt->fname);
124 +      return true;
125 +   }
126 +
127 +   return false;
128 +}
129 +
130  /*
131   * Find a single file.
132   * handle_file is the callback for handling the file.
133 diff -Naur --exclude=qt-console --exclude=.svn --exclude='*~' bacula.org/src/findlib/protos.h bacula/src/findlib/protos.h
134 --- bacula.org/src/findlib/protos.h     2007-02-17 18:11:57.000000000 +0100
135 +++ bacula/src/findlib/protos.h 2007-02-17 12:34:18.000000000 +0100
136 @@ -65,7 +65,7 @@
137                 int handle_file(FF_PKT *ff_pkt, void *hpkt, bool top_level),
138                 void *pkt, char *p, dev_t parent_device, bool top_level);
139  int   term_find_one(FF_PKT *ff);
140 -
141 +bool  file_have_changed(JCR *jcr, FF_PKT *ff_pkt);
142  
143  /* From get_priv.c */
144  int enable_backup_privileges(JCR *jcr, int ignore_errors);