xref: /freebsd/sbin/dump/dump.8 (revision 2357939bc239bd5334a169b62313806178dd8f30)
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.\" 4. 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 March 1, 2002
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 0123456789acLnSu
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.Pp
55.Nm rdump
56is an alternate name for
57.Nm .
58.Pp
59.in \" XXX
60(The
61.Bx 4.3
62option syntax is implemented for backward compatibility, but
63is not documented here.)
64.Sh DESCRIPTION
65The
66.Nm
67utility examines files
68on a file system
69and determines which files
70need to be backed up.
71These files
72are copied to the given disk, tape or other
73storage medium for safe keeping (see the
74.Fl f
75option below for doing remote backups).
76A dump that is larger than the output medium is broken into
77multiple volumes.
78On most media the size is determined by writing until an
79end-of-media indication is returned.
80This can be enforced
81by using the
82.Fl a
83option.
84.Pp
85On media that cannot reliably return an end-of-media indication
86(such as some cartridge tape drives)
87each volume is of a fixed size;
88the actual size is determined by the tape size and density and/or
89.Fl B
90options.
91By default, the same output file name is used for each volume
92after prompting the operator to change media.
93.Pp
94The file system to be dumped is specified by the argument
95.Ar filesystem
96as either its device-special file or its mount point
97(if that is in a standard entry in
98.Pa /etc/fstab ) .
99.Pp
100The following options are supported by
101.Nm :
102.Bl -tag -width Ds
103.It Fl 0-9
104Dump levels.
105A level 0, full backup,
106guarantees the entire file system is copied
107(but see also the
108.Fl h
109option below).
110A level number above 0,
111incremental backup,
112tells dump to
113copy all files new or modified since the
114last dump of any lower level.
115The default level is 0.
116.It Fl a
117.Dq auto-size .
118Bypass all tape length considerations, and enforce writing
119until an end-of-media indication is returned.
120This fits best for most modern tape drives.
121Use of this option is particularly
122recommended when appending to an existing tape, or using a tape
123drive with hardware compression (where you can never be sure about
124the compression ratio).
125.It Fl B Ar records
126The number of kilobytes per output volume, except that if it is
127not an integer multiple of the output block size,
128the command uses the next smaller such multiple.
129This option overrides the calculation of tape size
130based on length and density.
131.It Fl b Ar blocksize
132The number of kilobytes per output block.
133The default block size is 10.
134.It Fl C Ar cachesize
135Specify the cache size in megabytes.
136This will greatly improve performance
137at the cost of
138.Nm
139possibly not noticing changes in the file system between passes.
140It is
141recommended that you always use this option when dumping a snapshot.
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.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 filesystem being dumped and
234then does a dump of the snapshot.
235The snapshot is removed when the dump is complete.
236This option is ignored for unmounted or read-only filesystems.
237If the
238.Pa .snap
239directory does not exist in the root of the filesystem being dumped,
240the dump will fail.
241This problem can be corrected by creating a
242.Pa .snap
243directory in the root of the filesystem to be dumped;
244its owner should be root, its group should be operator,
245and its mode should be 0770.
246.It Fl n
247Whenever
248.Nm
249requires operator attention,
250notify all operators in the group
251.Dq operator
252by means similar to a
253.Xr wall 1 .
254.It Fl S
255Display an estimate of the backup size and the number of
256tapes required, and exit without actually performing the dump.
257.It Fl s Ar feet
258Attempt to calculate the amount of tape needed
259at a particular density.
260If this amount is exceeded,
261.Nm
262prompts for a new tape.
263It is recommended to be a bit conservative on this option.
264The default tape length is 2300 feet.
265.It Fl T Ar date
266Use the specified date as the starting time for the dump
267instead of the time determined from looking in
268the
269.Pa dumpdates
270file.
271The format of date is the same as that of
272.Xr ctime 3 .
273This option is useful for automated dump scripts that wish to
274dump over a specific period of time.
275The
276.Fl T
277option is mutually exclusive from the
278.Fl u
279option.
280.It Fl u
281Update the
282.Pa dumpdates
283file
284after a successful dump.
285The format of
286the
287.Pa dumpdates
288file
289is readable by people, consisting of one
290free format record per line:
291file system name,
292increment level
293and
294.Xr ctime 3
295format dump date.
296There may be only one entry per file system at each level.
297The
298.Pa dumpdates
299file
300may be edited to change any of the fields,
301if necessary.
302The default path for the
303.Pa dumpdates
304file is
305.Pa /etc/dumpdates ,
306but the
307.Fl D
308option may be used to change it.
309.It Fl W
310Tell the operator what file systems need to be dumped.
311This information is gleaned from the files
312.Pa dumpdates
313and
314.Pa /etc/fstab .
315The
316.Fl W
317option causes
318.Nm
319to print out, for each file system in
320the
321.Pa dumpdates
322file
323the most recent dump date and level,
324and highlights those file systems that should be dumped.
325If the
326.Fl W
327option is set, all other options are ignored, and
328.Nm
329exits immediately.
330.It Fl w
331Is like
332.Fl W ,
333but prints only those file systems which need to be dumped.
334.El
335.Pp
336Directories and regular files which have their
337.Dq nodump
338flag
339.Pq Dv UF_NODUMP
340set will be omitted along with everything under such directories,
341subject to the
342.Fl h
343option.
344.Pp
345The
346.Nm
347utility requires operator intervention on these conditions:
348end of tape,
349end of dump,
350tape write error,
351tape open error or
352disk read error (if there are more than a threshold of 32).
353In addition to alerting all operators implied by the
354.Fl n
355key,
356.Nm
357interacts with the operator on
358.Em dump's
359control terminal at times when
360.Nm
361can no longer proceed,
362or if something is grossly wrong.
363All questions
364.Nm
365poses
366.Em must
367be answered by typing
368.Dq yes
369or
370.Dq no ,
371appropriately.
372.Pp
373Since making a dump involves a lot of time and effort for full dumps,
374.Nm
375checkpoints itself at the start of each tape volume.
376If writing that volume fails for some reason,
377.Nm
378will,
379with operator permission,
380restart itself from the checkpoint
381after the old tape has been rewound and removed,
382and a new tape has been mounted.
383.Pp
384The
385.Nm
386utility tells the operator what is going on at periodic intervals
387(every 5 minutes, or promptly after receiving
388.Dv SIGINFO ) ,
389including usually low estimates of the number of blocks to write,
390the number of tapes it will take, the time to completion, and
391the time to the tape change.
392The output is verbose,
393so that others know that the terminal
394controlling
395.Nm
396is busy,
397and will be for some time.
398.Pp
399In the event of a catastrophic disk event, the time required
400to restore all the necessary backup tapes or files to disk
401can be kept to a minimum by staggering the incremental dumps.
402An efficient method of staggering incremental dumps
403to minimize the number of tapes follows:
404.Bl -bullet -offset indent
405.It
406Always start with a level 0 backup, for example:
407.Bd -literal -offset indent
408/sbin/dump -0u -f /dev/nsa0 /usr/src
409.Ed
410.Pp
411This should be done at set intervals, say once a month or once every two months,
412and on a set of fresh tapes that is saved forever.
413.It
414After a level 0, dumps of active file systems (file systems with files
415that change, depending on your partition layout some file systems may
416contain only data that does not change) are taken on a daily basis,
417using a modified Tower of Hanoi algorithm,
418with this sequence of dump levels:
419.Bd -literal -offset indent
4203 2 5 4 7 6 9 8 9 9 ...
421.Ed
422.Pp
423For the daily dumps, it should be possible to use a fixed number of tapes
424for each day, used on a weekly basis.
425Each week, a level 1 dump is taken, and
426the daily Hanoi sequence repeats beginning with 3.
427For weekly dumps, another fixed set of tapes per dumped file system is
428used, also on a cyclical basis.
429.El
430.Pp
431After several months or so, the daily and weekly tapes should get
432rotated out of the dump cycle and fresh tapes brought in.
433.Sh ENVIRONMENT
434.Bl -tag -width ".Ev TAPE"
435.It Ev TAPE
436Device from which to read backup.
437.It Ev RMT
438Pathname of the remote
439.Xr rmt 8
440program.
441.It Ev RSH
442Pathname of remote shell program, if not
443.Xr rsh 1 .
444.El
445.Sh FILES
446.Bl -tag -width /etc/dumpdates -compact
447.It Pa /dev/sa0
448default tape unit to dump to
449.It Pa /etc/dumpdates
450dump date records
451(this can be changed;
452see the
453.Fl D
454option)
455.It Pa /etc/fstab
456dump table: file systems and frequency
457.It Pa /etc/group
458to find group
459.Em operator
460.El
461.Sh SEE ALSO
462.Xr chflags 1 ,
463.Xr fstab 5 ,
464.Xr restore 8 ,
465.Xr rmt 8
466.Sh DIAGNOSTICS
467Many, and verbose.
468.Pp
469Dump exits with zero status on success.
470Startup errors are indicated with an exit code of 1;
471abnormal termination is indicated with an exit code of 3.
472.Sh BUGS
473Fewer than 32 read errors on the file system are ignored, though all
474errors will generate a warning message.
475This is a bit of a compromise.
476In practice it is possible to generate read errors when doing dumps
477on mounted partitions if the file system is being modified while the
478dump is running.
479Since dumps are often done in an unattended fashion using
480.Xr cron 8
481jobs asking for Operator intervention would result in the dump dying.
482However there is nothing wrong with a dump tape written when this sort
483of read error occurs and there is no reason to terminate the dump.
484.Pp
485Each reel requires a new process, so parent processes for
486reels already written just hang around until the entire tape
487is written.
488.Pp
489The
490.Nm
491utility with the
492.Fl W
493or
494.Fl w
495options does not report file systems that have never been recorded
496in the
497.Pa dumpdates
498file,
499even if listed in
500.Pa /etc/fstab .
501.Pp
502It would be nice if
503.Nm
504knew about the dump sequence,
505kept track of the tapes scribbled on,
506told the operator which tape to mount when,
507and provided more assistance
508for the operator running
509.Xr restore 8 .
510.Pp
511The
512.Nm
513utility cannot do remote backups without being run as root, due to its
514security history.
515This will be fixed in a later version of
516.Fx .
517Presently, it works if you set it setuid (like it used to be), but this
518might constitute a security risk.
519.Sh HISTORY
520A
521.Nm
522utility appeared in
523.At v6 .
524