xref: /freebsd/sbin/restore/restore.8 (revision 64db83a8ab2d1f72a9b2174b39d2ef42b5b0580c)
1.\" Copyright (c) 1985, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)restore.8	8.4 (Berkeley) 5/1/95
33.\" $FreeBSD$
34.\"
35.Dd May 1, 1995
36.Dt RESTORE 8
37.Os BSD 4
38.Sh NAME
39.Nm restore ,
40.Nm rrestore
41.Nd "restore files or file systems from backups made with dump"
42.Sh SYNOPSIS
43.Nm restore
44.Fl i
45.Op Fl chkmNuvy
46.Op Fl b Ar blocksize
47.Op Fl f Ar file
48.Op Fl s Ar fileno
49.Nm restore
50.Fl R
51.Op Fl ckNuvy
52.Op Fl b Ar blocksize
53.Op Fl f Ar file
54.Op Fl s Ar fileno
55.Nm restore
56.Fl r
57.Op Fl ckNuvy
58.Op Fl b Ar blocksize
59.Op Fl f Ar file
60.Op Fl s Ar fileno
61.Nm restore
62.Fl t
63.Op Fl chkNuvy
64.Op Fl b Ar blocksize
65.Op Fl f Ar file
66.Op Fl s Ar fileno
67.Op file ...
68.Nm restore
69.Fl x
70.Op Fl chkmNuvy
71.Op Fl b Ar blocksize
72.Op Fl f Ar file
73.Op Fl s Ar fileno
74.Op file ...
75.Pp
76.in -\\n(iSu
77(The
78.Bx 4.3
79option syntax is implemented for backward compatibility, but
80is not documented here.)
81.Sh DESCRIPTION
82The
83.Nm restore
84command performs the inverse function of
85.Xr dump 8 .
86A full backup of a file system may be restored and
87subsequent incremental backups layered on top of it.
88Single files and
89directory subtrees may be restored from full or partial
90backups.
91.Nm Restore
92works across a network;
93to do this see the
94.Fl f
95flag described below.
96Other arguments to the command are file or directory
97names specifying the files that are to be restored.
98Unless the
99.Fl h
100flag is specified (see below),
101the appearance of a directory name refers to
102the files and (recursively) subdirectories of that directory.
103.Pp
104Exactly one of the following flags is required:
105.Bl -tag -width Ds
106.It Fl i
107This mode allows interactive restoration of files from a dump.
108After reading in the directory information from the dump,
109.Nm restore
110provides a shell like interface that allows the user to move
111around the directory tree selecting files to be extracted.
112The available commands are given below;
113for those commands that require an argument,
114the default is the current directory.
115.Bl -tag -width Fl
116.It Ic add Op Ar arg
117The current directory or specified argument is added to the list of
118files to be extracted.
119If a directory is specified, then it and all its descendents are
120added to the extraction list
121(unless the
122.Fl h
123flag is specified on the command line).
124Files that are on the extraction list are prepended with a ``*''
125when they are listed by
126.Ic ls .
127.It Ic \&cd Ar arg
128Change the current working directory to the specified argument.
129.It Ic delete Op Ar arg
130The current directory or specified argument is deleted from the list of
131files to be extracted.
132If a directory is specified, then it and all its descendents are
133deleted from the extraction list
134(unless the
135.Fl h
136flag is specified on the command line).
137The most expedient way to extract most of the files from a directory
138is to add the directory to the extraction list and then delete
139those files that are not needed.
140.It Ic extract
141All the files that are on the extraction list are extracted
142from the dump.
143.Nm Restore
144will ask which volume the user wishes to mount.
145The fastest way to extract a few files is to
146start with the last volume, and work towards the first volume.
147.It Ic help
148List a summary of the available commands.
149.It Ic \&ls Op Ar arg
150List the current or specified directory.
151Entries that are directories are appended with a ``/''.
152Entries that have been marked for extraction are prepended with a ``*''.
153If the verbose
154flag is set the inode number of each entry is also listed.
155.It Ic pwd
156Print the full pathname of the current working directory.
157.It Ic quit
158Restore immediately exits,
159even if the extraction list is not empty.
160.It Ic setmodes
161All the directories that have been added to the extraction list
162have their owner, modes, and times set;
163nothing is extracted from the dump.
164This is useful for cleaning up after a restore has been prematurely aborted.
165.It Ic verbose
166The sense of the
167.Fl v
168flag is toggled.
169When set, the verbose flag causes the
170.Ic ls
171command to list the inode numbers of all entries.
172It also causes
173.Nm restore
174to print out information about each file as it is extracted.
175.El
176.It Fl R
177.Nm Restore
178requests a particular tape of a multi volume set on which to restart
179a full restore
180(see the
181.Fl r
182flag below).
183This is useful if the restore has been interrupted.
184.It Fl r
185Restore (rebuild a file system).
186The target file system should be made pristine with
187.Xr newfs 8 ,
188mounted and the user
189.Xr cd Ns 'd
190into the pristine file system
191before starting the restoration of the initial level 0 backup.
192If the
193level 0 restores successfully, the
194.Fl r
195flag may be used to restore
196any necessary incremental backups on top of the level 0.
197The
198.Fl r
199flag precludes an interactive file extraction and can be
200detrimental to one's health if not used carefully (not to mention
201the disk). An example:
202.Bd -literal -offset indent
203newfs /dev/da0s1a
204mount /dev/da0s1a /mnt
205cd /mnt
206
207restore rf /dev/rsa0
208.Ed
209.Pp
210Note that
211.Nm restore
212leaves a file
213.Pa restoresymtable
214in the root directory to pass information between incremental
215restore passes.
216This file should be removed when the last incremental has been
217restored.
218.Pp
219.Nm Restore ,
220in conjunction with
221.Xr newfs 8
222and
223.Xr dump 8 ,
224may be used to modify file system parameters
225such as size or block size.
226.It Fl t
227The names of the specified files are listed if they occur
228on the backup.
229If no file argument is given,
230then the root directory is listed,
231which results in the entire content of the
232backup being listed,
233unless the
234.Fl h
235flag has been specified.
236Note that the
237.Fl t
238flag replaces the function of the old
239.Xr dumpdir 8
240program.
241.ne 1i
242.It Fl x
243The named files are read from the given media.
244If a named file matches a directory whose contents
245are on the backup
246and the
247.Fl h
248flag is not specified,
249the directory is recursively extracted.
250The owner, modification time,
251and mode are restored (if possible).
252If no file argument is given,
253then the root directory is extracted,
254which results in the entire content of the
255backup being extracted,
256unless the
257.Fl h
258flag has been specified.
259.El
260.Pp
261The following additional options may be specified:
262.Bl -tag -width Ds
263.It Fl b Ar blocksize
264The number of kilobytes per dump record.
265If the
266.Fl b
267option is not specified,
268.Nm restore
269tries to determine the media block size dynamically.
270.It Fl c
271Normally,
272.Nm restore
273will try to determine dynamically whether the dump was made from an
274old (pre-4.4) or new format file system.  The
275.Fl c
276flag disables this check, and only allows reading a dump in the old
277format.
278.It Fl f Ar file
279Read the backup from
280.Ar file ;
281.Ar file
282may be a special device file
283like
284.Pa /dev/rsa0
285(a tape drive),
286.Pa /dev/da1c
287(a disk drive),
288an ordinary file,
289or
290.Ql Fl
291(the standard input).
292If the name of the file is of the form
293.Dq host:file ,
294or
295.Dq user@host:file ,
296.Nm restore
297reads from the named file on the remote host using
298.Xr rmt 8 .
299.Pp
300.It Fl k
301Use Kerberos authentication when contacting the remote tape server.
302(Only available if this options was enabled when
303.Nm restore
304was compiled.)
305.Pp
306.It Fl h
307Extract the actual directory,
308rather than the files that it references.
309This prevents hierarchical restoration of complete subtrees
310from the dump.
311.It Fl m
312Extract by inode numbers rather than by file name.
313This is useful if only a few files are being extracted,
314and one wants to avoid regenerating the complete pathname
315to the file.
316.It Fl N
317Do the extraction normally, but do not actually write any changes
318to disk.
319This can be used to check the integrity of dump media
320or other test purposes.
321.It Fl s Ar fileno
322Read from the specified
323.Ar fileno
324on a multi-file tape.
325File numbering starts at 1.
326.It Fl u
327When creating certain types of files, restore may generate a warning
328diagnostic if they already exist in the target directory.
329To prevent this, the
330.Fl u
331(unlink) flag causes restore to remove old entries before attempting
332to create new ones.
333.It Fl v
334Normally
335.Nm restore
336does its work silently.
337The
338.Fl v
339(verbose)
340flag causes it to type the name of each file it treats
341preceded by its file type.
342.It Fl y
343Do not ask the user whether to abort the restore in the event of an error.
344Always try to skip over the bad block(s) and continue.
345.El
346.Sh DIAGNOSTICS
347Complaints if it gets a read error.
348If
349.Fl y
350has been specified, or the user responds
351.Ql y ,
352.Nm restore
353will attempt to continue the restore.
354.Pp
355If a backup was made using more than one tape volume,
356.Nm restore
357will notify the user when it is time to mount the next volume.
358If the
359.Fl x
360or
361.Fl i
362flag has been specified,
363.Nm restore
364will also ask which volume the user wishes to mount.
365The fastest way to extract a few files is to
366start with the last volume, and work towards the first volume.
367.Pp
368There are numerous consistency checks that can be listed by
369.Nm restore .
370Most checks are self-explanatory or can ``never happen''.
371Common errors are given below.
372.Pp
373.Bl -tag -width Ds -compact
374.It Converting to new file system format.
375A dump tape created from the old file system has been loaded.
376It is automatically converted to the new file system format.
377.Pp
378.It <filename>: not found on tape
379The specified file name was listed in the tape directory,
380but was not found on the tape.
381This is caused by tape read errors while looking for the file,
382and from using a dump tape created on an active file system.
383.Pp
384.It expected next file <inumber>, got <inumber>
385A file that was not listed in the directory showed up.
386This can occur when using a dump created on an active file system.
387.Pp
388.It Incremental dump too low
389When doing incremental restore,
390a dump that was written before the previous incremental dump,
391or that has too low an incremental level has been loaded.
392.Pp
393.It Incremental dump too high
394When doing incremental restore,
395a dump that does not begin its coverage where the previous incremental
396dump left off,
397or that has too high an incremental level has been loaded.
398.Pp
399.It Tape read error while restoring <filename>
400.It Tape read error while skipping over inode <inumber>
401.It Tape read error while trying to resynchronize
402A tape (or other media) read error has occurred.
403If a file name is specified,
404then its contents are probably partially wrong.
405If an inode is being skipped or the tape is trying to resynchronize,
406then no extracted files have been corrupted,
407though files may not be found on the tape.
408.Pp
409.It resync restore, skipped <num> blocks
410After a dump read error,
411.Nm restore
412may have to resynchronize itself.
413This message lists the number of blocks that were skipped over.
414.El
415.Sh FILES
416.Bl -tag -width "./restoresymtable" -compact
417.It Pa /dev/rsa0
418the default tape drive
419.It Pa /tmp/rstdir*
420file containing directories on the tape.
421.It Pa /tmp/rstmode*
422owner, mode, and time stamps for directories.
423.It Pa \&./restoresymtable
424information passed between incremental restores.
425.El
426.Sh SEE ALSO
427.Xr dump 8 ,
428.Xr mount 8 ,
429.Xr newfs 8 ,
430.Xr rmt 8
431.Sh BUGS
432.Nm Restore
433can get confused when doing incremental restores from
434dumps that were made on active file systems.
435.Pp
436A level zero dump must be done after a full restore.
437Because restore runs in user code,
438it has no control over inode allocation;
439thus a full dump must be done to get a new set of directories
440reflecting the new inode numbering,
441even though the contents of the files is unchanged.
442.Pp
443To do a network restore, you have to run restore as root.  This is due
444to the previous security history of dump and restore.  (restore is
445written to be setuid root, but we are not certain all bugs are gone
446from the restore code - run setuid at your own risk.)
447.Sh HISTORY
448The
449.Nm restore
450command appeared in
451.Bx 4.2 .
452