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