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