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