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