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