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