1.\" Copyright (c) 1980, 1991, 1993 2.\" Regents of the University of California. 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 4. Neither the name of the University nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" @(#)dump.8 8.3 (Berkeley) 5/1/95 30.\" $FreeBSD$ 31.\" 32.Dd February 24, 2006 33.Dt DUMP 8 34.Os 35.Sh NAME 36.Nm dump , 37.Nm rdump 38.Nd file system backup 39.Sh SYNOPSIS 40.Nm 41.Op Fl 0123456789acLnSu 42.Op Fl B Ar records 43.Op Fl b Ar blocksize 44.Op Fl C Ar cachesize 45.Op Fl D Ar dumpdates 46.Op Fl d Ar density 47.Op Fl f Ar file | Fl P Ar pipecommand 48.Op Fl h Ar level 49.Op Fl s Ar feet 50.Op Fl T Ar date 51.Ar filesystem 52.Nm 53.Fl W | Fl w 54.Pp 55.Nm rdump 56is an alternate name for 57.Nm . 58.Pp 59.in \" XXX 60(The 61.Bx 4.3 62option syntax is implemented for backward compatibility, but 63is not documented here.) 64.Sh DESCRIPTION 65The 66.Nm 67utility examines files 68on a file system 69and determines which files 70need to be backed up. 71These files 72are copied to the given disk, tape or other 73storage medium for safe keeping (see the 74.Fl f 75option below for doing remote backups). 76A dump that is larger than the output medium is broken into 77multiple volumes. 78On most media the size is determined by writing until an 79end-of-media indication is returned. 80This can be enforced 81by using the 82.Fl a 83option. 84.Pp 85On media that cannot reliably return an end-of-media indication 86(such as some cartridge tape drives) 87each volume is of a fixed size; 88the actual size is determined by the tape size and density and/or 89.Fl B 90options. 91By default, the same output file name is used for each volume 92after prompting the operator to change media. 93.Pp 94The file system to be dumped is specified by the argument 95.Ar filesystem 96as either its device-special file or its mount point 97(if that is in a standard entry in 98.Pa /etc/fstab ) . 99.Pp 100The following options are supported by 101.Nm : 102.Bl -tag -width Ds 103.It Fl 0-9 104Dump levels. 105A level 0, full backup, 106guarantees the entire file system is copied 107(but see also the 108.Fl h 109option below). 110A level number above 0, 111incremental backup, 112tells dump to 113copy all files new or modified since the 114last dump of any lower level. 115The default level is 0. 116.It Fl a 117.Dq auto-size . 118Bypass all tape length considerations, and enforce writing 119until an end-of-media indication is returned. 120This fits best for most modern tape drives. 121Use of this option is particularly 122recommended when appending to an existing tape, or using a tape 123drive with hardware compression (where you can never be sure about 124the compression ratio). 125.It Fl B Ar records 126The number of kilobytes per output volume, except that if it is 127not an integer multiple of the output block size, 128the command uses the next smaller such multiple. 129This option overrides the calculation of tape size 130based on length and density. 131.It Fl b Ar blocksize 132The number of kilobytes per output block. 133The default block size is 10. 134.It Fl C Ar cachesize 135Specify the cache size in megabytes. 136This will greatly improve performance 137at the cost of 138.Nm 139possibly not noticing changes in the file system between passes. 140It is 141recommended that you always use this option when dumping a snapshot. 142Beware that 143.Nm 144forks, and the actual memory use may be larger than the specified cache 145size. 146The recommended cache size is between 8 and 32 (megabytes). 147.It Fl c 148Change the defaults for use with a cartridge tape drive, with a density 149of 8000 bpi, and a length of 1700 feet. 150.It Fl D Ar dumpdates 151Specify an alternate path to the 152.Pa dumpdates 153file. 154The default is 155.Pa /etc/dumpdates . 156.It Fl d Ar density 157Set tape density to 158.Ar density . 159The default is 1600BPI. 160.It Fl f Ar file 161Write the backup to 162.Ar file ; 163.Ar file 164may be a special device file 165like 166.Pa /dev/sa0 167(a tape drive), 168.Pa /dev/fd1 169(a floppy disk drive), 170an ordinary file, 171or 172.Sq Fl 173(the standard output). 174Multiple file names may be given as a single argument separated by commas. 175Each file will be used for one dump volume in the order listed; 176if the dump requires more volumes than the number of names given, 177the last file name will used for all remaining volumes after prompting 178for media changes. 179If the name of the file is of the form 180.Dq host:file , 181or 182.Dq user@host:file , 183.Nm 184writes to the named file on the remote host using 185.Xr rmt 8 . 186The default path name of the remote 187.Xr rmt 8 188program is 189.\" rmt path, is the path on the remote host 190.Pa /etc/rmt ; 191this can be overridden by the environment variable 192.Ev RMT . 193.It Fl P Ar pipecommand 194Use 195.Xr popen 3 196to execute the 197.Xr sh 1 198script string defined by 199.Ar pipecommand 200for the output device of each volume. 201This child pipeline's 202.Dv stdin 203.Pq Pa /dev/fd/0 204is redirected from the 205.Nm 206output stream, and the environment variable 207.Ev DUMP_VOLUME 208is set to the current volume number being written. 209After every volume, the writer side of the pipe is closed and 210.Ar pipecommand 211is executed again. 212Subject to the media size specified by 213.Fl B , 214each volume is written in this manner as if the output were a tape drive. 215.It Fl h Ar level 216Honor the user 217.Dq nodump 218flag 219.Pq Dv UF_NODUMP 220only for dumps at or above the given 221.Ar level . 222The default honor level is 1, 223so that incremental backups omit such files 224but full backups retain them. 225.It Fl L 226This option is to notify 227.Nm 228that it is dumping a live file system. 229To obtain a consistent dump image, 230.Nm 231takes a snapshot of the file system in the 232.Pa .snap 233directory in the root of the file system being dumped and 234then does a dump of the snapshot. 235The snapshot is unlinked as soon as the dump starts, and 236is thus removed when the dump is complete. 237This option is ignored for unmounted or read-only file systems. 238If the 239.Pa .snap 240directory does not exist in the root of the file system being dumped, 241a warning will be issued and the 242.Nm 243will revert to the standard behavior. 244This problem can be corrected by creating a 245.Pa .snap 246directory in the root of the file system to be dumped; 247its owner should be 248.Dq Li root , 249its group should be 250.Dq Li operator , 251and its mode should be 252.Dq Li 0770 . 253.It Fl n 254Whenever 255.Nm 256requires operator attention, 257notify all operators in the group 258.Dq operator 259by means similar to a 260.Xr wall 1 . 261.It Fl S 262Display an estimate of the backup size and the number of 263tapes required, and exit without actually performing the dump. 264.It Fl s Ar feet 265Attempt to calculate the amount of tape needed 266at a particular density. 267If this amount is exceeded, 268.Nm 269prompts for a new tape. 270It is recommended to be a bit conservative on this option. 271The default tape length is 2300 feet. 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 275the 276.Pa dumpdates 277file. 278The format of date is the same as that of 279.Xr ctime 3 . 280This option is useful for automated dump scripts that wish to 281dump over a specific period of time. 282The 283.Fl T 284option is mutually exclusive from the 285.Fl u 286option. 287.It Fl u 288Update the 289.Pa dumpdates 290file 291after a successful dump. 292The format of 293the 294.Pa dumpdates 295file 296is readable by people, consisting of one 297free format record per line: 298file system name, 299increment level 300and 301.Xr ctime 3 302format dump date. 303There may be only one entry per file system at each level. 304The 305.Pa dumpdates 306file 307may be edited to change any of the fields, 308if necessary. 309The default path for the 310.Pa dumpdates 311file is 312.Pa /etc/dumpdates , 313but the 314.Fl D 315option may be used to change it. 316.It Fl W 317Tell the operator what file systems need to be dumped. 318This information is gleaned from the files 319.Pa dumpdates 320and 321.Pa /etc/fstab . 322The 323.Fl W 324option causes 325.Nm 326to print out, for each file system in 327the 328.Pa dumpdates 329file 330the most recent dump date and level, 331and highlights those file systems that should be dumped. 332If the 333.Fl W 334option is set, all other options are ignored, and 335.Nm 336exits immediately. 337.It Fl w 338Is like 339.Fl W , 340but prints only those file systems which need to be dumped. 341.El 342.Pp 343Directories and regular files which have their 344.Dq nodump 345flag 346.Pq Dv UF_NODUMP 347set will be omitted along with everything under such directories, 348subject to the 349.Fl h 350option. 351.Pp 352The 353.Nm 354utility requires operator intervention on these conditions: 355end of tape, 356end of dump, 357tape write error, 358tape open error or 359disk read error (if there are more than a threshold of 32). 360In addition to alerting all operators implied by the 361.Fl n 362key, 363.Nm 364interacts with the operator on 365.Em dump's 366control terminal at times when 367.Nm 368can no longer proceed, 369or if something is grossly wrong. 370All questions 371.Nm 372poses 373.Em must 374be answered by typing 375.Dq yes 376or 377.Dq no , 378appropriately. 379.Pp 380Since making a dump involves a lot of time and effort for full dumps, 381.Nm 382checkpoints itself at the start of each tape volume. 383If writing that volume fails for some reason, 384.Nm 385will, 386with operator permission, 387restart itself from the checkpoint 388after the old tape has been rewound and removed, 389and a new tape has been mounted. 390.Pp 391The 392.Nm 393utility tells the operator what is going on at periodic intervals 394(every 5 minutes, or promptly after receiving 395.Dv SIGINFO ) , 396including usually low estimates of the number of blocks to write, 397the number of tapes it will take, the time to completion, and 398the time to the tape change. 399The output is verbose, 400so that others know that the terminal 401controlling 402.Nm 403is busy, 404and will be for some time. 405.Pp 406In the event of a catastrophic disk event, the time required 407to restore all the necessary backup tapes or files to disk 408can be kept to a minimum by staggering the incremental dumps. 409An efficient method of staggering incremental dumps 410to minimize the number of tapes follows: 411.Bl -bullet -offset indent 412.It 413Always start with a level 0 backup, for example: 414.Bd -literal -offset indent 415/sbin/dump -0u -f /dev/nsa0 /usr/src 416.Ed 417.Pp 418This should be done at set intervals, say once a month or once every two months, 419and on a set of fresh tapes that is saved forever. 420.It 421After a level 0, dumps of active file systems (file systems with files 422that change, depending on your partition layout some file systems may 423contain only data that does not change) are taken on a daily basis, 424using a modified Tower of Hanoi algorithm, 425with this sequence of dump levels: 426.Bd -literal -offset indent 4273 2 5 4 7 6 9 8 9 9 ... 428.Ed 429.Pp 430For the daily dumps, it should be possible to use a fixed number of tapes 431for each day, used on a weekly basis. 432Each week, a level 1 dump is taken, and 433the daily Hanoi sequence repeats beginning with 3. 434For weekly dumps, another fixed set of tapes per dumped file system is 435used, also on a cyclical basis. 436.El 437.Pp 438After several months or so, the daily and weekly tapes should get 439rotated out of the dump cycle and fresh tapes brought in. 440.Sh ENVIRONMENT 441.Bl -tag -width ".Ev TAPE" 442.It Ev TAPE 443The 444.Ar file 445or device to dump to if the 446.Fl f 447option is not used. 448.It Ev RMT 449Pathname of the remote 450.Xr rmt 8 451program. 452.It Ev RSH 453Pathname of a remote shell program, if not 454.Xr rsh 1 . 455.El 456.Sh FILES 457.Bl -tag -width /etc/dumpdates -compact 458.It Pa /dev/sa0 459default tape unit to dump to 460.It Pa /etc/dumpdates 461dump date records 462(this can be changed; 463see the 464.Fl D 465option) 466.It Pa /etc/fstab 467dump table: file systems and frequency 468.It Pa /etc/group 469to find group 470.Em operator 471.El 472.Sh EXIT STATUS 473Dump exits with zero status on success. 474Startup errors are indicated with an exit code of 1; 475abnormal termination is indicated with an exit code of 3. 476.Sh EXAMPLES 477Dumps the 478.Pa /u 479file system to DVDs using 480.Nm growisofs . 481Uses a 16MB cache, creates a snapshot of the dump, and records the 482.Pa dumpdates 483file. 484.Bd -literal 485/sbin/dump -0u -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /u 486.Ed 487.Sh DIAGNOSTICS 488Many, and verbose. 489.Sh SEE ALSO 490.Xr chflags 1 , 491.Xr fstab 5 , 492.Xr restore 8 , 493.Xr rmt 8 494.Sh HISTORY 495A 496.Nm 497utility appeared in 498.At v6 . 499.Sh BUGS 500Fewer than 32 read errors on the file system are ignored, though all 501errors will generate a warning message. 502This is a bit of a compromise. 503In practice, it is possible to generate read errors when doing dumps 504on mounted partitions if the file system is being modified while the 505.Nm 506is running. 507Since dumps are often done in an unattended fashion using 508.Xr cron 8 509jobs asking for Operator intervention would result in the 510.Nm 511dying. 512However, there is nothing wrong with a dump tape written when this sort 513of read error occurs, and there is no reason to terminate the 514.Nm . 515.Pp 516Each reel requires a new process, so parent processes for 517reels already written just hang around until the entire tape 518is written. 519.Pp 520The 521.Nm 522utility with the 523.Fl W 524or 525.Fl w 526options does not report file systems that have never been recorded 527in the 528.Pa dumpdates 529file, 530even if listed in 531.Pa /etc/fstab . 532.Pp 533It would be nice if 534.Nm 535knew about the dump sequence, 536kept track of the tapes scribbled on, 537told the operator which tape to mount when, 538and provided more assistance 539for the operator running 540.Xr restore 8 . 541.Pp 542The 543.Nm 544utility cannot do remote backups without being run as root, due to its 545security history. 546This will be fixed in a later version of 547.Fx . 548Presently, it works if you set it setuid (like it used to be), but this 549might constitute a security risk. 550