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