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 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 cdhkmNuvy 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 cdkNuvy 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 cdkNuvy 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 cdhkNuvy 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 cdhkmNuvy 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 d 282Sends verbose debugging output to the standard error. 283.It Fl f Ar file 284Read the backup from 285.Ar file ; 286.Ar file 287may be a special device file 288like 289.Pa /dev/sa0 290(a tape drive), 291.Pa /dev/da1c 292(a disk drive), 293an ordinary file, 294or 295.Ql Fl 296(the standard input). 297If the name of the file is of the form 298.Dq host:file , 299or 300.Dq user@host:file , 301.Nm 302reads from the named file on the remote host using 303.Xr rmt 8 . 304.Pp 305.It Fl k 306Use Kerberos authentication when contacting the remote tape server. 307(Only available if this options was enabled when 308.Nm 309was compiled.) 310.Pp 311.It Fl h 312Extract the actual directory, 313rather than the files that it references. 314This prevents hierarchical restoration of complete subtrees 315from the dump. 316.It Fl m 317Extract by inode numbers rather than by file name. 318This is useful if only a few files are being extracted, 319and one wants to avoid regenerating the complete pathname 320to the file. 321.It Fl N 322Do the extraction normally, but do not actually write any changes 323to disk. 324This can be used to check the integrity of dump media 325or other test purposes. 326.It Fl s Ar fileno 327Read from the specified 328.Ar fileno 329on a multi-file tape. 330File numbering starts at 1. 331.It Fl u 332When creating certain types of files, restore may generate a warning 333diagnostic if they already exist in the target directory. 334To prevent this, the 335.Fl u 336(unlink) flag causes restore to remove old entries before attempting 337to create new ones. 338.It Fl v 339Normally 340.Nm 341does its work silently. 342The 343.Fl v 344(verbose) 345flag causes it to type the name of each file it treats 346preceded by its file type. 347.It Fl y 348Do not ask the user whether to abort the restore in the event of an error. 349Always try to skip over the bad block(s) and continue. 350.El 351.Sh DIAGNOSTICS 352.Nm 353complains if it gets a read error. 354If 355.Fl y 356has been specified, or the user responds 357.Ql y , 358.Nm 359will attempt to continue the restore. 360.Pp 361If a backup was made using more than one tape volume, 362.Nm 363will notify the user when it is time to mount the next volume. 364If the 365.Fl x 366or 367.Fl i 368flag has been specified, 369.Nm 370will also ask which volume the user wishes to mount. 371The fastest way to extract a few files is to 372start with the last volume, and work towards the first volume. 373.Pp 374There are numerous consistency checks that can be listed by 375.Nm . 376Most checks are self-explanatory or can ``never happen''. 377Common errors are given below. 378.Pp 379.Bl -tag -width Ds -compact 380.It Converting to new file system format. 381A dump tape created from the old file system has been loaded. 382It is automatically converted to the new file system format. 383.Pp 384.It <filename>: not found on tape 385The specified file name was listed in the tape directory, 386but was not found on the tape. 387This is caused by tape read errors while looking for the file, 388and from using a dump tape created on an active file system. 389.Pp 390.It expected next file <inumber>, got <inumber> 391A file that was not listed in the directory showed up. 392This can occur when using a dump created on an active file system. 393.Pp 394.It Incremental dump too low 395When doing incremental restore, 396a dump that was written before the previous incremental dump, 397or that has too low an incremental level has been loaded. 398.Pp 399.It Incremental dump too high 400When doing incremental restore, 401a dump that does not begin its coverage where the previous incremental 402dump left off, 403or that has too high an incremental level has been loaded. 404.Pp 405.It Tape read error while restoring <filename> 406.It Tape read error while skipping over inode <inumber> 407.It Tape read error while trying to resynchronize 408A tape (or other media) read error has occurred. 409If a file name is specified, 410then its contents are probably partially wrong. 411If an inode is being skipped or the tape is trying to resynchronize, 412then no extracted files have been corrupted, 413though files may not be found on the tape. 414.Pp 415.It resync restore, skipped <num> blocks 416After a dump read error, 417.Nm 418may have to resynchronize itself. 419This message lists the number of blocks that were skipped over. 420.El 421.Sh FILES 422.Bl -tag -width "./restoresymtable" -compact 423.It Pa /dev/sa0 424the default tape drive 425.It Pa /tmp/rstdir* 426file containing directories on the tape. 427.It Pa /tmp/rstmode* 428owner, mode, and time stamps for directories. 429.It Pa \&./restoresymtable 430information passed between incremental restores. 431.El 432.Sh SEE ALSO 433.Xr dump 8 , 434.Xr mount 8 , 435.Xr newfs 8 , 436.Xr rmt 8 437.Sh BUGS 438.Nm Restore 439can get confused when doing incremental restores from 440dumps that were made on active file systems. 441.Pp 442A level zero dump must be done after a full restore. 443Because restore runs in user code, 444it has no control over inode allocation; 445thus a full dump must be done to get a new set of directories 446reflecting the new inode numbering, 447even though the contents of the files is unchanged. 448.Pp 449To do a network restore, you have to run restore as root. This is due 450to the previous security history of dump and restore. (restore is 451written to be setuid root, but we are not certain all bugs are gone 452from the restore code - run setuid at your own risk.) 453.Pp 454The temporary files 455.Pa /tmp/rstdir* 456and 457.Pa /tmp/rstmode* 458are generated with a unique name based on the date of the dump 459and the process ID (see 460.Xr mktemp 3 ) , 461except for when 462.Fl r 463or 464.Fl R 465is used. 466Because 467.Fl R 468allows you to restart a 469.Fl r 470operation that may have been interrupted, the temporary files should 471be the same across different processes. 472In all other cases, the files are unique because it is possible to 473have two different dumps started at the same time, and separate 474operations shouldn't conflict with each other. 475.Sh HISTORY 476The 477.Nm 478command appeared in 479.Bx 4.2 . 480