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 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 350.Nm 351complains if it gets a read error. 352If 353.Fl y 354has been specified, or the user responds 355.Ql y , 356.Nm 357will attempt to continue the restore. 358.Pp 359If a backup was made using more than one tape volume, 360.Nm 361will notify the user when it is time to mount the next volume. 362If the 363.Fl x 364or 365.Fl i 366flag has been specified, 367.Nm 368will also ask which volume the user wishes to mount. 369The fastest way to extract a few files is to 370start with the last volume, and work towards the first volume. 371.Pp 372There are numerous consistency checks that can be listed by 373.Nm . 374Most checks are self-explanatory or can ``never happen''. 375Common errors are given below. 376.Pp 377.Bl -tag -width Ds -compact 378.It Converting to new file system format. 379A dump tape created from the old file system has been loaded. 380It is automatically converted to the new file system format. 381.Pp 382.It <filename>: not found on tape 383The specified file name was listed in the tape directory, 384but was not found on the tape. 385This is caused by tape read errors while looking for the file, 386and from using a dump tape created on an active file system. 387.Pp 388.It expected next file <inumber>, got <inumber> 389A file that was not listed in the directory showed up. 390This can occur when using a dump created on an active file system. 391.Pp 392.It Incremental dump too low 393When doing incremental restore, 394a dump that was written before the previous incremental dump, 395or that has too low an incremental level has been loaded. 396.Pp 397.It Incremental dump too high 398When doing incremental restore, 399a dump that does not begin its coverage where the previous incremental 400dump left off, 401or that has too high an incremental level has been loaded. 402.Pp 403.It Tape read error while restoring <filename> 404.It Tape read error while skipping over inode <inumber> 405.It Tape read error while trying to resynchronize 406A tape (or other media) read error has occurred. 407If a file name is specified, 408then its contents are probably partially wrong. 409If an inode is being skipped or the tape is trying to resynchronize, 410then no extracted files have been corrupted, 411though files may not be found on the tape. 412.Pp 413.It resync restore, skipped <num> blocks 414After a dump read error, 415.Nm 416may have to resynchronize itself. 417This message lists the number of blocks that were skipped over. 418.El 419.Sh FILES 420.Bl -tag -width "./restoresymtable" -compact 421.It Pa /dev/sa0 422the default tape drive 423.It Pa /tmp/rstdir* 424file containing directories on the tape. 425.It Pa /tmp/rstmode* 426owner, mode, and time stamps for directories. 427.It Pa \&./restoresymtable 428information passed between incremental restores. 429.El 430.Sh SEE ALSO 431.Xr dump 8 , 432.Xr mount 8 , 433.Xr newfs 8 , 434.Xr rmt 8 435.Sh BUGS 436.Nm Restore 437can get confused when doing incremental restores from 438dumps that were made on active file systems. 439.Pp 440A level zero dump must be done after a full restore. 441Because restore runs in user code, 442it has no control over inode allocation; 443thus a full dump must be done to get a new set of directories 444reflecting the new inode numbering, 445even though the contents of the files is unchanged. 446.Pp 447To do a network restore, you have to run restore as root. This is due 448to the previous security history of dump and restore. (restore is 449written to be setuid root, but we are not certain all bugs are gone 450from the restore code - run setuid at your own risk.) 451.Pp 452The temporary files 453.Pa /tmp/rstdir* 454and 455.Pa /tmp/rstmode* 456are generated with a unique name based on the date of the dump 457and the process ID (see 458.Xr mktemp 3 ) , 459except for when 460.Fl r 461or 462.Fl R 463is used. 464Because 465.Fl R 466allows you to restart a 467.Fl r 468operation that may have been interrupted, the temporary files should 469be the same across different processes. 470In all other cases, the files are unique because it is possible to 471have two different dumps started at the same time, and separate 472operations shouldn't conflict with each other. 473.Sh HISTORY 474The 475.Nm 476command appeared in 477.Bx 4.2 . 478