Imported Upstream version 2.5.1
[debian/amanda] / docs / exclude.txt
1
2          Chapter 3. Excluding
3 Prev  Part I. Installation  Next
4
5 -------------------------------------------------------------------------------
6
7 Chapter 3. Excluding
8
9
10 Andrew Hall
11
12 Original text
13
14 Stefan G. Weichinger
15
16 XML-conversion;Updates
17 AMANDA Core Team
18 <sgw@amanda.org>
19 Table of Contents
20
21
22   Introduction
23
24   Please_Read
25
26   Before_We_Begin
27
28   Choosing_an_exclude_mechanism
29
30
31         Exclude_Mechanisms
32
33
34   Expression
35
36   Wildcard_Expansion
37
38   Troubleshooting
39
40
41         Broken_gnutar?
42
43         The_ps_command_is_your_friend.
44
45
46
47 Note
48
49 Refer to http://www.amanda.org/docs/exclude.html for the current version of
50 this document.
51
52  Introduction
53
54 There are times when data needs to be excluded from a backup. When these times
55 arise be confident that Amanda has this capability. (Actually it's not Amanda,
56 it's tar.) There are three ways of excluding data in an Amanda backup:
57
58 * Exclude an individual item explicitly in the dumptype
59 * Utilize an "Exclude List"
60 * Do not include the data in the disklist
61
62 This document is based on Amanda 2.4.2 and some of this might not work with
63 older versions. This was compiled from my personal experience and with help
64 from the members of the amanda-users mailing list (mailto://amanda-
65 users@amanda.org) when I was originally setting this up, to whom I wish to
66 thank for all of their support.
67
68  Please Read
69
70 As far as I am able to tell the only way to exclude files or directories with
71 Amanda is to use GNU-tar as the dump program (others?). The file system dump
72 programs provided with unix systems (e.g. dump, ufsdump) get data at a raw
73 drive level and generally do not allow exclusion of specific files or
74 directories.
75 The GNU version of tar, (GNU-tar or gtar), reads its data at a file system, (or
76 higher), level and does include the option to exclude specific files and/or
77 directories. It should be mentioned here that tar will change the access times
78 on files. Tar has the ability to preserve the access times however, doing so
79 effectively disables incremental backups since resetting the access time alters
80 the inode change time, which in turn causes the file to look like it needs to
81 be archived again.
82 The only exception that I am aware of is to just not include the data in
83 question in the disklist. This option may not be suitable for everyone's needs
84 and can confuse the issue some, so I have elected to include this mechanism in
85 its own section named Do_not_include_the_data_in_the_disklist.
86 For the purpose of this document an Amanda backup configuration named "exclude-
87 test" will be used. The machine that contains the tape drive which receives
88 data to be archived will be referred to as "SERVER". The machine that data is
89 being archived from will be referred to as "CLIENT". These two systems are
90 usually different machines but are not required to be, and may be the same
91 machine. Parts of this setup are on the server and some are on the client.
92
93 Note
94
95 When Amanda attempts to exclude a file or directory it does so relative to the
96 area being archived. For example if /var is in your disklist and you want to
97 exclude /var/log/somefile, then your exclude file would contain ./log/somefile.
98 You may use one exclude file in multiple dumptypes without any restriction.
99
100  Before We Begin
101
102 The first step that should be taken is to verify that backups are currently
103 working. Connect to SERVER and run amcheck as your Amanda user, to verify that
104 there are no errors in the current setup.
105
106   $ amcheck -cl CLIENT
107
108 Output should look something like below for success:
109
110         Amanda Tape Server Host Check
111         -----------------------------
112
113         /path/to/holding-disk: 4771300 KB disk space available, that's plenty.
114         Amanda Backup Client Hosts Check
115         --------------------------------
116         Client check: 1 host checked in 0.084 seconds, 0 problems found.
117
118 Next make sure that GNU-tar is the dump program currently in use. The easiest
119 way to tell if your dumptype is using gnutar is to run the following:
120
121   $ amadmin exclude-test disklist CLIENT
122
123 Among all the output is the "program" value currently in use. This value is
124 also specified with the "program" option in the dumptype. If the dumptype has
125 the line "program GNUTAR" your setup should be ready to exclude data.
126 If GNU-tar is not in use add the line "program GNUTAR" to the dumptype, and
127 then run amcheck again to verify that backups should work. The capitalization
128 of GNUTAR is required.
129 The dumptype should look something like:
130
131   define dumptype exclude-test {
132   comment "test dumptype for documentation"
133   priority high
134   program "GNUTAR"
135   }
136
137
138  Choosing an exclude mechanism
139
140 If the need is to exclude only one file or directory then the easiest way to
141 accomplish this is to exclude an individual item explicitly in the dumptype. If
142 the need is to exclude multiple files or directories then use an Exclude List.
143
144  Exclude Mechanisms
145
146
147  Exclude an individual item explicitly in the dumptype
148
149 The easiest way to exclude a file or directory is to specify it with the
150 "exclude" option in the dumptype. This option accepts an argument of the file
151 or directory to be excluded. Amanda allows only one exclude option in any
152 dumptype at a time.
153
154 Note
155
156 UPDATE: Recent Amanda-releases bring the option "exclude append" which enables
157 the administrator to define more than one exclusion-pattern within one dumptype
158 without using a exclude-list. Please look at the amanda.conf.5-manpage for
159 details.
160 Any path specified to be excluded must be encapsulated with quotes. Continuing
161 with our example from above /var/log/somefile and using the same dumptype as
162 above, the dumptype would now look like:
163
164   define dumptype exclude-test {
165   comment "test dumptype for documentation"
166   priority high
167   program "GNUTAR"
168   exclude "./log/somefile"
169   }
170
171 Next run amcheck again to verify that there are no problems with the revised
172 Amanda configuration. If the data is not being excluded as expected please see
173 the Troubleshooting section below. This completes the setup of excluding an
174 individual item in the dumptype.
175
176  Utilize an Exclude List
177
178 An exclude list is a file that resides on the CLIENT machine and contains paths
179 to be excluded, one per line. This file can be in any location on the CLIENT so
180 long as the same path is specified in the dumptype. Some find /usr/local/etc/
181 amanda an appropriate location, but it is up to you. I personally like to have
182 a subdirectory for exclude files but it is up to you where you place this file.
183 The exclude file may also be placed in the area being archived. This is an easy
184 way to have a different exclusion file for each disklist entry without needing
185 separate dumptype definitions. To use this technique, enter a path relative to
186 the area being archived as the exclude file below instead of an absolute path.
187 Connect to CLIENT and create the exclude directory as root. For example:
188
189   $ mkdir -p /usr/local/etc/amanda/exclude
190   $ cd /usr/local/etc/amanda/exclude
191
192 Next create the exclude list for Amanda to use. You can name the exclude file
193 anything you wish it to be. Create a file, and in this file place all paths to
194 files and directories that are to be excluded. Keeping with the /var example,
195 assume that /var/log/XFree86.0.log, and /var/log/maillog need to be excluded.
196 Remember that all paths are relative. The exclude list would look like:
197
198   ./log/XFree86.0.log
199   ./log/maillog
200
201 Make sure that permissions are restricted on this file. Run the following as
202 root, where exclude-filename is the name of the file you just created. For
203 example:
204
205   $ chmod 644 /usr/local/etc/amanda/exclude/exclude-filename
206
207 This concludes the necessary configuration on the client.
208 Connect to SERVER and cd to the exclude-test Amanda configuration directory.
209 Edit the Amanda configuration file e.g. amanda.conf. Add an entry similar to
210 the following line, to the dumptype for the client in question, where the
211 exclude-filename is the file that was created on CLIENT in the step above
212 including the quotes. For example:
213
214   exclude list "/usr/local/etc/amanda/exclude/exclude-filename"
215
216 The new dumptype should look something like:
217
218   define dumptype exclude-test{
219   comment "test dumptype for documentation"
220   priority high
221   program "GNUTAR"
222   exclude list "/usr/local/etc/amanda/exclude/exclude-filename"
223   }
224
225 Save the file. Run amcheck again to verify that there are no problems with the
226 revised Amanda configuration. If amcheck succeeds then run amdump to verify the
227 data is being excluded correctly. If the data is not being excluded as expected
228 please see the Troubleshooting section below. This completes the setup of an
229 exclude list.
230
231  Do not include the data in the disklist
232
233 Amanda uses disklist entries to define which directories or partitions should
234 be archived. This allows us to exclude data by just not placing the data in
235 question in the disklist. Assume that there is a disk mounted on /example. The
236 directory /example has five subdirectories "a", "b", "c", "d", and "e". The
237 directories "a", "b", and "c" need to be archived, while "d" and "e" should
238 not. This can be accomplished by not specifying "d" and "e" in the disklist.
239 Using the same dumptype and host in the above examples the disklist would
240 contain:
241
242   CLIENT /examples/a    exclude-test
243   CLIENT /examples/b    exclude-test
244   CLIENT /examples/c    exclude-test
245
246 Run amcheck to verify that Amanda is working correctly. If the data is not
247 being excluded as expected please see the Troubleshooting section below. This
248 completes the setup of using a disklist to exclude data.
249
250  Expression
251
252 Quiz: what is the difference between the following entries in an exclude list?
253
254   ./foo
255   ./foo/
256   ./foo/*
257
258 case 1 : directory ./foo won't be in the backup image (that's what you want)
259 case 2 : matches nothing (don't use it) case 3 : directory ./foo will be in the
260 backup image but nothing below it.
261
262  Wildcard Expansion
263
264 Amanda has the ability to use wildcard expansion while excluding data as
265 implemented by tar(1). The only places that wildcard expansion is allowed is in
266 the "exclude" option in the dumptype, or in the exclude list. Some simple
267 examples:
268 Exclude any file or directory that ends in ".log" e.g. ppp.log, XFree86.0.log
269
270   ./*.log
271
272 Exclude any file or directory with the string "log" e.g. logfile, maillog,
273 syslog, ppp.log, XFree86.0.log
274
275   */*log*
276
277 Exclude any file or directory that starts with string "cron" and ends in ".gz"
278 e.g. cron.1.gz, cron.2.gz, log/cron.1.gz
279
280   ./*cron*.gz
281
282 The question mark can be used to specify a single character. e.g. log.1, log.2,
283 etc
284
285   ./log.?
286
287
288  Troubleshooting
289
290 If you find that you are having trouble getting the exclude patterns to match
291 correctly, check out this really cool script written by John R. Jackson.
292 ftp://gandalf.cc.purdue.edu/pub/amanda/gtartest-exclude
293 This script allows you to test your patterns before placing them in an exclude
294 list or in the dumptype. Instructions on how to run the script are included in
295 the script.
296
297  Broken gnutar?
298
299 There are versions of GNU-tar that do not correctly exclude data. Version 1.12
300 (plus the Amanda patches from http://www.amanda.org) are known to work
301 correctly, as does version 1.13.19 (and later). Anything else is questionable.
302
303 Note
304
305 UPDATE:Using GNU-tar 1.13.25 is recommended.
306
307  The ps command is your friend.
308
309 Connect to CLIENT and run a
310
311   ps ax | grep tar
312
313 (or
314
315   ps ef | grep tar
316
317 on Solaris)
318 to see exactly how the tar command is running. Look in the output for the --
319 exclude or --exclude-from options in the running tar process. For example:
320
321   $ ps ax | grep tar
322
323   ?        R      0:37 /bin/tar --create --directory /var
324   --listed-incremental /var/lib/amanda/gnutar-lists/CLIENTvar_0.new
325   --sparse --one-file-system --ignore-failed-read --totals --file
326   /dev/null --exclude-from=/usr/local/etc/amanda/exclude-test/exclude.var
327   .
328
329 In the above output notice the string "--exclude-from=". The string following
330 the "=" is the exclude file currently in use. If the string was "--exclude"
331 then the string following the "=" is the file or directory that is currently
332 set to be excluded.
333 Contact the amanda-users mailing list: mailto://amanda-users@amanda.org.
334 Subscription information is available at http://www.amanda.org.
335 -------------------------------------------------------------------------------
336
337 Prev                                   Up                              Next
338 Chapter 2. Amanda Installation Notes  Home  Chapter 4. Indexing with Amanda
339