xref: /freebsd/sbin/dump/dump.8 (revision eb69d1f144a6fcc765d1b9d44a5ae8082353e70b)
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 October 3, 2016
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.
269.It Fl R
270Be even more rsync-friendly.
271This option disables the storage of the actual inode access time
272(storing it instead as the inode's modified time).
273This option permits rsync to be even more efficient
274when transferring dumps generated from filesystems with numerous files
275which are not changing other than their access times.
276The
277.Fl R
278option also sets
279.Fl r .
280.It Fl S
281Display an estimate of the backup size and the number of
282tapes required, and exit without actually performing the dump.
283.It Fl s Ar feet
284Attempt to calculate the amount of tape needed
285at a particular density.
286If this amount is exceeded,
287.Nm
288prompts for a new tape.
289It is recommended to be a bit conservative on this option.
290The default tape length is 2300 feet.
291.It Fl T Ar date
292Use the specified date as the starting time for the dump
293instead of the time determined from looking in
294the
295.Pa dumpdates
296file.
297The format of date is the same as that of
298.Xr ctime 3 .
299This option is useful for automated dump scripts that wish to
300dump over a specific period of time.
301The
302.Fl T
303option is mutually exclusive from the
304.Fl u
305option.
306.It Fl u
307Update the
308.Pa dumpdates
309file
310after a successful dump.
311The format of
312the
313.Pa dumpdates
314file
315is readable by people, consisting of one
316free format record per line:
317file system name,
318increment level
319and
320.Xr ctime 3
321format dump date.
322There may be only one entry per file system at each level.
323The
324.Pa dumpdates
325file
326may be edited to change any of the fields,
327if necessary.
328The default path for the
329.Pa dumpdates
330file is
331.Pa /etc/dumpdates ,
332but the
333.Fl D
334option may be used to change it.
335.It Fl W
336Tell the operator what file systems need to be dumped.
337This information is gleaned from the files
338.Pa dumpdates
339and
340.Pa /etc/fstab .
341The
342.Fl W
343option causes
344.Nm
345to print out, for each file system in
346the
347.Pa dumpdates
348file
349the most recent dump date and level,
350and highlights those file systems that should be dumped.
351If the
352.Fl W
353option is set, all other options are ignored, and
354.Nm
355exits immediately.
356.It Fl w
357Is like
358.Fl W ,
359but prints only those file systems which need to be dumped.
360.El
361.Pp
362Directories and regular files which have their
363.Dq nodump
364flag
365.Pq Dv UF_NODUMP
366set will be omitted along with everything under such directories,
367subject to the
368.Fl h
369option.
370.Pp
371The
372.Nm
373utility requires operator intervention on these conditions:
374end of tape,
375end of dump,
376tape write error,
377tape open error or
378disk read error (if there are more than a threshold of 32).
379In addition to alerting all operators implied by the
380.Fl n
381key,
382.Nm
383interacts with the operator on
384.Em dump's
385control terminal at times when
386.Nm
387can no longer proceed,
388or if something is grossly wrong.
389All questions
390.Nm
391poses
392.Em must
393be answered by typing
394.Dq yes
395or
396.Dq no ,
397appropriately.
398.Pp
399Since making a dump involves a lot of time and effort for full dumps,
400.Nm
401checkpoints itself at the start of each tape volume.
402If writing that volume fails for some reason,
403.Nm
404will,
405with operator permission,
406restart itself from the checkpoint
407after the old tape has been rewound and removed,
408and a new tape has been mounted.
409.Pp
410The
411.Nm
412utility tells the operator what is going on at periodic intervals
413(every 5 minutes, or promptly after receiving
414.Dv SIGINFO ) ,
415including usually low estimates of the number of blocks to write,
416the number of tapes it will take, the time to completion, and
417the time to the tape change.
418The output is verbose,
419so that others know that the terminal
420controlling
421.Nm
422is busy,
423and will be for some time.
424.Pp
425In the event of a catastrophic disk event, the time required
426to restore all the necessary backup tapes or files to disk
427can be kept to a minimum by staggering the incremental dumps.
428An efficient method of staggering incremental dumps
429to minimize the number of tapes follows:
430.Bl -bullet -offset indent
431.It
432Always start with a level 0 backup, for example:
433.Bd -literal -offset indent
434/sbin/dump -0u -f /dev/nsa0 /usr/src
435.Ed
436.Pp
437This should be done at set intervals, say once a month or once every two months,
438and on a set of fresh tapes that is saved forever.
439.It
440After a level 0, dumps of active file systems (file systems with files
441that change, depending on your partition layout some file systems may
442contain only data that does not change) are taken on a daily basis,
443using a modified Tower of Hanoi algorithm,
444with this sequence of dump levels:
445.Bd -literal -offset indent
4463 2 5 4 7 6 9 8 9 9 ...
447.Ed
448.Pp
449For the daily dumps, it should be possible to use a fixed number of tapes
450for each day, used on a weekly basis.
451Each week, a level 1 dump is taken, and
452the daily Hanoi sequence repeats beginning with 3.
453For weekly dumps, another fixed set of tapes per dumped file system is
454used, also on a cyclical basis.
455.El
456.Pp
457After several months or so, the daily and weekly tapes should get
458rotated out of the dump cycle and fresh tapes brought in.
459.Sh ENVIRONMENT
460.Bl -tag -width ".Ev TAPE"
461.It Ev TAPE
462The
463.Ar file
464or device to dump to if the
465.Fl f
466option is not used.
467.It Ev RMT
468Pathname of the remote
469.Xr rmt 8
470program.
471.It Ev RSH
472Pathname of a remote shell program, if not
473.Xr rsh 1 .
474.El
475.Sh FILES
476.Bl -tag -width /etc/dumpdates -compact
477.It Pa /dev/sa0
478default tape unit to dump to
479.It Pa /etc/dumpdates
480dump date records
481(this can be changed;
482see the
483.Fl D
484option)
485.It Pa /etc/fstab
486dump table: file systems and frequency
487.It Pa /etc/group
488to find group
489.Em operator
490.El
491.Sh EXIT STATUS
492Dump exits with zero status on success.
493Startup errors are indicated with an exit code of 1;
494abnormal termination is indicated with an exit code of 3.
495.Sh EXAMPLES
496Dumps the
497.Pa /u
498file system to DVDs using
499.Nm growisofs .
500Uses a 16MB cache, creates a snapshot of the dump, and records the
501.Pa dumpdates
502file.
503.Bd -literal
504/sbin/dump -0u  -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /u
505.Ed
506.Sh DIAGNOSTICS
507Many, and verbose.
508.Sh SEE ALSO
509.Xr chflags 1 ,
510.Xr fstab 5 ,
511.Xr restore 8 ,
512.Xr rmt 8
513.Sh HISTORY
514A
515.Nm
516utility appeared in
517.At v4 .
518.Sh BUGS
519Fewer than 32 read errors on the file system are ignored, though all
520errors will generate a warning message.
521This is a bit of a compromise.
522In practice, it is possible to generate read errors when doing dumps
523on mounted partitions if the file system is being modified while the
524.Nm
525is running.
526Since dumps are often done in an unattended fashion using
527.Xr cron 8
528jobs asking for Operator intervention would result in the
529.Nm
530dying.
531However, there is nothing wrong with a dump tape written when this sort
532of read error occurs, and there is no reason to terminate the
533.Nm .
534.Pp
535Each reel requires a new process, so parent processes for
536reels already written just hang around until the entire tape
537is written.
538.Pp
539The
540.Nm
541utility with the
542.Fl W
543or
544.Fl w
545options does not report file systems that have never been recorded
546in the
547.Pa dumpdates
548file,
549even if listed in
550.Pa /etc/fstab .
551.Pp
552It would be nice if
553.Nm
554knew about the dump sequence,
555kept track of the tapes scribbled on,
556told the operator which tape to mount when,
557and provided more assistance
558for the operator running
559.Xr restore 8 .
560.Pp
561The
562.Nm
563utility cannot do remote backups without being run as root, due to its
564security history.
565This will be fixed in a later version of
566.Fx .
567Presently, it works if you set it setuid (like it used to be), but this
568might constitute a security risk.
569