1.\" $NetBSD: dump.8,v 1.53 2003/08/07 10:04:13 agc Exp $ 2.\" 3.\" Copyright (c) 1980, 1991, 1993 4.\" Regents of the University of California. 5.\" 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.\" @(#)dump.8 8.3 (Berkeley) 5/1/95 32.\" 33.Dd May 26, 2003 34.Dt DUMP 8 35.Os 36.Sh NAME 37.Nm dump , 38.Nm rdump 39.Nd file system backup 40.Sh SYNOPSIS 41.Nm 42.Op Fl 0123456789aceFnStu 43.Bk -words 44.Op Fl B Ar records 45.Ek 46.Bk -words 47.Op Fl b Ar blocksize 48.Ek 49.Bk -words 50.Op Fl d Ar density 51.Ek 52.Bk -words 53.Op Fl f Ar file 54.Ek 55.Bk -words 56.Op Fl h Ar level 57.Ek 58.Bk -words 59.Op Fl k Ar read-blocksize 60.Ek 61.Bk -words 62.Op Fl L Ar label 63.Ek 64.Bk -words 65.Op Fl l Ar timeout 66.Ek 67.Bk -words 68.Op Fl r Ar cachesize 69.Ek 70.Bk -words 71.Op Fl s Ar feet 72.Ek 73.Bk -words 74.Op Fl T Ar date 75.Ek 76.Ar files-to-dump 77.Nm 78.Op Fl W Li \&| Fl w 79.Pp 80.in -\n(iSu 81(The 82.Bx 4.3 83option syntax is implemented for backward compatibility, but 84is not documented here). 85.Sh DESCRIPTION 86.Nm 87examines files on a file system and determines which files need to 88be backed up. 89These files are copied to the given disk, tape or other storage 90medium for safe keeping (see the 91.Fl f 92option below for doing remote backups). 93A dump that is larger than the output medium is broken into 94multiple volumes. 95On most media the size is determined by writing until an 96end-of-media indication is returned. 97This can be enforced by using the 98.Fl a 99option. 100.Pp 101On media that cannot reliably return an end-of-media indication 102(such as some cartridge tape drives) each volume is of a fixed size; 103the actual size is determined by the tape size and density and/or 104block count options below. 105By default, the same output file name is used for each volume 106after prompting the operator to change media. 107.Pp 108.Ar files-to-dump 109is either a single file system, 110or a list of files and directories on a single file system to be backed 111up as a subset of the file system. 112In the former case, 113.Ar files-to-dump 114may be the device of a file system, 115the path to a currently mounted file system, 116the path to an unmounted file system listed in 117.Pa /etc/fstab , 118or, if 119.Fl F 120is given, a file system image. 121In the latter case, certain restrictions are placed on the backup: 122.Fl u 123is ignored, the only dump level that is supported is 124.Fl 0 , 125and all of the files must reside on the same file system. 126.Pp 127The following options are supported by 128.Nm : 129.Bl -tag -width Ds 130.It Fl 0\-9 131Dump levels. 132A level 0, full backup, guarantees the entire file system is copied 133(but see also the 134.Fl h 135option below). 136A level number above 0, incremental backup, 137tells dump to copy all files new or modified since the 138last dump of a lower level. 139The default level is 9. 140.It Fl a 141.Dq auto-size . 142Bypass all tape length considerations, and enforce writing 143until an end-of-media indication is returned. 144This fits best for most modern tape drives. 145Use of this option is particularly recommended when appending to an 146existing tape, or using a tape drive with hardware compression (where 147you can never be sure about the compression ratio). 148.It Fl B Ar records 149The number of kilobytes per volume, rounded 150down to a multiple of the blocksize. 151This option overrides the calculation of tape size 152based on length and density. 153.It Fl b Ar blocksize 154The number of kilobytes per dump record. 155.It Fl c 156Modify the calculation of the default density and tape size to be more 157appropriate for cartridge tapes. 158.It Fl d Ar density 159Set tape density to 160.Ar density . 161The default is 1600 Bits Per Inch (BPI). 162.It Fl e 163Eject tape automatically if a tape change is required. 164.It Fl F 165Indicates that 166.Ar files-to-dump 167is a file system image. 168.It Fl f Ar file 169Write the backup to 170.Ar file ; 171.Ar file 172may be a special device file like 173.Pa /dev/rst0 174(a tape drive), 175.Pa /dev/rsd1c 176(a disk drive), 177an ordinary file, or 178.Ql Fl 179(the standard output). 180Multiple file names may be given as a single argument separated by commas. 181Each file will be used for one dump volume in the order listed; 182if the dump requires more volumes than the number of names given, 183the last file name will used for all remaining volumes after prompting 184for media changes. 185If the name of the file is of the form 186.Qq host:file , 187or 188.Qq user@host:file , 189.Nm 190writes to the named file on the remote host using 191.Xr rmt 8 . 192Note that methods more secure than 193.Xr rsh 1 194.Pq such as Xr ssh 1 195can be used to invoke 196.Xr rmt 8 197on the remote host, via the environment variable 198.Ev RCMD_CMD . 199See 200.Xr rcmd 3 201for more details. 202.It Fl h Ar level 203Honor the user 204.Qq nodump 205flag 206.Pq Dv UF_NODUMP 207only for dumps at or above the given 208.Ar level . 209The default honor level is 1, 210so that incremental backups omit such files 211but full backups retain them. 212.It Fl k Ar read blocksize 213The size in kilobyte of the read buffers, rounded up to a multiple of the 214file system block size. 215Default is 32k. 216.It Fl l Ar timeout 217If a tape change is required, eject the tape and wait for the drive to 218be ready again. 219This is to be used with tape changers which automatically load 220the next tape when the tape is ejected. 221If after the timeout (in seconds) the drive is not ready 222.Nm 223falls back to the default behavior, 224and prompts the operator for the next tape. 225.It Fl L Ar label 226The user-supplied text string 227.Ar label 228is placed into the dump header, where tools like 229.Xr restore 8 230and 231.Xr file 1 232can access it. 233Note that this label is limited to be at most LBLSIZE 234(currently 16) characters, which must include the terminating 235.Ql \e0 . 236.It Fl n 237Whenever 238.Nm 239requires operator attention, 240notify all operators in the group 241.Qq operator 242using 243.Xr wall 1 . 244.It Fl r Ar cachesize 245Use that many buffers for read cache operations. 246A value of zero disables the read cache altogether, higher values 247improve read performance by reading larger data blocks from the 248disk and maintaining them in an LRU cache. 249See the 250.Fl k 251option for the size of the buffers. 252Maximum is 512, the size of the cache is 253limited to 15% of the avail RAM by default. 254.It Fl s Ar feet 255Attempt to calculate the amount of tape needed 256at a particular density. 257If this amount is exceeded, 258.Nm 259prompts for a new tape. 260It is recommended to be a bit conservative on this option. 261The default tape length is 2300 feet. 262.It Fl S 263Display an estimate of the backup size and the number of tapes 264required, and exit without actually performing the dump. 265.It Fl t 266All informational log messages printed by 267.Nm 268will have the time prepended to them. 269Also, the completion time interval estimations 270will have the estimated time at which the dump 271will complete printed at the end of the line. 272.It Fl T Ar date 273Use the specified date as the starting time for the dump 274instead of the time determined from looking in 275.Pa /etc/dumpdates . 276The format of date is the same as that of 277.Xr ctime 3 . 278This option is useful for automated dump scripts that wish to 279dump over a specific period of time. 280The 281.Fl T 282option is mutually exclusive from the 283.Fl u 284option. 285.It Fl u 286Update the file 287.Pa /etc/dumpdates 288after a successful dump. 289The format of 290.Pa /etc/dumpdates 291is readable by people, consisting of one 292free format record per line: 293file system name, 294increment level 295and 296.Xr ctime 3 297format dump date. 298There may be only one entry per file system at each level. 299The file 300.Pa /etc/dumpdates 301may be edited to change any of the fields, 302if necessary. 303If a list of files or subdirectories is being dumped 304(as opposed to an entire file system), then 305.Fl u 306is ignored. 307.It Fl W 308.Nm 309tells the operator what file systems need to be dumped. 310This information is gleaned from the files 311.Pa /etc/dumpdates 312and 313.Pa /etc/fstab . 314The 315.Fl W 316option causes 317.Nm 318to print out, for each file system in 319.Pa /etc/dumpdates 320the most recent dump date and level, 321and highlights those file systems that should be dumped. 322If the 323.Fl W 324option is set, all other options are ignored, and 325.Nm 326exits immediately. 327.It Fl w 328Is like W, but prints only those file systems which need to be dumped. 329.El 330.Pp 331If 332.Nm 333honors the 334.Qq nodump 335flag 336.Pq Dv UF_NODUMP , 337files with the 338.Qq nodump 339flag will not be backed up. 340If a directory has the 341.Qq nodump 342flag, this directory and any file or directory under it will not be backed up. 343.Pp 344.Nm 345requires operator intervention on these conditions: 346end of tape, 347end of dump, 348tape write error, 349tape open error or 350disk read error (if there are more than a threshold of 32). 351In addition to alerting all operators implied by the 352.Fl n 353option, 354.Nm 355interacts with the operator on 356.Nm Ns 's 357control terminal at times when 358.Nm 359can no longer proceed, 360or if something is grossly wrong. 361All questions 362.Nm 363poses 364.Em must 365be answered by typing 366.Qq yes 367or 368.Qq no , 369appropriately. 370.Pp 371Since making a dump involves a lot of time and effort for full dumps, 372.Nm 373checkpoints itself at the start of each tape volume. 374If writing that volume fails for some reason, 375.Nm 376will, 377with operator permission, 378restart itself from the checkpoint 379after the old tape has been rewound and removed, 380and a new tape has been mounted. 381.Pp 382.Nm 383tells the operator what is going on at periodic intervals, 384including usually low estimates of the number of blocks to write, 385the number of tapes it will take, the time to completion, and 386the time to the tape change. 387The output is verbose, 388so that others know that the terminal 389controlling 390.Nm 391is busy, 392and will be for some time. 393.Pp 394In the event of a catastrophic disk event, the time required 395to restore all the necessary backup tapes or files to disk 396can be kept to a minimum by staggering the incremental dumps. 397An efficient method of staggering incremental dumps 398to minimize the number of tapes follows: 399.Bl -bullet -offset indent 400.It 401Always start with a level 0 backup, for example: 402.Bd -literal -offset indent 403/sbin/dump -0u -f /dev/nrst1 /usr/src 404.Ed 405.Pp 406This should be done at set intervals, say once a month or once every two months, 407and on a set of fresh tapes that is saved forever. 408.It 409After a level 0, dumps of active file 410systems are taken on a daily basis, 411using a modified Tower of Hanoi algorithm, 412with this sequence of dump levels: 413.Bd -literal -offset indent 4143 2 5 4 7 6 9 8 9 9 ... 415.Ed 416.Pp 417For the daily dumps, it should be possible to use a fixed number of tapes 418for each day, used on a weekly basis. 419Each week, a level 1 dump is taken, and 420the daily Hanoi sequence repeats beginning with 3. 421For weekly dumps, another fixed set of tapes per dumped file system is 422used, also on a cyclical basis. 423.El 424.Pp 425After several months or so, the daily and weekly tapes should get 426rotated out of the dump cycle and fresh tapes brought in. 427.Pp 428If 429.Nm 430receives a 431.Dv SIGINFO 432signal 433(see the 434.Qq status 435argument of 436.Xr stty 1 ) 437whilst a backup is in progress, statistics on the amount completed, 438current transfer rate, and estimated finished time, will be written 439to the standard error output. 440.Sh ENVIRONMENT 441If the following environment variables exist, they are used by 442.Nm . 443.Bl -tag -width Fl 444.It Ev TAPE 445If no -f option was specified, 446.Nm 447will use the device specified via 448.Ev TAPE 449as the dump device. 450.Ev TAPE 451may be of the form 452.Qq tapename , 453.Qq host:tapename , 454or 455.Qq user@host:tapename . 456.It Ev RCMD_CMD 457.Nm 458will use 459.Ev RCMD_CMD 460rather than 461.Xr rsh 1 462to invoke 463.Xr rmt 8 464on the remote machine. 465.It Ev TIMEFORMAT 466can be used to control the format of the timestamps produced by the 467.Fl t 468option. 469.Ev TIMEFORMAT 470is a string containing embedded formatting commands for 471.Xr strftime 3 . 472The total formatted string is limited to about 80 characters, if this 473limit is exceeded then 474.Qo 475ERROR: TIMEFORMAT too long, reverting to default 476.Qc 477will be printed and the time format will revert to the default one. 478If 479.Ev TIMEFORMAT 480is not set then the format string defaults to 481.Qo 482%T %Z 483.Qc 484.El 485.Sh FILES 486.Bl -tag -width /etc/dumpdates -compact 487.It Pa /dev/nrst0 488default tape unit to use. 489Taken from 490.Dv _PATH_DEFTAPE 491in 492.Pa /usr/include/paths.h . 493.It Pa /dev/rst* 494raw SCSI tape interface 495.It Pa /etc/dumpdates 496dump date records 497.It Pa /etc/fstab 498dump table: file systems and frequency 499.It Pa /etc/group 500to find group 501.Em operator 502.El 503.Sh DIAGNOSTICS 504Many, and verbose. 505.Pp 506.Nm 507exits with zero status on success. 508Startup errors are indicated with an exit code of 1; 509abnormal termination is indicated with an exit code of 3. 510.Sh SEE ALSO 511.Xr chflags 1 , 512.Xr rcmd 1 , 513.Xr stty 1 , 514.Xr wall 1 , 515.Xr fts 3 , 516.Xr rcmd 3 , 517.Xr st 4 , 518.Xr fstab 5 , 519.Xr environ 7 , 520.Xr restore 8 , 521.Xr rmt 8 522.Sh HISTORY 523A 524.Nm 525command appeared in 526.At v6 . 527.Sh BUGS 528Fewer than 32 read errors on the file system are ignored. 529.Pp 530Each reel requires a new process, so parent processes for 531reels already written just hang around until the entire tape 532is written. 533.Pp 534.Nm 535with the 536.Fl W 537or 538.Fl w 539options does not report file systems that have never been recorded 540in 541.Pa /etc/dumpdates , 542even if listed in 543.Pa /etc/fstab . 544.Pp 545When dumping a list of files or subdirectories, access privileges are 546required to scan the directory (as this is done via the 547.Xr fts 3 548routines rather than directly accessing the file system). 549.Pp 550It would be nice if 551.Nm 552knew about the dump sequence, 553kept track of the tapes scribbled on, 554told the operator which tape to mount when, 555and provided more assistance 556for the operator running 557.Xr restore 8 . 558