1.\" $NetBSD: dump_lfs.8,v 1.14 2006/06/24 07:57:07 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 July 23, 2006 34.Dt DUMP_LFS 8 35.Os 36.Sh NAME 37.Nm dump_lfs , 38.Nm rdump_lfs 39.Nd filesystem 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 237.Dv LBLSIZE 238(currently 16) characters, which must include the terminating 239.Ql \e0 . 240.It Fl n 241Whenever 242.Nm 243requires operator attention, 244notify all operators in the group 245.Qq operator 246using 247.Xr wall 1 . 248.It Fl r Ar cachesize 249Use that many buffers for read cache operations. 250A value of zero disables the read cache altogether, higher values 251improve read performance by reading larger data blocks from the 252disk and maintaining them in an LRU cache. 253See the 254.Fl k 255option for the size of the buffers. 256Maximum is 512, the size of the cache is 257limited to 15% of the avail RAM by default. 258.It Fl s Ar feet 259Attempt to calculate the amount of tape needed 260at a particular density. 261If this amount is exceeded, 262.Nm 263prompts for a new tape. 264It is recommended to be a bit conservative on this option. 265The default tape length is 2300 feet. 266.It Fl S 267Display an estimate of the backup size and the number of tapes 268required, and exit without actually performing the dump. 269.It Fl t 270All informational log messages printed by 271.Nm 272will have the time prepended to them. 273Also, the completion time interval estimations 274will have the estimated time at which the dump 275will complete printed at the end of the line. 276.It Fl T Ar date 277Use the specified date as the starting time for the dump 278instead of the time determined from looking in 279.Pa /etc/dumpdates . 280The format of date is the same as that of 281.Xr ctime 3 . 282This option is useful for automated dump scripts that wish to 283dump over a specific period of time. 284The 285.Fl T 286option is mutually exclusive from the 287.Fl u 288option. 289.It Fl u 290Update the file 291.Pa /etc/dumpdates 292after a successful dump. 293The format of 294.Pa /etc/dumpdates 295is readable by people, consisting of one 296free format record per line: 297file system name, 298increment level 299and 300.Xr ctime 3 301format dump date. 302There may be only one entry per file system at each level. 303The file 304.Pa /etc/dumpdates 305may be edited to change any of the fields, 306if necessary. 307If a list of files or subdirectories is being dumped 308(as opposed to an entire file system), then 309.Fl u 310is ignored. 311.It Fl X 312Prevent the log from wrapping until the dump completes, guaranteeing 313a consistent backup. 314Processes that write to the filesystem will continue as usual 315until the entire log is full, after which they will block 316until the dump is complete. 317This functionality is analogous to what 318.Xr fss 4 319provides for other file systems. 320The 321.Fl x 322flag is provided for compatibility with 323.Xr dump 8 ; 324it functions exactly as the 325.Fl X 326flag does (its argument is ignored). 327.It Fl W 328.Nm 329tells the operator what file systems need to be dumped. 330This information is gleaned from the files 331.Pa /etc/dumpdates 332and 333.Pa /etc/fstab . 334The 335.Fl W 336option causes 337.Nm 338to print out, for each file system in 339.Pa /etc/dumpdates 340the most recent dump date and level, 341and highlights those file systems that should be dumped. 342If the 343.Fl W 344option is set, all other options are ignored, and 345.Nm 346exits immediately. 347.It Fl w 348Is like W, but prints only those file systems which need to be dumped. 349.El 350.Pp 351If 352.Nm 353honors the 354.Qq nodump 355flag 356.Pq Dv UF_NODUMP , 357files with the 358.Qq nodump 359flag will not be backed up. 360If a directory has the 361.Qq nodump 362flag, this directory and any file or directory under it will not be backed up. 363.Pp 364.Nm 365requires operator intervention on these conditions: 366end of tape, 367end of dump, 368tape write error, 369tape open error or 370disk read error (if there are more than a threshold of 32). 371In addition to alerting all operators implied by the 372.Fl n 373option, 374.Nm 375interacts with the operator on 376.Nm Ns 's 377control terminal at times when 378.Nm 379can no longer proceed, 380or if something is grossly wrong. 381All questions 382.Nm 383poses 384.Em must 385be answered by typing 386.Qq yes 387or 388.Qq no , 389appropriately. 390.Pp 391Since making a dump involves a lot of time and effort for full dumps, 392.Nm 393checkpoints itself at the start of each tape volume. 394If writing that volume fails for some reason, 395.Nm 396will, 397with operator permission, 398restart itself from the checkpoint 399after the old tape has been rewound and removed, 400and a new tape has been mounted. 401.Pp 402.Nm 403tells the operator what is going on at periodic intervals, 404including usually low estimates of the number of blocks to write, 405the number of tapes it will take, the time to completion, and 406the time to the tape change. 407The output is verbose, 408so that others know that the terminal 409controlling 410.Nm 411is busy, 412and will be for some time. 413.Pp 414In the event of a catastrophic disk event, the time required 415to restore all the necessary backup tapes or files to disk 416can be kept to a minimum by staggering the incremental dumps. 417An efficient method of staggering incremental dumps 418to minimize the number of tapes follows: 419.Bl -bullet -offset indent 420.It 421Always start with a level 0 backup, for example: 422.Bd -literal -offset indent 423/sbin/dump -0u -f /dev/nrst1 /usr/src 424.Ed 425.Pp 426This should be done at set intervals, say once a month or once every two months, 427and on a set of fresh tapes that is saved forever. 428.It 429After a level 0, dumps of active file 430systems are taken on a daily basis, 431using a modified Tower of Hanoi algorithm, 432with this sequence of dump levels: 433.Bd -literal -offset indent 4343 2 5 4 7 6 9 8 9 9 ... 435.Ed 436.Pp 437For the daily dumps, it should be possible to use a fixed number of tapes 438for each day, used on a weekly basis. 439Each week, a level 1 dump is taken, and 440the daily Hanoi sequence repeats beginning with 3. 441For weekly dumps, another fixed set of tapes per dumped file system is 442used, also on a cyclical basis. 443.El 444.Pp 445After several months or so, the daily and weekly tapes should get 446rotated out of the dump cycle and fresh tapes brought in. 447.Pp 448If 449.Nm 450receives a 451.Dv SIGINFO 452signal 453(see the 454.Qq status 455argument of 456.Xr stty 1 ) 457whilst a backup is in progress, statistics on the amount completed, 458current transfer rate, and estimated finished time, will be written 459to the standard error output. 460.Sh ENVIRONMENT 461If the following environment variables exist, they are used by 462.Nm . 463.Bl -tag -width Fl 464.It Ev TAPE 465If no -f option was specified, 466.Nm 467will use the device specified via 468.Ev TAPE 469as the dump device. 470.Ev TAPE 471may be of the form 472.Qq tapename , 473.Qq host:tapename , 474or 475.Qq user@host:tapename . 476.It Ev RCMD_CMD 477.Nm 478will use 479.Ev RCMD_CMD 480rather than 481.Xr rsh 1 482to invoke 483.Xr rmt 8 484on the remote machine. 485.It Ev TIMEFORMAT 486can be used to control the format of the timestamps produced by the 487.Fl t 488option. 489.Ev TIMEFORMAT 490is a string containing embedded formatting commands for 491.Xr strftime 3 . 492The total formatted string is limited to about 80 characters, if this 493limit is exceeded then 494.Qo 495ERROR: TIMEFORMAT too long, reverting to default 496.Qc 497will be printed and the time format will revert to the default one. 498If 499.Ev TIMEFORMAT 500is not set then the format string defaults to 501.Qo 502%T %Z 503.Qc 504.El 505.Sh FILES 506.Bl -tag -width /etc/dumpdates -compact 507.It Pa /dev/nrst0 508default tape unit to use. 509Taken from 510.Dv _PATH_DEFTAPE 511in 512.Pa /usr/include/paths.h . 513.It Pa /dev/rst* 514raw SCSI tape interface 515.It Pa /etc/dumpdates 516dump date records 517.It Pa /etc/fstab 518dump table: file systems and frequency 519.It Pa /etc/group 520to find group 521.Em operator 522.El 523.Sh DIAGNOSTICS 524Many, and verbose. 525.Pp 526.Nm 527exits with zero status on success. 528Startup errors are indicated with an exit code of 1; 529abnormal termination is indicated with an exit code of 3. 530.Sh SEE ALSO 531.Xr chflags 1 , 532.Xr rcmd 1 , 533.Xr stty 1 , 534.Xr wall 1 , 535.Xr fts 3 , 536.Xr rcmd 3 , 537.Xr st 4 , 538.Xr fstab 5 , 539.Xr environ 7 , 540.Xr restore 8 , 541.Xr rmt 8 542.Sh HISTORY 543A 544.Nm 545command appeared in 546.Nx 1.5 . 547.Sh BUGS 548Fewer than 32 read errors on the file system are ignored. 549.Pp 550Each reel requires a new process, so parent processes for 551reels already written just hang around until the entire tape 552is written. 553.Pp 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.Pp 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.Pp 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