Imported Upstream version 2.4.4p3
[debian/amanda] / docs / HOWTO-FILE-DRIVER
1 ---
2
3         AMANDA FILE-DRIVER-USAGE HOWTO.
4
5 ---
6
7         This document covers the use of the file-driver in AMANDA
8         2.4.3 and higher. Examples given here have been taken from a 
9         SuSe-Linux-8.2-Pro-environment, using AMANDA 2.4.4p1 and the
10         snapshot 2.4.4p1-20031202.
11
12         Please adjust paths, configuration names and other parameters 
13         to your system.
14
15         Stefan G. Weichinger, November - December, 2003
16
17 ---
18
19         Since release 2.4.3 AMANDA supports the usage of a output
20         driver called "file".  See the AMANDA-man page, section
21         OUTPUT DRIVERS, for more information on its implementation. 
22         As the name suggests, this driver uses files as virtual (or file)
23         tapes.  Once created and labeled, these file tapes can be selected
24         and changed with the standard tape-changer-interface of the AMANDA
25         server.
26
27 ---
28
29 POSSIBLE USES
30         
31 ---
32
33         - test installations.
34         You can easily explore the rich features of AMANDA on
35         systems without tape drives.
36         
37         - cheap installations.
38         Without buying a tape drive you can enjoy the benefits
39         of AMANDA and backup to a bunch of harddisks. You can
40         create CD/DVD-sized backups which you can burn onto optical 
41         disks later.
42         
43         - raid installations.
44         You can use the file-driver to backup onto a set of
45         file tapes hosted on a raid-system. Combined with
46         another AMANDA-configuration that dumps the file tapes to
47         real tapes, you can provide reliable backup with faster
48         tapeless recovery.
49         
50 ---
51
52 SETUP
53
54 ---
55
56 BASICS
57
58         This guide assumes you have setup the basic AMANDA-services
59         as described in the "INSTALL"-file.
60
61         The configuration in this HOWTO is called "daily".
62         The file tapes are also called "vtapes" in this document, which 
63         stands for "virtual tapes".
64
65         Please be sure to understand the differences between holding disks and
66         file tapes. The two serve different purposes; holding disks allow for
67         parallelism of multiple DLE's being backed up while file tapes are a 
68         replacement for physical tapes.
69
70         Before beginning you will need to decide on (a) dedicated part(s)
71         of your hard disk(s) for your file tape storage.  While this space
72         could be spread among several file systems and hard disks, I
73         recommend to dedicate at least a specific partition, better a specific 
74         physical harddisk to the task of keeping your vtapes.
75         The use of a dedicated disk will speed things up definitely.
76
77         The disk space you dedicate for your vtapes should NOT
78         be backed up by AMANDA.  Also, for performance reasons there
79         should be NO holding disks on the same partition as the
80         vtapes, preferably not even on the same physical drive.
81
82         If you only have one harddisk, it will work out, too, but
83         you will suffer low performance due to massive head-moving
84         in your harddisk, resulting from copying data between the
85         filesystems.
86
87 ---
88
89 STEPS
90
91 Step 0.  Prepare the filesystem(s) used for the tapes.
92
93         Decide on where to put your files, create the
94         appropriate partition(s) and filesystem(s) and mount them.
95
96         In our example we have the dedicated partition "hdc1", 
97         mounted on /amandatapes for vtape storage.
98
99         $ mount
100         ...
101         /dev/hdc1 on /amandatapes type reiserfs (rw)
102         ...
103
104         Make sure there is space left.
105         Determine the amount of space you will use.
106
107         $ df -h /amandatapes
108         Filesystem      Size  Used  Avail  Use%   Mounted on
109         /dev/hdc1        20G    0G    20G    0%   /amandatapes
110
111         In our example we have 20GB diskspace left on /amandatapes.
112
113 Step 1.  Determine length and number of tapes
114
115         After deciding on the number of vtapes you want to create,
116         evenly allocate the available space among them.
117
118         Look at the following rule of thumb:
119
120         As many types file systems exhibit dramatically reduced performance
121         when they are nearly full I have chosen to allocate
122         only 90% of the available space. So we have:
123
124         (Available Space * 0.9) >= tapelength * tapecycle
125
126
127         This is a very conservative approach to make sure you don´t suffer
128         any performance drop due to a nearly-full-filesystem.
129
130         As it is uncommon for AMANDA to fill, or almost fill an entire tape 
131         you may also wish to use more space than that.
132
133         So you could determine possible combinations of tapelength/tapecycle
134         with the more general formula:
135
136         Available Space >= tapelength * tapecycle
137
138
139         In our example we take the conservative approach:
140
141         20 GB * 0.9 = 18 GB to use and so we could create the
142         following combinations:
143
144         18 GB = 18 GB * 1
145         18 GB =  9 GB * 2
146         18 GB =  6 GB * 3
147         18 GB =  3 GB * 6
148         18 GB = .........   you get the picture. 
149
150         Using only one tape is generally considered a bad idea
151         when it comes to backup, so we should use at least 3
152         tapes (for testing purposes), better 6 or more tapes.
153
154         18 GB =  3 GB * 6   so we get the value 3GB for the
155         tapelength if we want to use 6 tapes.
156
157 Step 2.  Create a tapetype definition.
158
159         Add a new tapetype definition similar to the following to your amanda.conf.
160         I named my definition "HARD-DISK".  Choose whatever name you
161         consider appropriate.
162
163         define tapetype HARD-DISK {
164                 comment "Dump onto hard disk"
165                 length 3072 mbytes      # specified in mbytes to get the exact size of 3GB
166         }
167
168         You don´t have to specify the "speed"-parameter (as it is
169         commonly listed in tapetype definitions and reported by 
170         the program "amtapetype"). AMANDA does not use this parameter.
171
172         There is also an optional "filemark"-parameter, which indicates
173         the amount of space wasted after each tape-section. Leave it
174         blank and AMANDA uses the default of 1KB.
175
176 Step 3. Think about tapechangers. 
177
178         As you will use a set of vtapes, you have to also use a kind of vtape-changer.
179         There are several tape-changer-scripts included in the AMANDA-tarball.
180         Read more about tape-changer-scripts in TAPE.CHANGERS.
181
182         Right now there are two scripts that can be used with vtapes.
183         These scripts take different approaches to the handling of tapes.
184
185         The script chg-multi handles many drives with a tape in each drive.
186         The script chg-disk handles a library with one drive and multiple tapes.
187
188         So with vtapes you could look at it this way:
189
190         chg-multi simulates multiple tape drives with one tape in each drive.
191         chg-disk simulates one tape-library with multiple tapes in.
192
193         As chg-multi exists for a much longer time than chg-disk, it is still
194         used in many AMANDA-vtape-installations.
195
196         chg-disk was introduced with the snapshot 20031202.
197         Contrary to chg-multi, which is a generic changer-script that must
198         be somewhat adjusted to the use of the file-driver, chg-disk offers
199         exactly the behavior needed for handling vtapes
200
201         IMHO the approach is much more logical, so I recommend to use chg-disk
202         in new AMANDA-vtape-installations.
203
204         To use chg-disk you need to have at least amanda-2.4.4p1-20031202.
205
206         Choose the one that fits your way of vtape-handling and -maintenance.
207
208         In this HOWTO I only cover the use of chg-disk.
209         Usage of chg-multi is pretty similar and will maybe covered in a later
210         version of this document.
211
212 Step 4. Set up your tape-config.
213
214         In the general section you have to set the parameters tapecycle,
215         tapetype, tpchanger, changerfile, tapedev, rawtapedev and changerdev.
216
217         Example:
218
219         $ vi /usr/local/etc/amanda/daily/amanda.conf
220         ...
221
222         tapecycle 6
223         tapetype HARD-DISK
224         tpchanger "chg-disk"
225         changerfile "/usr/local/etc/amanda/daily/changer"
226         tapedev  "file:/amandatapes/daily"
227
228         This reflects the use of your defined tapetype.
229
230         The "tapecycle"-parameter tells AMANDA how much tapes can be used.
231         Set this value according to the number of tapes you want to use.
232
233         The "tapetype"-parameter points to the tapetype definition you have
234         created in Step 2.
235
236         The "tpchanger"-parameter tells AMANDA to use the generic
237         tape-changer-script to handle the virtual tapes. You
238         can think of it as a virtual tape-changer-device.
239
240         The "changerfile"-parameter is used to give chg-disk the "prefix"
241         for the "%s-changer, %s-clean, %s-slot" files it needs.
242         Use something like "changer" in your config-dir.
243         Please note that this file does NOT have to exist, but it won't
244         hurt anyway.
245
246         The "tapedev"-parameter tells the chg-disk-script where the 
247         root-dir for your vtapes is. 
248         In our example the vtape-files go to
249         /amandatapes, and to separate multiple configurations we decided
250         to use subdirectories according to the configuration name "daily".
251
252 Step 5. Create the virtual tapes.
253
254         Now you have to create the tape-directories. 
255         chg-disk needs a directory structure like:
256
257         slot_root_dir -|
258                        |- info
259                        |- data -> slot1/
260                        |- slot1/
261                        |- slot2/
262                        |- ...
263                        |- slotn/
264
265         where 'slot_root_dir' is the tapedev 'file:xxx' parameter 
266         and 'n' is the tapecycle parameter.
267
268         So in our example we do:
269
270         $ mkdir /amandatapes/daily
271
272         for the 'slot_root_dir' and
273
274         $ mkdir /amandatapes/daily/slot1
275         $ mkdir /amandatapes/daily/slot2
276         ....
277
278         for the virtual slots that will later contain the vtapes.
279
280         If you have many vtapes to create and their names follow a pattern
281         you may be able to do them all with a single loop such as:
282
283         $ for n in 1 2 3 4 5 6 7 8 9 10 11 12
284         > do
285         >    mkdir /amandatapes/daily/slot${n}
286         > done
287
288         Create the info-file:
289
290         $ touch /amandatapes/daily/info
291         
292         and link the first slot to the data-file (to "load" the vtape
293         in the first slot):
294
295         $ ln -s /amandatapes/daily/slot1 /amandatapes/daily/data
296
297         Make sure the AMANDA-user has write-permissions on these directories:
298
299         $ chown -R <amanda_user> /amandatapes
300         $ chgrp -R <amanda_group> /amandatapes
301         $ chmod -R 750 /amandatapes
302
303 Step 8. Label the virtual tapes.
304
305         As the virtual tapes are handled just like physical
306         tapes by the AMANDA-Server they have to be labeled
307         before use.
308
309         Usage: amlabel [-f] <conf> <label> [slot <slot-number>]
310
311         Example:
312
313         $ amlabel daily daily1 slot 1
314         ....
315         $ amlabel daily daily2 slot 2
316         ....
317
318         If you have many vtapes to label and their names follow a pattern
319         you may be able to do them all with a single loop such as:
320
321         $ for n in 01 02 03 04 05 06 07 08 09 10 11 12
322         > do
323         >    amlabel daily daily${n} slot ${n}
324         > done
325
326         Label all your created tapes according to the
327         "labelstr"-parameter in your amanda.conf.  Consult the
328         amlabel-man-page for details.
329
330 Step 9. Test your setup with amcheck.
331
332         Run amcheck daily (or, more general, amcheck <config>)
333         and look for anything AMANDA complains about.
334
335         A proper output looks like:
336
337         $ amcheck daily
338         Amanda Tape Server Host Check
339         -----------------------------
340         Holding disk /amhold: 6924940 KB disk space available,
341         that's plenty
342         amcheck-server: slot 2: date 20031115 label daily02
343         (exact label match)
344         NOTE: skipping tape-writable test
345         Tape daily02 label ok
346         Server check took 0.377 seconds
347
348         Recheck your files if errors occur.
349
350 ----
351
352
353 THAT'S IT!  YOU ARE READY TO RUN, UNLESS WE FORGOT
354 SOMETHING.  PLEASE send mail to amanda-users@amanda.org if
355 you have any comments or questions.  We're not afraid of
356 negative reviews, so let us have it!