6d16a6598bfb806885f4ba26281f660eeb540892
[debian/amanda] / docs / howto-filedriver.txt
1
2 Chapter 13. How to use the AMANDA file-driver
3 Prev  Part III. HOWTOs                   Next
4
5 -------------------------------------------------------------------------------
6
7 Chapter 13. How to use the AMANDA file-driver
8
9
10 Stefan G. Weichinger
11
12 Original text;XML-conversion;Updates
13 AMANDA Core Team
14 <sgw@amanda.org>
15 Table of Contents
16
17
18   Introduction
19
20   Possible_Uses
21
22   Setup
23
24
25         Basics
26
27
28   Recovery
29
30
31 Note
32
33 Refer to http://www.amanda.org/docs/howto-filedriver.html for the current
34 version of this document.
35 This document covers the use of the file-driver in AMANDA 2.4.3 and higher.
36 Examples given here have been taken from a SuSE-Linux-8.2-Pro-environment,
37 using AMANDA 2.4.4p1 and the snapshot 2.4.4p1-20031202. Please adjust paths,
38 configuration names and other parameters to your system.
39 Stefan G. Weichinger, November - December, 2003 ; minor updates in April, 2005.
40
41 Introduction
42
43 Since release 2.4.3 AMANDA supports the usage of a output driver called "file".
44 See man amanda, section OUTPUT DRIVERS, for more information on its
45 implementation. As the name suggests, this driver uses files as virtual (or
46 file) tapes. Once created and labeled, these file tapes can be selected and
47 changed with the standard tape-changer-interface of the AMANDA server.
48
49  Possible Uses
50
51
52 * test installations
53   You can easily explore the rich features of AMANDA on systems without tape
54   drives.
55 * cheap installations
56   Without buying a tape drive you can enjoy the benefits of AMANDA and backup
57   to a bunch of harddisks. You can create CD/DVD-sized backups which you can
58   burn onto optical disks later.
59 * disk-based installations
60   You can use the file-driver to backup onto a set of file tapes hosted on a
61   bunch of hard-disks or a RAID-system. Combined with another AMANDA-
62   configuration that dumps the file tapes to real tapes, you can provide
63   reliable backup with faster tapeless recovery. This is called "disk-to-disk-
64   to-tape"-backup by some people today.
65
66
67  Setup
68
69
70  Basics
71
72 This guide assumes you have setup the basic AMANDA-services as described in
73 Amanda_Installation_Notes
74 The configuration in this HOWTO is called "daily". The file tapes are also
75 called  vtapes in this document, which stands for "virtual tapes".
76 Please be sure to understand the differences between holding disks and file
77 tapes. The two serve different purposes; holding disks allow for parallelism of
78 multiple DLE's being backed up while file tapes are a replacement for physical
79 tapes.
80 Before beginning you will need to decide on (a) dedicated part(s) of your hard
81 disk(s) for your file tape storage. While this space could be spread among
82 several file systems and hard disks, I recommend to dedicate at least a
83 specific partition, better a specific physical harddisk to the task of keeping
84 your vtapes. The use of a dedicated disk will speed things up definitely.
85 The disk space you dedicate for your vtapes should NOT be backed up by AMANDA.
86 Also, for performance reasons there should be NO holding disks on the same
87 partition as the vtapes, preferably not even on the same physical drive.
88 If you only have one harddisk, it will work out, too, but you will suffer low
89 performance due to massive head-moving in your harddisk, resulting from copying
90 data between the filesystems.
91 Steps
92
93   1. Prepare the filesystem(s) used for the tapes.
94      Decide on where to put your files, create the appropriate partition(s) and
95      filesystem(s) and mount them.
96      In our example we have the dedicated partition hdc1, mounted on /
97      amandatapes for vtape storage.
98
99         $ mount
100         [...]
101         /dev/hdc1 on /amandatapes type reiserfs (rw)
102         [...]
103         
104
105      Make sure there is space left. 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
112      In our example we have 20GB diskspace left on /amandatapes.
113   2. Determine length and number of tapes
114      After deciding on the number of vtapes you want to create, evenly allocate
115      the available space among them.
116      Look at the following rule of thumb:
117      As many filesystems exhibit dramatically reduced performance when they are
118      nearly full I have chosen to allocate only 90% of the available space. So
119      we have:
120      (Available Space * 0.9) >= tapelength * tapecycle
121      This is a very conservative approach to make sure you don´t suffer any
122      performance drop due to a nearly-full-filesystem.
123      As it is uncommon for AMANDA to fill, or almost fill an entire tape you
124      may also wish to use more space than that.
125      So you could determine possible combinations of tapelength/tapecycle with
126      the more general formula:
127      Available Space >= tapelength * tapecycle
128      In our example we take the conservative approach:
129
130      * 20 GB * 0.9 = 18 GB to use
131        and so we could create the following combinations:
132
133
134      * 18 GB = 18 GB * 1
135      * 18 GB = 9 GB * 2
136      * 18 GB = 6 GB * 3
137      * 18 GB = 3 GB * 6
138      * 18 GB = ......... you get the picture.
139
140      Using only one tape is generally considered a bad idea when it comes to
141      backup, so we should use at least 3 tapes (for testing purposes), better 6
142      or more tapes.
143
144      * 18 GB = 3 GB * 6
145        so we get the value 3 GB for the tapelength if we want to use 6 tapes.
146
147   3. Create a tapetype definition.
148      Add a new tapetype definition similar to the following to your
149      amanda.conf. I named my definition "HARD-DISK". Choose whatever name you
150      consider appropriate.
151
152         define tapetype HARD-DISK {
153                 comment "Dump onto hard disk"
154                 length 3072 mbytes      # specified in mbytes to get the exact size of 3GB
155         }
156         
157
158      You don´t have to specify the parameter speed (as it is commonly listed in
159      tapetype definitions and reported by the program amtapetype). AMANDA does
160      not use this parameter right now.
161      There is also an optional parameter filemark, which indicates the amount
162      of space "wasted" after each tape-listitem. Leave it blank and AMANDA uses
163      the default of 1KB.
164   4. Think about tapechangers.
165      As you will use a set of vtapes, you have to also use a kind of vtape-
166      changer. There are several tape-changer-scripts included in the AMANDA-
167      tarball. Read more about tape-changer-scripts in AMANDA_Tape_Changer
168      Support.
169      Right now there are two scripts that can be used with vtapes. These
170      scripts take different approaches to the handling of tapes.
171      The script chg-multi handles many drives with a tape in each drive. The
172      script chg-disk handles a library with one drive and multiple tapes.
173      So with vtapes you could look at it this way:
174      chg-multi simulates multiple tape drives with one tape in each drive. chg-
175      disk simulates one tape-library with multiple tapes in.
176      As chg-multi exists for a much longer time than chg-disk, it is still used
177      in many AMANDA-vtape-installations.
178      chg-disk was introduced with the snapshot 20031202. Contrary to chg-multi,
179      which is a generic changer-script that must be somewhat adjusted to the
180      use of the file-driver, chg-disk offers exactly the behavior needed for
181      handling vtapes
182      IMHO the approach is much more logical, so I recommend to use chg-disk in
183      new AMANDA-vtape-installations.
184
185      Note
186
187      To use chg-disk you need to have at least amanda-2.4.4p1-20031202.
188      Choose the one that fits your way of vtape-handling and -maintenance.
189      In this HOWTO I only cover the use of chg-disk. Usage of chg-multi is
190      pretty similar and will maybe covered in a later version of this document.
191   5. Set up your tape-config.
192      In the general section you have to set the parameters tapecycle , tapetype
193      , tpchanger , changerfile , tapedev , rawtapedev and changerdev.
194      Example:
195
196                $ vi /usr/local/etc/amanda/daily/amanda.conf
197                ...
198
199                tapecycle 6
200                tapetype HARD-DISK
201                tpchanger "chg-disk"
202                changerfile "/usr/local/etc/amanda/daily/changer"
203         tapedev  "file:/amandatapes/daily"
204         
205
206      This reflects the use of your defined tapetype.
207      The parameter tapecycle tells AMANDA how much tapes can be used, Set this
208      value according to the number of tapes you want to use.
209      The parameter tapetype , points to the tapetype definition you have
210      created before.
211      The parameter tpchanger tells AMANDA to use the generic tape-changer-
212      script to handle the vtapes. You can think of it as a virtual tape-
213      changer-device.
214      The parameter changerfile is used to give chg-disk the "prefix" for the
215      "%s-changer, %s-clean, %s-slot" files it needs. Use something like
216      "changer" in your config-dir. Please note that this file does NOT have to
217      exist, but it won't hurt anyway.
218      The parameter tapedev tells the chg-disk-script where the root-dir for
219      your vtapes is.
220      In our example the vtape-files go to /amandatapes.
221      To separate multiple configurations, we decided to use subdirectories
222      according to the configuration name "daily".
223
224      Note
225
226      The parameter changerdev is NOT needed with chg-disk as it is not parsed
227      by chg-disk.
228   6. Create the virtual tapes.
229
230      Note
231
232      Gene Heskett has committed a shell-script which creates and labels the
233      vtapes in one step. Stefan G. Weichinger will generalize this script and
234      contribute it, this script will just read your settings in amanda.conf and
235      create the appropriate vtape-directories.
236      Now you have to create the tape-directories. chg-disk needs a directory
237      structure like:
238
239         slot_root_dir -|
240                        |- info
241                        |- data -> slot1/
242                        |- slot1/
243                        |- slot2/
244                        |- ...
245                        |- slotn/
246                 
247
248      where 'slot_root_dir' is the tapedev 'file:xxx' parameter and 'n' is the
249      tapecycle parameter.
250      So in our example we do:
251
252         $ mkdir /amandatapes/daily
253         
254
255      for the 'slot_root_dir' and
256
257         $ mkdir /amandatapes/daily/slot1
258         $ mkdir /amandatapes/daily/slot2
259         ....
260         
261
262      for the virtual slots that will later contain the vtapes.
263      If you have many vtapes to create and their names follow a pattern you may
264      be able to do them all with a single loop such as:
265
266                $ for n in 1 2 3 4 5 6 7 8 9 10 11 12
267                > do
268                >    mkdir /amandatapes/daily/slot${n}
269                > done
270         
271
272      Create the info-file:
273
274         $ touch /amandatapes/daily/info
275         
276
277      and link the first slot to the data-file (to "load" the vtape into the
278      first slot):
279
280         $ ln -s /amandatapes/daily/slot1 /amandatapes/daily/data
281         
282
283      Make sure the AMANDA-user has write-permissions on these directories:
284
285         $ chown -R amanda_user /amandatapes
286         $ chgrp -R amanda_group /amandatapes
287         $ chmod -R 750 /amandatapes
288         
289
290   7. Label the virtual tapes.
291      As the virtual tapes are handled just like physical tapes by the AMANDA-
292      Server they have to be labeled before use.
293
294         Usage: amlabel [-f] <conf> <label> [slot <slot-number>]
295         
296
297      Example:
298
299         $ amlabel daily daily1 slot 1
300         ....
301         $ amlabel daily daily2 slot 2
302         ....
303         
304
305      If you have many vtapes to label and their names follow a pattern you may
306      be able to do them all with a single loop such as:
307
308                $ for n in 1 2 3 4 5 6 7 8 9 10 11 12
309         > do
310         >    amlabel daily daily${n} slot ${n}
311         > done
312         
313
314      Label all your created tapes according to the "labelstr"-parameter in your
315      amanda.conf. Consult the amlabel-man-page for details.
316   8. Test your setup with amcheck.
317      Run amcheck daily (or, more general, amcheck <config>) and look for
318      anything AMANDA complains about.
319      A proper output looks like:
320
321         $ amcheck daily
322         Amanda Tape Server Host Check
323         --
324         Holding disk /amhold: 6924940 KB disk space available,
325         that's plenty
326         amcheck-server: slot 2: date 20031115 label daily02
327         (exact label match)
328         NOTE: skipping tape-writable test
329         Tape daily02 label ok
330         Server check took 0.377 seconds
331         
332
333      Recheck your files if errors occur.
334
335
336  Recovery
337
338 Recovering files from vtapes is very similar to recovering files from a "real"
339 tapechanger.
340 Make sure you read the chapter Restore.
341 I will simply paste a amrecover-session here (provided by JC Simonetti, author
342 of chg-disk):
343
344   # /usr/local/amanda/sbin/amrecover woo
345   AMRECOVER Version 2.4.4p3. Contacting server on backupserver.local ...
346   220 backupserver AMANDA index server (2.4.4p3) ready.
347   200 Access OK
348   Setting restore date to today (2004-10-08)
349   200 Working date set to 2004-10-08.
350   Scanning /BACKUP2/holding...
351   Scanning /BACKUP/holding...
352   200 Config set to woo.
353   200 Dump host set to backupserver.local.
354   Trying disk /tmp ...
355   $CWD '/tmp/RECOVER' is on disk '/tmp' mounted at '/tmp'.
356   200 Disk set to /tmp.
357   Invalid directory - /tmp/RECOVER
358   amrecover> sethost backupserver.local
359   200 Dump host set to backupserver.local.
360   amrecover> setdisk /
361   200 Disk set to /.
362   amrecover> cd /etc
363   /etc
364   amrecover> add passwd
365   Added /etc/passwd
366   amrecover> list
367   TAPE B3_14 LEVEL 0 DATE 2004-09-26
368           /etc/passwd
369   amrecover> extract
370
371   Extracting files using tape drive file:/BACKUP2/slots/ on host
372   backupserver.local. The following tapes are needed: B3_14
373
374   Restoring files into directory /tmp/RECOVER
375   Continue [?/Y/n]? Y
376
377   Extracting files using tape drive file:/BACKUP2/slots/ on host
378   backupserver.local. Load tape B3_14 now
379   Continue [?/Y/n/s/t]? Y
380   ./etc/passwd
381   amrecover> quit
382   200 Good bye.
383
384 Nothing spectacular? The trick is this:
385 When AMANDA asks you
386
387   Load tape B3_14 now Continue [?/Y/n/s/t]?
388
389 you have to run the following in a second terminal:
390
391   $ amtape woo slot 14
392   amtape: changed to slot 14 on file:/BACKUP2/slots/
393
394 This step is necessary to load the proper tape into your virtual changer.
395 Let me express this in a more general way:
396 When amrecover prompts for the tape it needs to restore the files you
397 requested, you have to "load" the tape it requests.
398 The recommended way to do this is to use amtape. The options that make sense in
399 this context are:
400
401   # amtape
402   Usage: amtape <conf> <command>
403           Valid commands are:
404                 [...]
405                   slot <slot #>        load tape from slot <slot #>
406                 [...]
407                   label <label>        find and load labeled tape
408                 [...]
409                 
410
411 If you know which slot contains the requested tape (for example, if you have
412 tape daily01 in slot 1, tape daily02 in slot 2, and so on) you may use the
413 first option. If you just know the label of the tape you need, use the second
414 option.
415 To continue the upper example:
416
417   amtape woo slot 14    # option 1 OR
418   amtape woo label B3_14        # option 2
419
420 amtape will return something like:
421
422   amtape: label B3_14 is now loaded.
423
424 After this you can return to your amrecover-session and continue restoring your
425 files.
426 Please be aware of the fact reported by JC Simonetti: " I have never never used
427 the "settape" command of amrecover [with chg-disk] since there's some problems
428 with it (tape not loaded correctly, or impossible to change from tape to tape
429 when restoring data shared accross multiple tapes...) "
430 -------------------------------------------------------------------------------
431
432 Prev                                 Up                    Next
433 Chapter 12. AMANDA on Cygwin HOWTO  Home  Chapter 14. AFS HOWTO
434