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