]> git.wh0rd.org - dump.git/blame - restore/restore.8
Version 0.4b6.
[dump.git] / restore / restore.8
CommitLineData
1227625a
SP
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
ddd2ef55 33.\" $Id: restore.8,v 1.3 1999/10/11 12:59:20 stelian Exp $
1227625a
SP
34.\"
35.Dd May 1, 1995
36.Dt RESTORE 8
37.Os BSD 4
38.Sh NAME
39.Nm restore
40.Nd "restore files or file systems from backups made with dump"
41.Sh SYNOPSIS
42.Nm restore
43.Fl C
b45f51d6 44.Op Fl ckvy
1227625a
SP
45.Op Fl b Ar blocksize
46.Op Fl D Ar filesystem
47.Op Fl f Ar file
48.Op Fl s Ar fileno
49.Op Fl T Ar directory
50.Nm restore
51.Fl i
b45f51d6 52.Op Fl chkmNuvy
1227625a
SP
53.Op Fl b Ar blocksize
54.Op Fl f Ar file
55.Op Fl s Ar fileno
56.Op Fl T Ar directory
57.Nm restore
58.Fl R
b45f51d6 59.Op Fl ckNuvy
1227625a
SP
60.Op Fl b Ar blocksize
61.Op Fl f Ar file
62.Op Fl s Ar fileno
63.Op Fl T Ar directory
64.Nm restore
65.Fl r
b45f51d6 66.Op Fl ckNuvy
1227625a
SP
67.Op Fl b Ar blocksize
68.Op Fl f Ar file
69.Op Fl s Ar fileno
70.Op Fl T Ar directory
71.Nm restore
72.Fl t
b45f51d6 73.Op Fl chkNuvy
1227625a
SP
74.Op Fl b Ar blocksize
75.Op Fl f Ar file
76.Op Fl s Ar fileno
77.Op Fl T Ar directory
78.Op file ...
79.Nm restore
80.Fl x
b45f51d6 81.Op Fl chkmNuvy
1227625a
SP
82.Op Fl b Ar blocksize
83.Op Fl f Ar file
84.Op Fl s Ar fileno
85.Op Fl T Ar directory
86.Op file ...
87.Pp
88.in -\\n(iSu
89(The
90.Bx 4.3
ddd2ef55 91option syntax is implemented for backward compatibility but
1227625a
SP
92is not documented here.)
93.Sh DESCRIPTION
94The
95.Nm restore
96command performs the inverse function of
97.Xr dump 8 .
98A full backup of a file system may be restored and
99subsequent incremental backups layered on top of it.
100Single files and
101directory subtrees may be restored from full or partial
102backups.
103.Nm Restore
104works across a network;
105to do this see the
106.Fl f
107flag described below.
108Other arguments to the command are file or directory
109names specifying the files that are to be restored.
110Unless the
111.Fl h
112flag is specified (see below),
113the appearance of a directory name refers to
114the files and (recursively) subdirectories of that directory.
115.Pp
116Exactly one of the following flags is required:
117.Bl -tag -width Ds
118.It Fl C
119This mode allows comparison of files from a dump.
120.Nm Restore
121reads the backup and compares its contents with files present on the
122disk.
123It first changes its working directory to the root of the filesystem
124that was dumped and compares the tape with the files in its new
125current directory.
126.It Fl i
127This mode allows interactive restoration of files from a dump.
128After reading in the directory information from the dump,
129.Nm restore
130provides a shell like interface that allows the user to move
131around the directory tree selecting files to be extracted.
132The available commands are given below;
133for those commands that require an argument,
134the default is the current directory.
135.Bl -tag -width Fl
136.It Ic add Op Ar arg
137The current directory or specified argument is added to the list of
138files to be extracted.
139If a directory is specified, then it and all its descendents are
140added to the extraction list
141(unless the
142.Fl h
143flag is specified on the command line).
ddd2ef55
SP
144Files that are on the extraction list are prepended with a
145.Dq \&*
1227625a
SP
146when they are listed by
147.Ic ls .
148.It Ic \&cd Ar arg
149Change the current working directory to the specified argument.
150.It Ic delete Op Ar arg
151The current directory or specified argument is deleted from the list of
152files to be extracted.
153If a directory is specified, then it and all its descendents are
154deleted from the extraction list
155(unless the
156.Fl h
157flag is specified on the command line).
158The most expedient way to extract most of the files from a directory
159is to add the directory to the extraction list and then delete
160those files that are not needed.
161.It Ic extract
ddd2ef55 162All files on the extraction list are extracted
1227625a
SP
163from the dump.
164.Nm Restore
165will ask which volume the user wishes to mount.
166The fastest way to extract a few files is to
ddd2ef55 167start with the last volume and work towards the first volume.
1227625a
SP
168.It Ic help
169List a summary of the available commands.
170.It Ic \&ls Op Ar arg
171List the current or specified directory.
ddd2ef55
SP
172Entries that are directories are appended with a
173.Dq \&* .
1227625a
SP
174Entries that have been marked for extraction are prepended with a ``*''.
175If the verbose
ddd2ef55 176flag is set, the inode number of each entry is also listed.
1227625a
SP
177.It Ic pwd
178Print the full pathname of the current working directory.
179.It Ic quit
180Restore immediately exits,
181even if the extraction list is not empty.
182.It Ic setmodes
ddd2ef55 183All directories that have been added to the extraction list
1227625a
SP
184have their owner, modes, and times set;
185nothing is extracted from the dump.
186This is useful for cleaning up after a restore has been prematurely aborted.
187.It Ic verbose
188The sense of the
189.Fl v
190flag is toggled.
191When set, the verbose flag causes the
192.Ic ls
193command to list the inode numbers of all entries.
194It also causes
195.Nm restore
196to print out information about each file as it is extracted.
197.El
198.It Fl R
199.Nm Restore
ddd2ef55 200requests a particular tape of a multi-volume set on which to restart
1227625a
SP
201a full restore
202(see the
203.Fl r
204flag below).
205This is useful if the restore has been interrupted.
206.It Fl r
ddd2ef55 207Restore (rebuild) a file system.
1227625a
SP
208The target file system should be made pristine with
209.Xr newfs 8 ,
ddd2ef55 210mounted, and the user
1227625a
SP
211.Xr cd Ns 'd
212into the pristine file system
213before starting the restoration of the initial level 0 backup. If the
214level 0 restores successfully, the
215.Fl r
216flag may be used to restore
217any necessary incremental backups on top of the level 0.
218The
219.Fl r
220flag precludes an interactive file extraction and can be
ddd2ef55
SP
221detrimental to one's health (not to mention the disk) if not used carefully.
222An example:
1227625a
SP
223.Bd -literal -offset indent
224newfs /dev/rrp0g eagle
225mount /dev/rp0g /mnt
226cd /mnt
227
228restore rf /dev/rst8
229.Ed
230.Pp
231Note that
232.Nm restore
233leaves a file
234.Pa restoresymtable
235in the root directory to pass information between incremental
236restore passes.
237This file should be removed when the last incremental has been
238restored.
239.Pp
240.Nm Restore ,
241in conjunction with
242.Xr newfs 8
243and
244.Xr dump 8 ,
245may be used to modify file system parameters
246such as size or block size.
247.It Fl t
248The names of the specified files are listed if they occur
249on the backup.
250If no file argument is given,
ddd2ef55 251the root directory is listed,
1227625a
SP
252which results in the entire content of the
253backup being listed,
254unless the
255.Fl h
256flag has been specified.
257Note that the
258.Fl t
259flag replaces the function of the old
260.Xr dumpdir 8
261program.
262.ne 1i
263.It Fl x
264The named files are read from the given media.
265If a named file matches a directory whose contents
266are on the backup
267and the
268.Fl h
269flag is not specified,
270the directory is recursively extracted.
271The owner, modification time,
272and mode are restored (if possible).
273If no file argument is given,
ddd2ef55 274the root directory is extracted,
1227625a
SP
275which results in the entire content of the
276backup being extracted,
277unless the
278.Fl h
279flag has been specified.
280.El
281.Pp
282The following additional options may be specified:
283.Bl -tag -width Ds
284.It Fl b Ar blocksize
285The number of kilobytes per dump record.
286If the
287.Fl b
288option is not specified,
289.Nm restore
b45f51d6 290tries to determine the media block size dynamically.
1227625a
SP
291.It Fl c
292Normally,
293.Nm restore
294will try to determine dynamically whether the dump was made from an
b45f51d6 295old (pre-4.4) or new format file system. The
1227625a
SP
296.Fl c
297flag disables this check, and only allows reading a dump in the old
298format.
299.It Fl D Ar filesystem
300The
301.Fl D
302flag allows the user to specify the filesystem name when using
303.Nm restore
304with the
305.Fl C
306option to check the backup.
307.It Fl f Ar file
308Read the backup from
309.Ar file ;
310.Ar file
311may be a special device file
312like
ddd2ef55 313.Pa /dev/st0
1227625a
SP
314(a tape drive),
315.Pa /dev/rsd1c
316(a disk drive),
317an ordinary file,
318or
319.Ql Fl
320(the standard input).
321If the name of the file is of the form
ddd2ef55 322.Dq host:file
1227625a
SP
323or
324.Dq user@host:file ,
325.Nm restore
326reads from the named file on the remote host using
327.Xr rmt 8 .
328.Pp
b45f51d6
SP
329.It Fl k
330Use Kerberos authentication when contacting the remote tape server.
331(Only available if this options was enabled when
332.Nm restore
333was compiled.)
334.Pp
1227625a
SP
335.It Fl h
336Extract the actual directory,
337rather than the files that it references.
338This prevents hierarchical restoration of complete subtrees
339from the dump.
340.It Fl m
341Extract by inode numbers rather than by file name.
342This is useful if only a few files are being extracted,
343and one wants to avoid regenerating the complete pathname
344to the file.
345.It Fl N
346The
347.Fl N
348flag causes
349.Nm restore to only print file names. Files are not extracted.
350.It Fl s Ar fileno
351Read from the specified
352.Ar fileno
353on a multi-file tape.
354File numbering starts at 1.
355.It Fl T Ar directory
356The
357.Fl T
358flag allows the user to specify a directory to use for the storage of
359temporary files. The default value is /tmp. This flag is most useful
360when restoring files after having booted from a floppy. There might be little
361or no space on the floppy filesystem, but another source of space might exist.
b45f51d6
SP
362.It Fl u
363When creating certain types of files, restore may generate a warning
364diagnostic if they already exist in the target directory.
365To prevent this, the
366.Fl u
367(unlink) flag causes restore to remove old entries before attempting
368to create new ones.
1227625a
SP
369.It Fl v
370Normally
371.Nm restore
372does its work silently.
373The
374.Fl v
375(verbose)
376flag causes it to type the name of each file it treats
377preceded by its file type.
378.It Fl y
379Do not ask the user whether to abort the restore in the event of an error.
380Always try to skip over the bad block(s) and continue.
381.El
382.Sh DIAGNOSTICS
ddd2ef55 383Complains if it gets a read error.
1227625a
SP
384If
385.Fl y
386has been specified, or the user responds
387.Ql y ,
388.Nm restore
389will attempt to continue the restore.
390.Pp
391If a backup was made using more than one tape volume,
392.Nm restore
393will notify the user when it is time to mount the next volume.
394If the
395.Fl x
396or
397.Fl i
398flag has been specified,
399.Nm restore
400will also ask which volume the user wishes to mount.
401The fastest way to extract a few files is to
402start with the last volume, and work towards the first volume.
403.Pp
404There are numerous consistency checks that can be listed by
405.Nm restore .
ddd2ef55
SP
406Most checks are self-explanatory or can
407.Dq never happen .
1227625a
SP
408Common errors are given below.
409.Pp
410.Bl -tag -width Ds -compact
ddd2ef55 411.It Converting to new file system format
1227625a
SP
412A dump tape created from the old file system has been loaded.
413It is automatically converted to the new file system format.
414.Pp
415.It <filename>: not found on tape
416The specified file name was listed in the tape directory,
417but was not found on the tape.
418This is caused by tape read errors while looking for the file,
419and from using a dump tape created on an active file system.
420.Pp
421.It expected next file <inumber>, got <inumber>
422A file that was not listed in the directory showed up.
423This can occur when using a dump created on an active file system.
424.Pp
425.It Incremental dump too low
ddd2ef55 426When doing an incremental restore,
1227625a
SP
427a dump that was written before the previous incremental dump,
428or that has too low an incremental level has been loaded.
429.Pp
430.It Incremental dump too high
ddd2ef55 431When doing an incremental restore,
1227625a
SP
432a dump that does not begin its coverage where the previous incremental
433dump left off,
434or that has too high an incremental level has been loaded.
435.Pp
436.It Tape read error while restoring <filename>
437.It Tape read error while skipping over inode <inumber>
438.It Tape read error while trying to resynchronize
439A tape (or other media) read error has occurred.
440If a file name is specified,
ddd2ef55 441its contents are probably partially wrong.
1227625a 442If an inode is being skipped or the tape is trying to resynchronize,
ddd2ef55 443no extracted files have been corrupted,
1227625a
SP
444though files may not be found on the tape.
445.Pp
446.It resync restore, skipped <num> blocks
447After a dump read error,
448.Nm restore
449may have to resynchronize itself.
450This message lists the number of blocks that were skipped over.
451.El
b45f51d6 452.Sh ENVIRONMENT
ddd2ef55
SP
453If the following environment variable exists it will be utilized by
454.Nm restore :
455.Pp
456.Bl -tag -width "TMPDIR" -compact
b45f51d6
SP
457.It Ev TAPE
458If no -f option was specified,
459.Nm
460will use the device specified via
461.Ev TAPE
462as the dump device.
463.Ev TAPE
464may be of the form
465.Qq tapename ,
ddd2ef55 466.Qq host:tapename
b45f51d6
SP
467or
468.Qq user@host:tapename .
ddd2ef55
SP
469.It Ev TMPDIR
470The directory given in
471.Ev TMPDIR
472will be used
473instead of
474.Pa /tmp
475to store temporary files.
b45f51d6
SP
476.It Ev RMT
477The environment variable
478.Ev RMT
479will be used to determine the pathname of the remote
480.Xr rmt 8
481program.
1227625a
SP
482.Sh FILES
483.Bl -tag -width "./restoresymtable" -compact
ddd2ef55 484.It Pa /dev/st0
1227625a
SP
485the default tape drive
486.It Pa /tmp/rstdir*
ddd2ef55 487file containing directories on the tape
1227625a 488.It Pa /tmp/rstmode*
ddd2ef55 489owner, mode, and time stamps for directories
1227625a 490.It Pa \&./restoresymtable
ddd2ef55 491information passed between incremental restores
1227625a
SP
492.El
493.Sh SEE ALSO
494.Xr dump 8 ,
1227625a 495.Xr mount 8 ,
b45f51d6 496.Xr newfs 8 ,
1227625a
SP
497.Xr mkfs 8 ,
498.Xr rmt 8
499.Sh BUGS
500.Nm Restore
501can get confused when doing incremental restores from
502dumps that were made on active file systems.
503.Pp
ddd2ef55
SP
504A level 0 dump must be done after a full restore.
505Because
506.Nm restore
507runs in user code,
1227625a
SP
508it has no control over inode allocation;
509thus a full dump must be done to get a new set of directories
510reflecting the new inode numbering,
ddd2ef55
SP
511even though the content of the files is unchanged.
512.Pp
513The temporary files
514.Pa /tmp/rstdir*
515and
516.Pa /tmp/rstmode*
517are generated with a unique name based on the date of the dump
518and the process ID (see
519.Xr mktemp 3 ),
520except when
521.Fl r
522or
523.Fl R
524is used.
525Because
526.Fl R
527allows you to restart a
528.Fl r
529operation that may have been interrupted, the temporary files should
530be the same across different processes.
531In all other cases, the files are unique because it is possible to
532have two different dumps started at the same time, and separate
533operations shouldn't conflict with each other.
b45f51d6
SP
534.Pp
535To do a network restore, you have to run restore as root. This is due
536to the previous security history of dump and restore. (restore is
537written to be setuid root, but we are not certain all bugs are gone
538from the restore code - run setuid at your own risk.)
1227625a
SP
539.Sh HISTORY
540The
541.Nm restore
542command appeared in
543.Bx 4.2 .