1.\" $NetBSD: dump_lfs.8,v 1.10 2003/05/26 10:18:40 lukem 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. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)dump.8 8.3 (Berkeley) 5/1/95 36.\" 37.Dd May 26, 2003 38.Dt DUMP_LFS 8 39.Os 40.Sh NAME 41.Nm dump_lfs , 42.Nm rdump_lfs 43.Nd filesystem backup 44.Sh SYNOPSIS 45.Nm 46.Op Fl 0123456789cnSu 47.Op Fl B Ar records 48.Op Fl b Ar blocksize 49.Op Fl d Ar density 50.Op Fl f Ar file 51.Op Fl h Ar level 52.Op Fl k Ar read blocksize 53.Op Fl L Ar label 54.Op Fl r Ar cachesize 55.Op Fl s Ar feet 56.Op Fl T Ar date 57.Ar files-to-dump 58.Nm 59.Op Fl W Li \&| Fl w 60.Pp 61.in -\n(iSu 62(The 63.Bx 4.3 64option syntax is implemented for backward compatibility, but 65is not documented here). 66.Sh DESCRIPTION 67.Nm 68examines files on a filesystem and determines which files need to 69be backed up. 70These files are copied to the given disk, tape or other storage 71medium for safe keeping (see the 72.Fl f 73option below for doing remote backups). 74A dump that is larger than the output medium is broken into 75multiple volumes. 76On most media the size is determined by writing until an 77end-of-media indication is returned. 78On media that cannot reliably return an end-of-media indication 79(such as some cartridge tape drives) 80each 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 mountpoint of a filesystem, 88or a list of files and directories on a single filesystem to be backed 89up as a subset of the filesystem. 90In the former case, either the path to a mounted filesystem, 91or the device of an unmounted filesystem can be used. 92In the latter case, certain restrictions are placed on the backup: 93.Fl u 94is ignored, the only dump level that is supported is 95.Fl 0 , 96and all of the files must reside on the same filesystem. 97.Pp 98The following options are supported by 99.Nm : 100.Bl -tag -width Ds 101.It Fl 0\-9 102Dump levels. 103A level 0, full backup, 104guarantees the entire file system is copied 105(but see also the 106.Fl h 107option below). 108A level number above 0, 109incremental backup, 110tells dump to 111copy all files new or modified since the 112last dump of a lower level. 113The default level is 9. 114.It Fl B Ar records 115The number of kilobytes per volume, rounded 116down to a multiple of the blocksize. 117This option overrides the calculation of tape size 118based on length and density. 119.It Fl b Ar blocksize 120The number of kilobytes per dump record. 121.It Fl c 122Modify the calculation of the default density and tape size to be more 123appropriate for cartridge tapes. 124.It Fl d Ar density 125Set tape density to 126.Ar density . 127The default is 1600 Bits Per Inch (BPI). 128.It Fl f Ar file 129Write the backup to 130.Ar file ; 131.Ar file 132may be a special device file 133like 134.Pa /dev/rst0 135(a tape drive), 136.Pa /dev/rsd1c 137(a disk drive), 138an ordinary file, 139or 140.Ql Fl 141(the standard output). 142Multiple file names may be given as a single argument separated by commas. 143Each file will be used for one dump volume in the order listed; 144if the dump requires more volumes than the number of names given, 145the last file name will used for all remaining volumes after prompting 146for media changes. 147If the name of the file is of the form 148.Qq host:file , 149or 150.Qq user@host:file , 151.Nm 152writes to the named file on the remote host using 153.Xr rmt 8 . 154Note that methods more secure than 155.Xr rsh 1 156.Pq such as Xr ssh 1 157can be used to invoke 158.Xr rmt 8 159on the remote host, via the environment variable 160.Ev RCMD_CMD . 161See 162.Xr rcmd 3 163for more details. 164.It Fl h Ar level 165Honor the user 166.Qq nodump 167flag 168.Pq Dv UF_NODUMP 169only for dumps at or above the given 170.Ar level . 171The default honor level is 1, 172so that incremental backups omit such files 173but full backups retain them. 174.It Fl k Ar read blocksize 175The size in kilobyte of the read buffers, rounded up to a multiple of the 176filesystem block size. 177Default is 32k. 178.It Fl L Ar label 179The user-supplied text string 180.Ar label 181is placed into the dump header, where tools like 182.Xr restore 8 183and 184.Xr file 1 185can access it. 186Note that this label is limited 187to be at most LBLSIZE (currently 16) characters, which must include 188the terminating 189.Ql \e0 . 190.It Fl n 191Whenever 192.Nm 193requires operator attention, 194notify all operators in the group 195.Qq operator 196by means similar to a 197.Xr wall 1 . 198.It Fl r Ar cachesize 199Use that many buffers for read cache operations. 200A value of zero disables the read cache altogether, higher values 201improve read performance by reading larger data blocks from the 202disk and maintaining them in an LRU cache. 203See the 204.Fl k 205option for the size of the buffers. 206Maximum is 512, the size of the cache is 207limited to 15% of the avail RAM by default. 208.It Fl s Ar feet 209Attempt to calculate the amount of tape needed 210at a particular density. 211If this amount is exceeded, 212.Nm 213prompts for a new tape. 214It is recommended to be a bit conservative on this option. 215The default tape length is 2300 feet. 216.It Fl S 217Display an estimate of the backup size and the number of tapes 218required, and exit without actually performing the dump. 219.It Fl T Ar date 220Use the specified date as the starting time for the dump 221instead of the time determined from looking in 222.Pa /etc/dumpdates . 223The format of date is the same as that of 224.Xr ctime 3 . 225This option is useful for automated dump scripts that wish to 226dump over a specific period of time. 227The 228.Fl T 229option is mutually exclusive from the 230.Fl u 231option. 232.It Fl u 233Update the file 234.Pa /etc/dumpdates 235after a successful dump. 236The format of 237.Pa /etc/dumpdates 238is readable by people, consisting of one 239free format record per line: 240filesystem name, 241increment level 242and 243.Xr ctime 3 244format dump date. 245There may be only one entry per filesystem at each level. 246The file 247.Pa /etc/dumpdates 248may be edited to change any of the fields, 249if necessary. 250If a list of files or subdirectories is being dumped 251(as opposed to and entire filesystem), then 252.Fl u 253is ignored. 254.It Fl W 255.Nm 256tells the operator what file systems need to be dumped. 257This information is gleaned from the files 258.Pa /etc/dumpdates 259and 260.Pa /etc/fstab . 261The 262.Fl W 263option causes 264.Nm 265to print out, for each file system in 266.Pa /etc/dumpdates 267the most recent dump date and level, 268and highlights those file systems that should be dumped. 269If the 270.Fl W 271option is set, all other options are ignored, and 272.Nm 273exits immediately. 274.It Fl w 275Is like W, but prints only those filesystems which need to be dumped. 276.El 277.Pp 278If 279.Nm 280honors the 281.Qq nodump 282flag 283.Pq Dv UF_NODUMP , 284files with the 285.Qq nodump 286flag will not be backed up. 287If a directory has the 288.Qq nodump 289flag, this directory and any file or directory under it will not be backed up. 290.Pp 291.Nm 292requires operator intervention on these conditions: 293end of tape, 294end of dump, 295tape write error, 296tape open error or 297disk read error (if there are more than a threshold of 32). 298In addition to alerting all operators implied by the 299.Fl n 300option, 301.Nm 302interacts with the operator on 303.Nm Ns 's 304control terminal at times when 305.Nm 306can no longer proceed, 307or if something is grossly wrong. 308All questions 309.Nm 310poses 311.Em must 312be answered by typing 313.Qq yes 314or 315.Qq no , 316appropriately. 317.Pp 318Since making a dump involves a lot of time and effort for full dumps, 319.Nm 320checkpoints itself at the start of each tape volume. 321If writing that volume fails for some reason, 322.Nm 323will, 324with operator permission, 325restart itself from the checkpoint 326after the old tape has been rewound and removed, 327and a new tape has been mounted. 328.Pp 329.Nm 330tells the operator what is going on at periodic intervals, 331including usually low estimates of the number of blocks to write, 332the number of tapes it will take, the time to completion, and 333the time to the tape change. 334The output is verbose, 335so that others know that the terminal 336controlling 337.Nm 338is busy, 339and will be for some time. 340.Pp 341In the event of a catastrophic disk event, the time required 342to restore all the necessary backup tapes or files to disk 343can be kept to a minimum by staggering the incremental dumps. 344An efficient method of staggering incremental dumps 345to minimize the number of tapes follows: 346.Bl -bullet -offset indent 347.It 348Always start with a level 0 backup, for example: 349.Bd -literal -offset indent 350/sbin/dump -0u -f /dev/nrst1 /usr/src 351.Ed 352.Pp 353This should be done at set intervals, say once a month or once every two months, 354and on a set of fresh tapes that is saved forever. 355.It 356After a level 0, dumps of active file 357systems are taken on a daily basis, 358using a modified Tower of Hanoi algorithm, 359with this sequence of dump levels: 360.Bd -literal -offset indent 3613 2 5 4 7 6 9 8 9 9 ... 362.Ed 363.Pp 364For the daily dumps, it should be possible to use a fixed number of tapes 365for each day, used on a weekly basis. 366Each week, a level 1 dump is taken, and 367the daily Hanoi sequence repeats beginning with 3. 368For weekly dumps, another fixed set of tapes per dumped file system is 369used, also on a cyclical basis. 370.El 371.Pp 372After several months or so, the daily and weekly tapes should get 373rotated out of the dump cycle and fresh tapes brought in. 374.Pp 375If 376.Nm 377receives a 378.Dv SIGINFO 379signal 380(see the 381.Qq status 382argument of 383.Xr stty 1 ) 384whilst a backup is in progress, statistics on the amount completed, 385current transfer rate, and estimated finished time, will be written 386to the standard error output. 387.Sh ENVIRONMENT 388If the following environment variables exist, they are used by 389.Nm . 390.Bl -tag -width Fl 391.It Ev TAPE 392If no -f option was specified, 393.Nm 394will use the device specified via 395.Ev TAPE 396as the dump device. 397.Ev TAPE 398may be of the form 399.Qq tapename , 400.Qq host:tapename , 401or 402.Qq user@host:tapename . 403.It Ev RCMD_CMD 404.Nm 405will use 406.Ev RCMD_CMD 407rather than 408.Xr rsh 1 409to invoke 410.Xr rmt 8 411on the remote machine. 412.El 413.Sh FILES 414.Bl -tag -width /etc/dumpdates -compact 415.It Pa /dev/nrst0 416default tape unit to use. 417Taken from 418.Dv _PATH_DEFTAPE 419in 420.Pa /usr/include/paths.h . 421.It Pa /dev/rst* 422raw SCSI tape interface 423.It Pa /etc/dumpdates 424dump date records 425.It Pa /etc/fstab 426dump table: file systems and frequency 427.It Pa /etc/group 428to find group 429.Em operator 430.El 431.Sh DIAGNOSTICS 432Many, and verbose. 433.Pp 434.Nm 435exits with zero status on success. 436Startup errors are indicated with an exit code of 1; 437abnormal termination is indicated with an exit code of 3. 438.Sh SEE ALSO 439.Xr chflags 1 , 440.Xr rcmd 1 , 441.Xr stty 1 , 442.Xr fts 3 , 443.Xr rcmd 3 , 444.Xr st 4 , 445.Xr fstab 5 , 446.Xr environ 7 , 447.Xr restore 8 , 448.Xr rmt 8 449.Sh HISTORY 450A 451.Nm 452command appeared in 453.Nx 1.5 . 454.Sh BUGS 455Fewer than 32 read errors on the filesystem are ignored. 456.Pp 457Each reel requires a new process, so parent processes for 458reels already written just hang around until the entire tape 459is written. 460.Pp 461.Nm 462with the 463.Fl W 464or 465.Fl w 466options does not report filesystems that have never been recorded 467in 468.Pa /etc/dumpdates , 469even if listed in 470.Pa /etc/fstab . 471.Pp 472When dumping a list of files or subdirectories, access privileges are 473required to scan the directory (as this is done via the 474.Xr fts 3 475routines rather than directly accessing the filesystem). 476.Pp 477It would be nice if 478.Nm 479knew about the dump sequence, 480kept track of the tapes scribbled on, 481told the operator which tape to mount when, 482and provided more assistance 483for the operator running 484.Xr restore 8 . 485