xref: /original-bsd/sbin/restore/restore.8 (revision 0c891ede)
15f8b5756Sbostic.\" Copyright (c) 1985, 1991, 1993
25f8b5756Sbostic.\"	The Regents of the University of California.  All rights reserved.
369d99d74Smckusick.\"
43c87ae62Strent.\" %sccs.include.redist.man%
5179758f1Sbostic.\"
6*0c891edeSmckusick.\"     @(#)restore.8	8.4 (Berkeley) 05/01/95
769d99d74Smckusick.\"
8b7238cd9Scael.Dd
9b7238cd9Scael.Dt RESTORE 8
10b7238cd9Scael.Os BSD 4
11b7238cd9Scael.Sh NAME
12b7238cd9Scael.Nm restore
13b7238cd9Scael.Nd "restore files or file systems from backups made with dump"
14b7238cd9Scael.Sh SYNOPSIS
15b7238cd9Scael.Nm restore
16*0c891edeSmckusick.Fl i
17*0c891edeSmckusick.Op Fl chmvy
18*0c891edeSmckusick.Op Fl b Ar blocksize
19*0c891edeSmckusick.Op Fl f Ar file
20*0c891edeSmckusick.Op Fl s Ar fileno
21*0c891edeSmckusick.Nm restore
22*0c891edeSmckusick.Fl R
23*0c891edeSmckusick.Op Fl cvy
24*0c891edeSmckusick.Op Fl b Ar blocksize
25*0c891edeSmckusick.Op Fl f Ar file
26*0c891edeSmckusick.Op Fl s Ar fileno
27*0c891edeSmckusick.Nm restore
28*0c891edeSmckusick.Fl r
29*0c891edeSmckusick.Op Fl cvy
30*0c891edeSmckusick.Op Fl b Ar blocksize
31*0c891edeSmckusick.Op Fl f Ar file
32*0c891edeSmckusick.Op Fl s Ar fileno
33*0c891edeSmckusick.Nm restore
34*0c891edeSmckusick.Fl t
35*0c891edeSmckusick.Op Fl chvy
36*0c891edeSmckusick.Op Fl b Ar blocksize
37*0c891edeSmckusick.Op Fl f Ar file
38*0c891edeSmckusick.Op Fl s Ar fileno
39*0c891edeSmckusick.Op file ...
40*0c891edeSmckusick.Nm restore
41*0c891edeSmckusick.Fl x
42*0c891edeSmckusick.Op Fl chmvy
43*0c891edeSmckusick.Op Fl b Ar blocksize
44*0c891edeSmckusick.Op Fl f Ar file
45*0c891edeSmckusick.Op Fl s Ar fileno
46*0c891edeSmckusick.Op file ...
47*0c891edeSmckusick.Pp
48*0c891edeSmckusick.in -\\n(iSu
49*0c891edeSmckusick(The
50*0c891edeSmckusick.Bx 4.3
51*0c891edeSmckusickoption syntax is implemented for backward compatibility, but
52*0c891edeSmckusickis not documented here.)
53b7238cd9Scael.Sh DESCRIPTION
5469d99d74SmckusickThe
55b7238cd9Scael.Nm restore
56b7238cd9Scaelcommand performs the inverse function of
57b7238cd9Scael.Xr dump 8 .
58b7238cd9ScaelA full backup of a file system may be restored and
59b7238cd9Scaelsubsequent incremental backups layered on top of it.
60b7238cd9ScaelSingle files and
61b7238cd9Scaeldirectory subtrees may be restored from full or partial
62b7238cd9Scaelbackups.
63b7238cd9Scael.Nm Restore
64c6e7b19cSmckusickworks across a network;
65c6e7b19cSmckusickto do this see the
66c6e7b19cSmckusick.Fl f
67c6e7b19cSmckusickflag described below.
68de843955SmckusickOther arguments to the command are file or directory
69de843955Smckusicknames specifying the files that are to be restored.
70de843955SmckusickUnless the
71*0c891edeSmckusick.Fl h
72*0c891edeSmckusickflag is specified (see below),
73de843955Smckusickthe appearance of a directory name refers to
74de843955Smckusickthe files and (recursively) subdirectories of that directory.
75b7238cd9Scael.Pp
76*0c891edeSmckusickExactly one of the following flags is required:
77b7238cd9Scael.Bl -tag -width Ds
78*0c891edeSmckusick.It Fl i
79*0c891edeSmckusickThis mode allows interactive restoration of files from a dump.
80*0c891edeSmckusickAfter reading in the directory information from the dump,
81*0c891edeSmckusick.Nm restore
82*0c891edeSmckusickprovides a shell like interface that allows the user to move
83*0c891edeSmckusickaround the directory tree selecting files to be extracted.
84*0c891edeSmckusickThe available commands are given below;
85*0c891edeSmckusickfor those commands that require an argument,
86*0c891edeSmckusickthe default is the current directory.
87*0c891edeSmckusick.Bl -tag -width Fl
88*0c891edeSmckusick.It Ic add Op Ar arg
89*0c891edeSmckusickThe current directory or specified argument is added to the list of
90*0c891edeSmckusickfiles to be extracted.
91*0c891edeSmckusickIf a directory is specified, then it and all its descendents are
92*0c891edeSmckusickadded to the extraction list
93*0c891edeSmckusick(unless the
94*0c891edeSmckusick.Fl h
95*0c891edeSmckusickflag is specified on the command line).
96*0c891edeSmckusickFiles that are on the extraction list are prepended with a ``*''
97*0c891edeSmckusickwhen they are listed by
98*0c891edeSmckusick.Ic ls .
99*0c891edeSmckusick.It Ic \&cd Ar arg
100*0c891edeSmckusickChange the current working directory to the specified argument.
101*0c891edeSmckusick.It Ic delete Op Ar arg
102*0c891edeSmckusickThe current directory or specified argument is deleted from the list of
103*0c891edeSmckusickfiles to be extracted.
104*0c891edeSmckusickIf a directory is specified, then it and all its descendents are
105*0c891edeSmckusickdeleted from the extraction list
106*0c891edeSmckusick(unless the
107*0c891edeSmckusick.Fl h
108*0c891edeSmckusickflag is specified on the command line).
109*0c891edeSmckusickThe most expedient way to extract most of the files from a directory
110*0c891edeSmckusickis to add the directory to the extraction list and then delete
111*0c891edeSmckusickthose files that are not needed.
112*0c891edeSmckusick.It Ic extract
113*0c891edeSmckusickAll the files that are on the extraction list are extracted
114*0c891edeSmckusickfrom the dump.
115*0c891edeSmckusick.Nm Restore
116*0c891edeSmckusickwill ask which volume the user wishes to mount.
117*0c891edeSmckusickThe fastest way to extract a few files is to
118*0c891edeSmckusickstart with the last volume, and work towards the first volume.
119*0c891edeSmckusick.It Ic help
120*0c891edeSmckusickList a summary of the available commands.
121*0c891edeSmckusick.It Ic \&ls Op Ar arg
122*0c891edeSmckusickList the current or specified directory.
123*0c891edeSmckusickEntries that are directories are appended with a ``/''.
124*0c891edeSmckusickEntries that have been marked for extraction are prepended with a ``*''.
125*0c891edeSmckusickIf the verbose
126*0c891edeSmckusickflag is set the inode number of each entry is also listed.
127*0c891edeSmckusick.It Ic pwd
128*0c891edeSmckusickPrint the full pathname of the current working directory.
129*0c891edeSmckusick.It Ic quit
130*0c891edeSmckusickRestore immediately exits,
131*0c891edeSmckusickeven if the extraction list is not empty.
132*0c891edeSmckusick.It Ic setmodes
133*0c891edeSmckusickAll the directories that have been added to the extraction list
134*0c891edeSmckusickhave their owner, modes, and times set;
135*0c891edeSmckusicknothing is extracted from the dump.
136*0c891edeSmckusickThis is useful for cleaning up after a restore has been prematurely aborted.
137*0c891edeSmckusick.It Ic verbose
138*0c891edeSmckusickThe sense of the
139*0c891edeSmckusick.Fl v
140*0c891edeSmckusickflag is toggled.
141*0c891edeSmckusickWhen set, the verbose flag causes the
142*0c891edeSmckusick.Ic ls
143*0c891edeSmckusickcommand to list the inode numbers of all entries.
144*0c891edeSmckusickIt also causes
145*0c891edeSmckusick.Nm restore
146*0c891edeSmckusickto print out information about each file as it is extracted.
147*0c891edeSmckusick.El
148*0c891edeSmckusick.It Fl R
149*0c891edeSmckusick.Nm Restore
150*0c891edeSmckusickrequests a particular tape of a multi volume set on which to restart
151*0c891edeSmckusicka full restore
152*0c891edeSmckusick(see the
153*0c891edeSmckusick.Fl r
154*0c891edeSmckusickflag below).
155*0c891edeSmckusickThis is useful if the restore has been interrupted.
156*0c891edeSmckusick.It Fl r
157b7238cd9ScaelRestore (rebuild a file system).
158b7238cd9ScaelThe target file system should be made pristine with
159b7238cd9Scael.Xr newfs 8 ,
160*0c891edeSmckusickmounted and the user
161b7238cd9Scael.Xr cd Ns 'd
162b7238cd9Scaelinto the pristine file system
163b7238cd9Scaelbefore starting the restoration of the initial level 0 backup. If the
164b7238cd9Scaellevel 0 restores successfully, the
165*0c891edeSmckusick.Fl r
166*0c891edeSmckusickflag may be used to restore
167b7238cd9Scaelany necessary incremental backups on top of the level 0.
168b7238cd9ScaelThe
169*0c891edeSmckusick.Fl r
170*0c891edeSmckusickflag precludes an interactive file extraction and can be
17195ecee29Smckusickdetrimental to one's health if not used carefully (not to mention
172b7238cd9Scaelthe disk). An example:
173b7238cd9Scael.Bd -literal -offset indent
1743c87ae62Strentnewfs /dev/rrp0g eagle
1753c87ae62Strentmount /dev/rp0g /mnt
176de843955Smckusickcd /mnt
177b7238cd9Scael
178b7238cd9Scaelrestore rf /dev/rst8
179b7238cd9Scael.Ed
180b7238cd9Scael.Pp
181de843955SmckusickNote that
182b7238cd9Scael.Nm restore
183de843955Smckusickleaves a file
184b7238cd9Scael.Pa restoresymtable
185de843955Smckusickin the root directory to pass information between incremental
186de843955Smckusickrestore passes.
187b7238cd9ScaelThis file should be removed when the last incremental has been
188de843955Smckusickrestored.
189b7238cd9Scael.Pp
190b7238cd9Scael.Nm Restore ,
191b7238cd9Scaelin conjunction with
192b7238cd9Scael.Xr newfs 8
193b7238cd9Scaeland
194b7238cd9Scael.Xr dump 8 ,
195b7238cd9Scaelmay be used to modify file system parameters
196b7238cd9Scaelsuch as size or block size.
197*0c891edeSmckusick.It Fl t
198*0c891edeSmckusickThe names of the specified files are listed if they occur
199*0c891edeSmckusickon the backup.
200*0c891edeSmckusickIf no file argument is given,
201*0c891edeSmckusickthen the root directory is listed,
202*0c891edeSmckusickwhich results in the entire content of the
203*0c891edeSmckusickbackup being listed,
204*0c891edeSmckusickunless the
205*0c891edeSmckusick.Fl h
206*0c891edeSmckusickflag has been specified.
207*0c891edeSmckusickNote that the
208*0c891edeSmckusick.Fl t
209*0c891edeSmckusickflag replaces the function of the old
210*0c891edeSmckusick.Xr dumpdir 8
211*0c891edeSmckusickprogram.
212*0c891edeSmckusick.ne 1i
213*0c891edeSmckusick.It Fl x
214b7238cd9ScaelThe named files are read from the given media.
215b7238cd9ScaelIf a named file matches a directory whose contents
216b7238cd9Scaelare on the backup
217de843955Smckusickand the
218*0c891edeSmckusick.Fl h
219*0c891edeSmckusickflag is not specified,
220de843955Smckusickthe directory is recursively extracted.
221de843955SmckusickThe owner, modification time,
222de843955Smckusickand mode are restored (if possible).
223de843955SmckusickIf no file argument is given,
224de843955Smckusickthen the root directory is extracted,
225de843955Smckusickwhich results in the entire content of the
226b7238cd9Scaelbackup being extracted,
227de843955Smckusickunless the
228*0c891edeSmckusick.Fl h
229*0c891edeSmckusickflag has been specified.
230b7238cd9Scael.El
231b7238cd9Scael.Pp
232*0c891edeSmckusickThe following additional options may be specified:
233b7238cd9Scael.Bl -tag -width Ds
234*0c891edeSmckusick.It Fl b Ar blocksize
235*0c891edeSmckusickThe number of kilobytes per dump record.
236b7238cd9ScaelIf the
237b7238cd9Scael.Fl b
238b7238cd9Scaeloption is not specified,
239b7238cd9Scael.Nm restore
240*0c891edeSmckusicktries to determine the block size dynamically.
241*0c891edeSmckusick.It Fl c
242*0c891edeSmckusickNormally,
243b7238cd9Scael.Nm restore
244*0c891edeSmckusickwill try to determine dynamically whether the dump was made from an
245*0c891edeSmckusickold (pre-4.4) or new format file sytem.  The
246*0c891edeSmckusick.Fl c
247*0c891edeSmckusickflag disables this check, and only allows reading a dump in the old
248*0c891edeSmckusickformat.
249*0c891edeSmckusick.It Fl f Ar file
250*0c891edeSmckusickRead the backup from
251*0c891edeSmckusick.Ar file ;
252*0c891edeSmckusick.Ar file
253*0c891edeSmckusickmay be a special device file
254*0c891edeSmckusicklike
255*0c891edeSmckusick.Pa /dev/rmt12
256*0c891edeSmckusick(a tape drive),
257*0c891edeSmckusick.Pa /dev/rsd1c
258*0c891edeSmckusick(a disk drive),
259*0c891edeSmckusickan ordinary file,
260*0c891edeSmckusickor
261*0c891edeSmckusick.Ql Fl
262*0c891edeSmckusick(the standard input).
263c6e7b19cSmckusickIf the name of the file is of the form
264c6e7b19cSmckusick.Dq host:file ,
265*0c891edeSmckusickor
266*0c891edeSmckusick.Dq user@host:file ,
267c6e7b19cSmckusick.Nm restore
268c6e7b19cSmckusickreads from the named file on the remote host using
269c6e7b19cSmckusick.Xr rmt 8 .
270b7238cd9Scael.Pp
271*0c891edeSmckusick.It Fl h
272*0c891edeSmckusickExtract the actual directory,
273784a5873Scaelrather than the files that it references.
274784a5873ScaelThis prevents hierarchical restoration of complete subtrees
275784a5873Scaelfrom the dump.
276*0c891edeSmckusick.It Fl m
277*0c891edeSmckusickExtract by inode numbers rather than by file name.
278784a5873ScaelThis is useful if only a few files are being extracted,
279784a5873Scaeland one wants to avoid regenerating the complete pathname
280784a5873Scaelto the file.
281*0c891edeSmckusick.It Fl s Ar fileno
282*0c891edeSmckusickRead from the specified
283*0c891edeSmckusick.Ar fileno
284*0c891edeSmckusickon a multi-file tape.
285*0c891edeSmckusickFile numbering starts at 1.
286*0c891edeSmckusick.It Fl v
2875a64dc6aSmckusickNormally
288b7238cd9Scael.Nm restore
2895a64dc6aSmckusickdoes its work silently.
2905a64dc6aSmckusickThe
291*0c891edeSmckusick.Fl v
2925a64dc6aSmckusick(verbose)
293*0c891edeSmckusickflag causes it to type the name of each file it treats
2945a64dc6aSmckusickpreceded by its file type.
295*0c891edeSmckusick.It Fl y
296*0c891edeSmckusickDo not ask the user whether to abort the restore in the event of an error.
297*0c891edeSmckusickAlways try to skip over the bad block(s) and continue.
298b7238cd9Scael.El
299b7238cd9Scael.Sh DIAGNOSTICS
300de843955SmckusickComplaints if it gets a read error.
301de843955SmckusickIf
302*0c891edeSmckusick.Fl y
303b7238cd9Scaelhas been specified, or the user responds
304b7238cd9Scael.Ql y ,
305b7238cd9Scael.Nm restore
306de843955Smckusickwill attempt to continue the restore.
307b7238cd9Scael.Pp
308b7238cd9ScaelIf a backup was made using more than one tape volume,
309b7238cd9Scael.Nm restore
310b7238cd9Scaelwill notify the user when it is time to mount the next volume.
311de843955SmckusickIf the
312*0c891edeSmckusick.Fl x
313de843955Smckusickor
314*0c891edeSmckusick.Fl i
315*0c891edeSmckusickflag has been specified,
316b7238cd9Scael.Nm restore
317de843955Smckusickwill also ask which volume the user wishes to mount.
318de843955SmckusickThe fastest way to extract a few files is to
319de843955Smckusickstart with the last volume, and work towards the first volume.
320b7238cd9Scael.Pp
321de843955SmckusickThere are numerous consistency checks that can be listed by
322b7238cd9Scael.Nm restore .
323de843955SmckusickMost checks are self-explanatory or can ``never happen''.
324de843955SmckusickCommon errors are given below.
325b7238cd9Scael.Pp
326b7238cd9Scael.Bl -tag -width Ds -compact
327b7238cd9Scael.It Converting to new file system format.
328de843955SmckusickA dump tape created from the old file system has been loaded.
329de843955SmckusickIt is automatically converted to the new file system format.
330b7238cd9Scael.Pp
331b7238cd9Scael.It <filename>: not found on tape
332de843955SmckusickThe specified file name was listed in the tape directory,
333de843955Smckusickbut was not found on the tape.
334de843955SmckusickThis is caused by tape read errors while looking for the file,
335de843955Smckusickand from using a dump tape created on an active file system.
336b7238cd9Scael.Pp
337b7238cd9Scael.It expected next file <inumber>, got <inumber>
338de843955SmckusickA file that was not listed in the directory showed up.
339b7238cd9ScaelThis can occur when using a dump created on an active file system.
340b7238cd9Scael.Pp
341b7238cd9Scael.It Incremental dump too low
342de843955SmckusickWhen doing incremental restore,
343b7238cd9Scaela dump that was written before the previous incremental dump,
344de843955Smckusickor that has too low an incremental level has been loaded.
345b7238cd9Scael.Pp
346b7238cd9Scael.It Incremental dump too high
347de843955SmckusickWhen doing incremental restore,
348b7238cd9Scaela dump that does not begin its coverage where the previous incremental
349b7238cd9Scaeldump left off,
350de843955Smckusickor that has too high an incremental level has been loaded.
351b7238cd9Scael.Pp
352b7238cd9Scael.It Tape read error while restoring <filename>
353b7238cd9Scael.It Tape read error while skipping over inode <inumber>
354b7238cd9Scael.It Tape read error while trying to resynchronize
355b7238cd9ScaelA tape (or other media) read error has occurred.
356de843955SmckusickIf a file name is specified,
357de843955Smckusickthen its contents are probably partially wrong.
358de843955SmckusickIf an inode is being skipped or the tape is trying to resynchronize,
359de843955Smckusickthen no extracted files have been corrupted,
360de843955Smckusickthough files may not be found on the tape.
361b7238cd9Scael.Pp
362b7238cd9Scael.It resync restore, skipped <num> blocks
363b7238cd9ScaelAfter a dump read error,
364b7238cd9Scael.Nm restore
365de843955Smckusickmay have to resynchronize itself.
366de843955SmckusickThis message lists the number of blocks that were skipped over.
367b7238cd9Scael.El
368b7238cd9Scael.Sh FILES
369b7238cd9Scael.Bl -tag -width "./restoresymtable" -compact
370b7238cd9Scael.It Pa /dev/rmt?
371b7238cd9Scaelthe default tape drive
372b7238cd9Scael.It Pa /tmp/rstdir*
373b7238cd9Scaelfile containing directories on the tape.
374b7238cd9Scael.It Pa /tmp/rstmode*
375b7238cd9Scaelowner, mode, and time stamps for directories.
376b7238cd9Scael.It Pa \&./restoresymtable
377b7238cd9Scaelinformation passed between incremental restores.
378b7238cd9Scael.El
379b7238cd9Scael.Sh SEE ALSO
380b7238cd9Scael.Xr dump 8 ,
381b7238cd9Scael.Xr newfs 8 ,
382b7238cd9Scael.Xr mount 8 ,
383c6e7b19cSmckusick.Xr mkfs 8 ,
384c6e7b19cSmckusick.Xr rmt 8
385b7238cd9Scael.Sh BUGS
386b7238cd9Scael.Nm Restore
387de843955Smckusickcan get confused when doing incremental restores from
388*0c891edeSmckusickdumps that were made on active file systems.
389b7238cd9Scael.Pp
390de843955SmckusickA level zero dump must be done after a full restore.
391de843955SmckusickBecause restore runs in user code,
392de843955Smckusickit has no control over inode allocation;
393*0c891edeSmckusickthus a full dump must be done to get a new set of directories
394de843955Smckusickreflecting the new inode numbering,
395de843955Smckusickeven though the contents of the files is unchanged.
396b7238cd9Scael.Sh HISTORY
397b7238cd9ScaelThe
398784a5873Scael.Nm restore
399b7238cd9Scaelcommand appeared in
400b7238cd9Scael.Bx 4.2 .
401