1.\" $NetBSD: dump.8,v 1.68 2016/08/15 00:03:14 sevan 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 August 15, 2016 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 be 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 kilobytes of the read buffers, rounded up to a multiple of the 209file system block size. 210Default is the value of the 211.Xr sysctl 7 212kern.maxphys. 213.It Fl L Ar label 214The user-supplied text string 215.Ar label 216is placed into the dump header, where tools like 217.Xr restore 8 218and 219.Xr file 1 220can access it. 221Note that this label is limited to be at most LBLSIZE 222(currently 16) characters, which must include the terminating 223.Ql \e0 . 224.It Fl l Ar timeout 225If a tape change is required, eject the tape and wait for the drive to 226be ready again. 227This is to be used with tape changers which automatically load 228the next tape when the tape is ejected. 229If after the timeout (in seconds) the drive is not ready 230.Nm 231falls back to the default behavior, 232and prompts the operator for the next tape. 233.It Fl n 234Whenever 235.Nm 236requires operator attention, 237notify all operators in the group 238.Qq operator 239using 240.Xr wall 1 . 241.It Fl r Ar cachesize 242Use that many buffers for read cache operations. 243A value of zero disables the read cache altogether, higher values 244improve read performance by reading larger data blocks from the 245disk and maintaining them in an LRU cache. 246See the 247.Fl k 248option for the size of the buffers. 249Maximum is 512, the size of the cache is 250limited to 15% of the avail RAM by default. 251.It Fl S 252Display an estimate of the backup size and the number of tapes 253required, and exit without actually performing the dump. 254.It Fl s Ar feet 255Attempt to calculate the amount of tape needed 256at a particular density. 257If this amount is exceeded, 258.Nm 259prompts for a new tape. 260It is recommended to be a bit conservative on this option. 261The default tape length is 2300 feet. 262.It Fl T Ar date 263Use the specified date as the starting time for the dump 264instead of the time determined from looking in 265.Pa /etc/dumpdates . 266The format of 267.Ar date 268is the same as that of 269.Xr ctime 3 . 270This option is useful for automated dump scripts that wish to 271dump over a specific period of time. 272The 273.Fl T 274option and the 275.Fl u 276option are mutually exclusive. 277.It Fl t 278All informational log messages printed by 279.Nm 280will have the time prepended to them. 281Also, the completion time interval estimations 282will have the estimated time at which the dump 283will complete printed at the end of the line. 284.It Fl u 285Update the file 286.Pa /etc/dumpdates 287after a successful dump. 288The format of 289.Pa /etc/dumpdates 290is readable by people, consisting of one 291free format record per line: 292file system name, 293increment level 294and 295.Xr ctime 3 296format dump date. 297There may be only one entry per file system at each level. 298The file 299.Pa /etc/dumpdates 300may be edited to change any of the fields, 301if necessary. 302If a list of files or subdirectories is being dumped 303(as opposed to an entire file system), then 304.Fl u 305is ignored. 306.It Fl W 307.Nm 308tells the operator what file systems need to be dumped. 309This information is gleaned from the files 310.Pa /etc/dumpdates 311and 312.Pa /etc/fstab . 313The 314.Fl W 315option causes 316.Nm 317to print out, for each file system in 318.Pa /etc/dumpdates 319the most recent dump date and level, 320and highlights those file systems that should be dumped. 321If the 322.Fl W 323option is set, all other options are ignored, and 324.Nm 325exits immediately. 326.It Fl w 327Like 328.Fl W , 329but prints only those file systems which need to be dumped. 330.It Fl X 331Similar to 332.Fl x 333but uses a file system internal snapshot on the file system to be dumped. 334.It Fl x Ar snap-backup 335Use a snapshot with 336.Ar snap-backup 337as backup for this dump. 338See 339.Xr fss 4 340for more details. 341.El 342.Pp 343If 344.Nm 345honors the 346.Qq nodump 347flag 348.Pq Dv UF_NODUMP , 349files with the 350.Qq nodump 351flag will not be backed up. 352If a directory has the 353.Qq nodump 354flag, this directory and any file or directory under it will not be backed up. 355.Pp 356.Nm 357requires operator intervention on these conditions: 358end of tape, 359end of dump, 360tape write error, 361tape open error or 362disk read error (if there are more than a threshold of 32). 363In addition to alerting all operators implied by the 364.Fl n 365option, 366.Nm 367interacts with the operator on 368.Nm Ns 's 369control terminal at times when 370.Nm 371can no longer proceed, 372or if something is grossly wrong. 373All questions 374.Nm 375poses 376.Em must 377be answered by typing 378.Qq yes 379or 380.Qq no , 381appropriately. 382.Pp 383Since making a dump involves a lot of time and effort for full dumps, 384.Nm 385checkpoints itself at the start of each tape volume. 386If writing that volume fails for some reason, 387.Nm 388will, 389with operator permission, 390restart itself from the checkpoint 391after the old tape has been rewound and removed, 392and a new tape has been mounted. 393.Pp 394.Nm 395tells the operator what is going on at periodic intervals, 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/nrst1 /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 422systems are taken on a daily basis, 423using a modified Tower of Hanoi algorithm, 424with this sequence of dump levels: 425.Bd -literal -offset indent 4263 2 5 4 7 6 9 8 9 9 ... 427.Ed 428.Pp 429For the daily dumps, it should be possible to use a fixed number of tapes 430for each day, used on a weekly basis. 431Each week, a level 1 dump is taken, and 432the daily Hanoi sequence repeats beginning with 3. 433For weekly dumps, another fixed set of tapes per dumped file system is 434used, also on a cyclical basis. 435.El 436.Pp 437After several months or so, the daily and weekly tapes should get 438rotated out of the dump cycle and fresh tapes brought in. 439.Pp 440If 441.Nm 442receives a 443.Dv SIGINFO 444signal 445(see the 446.Qq status 447argument of 448.Xr stty 1 ) 449whilst a backup is in progress, statistics on the amount completed, 450current transfer rate, and estimated finished time, will be written 451to the standard error output. 452.Sh ENVIRONMENT 453If the following environment variables exist, they are used by 454.Nm . 455.Bl -tag -width Fl 456.It Ev TAPE 457If no -f option was specified, 458.Nm 459will use the device specified via 460.Ev TAPE 461as the dump device. 462.Ev TAPE 463may be of the form 464.Qq tapename , 465.Qq host:tapename , 466or 467.Qq user@host:tapename . 468.It Ev RCMD_CMD 469.Nm 470will use 471.Ev RCMD_CMD 472rather than 473.Xr rsh 1 474to invoke 475.Xr rmt 8 476on the remote machine. 477.It Ev TIMEFORMAT 478can be used to control the format of the timestamps produced by the 479.Fl t 480option. 481.Ev TIMEFORMAT 482is a string containing embedded formatting commands for 483.Xr strftime 3 . 484The total formatted string is limited to about 80 characters, if this 485limit is exceeded then 486.Qo 487ERROR: TIMEFORMAT too long, reverting to default 488.Qc 489will be printed and the time format will revert to the default one. 490If 491.Ev TIMEFORMAT 492is not set then the format string defaults to 493.Qo 494%T %Z 495.Qc 496.El 497.Sh FILES 498.Bl -tag -width /etc/dumpdates -compact 499.It Pa /dev/nrst0 500default tape unit to use. 501Taken from 502.Dv _PATH_DEFTAPE 503in 504.Pa /usr/include/paths.h . 505.It Pa /dev/rst* 506raw SCSI tape interface 507.It Pa /etc/dumpdates 508dump date records 509.It Pa /etc/fstab 510dump table: file systems and frequency 511.It Pa /etc/group 512to find group 513.Em operator 514.El 515.Sh DIAGNOSTICS 516Many, and verbose. 517.Pp 518.Nm 519exits with zero status on success. 520Startup errors are indicated with an exit code of 1; 521abnormal termination is indicated with an exit code of 3. 522.Sh SEE ALSO 523.Xr chflags 1 , 524.Xr rcmd 1 , 525.Xr stty 1 , 526.Xr wall 1 , 527.Xr fts 3 , 528.Xr rcmd 3 , 529.Xr fss 4 , 530.Xr st 4 , 531.Xr fstab 5 , 532.Xr environ 7 , 533.Xr restore 8 , 534.Xr rmt 8 535.Sh HISTORY 536A 537.Nm 538command appeared in 539.At v4 . 540.Pp 541The 542.Fl i 543flag was inspired by the 544.Fl x 545flag from Sun's Solstice Backup utility. 546.Sh BUGS 547At least the following caveats can be mentioned. 548.Bl -bullet 549.It 550Fewer than 32 read errors on the file system are ignored. 551.It 552Each reel requires a new process, so parent processes for 553reels already written just hang around until the entire tape 554is written. 555.It 556.Nm 557with the 558.Fl W 559or 560.Fl w 561options does not report file systems that have never been recorded 562in 563.Pa /etc/dumpdates , 564even if listed in 565.Pa /etc/fstab . 566.It 567When dumping a list of files or subdirectories, access privileges are 568required to scan the directory (as this is done via the 569.Xr fts 3 570routines rather than directly accessing the file system). 571.It 572It would be nice if 573.Nm 574knew about the dump sequence, 575kept track of the tapes scribbled on, 576told the operator which tape to mount when, 577and provided more assistance 578for the operator running 579.Xr restore 8 . 580.It 581Snapshot support is 582.Em experimental . 583Be sure you have a backup before you use it. 584.El 585