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