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