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