xref: /freebsd/sbin/restore/restore.8 (revision 5521ff5a4d1929056e7ffc982fac3341ca54df7c)
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
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
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
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
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 Ar
68.Nm
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 Ar
75.Pp
76.in \" XXX
77(The
78.Bx 4.3
79option syntax is implemented for backward compatibility, but
80is not documented here.)
81.Sh DESCRIPTION
82The
83.Nm
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
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
174to print out information about each file as it is extracted.
175.It Ic what
176Displays dump header information, which includes: date,
177level, label, and the filesystem and host dump was made
178from.
179.El
180.It Fl R
181.Nm Restore
182requests a particular tape of a multi volume set on which to restart
183a full restore
184(see the
185.Fl r
186flag below).
187This is useful if the restore has been interrupted.
188.It Fl r
189Restore (rebuild a file system).
190The target file system should be made pristine with
191.Xr newfs 8 ,
192mounted and the user
193.Xr cd Ns 'd
194into the pristine file system
195before starting the restoration of the initial level 0 backup.
196If the
197level 0 restores successfully, the
198.Fl r
199flag may be used to restore
200any necessary incremental backups on top of the level 0.
201The
202.Fl r
203flag precludes an interactive file extraction and can be
204detrimental to one's health if not used carefully (not to mention
205the disk). An example:
206.Bd -literal -offset indent
207newfs /dev/da0s1a
208mount /dev/da0s1a /mnt
209cd /mnt
210
211restore rf /dev/sa0
212.Ed
213.Pp
214Note that
215.Nm
216leaves a file
217.Pa restoresymtable
218in the root directory to pass information between incremental
219restore passes.
220This file should be removed when the last incremental has been
221restored.
222.Pp
223.Nm Restore ,
224in conjunction with
225.Xr newfs 8
226and
227.Xr dump 8 ,
228may be used to modify file system parameters
229such as size or block size.
230.It Fl t
231The names of the specified files are listed if they occur
232on the backup.
233If no file argument is given,
234then the root directory is listed,
235which results in the entire content of the
236backup being listed,
237unless the
238.Fl h
239flag has been specified.
240Note that the
241.Fl t
242flag replaces the function of the old
243.Xr dumpdir 8
244program.
245.It Fl x
246The named files are read from the given media.
247If a named file matches a directory whose contents
248are on the backup
249and the
250.Fl h
251flag is not specified,
252the directory is recursively extracted.
253The owner, modification time,
254and mode are restored (if possible).
255If no file argument is given,
256then the root directory is extracted,
257which results in the entire content of the
258backup being extracted,
259unless the
260.Fl h
261flag has been specified.
262.El
263.Pp
264The following additional options may be specified:
265.Bl -tag -width Ds
266.It Fl b Ar blocksize
267The number of kilobytes per dump record.
268If the
269.Fl b
270option is not specified,
271.Nm
272tries to determine the media block size dynamically.
273.It Fl c
274Normally,
275.Nm
276will try to determine dynamically whether the dump was made from an
277old (pre-4.4) or new format file system.  The
278.Fl c
279flag disables this check, and only allows reading a dump in the old
280format.
281.It Fl f Ar file
282Read the backup from
283.Ar file ;
284.Ar file
285may be a special device file
286like
287.Pa /dev/sa0
288(a tape drive),
289.Pa /dev/da1c
290(a disk drive),
291an ordinary file,
292or
293.Ql Fl
294(the standard input).
295If the name of the file is of the form
296.Dq host:file ,
297or
298.Dq user@host:file ,
299.Nm
300reads from the named file on the remote host using
301.Xr rmt 8 .
302.Pp
303.It Fl k
304Use Kerberos authentication when contacting the remote tape server.
305(Only available if this options was enabled when
306.Nm
307was compiled.)
308.Pp
309.It Fl h
310Extract the actual directory,
311rather than the files that it references.
312This prevents hierarchical restoration of complete subtrees
313from the dump.
314.It Fl m
315Extract by inode numbers rather than by file name.
316This is useful if only a few files are being extracted,
317and one wants to avoid regenerating the complete pathname
318to the file.
319.It Fl N
320Do the extraction normally, but do not actually write any changes
321to disk.
322This can be used to check the integrity of dump media
323or other test purposes.
324.It Fl s Ar fileno
325Read from the specified
326.Ar fileno
327on a multi-file tape.
328File numbering starts at 1.
329.It Fl u
330When creating certain types of files, restore may generate a warning
331diagnostic if they already exist in the target directory.
332To prevent this, the
333.Fl u
334(unlink) flag causes restore to remove old entries before attempting
335to create new ones.
336.It Fl v
337Normally
338.Nm
339does its work silently.
340The
341.Fl v
342(verbose)
343flag causes it to type the name of each file it treats
344preceded by its file type.
345.It Fl y
346Do not ask the user whether to abort the restore in the event of an error.
347Always try to skip over the bad block(s) and continue.
348.El
349.Sh DIAGNOSTICS
350Complaints if it gets a read error.
351If
352.Fl y
353has been specified, or the user responds
354.Ql y ,
355.Nm
356will attempt to continue the restore.
357.Pp
358If a backup was made using more than one tape volume,
359.Nm
360will notify the user when it is time to mount the next volume.
361If the
362.Fl x
363or
364.Fl i
365flag has been specified,
366.Nm
367will also ask which volume the user wishes to mount.
368The fastest way to extract a few files is to
369start with the last volume, and work towards the first volume.
370.Pp
371There are numerous consistency checks that can be listed by
372.Nm .
373Most checks are self-explanatory or can ``never happen''.
374Common errors are given below.
375.Pp
376.Bl -tag -width Ds -compact
377.It Converting to new file system format.
378A dump tape created from the old file system has been loaded.
379It is automatically converted to the new file system format.
380.Pp
381.It <filename>: not found on tape
382The specified file name was listed in the tape directory,
383but was not found on the tape.
384This is caused by tape read errors while looking for the file,
385and from using a dump tape created on an active file system.
386.Pp
387.It expected next file <inumber>, got <inumber>
388A file that was not listed in the directory showed up.
389This can occur when using a dump created on an active file system.
390.Pp
391.It Incremental dump too low
392When doing incremental restore,
393a dump that was written before the previous incremental dump,
394or that has too low an incremental level has been loaded.
395.Pp
396.It Incremental dump too high
397When doing incremental restore,
398a dump that does not begin its coverage where the previous incremental
399dump left off,
400or that has too high an incremental level has been loaded.
401.Pp
402.It Tape read error while restoring <filename>
403.It Tape read error while skipping over inode <inumber>
404.It Tape read error while trying to resynchronize
405A tape (or other media) read error has occurred.
406If a file name is specified,
407then its contents are probably partially wrong.
408If an inode is being skipped or the tape is trying to resynchronize,
409then no extracted files have been corrupted,
410though files may not be found on the tape.
411.Pp
412.It resync restore, skipped <num> blocks
413After a dump read error,
414.Nm
415may have to resynchronize itself.
416This message lists the number of blocks that were skipped over.
417.El
418.Sh FILES
419.Bl -tag -width "./restoresymtable" -compact
420.It Pa /dev/sa0
421the default tape drive
422.It Pa /tmp/rstdir*
423file containing directories on the tape.
424.It Pa /tmp/rstmode*
425owner, mode, and time stamps for directories.
426.It Pa \&./restoresymtable
427information passed between incremental restores.
428.El
429.Sh SEE ALSO
430.Xr dump 8 ,
431.Xr mount 8 ,
432.Xr newfs 8 ,
433.Xr rmt 8
434.Sh BUGS
435.Nm Restore
436can get confused when doing incremental restores from
437dumps that were made on active file systems.
438.Pp
439A level zero dump must be done after a full restore.
440Because restore runs in user code,
441it has no control over inode allocation;
442thus a full dump must be done to get a new set of directories
443reflecting the new inode numbering,
444even though the contents of the files is unchanged.
445.Pp
446To do a network restore, you have to run restore as root.  This is due
447to the previous security history of dump and restore.  (restore is
448written to be setuid root, but we are not certain all bugs are gone
449from the restore code - run setuid at your own risk.)
450.Pp
451The temporary files
452.Pa /tmp/rstdir*
453and
454.Pa /tmp/rstmode*
455are generated with a unique name based on the date of the dump
456and the process ID (see
457.Xr mktemp 3 ) ,
458except for when
459.Fl r
460or
461.Fl R
462is used.
463Because
464.Fl R
465allows you to restart a
466.Fl r
467operation that may have been interrupted, the temporary files should
468be the same across different processes.
469In all other cases, the files are unique because it is possible to
470have two different dumps started at the same time, and separate
471operations shouldn't conflict with each other.
472.Sh HISTORY
473The
474.Nm
475command appeared in
476.Bx 4.2 .
477