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