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