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