1.\" Copyright (c) 1985, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)restore.8 6.10 (Berkeley) 07/23/91 7.\" 8.Dd 9.Dt RESTORE 8 10.Os BSD 4 11.Sh NAME 12.Nm restore 13.Nd "restore files or file systems from backups made with dump" 14.Sh SYNOPSIS 15.Nm restore 16.Ar key 17.Op Ar name Ar ... 18.Sh DESCRIPTION 19The 20.Nm restore 21command performs the inverse function of 22.Xr dump 8 . 23A full backup of a file system may be restored and 24subsequent incremental backups layered on top of it. 25Single files and 26directory subtrees may be restored from full or partial 27backups. 28.Nm Restore 29cannot work across a network, to do this, see the companion 30command 31.Xr rrestore . 32The actions 33of 34.Nm restore 35are controlled by the given 36.Cm key , 37which 38is a string of characters containing 39at most one function letter and possibly 40one or more function modifiers. 41Other arguments to the command are file or directory 42names specifying the files that are to be restored. 43Unless the 44.Cm h 45key is specified (see below), 46the appearance of a directory name refers to 47the files and (recursively) subdirectories of that directory. 48.Pp 49The function portion of 50the key is specified by one of the following letters: 51.Bl -tag -width Ds 52.It Cm r 53Restore (rebuild a file system). 54The target file system should be made pristine with 55.Xr newfs 8 , 56mounted and the 57user 58.Xr cd Ns 'd 59into the pristine file system 60before starting the restoration of the initial level 0 backup. If the 61level 0 restores successfully, the 62.Cm r 63key may be used to restore 64any necessary incremental backups on top of the level 0. 65The 66.Cm r 67key precludes an interactive file extraction and can be 68detrimental to ones health if not used carefully (not to mention 69the disk). An example: 70.Bd -literal -offset indent 71newfs /dev/rrp0g eagle 72mount /dev/rp0g /mnt 73cd /mnt 74 75restore rf /dev/rst8 76.Ed 77.Pp 78Note that 79.Nm restore 80leaves a file 81.Pa restoresymtable 82in the root directory to pass information between incremental 83restore passes. 84This file should be removed when the last incremental has been 85restored. 86.Pp 87.Nm Restore , 88in conjunction with 89.Xr newfs 8 90and 91.Xr dump 8 , 92may be used to modify file system parameters 93such as size or block size. 94.It Cm R 95.Nm Restore 96requests a particular tape of a multi volume set on which to restart 97a full restore 98(see the 99.Cm r 100key above). 101This is useful if the restore has been interrupted. 102.It Cm x 103The named files are read from the given media. 104If a named file matches a directory whose contents 105are on the backup 106and the 107.Cm h 108key is not specified, 109the directory is recursively extracted. 110The owner, modification time, 111and mode are restored (if possible). 112If no file argument is given, 113then the root directory is extracted, 114which results in the entire content of the 115backup being extracted, 116unless the 117.Cm h 118key has been specified. 119.It Cm t 120The names of the specified files are listed if they occur 121on the backup. 122If no file argument is given, 123then the root directory is listed, 124which results in the entire content of the 125backup being listed, 126unless the 127.Cm h 128key has been specified. 129Note that the 130.Cm t 131key replaces the function of the old 132.Xr dumpdir 8 133program. 134.It Cm i 135This mode allows interactive restoration of files from a dump. 136After reading in the directory information from the dump, 137.Nm restore 138provides a shell like interface that allows the user to move 139around the directory tree selecting files to be extracted. 140The available commands are given below; 141for those commands that require an argument, 142the default is the current directory. 143.Bl -tag -width Fl 144.It Ic add Op Ar arg 145The current directory or specified argument is added to the list of 146files to be extracted. 147If a directory is specified, then it and all its descendents are 148added to the extraction list 149(unless the 150.Cm h 151key is specified on the command line). 152Files that are on the extraction list are prepended with a ``*'' 153when they are listed by 154.Ic ls . 155.It Ic \&cd Ar arg 156Change the current working directory to the specified argument. 157.It Ic delete Op Ar arg 158The current directory or specified argument is deleted from the list of 159files to be extracted. 160If a directory is specified, then it and all its descendents are 161deleted from the extraction list 162(unless the 163.Cm h 164key is specified on the command line). 165The most expedient way to extract most of the files from a directory 166is to add the directory to the extraction list and then delete 167those files that are not needed. 168.It Ic extract 169All the files that are on the extraction list are extracted 170from the dump. 171.Nm Restore 172will ask which volume the user wishes to mount. 173The fastest way to extract a few files is to 174start with the last volume, and work towards the first volume. 175.It Ic help 176List a summary of the available commands. 177.It Ic \&ls Op Ar arg 178List the current or specified directory. 179Entries that are directories are appended with a ``/''. 180Entries that have been marked for extraction are prepended with a ``*''. 181If the verbose key is set the inode number of each entry is also listed. 182.It Ic pwd 183Print the full pathname of the current working directory. 184.It Ic quit 185Restore immediately exits, 186even if the extraction list is not empty. 187.It Ic setmodes 188All the directories that have been added to the extraction list 189have their owner, modes, and times set; 190nothing is extracted from the dump. 191This is useful for cleaning up after a restore has been prematurely aborted. 192.It Ic verbose 193The sense of the 194.Cm v 195key is toggled. 196When set, the verbose key causes the 197.Ic ls 198command to list the inode numbers of all entries. 199It also causes 200.Nm restore 201to print out information about each file as it is extracted. 202.El 203.El 204.Pp 205The following characters may be used in addition to the letter 206that selects the function desired. 207.Bl -tag -width Ds 208.It Cm b 209The next argument to 210.Nm restore 211is used as the block size of the media (in kilobytes). 212If the 213.Fl b 214option is not specified, 215.Nm restore 216tries to determine the media block size dynamically. 217.It Cm f 218The next argument to 219.Nm restore 220is used as the name of the archive instead 221of 222.Pa /dev/rmt? . 223If the name of the file is 224.Ql Fl , 225.Nm restore 226reads from standard input. 227Thus, 228.Xr dump 8 229and 230.Nm restore 231can be used in a pipeline to dump and restore a file system 232with the command 233.Bd -literal -offset indent 234dump 0f - /usr | (cd /mnt; restore xf -) 235.Ed 236.Pp 237.It Cm h 238.Nm Restore 239extracts the actual directory, 240rather than the files that it references. 241This prevents hierarchical restoration of complete subtrees 242from the dump. 243.It Cm m 244.Nm Restore 245will extract by inode numbers rather than by file name. 246This is useful if only a few files are being extracted, 247and one wants to avoid regenerating the complete pathname 248to the file. 249.It Cm s 250The next argument to 251.Nm restore 252is a number which 253selects the file on a multi-file dump tape. File numbering 254starts at 1. 255.It Cm v 256Normally 257.Nm restore 258does its work silently. 259The 260.Cm v 261(verbose) 262key causes it to type the name of each file it treats 263preceded by its file type. 264.It Cm y 265.Nm Restore 266will not ask whether it should abort the restore if gets an error. 267It will always try to skip over the bad block(s) and continue as 268best it can. 269.El 270.Sh DIAGNOSTICS 271Complaints about bad key characters. 272.Pp 273Complaints if it gets a read error. 274If 275.Cm y 276has been specified, or the user responds 277.Ql y , 278.Nm restore 279will attempt to continue the restore. 280.Pp 281If a backup was made using more than one tape volume, 282.Nm restore 283will notify the user when it is time to mount the next volume. 284If the 285.Cm x 286or 287.Cm i 288key has been specified, 289.Nm restore 290will also ask which volume the user wishes to mount. 291The fastest way to extract a few files is to 292start with the last volume, and work towards the first volume. 293.Pp 294There are numerous consistency checks that can be listed by 295.Nm restore . 296Most checks are self-explanatory or can ``never happen''. 297Common errors are given below. 298.Pp 299.Bl -tag -width Ds -compact 300.It Converting to new file system format. 301A dump tape created from the old file system has been loaded. 302It is automatically converted to the new file system format. 303.Pp 304.It <filename>: not found on tape 305The specified file name was listed in the tape directory, 306but was not found on the tape. 307This is caused by tape read errors while looking for the file, 308and from using a dump tape created on an active file system. 309.Pp 310.It expected next file <inumber>, got <inumber> 311A file that was not listed in the directory showed up. 312This can occur when using a dump created on an active file system. 313.Pp 314.It Incremental dump too low 315When doing incremental restore, 316a dump that was written before the previous incremental dump, 317or that has too low an incremental level has been loaded. 318.Pp 319.It Incremental dump too high 320When doing incremental restore, 321a dump that does not begin its coverage where the previous incremental 322dump left off, 323or that has too high an incremental level has been loaded. 324.Pp 325.It Tape read error while restoring <filename> 326.It Tape read error while skipping over inode <inumber> 327.It Tape read error while trying to resynchronize 328A tape (or other media) read error has occurred. 329If a file name is specified, 330then its contents are probably partially wrong. 331If an inode is being skipped or the tape is trying to resynchronize, 332then no extracted files have been corrupted, 333though files may not be found on the tape. 334.Pp 335.It resync restore, skipped <num> blocks 336After a dump read error, 337.Nm restore 338may have to resynchronize itself. 339This message lists the number of blocks that were skipped over. 340.El 341.Sh FILES 342.Bl -tag -width "./restoresymtable" -compact 343.It Pa /dev/rmt? 344the default tape drive 345.It Pa /tmp/rstdir* 346file containing directories on the tape. 347.It Pa /tmp/rstmode* 348owner, mode, and time stamps for directories. 349.It Pa \&./restoresymtable 350information passed between incremental restores. 351.El 352.Sh SEE ALSO 353.Xr rrestore 8 354.Xr dump 8 , 355.Xr newfs 8 , 356.Xr mount 8 , 357.Xr mkfs 8 358.Sh BUGS 359.Nm Restore 360can get confused when doing incremental restores from 361dump that were made on active file systems. 362.Pp 363A level zero dump must be done after a full restore. 364Because restore runs in user code, 365it has no control over inode allocation; 366thus a full restore must be done to get a new set of directories 367reflecting the new inode numbering, 368even though the contents of the files is unchanged. 369.Sh HISTORY 370The 371.Nm restore 372command appeared in 373.Bx 4.2 . 374