xref: /netbsd-src/sbin/dump/dump.8 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.\"	$NetBSD: dump.8,v 1.69 2018/07/15 06:14:13 dholland 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 15, 2018
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.Pp
453The historic alternate name
454.Nm rdump
455was once required when dumping to a remote host.
456This functionality is now built into
457.Nm
458itself.
459.Sh ENVIRONMENT
460If the following environment variables exist, they are used by
461.Nm .
462.Bl -tag -width Fl
463.It Ev TAPE
464If no -f option was specified,
465.Nm
466will use the device specified via
467.Ev TAPE
468as the dump device.
469.Ev TAPE
470may be of the form
471.Qq tapename ,
472.Qq host:tapename ,
473or
474.Qq user@host:tapename .
475.It Ev RCMD_CMD
476.Nm
477will use
478.Ev RCMD_CMD
479rather than
480.Xr rsh 1
481to invoke
482.Xr rmt 8
483on the remote machine.
484.It Ev TIMEFORMAT
485can be used to control the format of the timestamps produced by the
486.Fl t
487option.
488.Ev TIMEFORMAT
489is a string containing embedded formatting commands for
490.Xr strftime 3 .
491The total formatted string is limited to about 80 characters, if this
492limit is exceeded then
493.Qo
494ERROR: TIMEFORMAT too long, reverting to default
495.Qc
496will be printed and the time format will revert to the default one.
497If
498.Ev TIMEFORMAT
499is not set then the format string defaults to
500.Qo
501%T %Z
502.Qc
503.El
504.Sh FILES
505.Bl -tag -width /etc/dumpdates -compact
506.It Pa /dev/nrst0
507default tape unit to use.
508Taken from
509.Dv _PATH_DEFTAPE
510in
511.Pa /usr/include/paths.h .
512.It Pa /dev/rst*
513raw SCSI tape interface
514.It Pa /etc/dumpdates
515dump date records
516.It Pa /etc/fstab
517dump table: file systems and frequency
518.It Pa /etc/group
519to find group
520.Em operator
521.El
522.Sh DIAGNOSTICS
523Many, and verbose.
524.Pp
525.Nm
526exits with zero status on success.
527Startup errors are indicated with an exit code of 1;
528abnormal termination is indicated with an exit code of 3.
529.Sh SEE ALSO
530.Xr chflags 1 ,
531.Xr rcmd 1 ,
532.Xr stty 1 ,
533.Xr wall 1 ,
534.Xr fts 3 ,
535.Xr rcmd 3 ,
536.Xr fss 4 ,
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.At v4 .
547.Pp
548The
549.Fl i
550flag was inspired by the
551.Fl x
552flag from Sun's Solstice Backup utility.
553.Sh BUGS
554At least the following caveats can be mentioned.
555.Bl -bullet
556.It
557Fewer than 32 read errors on the file system are ignored.
558.It
559Each reel requires a new process, so parent processes for
560reels already written just hang around until the entire tape
561is written.
562.It
563.Nm
564with the
565.Fl W
566or
567.Fl w
568options does not report file systems that have never been recorded
569in
570.Pa /etc/dumpdates ,
571even if listed in
572.Pa /etc/fstab .
573.It
574When dumping a list of files or subdirectories, access privileges are
575required to scan the directory (as this is done via the
576.Xr fts 3
577routines rather than directly accessing the file system).
578.It
579It would be nice if
580.Nm
581knew about the dump sequence,
582kept track of the tapes scribbled on,
583told the operator which tape to mount when,
584and provided more assistance
585for the operator running
586.Xr restore 8 .
587.It
588Snapshot support is
589.Em experimental .
590Be sure you have a backup before you use it.
591.El
592