Imported Upstream version 2.4.4p3
[debian/amanda] / docs / RESTORE
1 This document was originally written by Daniel Moore
2 <dmoore@jeffco.k12.co.us>, on Jan 12, 1998.  Substantially rewritten by
3 Alexandre Oliva <oliva@dcc.unicamp.br>.  Additional corrections and
4 additions from Murf <jam@philabs.research.philips.com> and Ralf Fassel
5 <ralf@atg.venture.de>.  It describes how to restore files backed up with
6 amanda either with or without amanda tools. 
7
8 All these cases assume you're trying to restore a complete disk, that
9 is, you've replaced the lost disk with a new one, or created a new
10 filesystem on it.  Tweaking with the arguments to restore (not
11 amrestore), you will be able to restore individual files.
12
13 Also, this text does not cover amrecover, a program that provides a
14 text user interface similar to interactive restore (restore -i), but
15 it allows you to select individual files to recover and automatically
16 determines the tapes where they were stored.  The backups must be
17 performed with the `index' option enabled for this to work.
18
19 I considered 6 cases.
20 1)  Client machine fails, non-system critical.
21 2)  Client machine fails, system critical disk.
22 3)  Server machine fails, non-system critical, non-amanda disk.
23 4)  Server machine fails, system critical, non-amanda disk.
24 5)  Server machine fails, non-system critical, amanda disk, with db.
25 6)  Server machine fails, non-system critical, amanda disk, with binaries.
26
27 The server machine (machine Aaron) is solaris, the client machine 
28 (machine Barney) is sunos.
29
30 Cases:
31
32 1)  Client machine fails, non-system critical. 
33 Example: /home fails on Barney.
34
35 First, use amadmin to find the tapes most recently used to backup the 
36 partition.
37
38 amadmin <config> info Barney '/home$'
39
40 Current info for Barney /home:
41   Stats: dump rates (kps), Full:   41.1,  33.1,  38.8
42                     Incremental:    9.5,   2.1,  24.7
43           compressed size, Full:  63.1%, 54.0%, 52.9%
44                     Incremental:  43.7%, 15.5%, 47.8%
45   Dumps: lev datestmp  tape             file   origK   compK secs
46           0  19971223  Barney01           16  329947  208032 5060
47           1  19980108  Barney16            8    1977     864   91
48           2  19971222  Barney06            7    1874     672   83
49           3  19970926  Barney03           11   12273    3040  211
50
51 This tells us that we will need two tapes to do a full restore
52 (Barney01, Barney16).  Note that, even if Barney06 and Barney03 are
53 listed, they are actually older than the full backup, so they should
54 not be used to restore any data.
55
56 Log into Barney.  Cd to the /home directory.  Insert the tape with the 
57 level 0 dump on it into the tape drive of Aaron.
58
59 Become super-user in the client host and run (replace <amanda> with
60 the username under which amanda runs):
61
62 rsh -n -l <amanda> Aaron amrestore -p /dev/rmt/0cn Barney '/home\$' |
63 restore -ivbf 2 -
64
65 This requires client root to have login access to <amanda>@Aaron, with
66 a .rhosts entry (.amandahosts won't do).  If you use ssh, you may be
67 able to type a password in order to be authenticated.  Another
68 alternative is to start the operation in the server, and rsh to the
69 client.  You should be the amanda user or root in the tape server and run:
70
71 amrestore -p /dev/rmt/0cn Barney '/home$' |
72 rsh Barney -l root /usr/etc/restore -ivbf 2 -
73
74 If you don't want to use rsh at all, you may run:
75
76 amrestore /dev/rmt/0cn Barney '/home$'
77
78 This should create a file whose name contains the hostname, directory
79 name, dump level and dump date of the backup.  Now you have to move
80 this file to the client somehow: you may use NFS, rcp, ftp, floppy
81 disks :-), whatever.  Suppose you rename that file to `home.0'.  Then,
82 on the client, you should become root and run:
83
84 restore -ivbf 2 home.0
85
86 Repeat one of these steps, incrementing the level of the dump, until
87 there are no more available backups.
88
89
90 2)  Client machine fails, system critical disk.
91 Example: / fails on Barney.
92
93 First of all, boot off the CD, and reinstall the system critical
94 partition, restoring it to vendor supplied state.  Then, go through all of
95 Scenario 1. 
96
97
98 3)  Server machine fails, non-system critical, non-amanda disk.
99
100 Proceed just as described in Scenario 1.  However, you won't have to go 
101 through the rsh process, because you can just use amrestore to 
102 replace the lost data directly.
103
104
105 4)  Server machine fails, system critical, non-amanda disk.
106 Example: / on Aaron
107
108 First of all, boot off the CD, and reinstall the system critical 
109 partition, restoring it to vendor supplied state.
110
111 Then, follow steps in Scenario 3.
112
113
114 5)  Server machine fails, non-system critical, amanda disk, with db.
115 An example: /opt on Aaron
116
117 If the disk that the amanda database is toast, then you need to rebuild 
118 the database.  The easiest way to do it is to take the text file that you 
119 had mailed to you via the 'amadmin export' command, and import via the 
120 'amadmin import' command.  Then you should be able to follow the steps 
121 outlined in Scenario 4.
122
123 Note that amanda does not mail the exported database automatically;
124 you may add this to the crontab entry that runs amanda.
125
126 Maybe it's a good idea to print out the text files as well and store the
127 last 2 dumpcycles worth of paper (the disc text files might have got
128 toasted as well).  From the paper you still are able to reconstruct where
129 your discs are.
130
131
132 6)  Server machine fails, non-system critical, amanda disk, with binaries.
133 Example: /usr/local on Aaron
134
135 This is where things get hairy.  If the disk with the amanda binaries on 
136 it is toast, you have three options.  
137
138 i) reinstall the amanda binaries from another tape, on which you have 
139 conveniently backed up the binaries within the last couple of weeks (not 
140 using amanda).
141
142 ii) recompile amanda, making sure not to overwrite your db files.
143
144 iii) use dd to read amanda formatted tapes.  This is the option I am 
145 going to explore most fully, because this seems the most likely to occur.
146
147 a) Find out the device name used by amanda, by looking in amanda.conf.  
148 Turns out to be /dev/rmt/0cn for this system.
149
150 If amanda.conf isn't at hand: this must be a non-rewinding tape device
151 specifier (which I believe the trailing `n' stands for).
152
153 b) Look over the copy of the output of 'amadmin <config> export', and find
154 out which tapes /usr/local was backed up on.
155
156 c) Grab the tapes that /opt was backed up on, and stick the level 0 into 
157 the drive.  cd to /usr/local.
158
159 d) Skip the first record, which is just the tape header, by using the
160 appropriate tape command.
161
162 mt -f /dev/rmt/0cn fsf 1
163
164 e) Now you want to start looking for /usr/local on this tape.
165
166 dd if=/dev/rmt/0cn bs=32k skip=1 | gzip -d | /usr/sbin/ufsrestore -ivf -
167 This command gives us an interactive restore of this record, including
168 telling us what partition, what host, and what level the backup was.  The
169 gzip -d portion of the pipe can be omitted if there was no compression. 
170
171 f) If you don't find /usr/local on the first try, quit ufsrestore, and move 
172 forward one record.
173 mt -f /dev/rmt/0cn fsf 1
174 and try the dd/restore command shown above.  Do this until you find /opt 
175 on the disk.
176
177 Another possibility: quick and dirty tape index in case you don't know
178 which partition /usr/local was on: (from ralf@atg.venture.de)
179
180 #!/bin/sh
181 TAPEDEV=</dev/nrtape>
182 while mt -f $TAPEDEV fsf 1 ; do
183   dd if=$TAPEDEV bs=32k count=1 | head -1
184   sleep 1
185 done
186
187 Example output:
188 AMANDA: FILE 19971220 uri /root-sun4 lev 1 comp .gz program DUMP
189 AMANDA: FILE 19971220 uri /misc lev 1 comp .gz program DUMP
190 AMANDA: FILE 19971220 uri / lev 1 comp .gz program DUMP
191
192 g) Restore the amanda binaries (what else do you need??), and then bail 
193 out of ufsrestore.  You can use amrestore, as in Scenario 3.