xref: /freebsd/sbin/dump/dump.8 (revision cc68614da8232d8baaca0ae0d0dd8f890f06623e)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	 Regents of the University of California.
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of the University nor the names of its contributors
14.\"    may be used to endorse or promote products derived from this software
15.\"    without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\"     @(#)dump.8	8.3 (Berkeley) 5/1/95
30.\" $FreeBSD$
31.\"
32.Dd December 28, 2020
33.Dt DUMP 8
34.Os
35.Sh NAME
36.Nm dump ,
37.Nm rdump
38.Nd file system backup
39.Sh SYNOPSIS
40.Nm
41.Op Fl 0123456789acLnrRSu
42.Op Fl B Ar records
43.Op Fl b Ar blocksize
44.Op Fl C Ar cachesize
45.Op Fl D Ar dumpdates
46.Op Fl d Ar density
47.Op Fl f Ar file | Fl P Ar pipecommand
48.Op Fl h Ar level
49.Op Fl s Ar feet
50.Op Fl T Ar date
51.Ar filesystem
52.Nm
53.Fl W | Fl w
54.Sh DESCRIPTION
55The
56.Nm
57utility examines files
58on a file system
59and determines which files
60need to be backed up.
61These files
62are copied to the given disk, tape or other
63storage medium for safe keeping (see the
64.Fl f
65option below for doing remote backups).
66A dump that is larger than the output medium is broken into
67multiple volumes.
68On most media the size is determined by writing until an
69end-of-media indication is returned.
70This can be enforced
71by using the
72.Fl a
73option.
74.Pp
75On media that cannot reliably return an end-of-media indication
76(such as some cartridge tape drives)
77each volume is of a fixed size;
78the actual size is determined by the tape size and density and/or
79.Fl B
80options.
81By default, the same output file name is used for each volume
82after prompting the operator to change media.
83.Pp
84The file system to be dumped is specified by the argument
85.Ar filesystem
86as either its device-special file or its mount point
87(if that is in a standard entry in
88.Pa /etc/fstab ) .
89.Pp
90.Nm
91may also be invoked as
92.Nm rdump .
93The
94.Bx 4.3
95option syntax is implemented for backward compatibility, but
96is not documented here.
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 any lower level.
113The default level is 0.
114.It Fl a
115.Dq auto-size .
116Bypass all tape length considerations, and enforce writing
117until an end-of-media indication is returned.
118This fits best for most modern tape drives.
119Use of this option is particularly
120recommended when appending to an existing tape, or using a tape
121drive with hardware compression (where you can never be sure about
122the compression ratio).
123.It Fl B Ar records
124The number of kilobytes per output volume, except that if it is
125not an integer multiple of the output block size,
126the command uses the next smaller such multiple.
127This option overrides the calculation of tape size
128based on length and density.
129.It Fl b Ar blocksize
130The number of kilobytes per output block.
131The default block size is 10.
132.It Fl C Ar cachesize
133Specify the cache size in megabytes.
134This will greatly improve performance
135at the cost of
136.Nm
137possibly not noticing changes in the file system between passes
138unless a snapshot is being used.
139The potential for performance improvement indicates that
140use of this option together with snapshots is the recommended
141course of action.
142Beware that
143.Nm
144forks, and the actual memory use may be larger than the specified cache
145size.
146The recommended cache size is between 8 and 32 (megabytes).
147.It Fl c
148Change the defaults for use with a cartridge tape drive, with a density
149of 8000 bpi, and a length of 1700 feet.
150.It Fl D Ar dumpdates
151Specify an alternate path to the
152.Pa dumpdates
153file.
154The default is
155.Pa /etc/dumpdates .
156.It Fl d Ar density
157Set tape density to
158.Ar density .
159The default is 1600BPI.
160.It Fl f Ar file
161Write the backup to
162.Ar file ;
163.Ar file
164may be a special device file
165like
166.Pa /dev/sa0
167(a tape drive),
168.Pa /dev/fd1
169(a floppy disk drive),
170an ordinary file,
171or
172.Sq 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 used for all remaining volumes after prompting
178for media changes.
179If the name of the file is of the form
180.Dq host:file ,
181or
182.Dq user@host:file ,
183.Nm
184writes to the named file on the remote host using
185.Xr rmt 8 .
186The default path name of the remote
187.Xr rmt 8
188program is
189.\" rmt path, is the path on the remote host
190.Pa /etc/rmt ;
191this can be overridden by the environment variable
192.Ev RMT .
193.It Fl P Ar pipecommand
194Use
195.Xr popen 3
196to execute the
197.Xr sh 1
198script string defined by
199.Ar pipecommand
200for the output device of each volume.
201This child pipeline's
202.Dv stdin
203.Pq Pa /dev/fd/0
204is redirected from the
205.Nm
206output stream, and the environment variable
207.Ev DUMP_VOLUME
208is set to the current volume number being written.
209After every volume, the writer side of the pipe is closed and
210.Ar pipecommand
211is executed again.
212Subject to the media size specified by
213.Fl B ,
214each volume is written in this manner as if the output were a tape drive.
215.It Fl h Ar level
216Honor the user
217.Dq nodump
218flag
219.Pq Dv UF_NODUMP
220only for dumps at or above the given
221.Ar level .
222The default honor level is 1,
223so that incremental backups omit such files
224but full backups retain them.
225.It Fl L
226This option is to notify
227.Nm
228that it is dumping a live file system.
229To obtain a consistent dump image,
230.Nm
231takes a snapshot of the file system in the
232.Pa .snap
233directory in the root of the file system being dumped and
234then does a dump of the snapshot.
235The snapshot is unlinked as soon as the dump starts, and
236is thus removed when the dump is complete.
237This option is ignored for unmounted or read-only file systems.
238If the
239.Pa .snap
240directory does not exist in the root of the file system being dumped,
241a warning will be issued and the
242.Nm
243will revert to the standard behavior.
244This problem can be corrected by creating a
245.Pa .snap
246directory in the root of the file system to be dumped;
247its owner should be
248.Dq Li root ,
249its group should be
250.Dq Li operator ,
251and its mode should be
252.Dq Li 0770 .
253.It Fl n
254Whenever
255.Nm
256requires operator attention,
257notify all operators in the group
258.Dq operator
259by means similar to a
260.Xr wall 1 .
261.It Fl r
262Be rsync-friendly.
263Normally dump stores the date of the current
264and prior dump in numerous places throughout the dump.
265These scattered changes significantly slow down rsync or
266another incremental file transfer program when they are
267used to update a remote copy of a level 0 dump,
268since the date changes for each dump.
269This option sets both dates to the epoch, permitting
270rsync to be much more efficient when transferring a dump file.
271The
272.Fl r
273option can be used only to create level 0 dumps.
274A dump using the
275.Fl r
276option cannot be used as the basis for a later incremental dump.
277.It Fl R
278Be even more rsync-friendly.
279This option disables the storage of the actual inode access time
280(storing it instead as the inode's modified time).
281This option permits rsync to be even more efficient
282when transferring dumps generated from filesystems with numerous files
283which are not changing other than their access times.
284The
285.Fl R
286option also sets
287.Fl r .
288The
289.Fl R
290option can be used only to create level 0 dumps.
291A dump using the
292.Fl R
293option cannot be used as the basis for a later incremental dump.
294.It Fl S
295Display an estimate of the backup size and the number of
296tapes required, and exit without actually performing the dump.
297.It Fl s Ar feet
298Attempt to calculate the amount of tape needed
299at a particular density.
300If this amount is exceeded,
301.Nm
302prompts for a new tape.
303It is recommended to be a bit conservative on this option.
304The default tape length is 2300 feet.
305.It Fl T Ar date
306Use the specified date as the starting time for the dump
307instead of the time determined from looking in
308the
309.Pa dumpdates
310file.
311The format of date is the same as that of
312.Xr ctime 3 .
313This option is useful for automated dump scripts that wish to
314dump over a specific period of time.
315The
316.Fl T
317option is mutually exclusive from the
318.Fl u
319option.
320.It Fl u
321Update the
322.Pa dumpdates
323file
324after a successful dump.
325The format of
326the
327.Pa dumpdates
328file
329is readable by people, consisting of one
330free format record per line:
331file system name,
332increment level
333and
334.Xr ctime 3
335format dump date.
336There may be only one entry per file system at each level.
337The
338.Pa dumpdates
339file
340may be edited to change any of the fields,
341if necessary.
342The default path for the
343.Pa dumpdates
344file is
345.Pa /etc/dumpdates ,
346but the
347.Fl D
348option may be used to change it.
349.It Fl W
350Tell the operator what file systems need to be dumped.
351This information is gleaned from the files
352.Pa dumpdates
353and
354.Pa /etc/fstab .
355The
356.Fl W
357option causes
358.Nm
359to print out, for each file system in
360the
361.Pa dumpdates
362file
363the most recent dump date and level,
364and highlights those file systems that should be dumped.
365If the
366.Fl W
367option is set, all other options are ignored, and
368.Nm
369exits immediately.
370.It Fl w
371Is like
372.Fl W ,
373but prints only those file systems which need to be dumped.
374.El
375.Pp
376Directories and regular files which have their
377.Dq nodump
378flag
379.Pq Dv UF_NODUMP
380set will be omitted along with everything under such directories,
381subject to the
382.Fl h
383option.
384.Pp
385The
386.Nm
387utility requires operator intervention on these conditions:
388end of tape,
389end of dump,
390tape write error,
391tape open error or
392disk read error (if there are more than a threshold of 32).
393In addition to alerting all operators implied by the
394.Fl n
395key,
396.Nm
397interacts with the operator on
398.Em dump's
399control terminal at times when
400.Nm
401can no longer proceed,
402or if something is grossly wrong.
403All questions
404.Nm
405poses
406.Em must
407be answered by typing
408.Dq yes
409or
410.Dq no ,
411appropriately.
412.Pp
413Since making a dump involves a lot of time and effort for full dumps,
414.Nm
415checkpoints itself at the start of each tape volume.
416If writing that volume fails for some reason,
417.Nm
418will,
419with operator permission,
420restart itself from the checkpoint
421after the old tape has been rewound and removed,
422and a new tape has been mounted.
423.Pp
424The
425.Nm
426utility tells the operator what is going on at periodic intervals
427(every 5 minutes, or promptly after receiving
428.Dv SIGINFO ) ,
429including usually low estimates of the number of blocks to write,
430the number of tapes it will take, the time to completion, and
431the time to the tape change.
432The output is verbose,
433so that others know that the terminal
434controlling
435.Nm
436is busy,
437and will be for some time.
438.Pp
439In the event of a catastrophic disk event, the time required
440to restore all the necessary backup tapes or files to disk
441can be kept to a minimum by staggering the incremental dumps.
442An efficient method of staggering incremental dumps
443to minimize the number of tapes follows:
444.Bl -bullet -offset indent
445.It
446Always start with a level 0 backup, for example:
447.Bd -literal -offset indent
448/sbin/dump -0u -f /dev/nsa0 /usr/src
449.Ed
450.Pp
451This should be done at set intervals, say once a month or once every two months,
452and on a set of fresh tapes that is saved forever.
453.It
454After a level 0, dumps of active file systems (file systems with files
455that change, depending on your partition layout some file systems may
456contain only data that does not change) are taken on a daily basis,
457using a modified Tower of Hanoi algorithm,
458with this sequence of dump levels:
459.Bd -literal -offset indent
4603 2 5 4 7 6 9 8 9 9 ...
461.Ed
462.Pp
463For the daily dumps, it should be possible to use a fixed number of tapes
464for each day, used on a weekly basis.
465Each week, a level 1 dump is taken, and
466the daily Hanoi sequence repeats beginning with 3.
467For weekly dumps, another fixed set of tapes per dumped file system is
468used, also on a cyclical basis.
469.El
470.Pp
471After several months or so, the daily and weekly tapes should get
472rotated out of the dump cycle and fresh tapes brought in.
473.Sh ENVIRONMENT
474.Bl -tag -width ".Ev TAPE"
475.It Ev TAPE
476The
477.Ar file
478or device to dump to if the
479.Fl f
480option is not used.
481.It Ev RMT
482Pathname of the remote
483.Xr rmt 8
484program.
485.It Ev RSH
486Pathname of a remote shell program, if not
487.Xr rsh 1 .
488.El
489.Sh FILES
490.Bl -tag -width /etc/dumpdates -compact
491.It Pa /dev/sa0
492default tape unit to dump to
493.It Pa /etc/dumpdates
494dump date records
495(this can be changed;
496see the
497.Fl D
498option)
499.It Pa /etc/fstab
500dump table: file systems and frequency
501.It Pa /etc/group
502to find group
503.Em operator
504.El
505.Sh EXIT STATUS
506Dump exits with zero status on success.
507Startup errors are indicated with an exit code of 1;
508abnormal termination is indicated with an exit code of 3.
509.Sh EXAMPLES
510Dumps the
511.Pa /u
512file system to DVDs using
513.Nm growisofs .
514Uses a 16MB cache, creates a snapshot of the dump, and records the
515.Pa dumpdates
516file.
517.Bd -literal
518/sbin/dump -0u  -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /u
519.Ed
520.Sh DIAGNOSTICS
521Many, and verbose.
522.Sh SEE ALSO
523.Xr chflags 1 ,
524.Xr fstab 5 ,
525.Xr restore 8 ,
526.Xr rmt 8
527.Sh HISTORY
528A
529.Nm
530utility appeared in
531.At v4 .
532.Sh BUGS
533Fewer than 32 read errors on the file system are ignored, though all
534errors will generate a warning message.
535This is a bit of a compromise.
536In practice, it is possible to generate read errors when doing dumps
537on mounted partitions if the file system is being modified while the
538.Nm
539is running.
540Since dumps are often done in an unattended fashion using
541.Xr cron 8
542jobs asking for Operator intervention would result in the
543.Nm
544dying.
545However, there is nothing wrong with a dump tape written when this sort
546of read error occurs, and there is no reason to terminate the
547.Nm .
548.Pp
549Each reel requires a new process, so parent processes for
550reels already written just hang around until the entire tape
551is written.
552.Pp
553The
554.Nm
555utility with the
556.Fl W
557or
558.Fl w
559options does not report file systems that have never been recorded
560in the
561.Pa dumpdates
562file,
563even if listed in
564.Pa /etc/fstab .
565.Pp
566It would be nice if
567.Nm
568knew about the dump sequence,
569kept track of the tapes scribbled on,
570told the operator which tape to mount when,
571and provided more assistance
572for the operator running
573.Xr restore 8 .
574.Pp
575The
576.Nm
577utility cannot do remote backups without being run as root, due to its
578security history.
579This will be fixed in a later version of
580.Fx .
581Presently, it works if you set it setuid (like it used to be), but this
582might constitute a security risk.
583