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