]> Dogcows Code - chaz/tar/blob - doc/tar.texi
Updated
[chaz/tar] / doc / tar.texi
1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename tar.info
4 @include version.texi
5 @settitle GNU tar @value{VERSION}
6 @setchapternewpage odd
7
8 @finalout
9
10 @smallbook
11 @c %**end of header
12
13 @c ======================================================================
14 @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
15 @c as decided by @set symbols. The PUBLISH rendition does not show
16 @c notes or marks asking for revision. Most users will prefer having more
17 @c information, even if this information is not fully revised for adequacy,
18 @c so DISTRIB is the default for tar distributions. The PROOF rendition
19 @c show all marks to the point of ugliness, but is nevertheless useful to
20 @c those working on the manual itself.
21 @c ======================================================================
22
23 @ifclear PUBLISH
24 @ifclear DISTRIB
25 @ifclear PROOF
26 @set DISTRIB
27 @end ifclear
28 @end ifclear
29 @end ifclear
30
31 @ifset PUBLISH
32 @set RENDITION The book, version
33 @end ifset
34
35 @ifset DISTRIB
36 @set RENDITION FTP release, version
37 @end ifset
38
39 @ifset PROOF
40 @set RENDITION Proof reading version
41 @end ifset
42
43 @c ---------------------------------------------------------------------
44 @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
45 @c plan. These annotations are somewhat precious to him; he asks that I
46 @c do not alter them inconsiderately. Much work is needed for GNU tar
47 @c internals (the sources, the programs themselves). Revising the
48 @c adequacy of the manual while revising the sources, and cleaning them
49 @c both at the same time, is a good way to proceed.
50 @c ---------------------------------------------------------------------
51
52 @c Output marks for nodes needing revision, but not in PUBLISH rendition.
53
54 @macro UNREVISED
55 @ifclear PUBLISH
56 @quotation
57 @emph{(This message will disappear, once this node revised.)}
58 @end quotation
59 @end ifclear
60 @end macro
61
62 @c Output various FIXME information only in PROOF rendition.
63
64 @macro FIXME{string}
65 @allow-recursion
66 @quote-arg
67 @ifset PROOF
68 @strong{<FIXME>} \string\ @strong{</>}
69 @end ifset
70
71 @end macro
72
73 @macro FIXME-ref{string}
74 @quote-arg
75 @ifset PROOF
76 @strong{<REF>} \string\ @strong{</>}
77 @end ifset
78
79 @end macro
80
81 @macro FIXME-pxref{string}
82 @quote-arg
83 @ifset PROOF
84 @strong{<PXREF>} \string\ @strong{</>}
85 @end ifset
86
87 @end macro
88
89 @macro FIXME-xref{string}
90 @quote-arg
91 @ifset PROOF
92 @strong{<XREF>} \string\ @strong{</>}
93 @end ifset
94
95 @end macro
96
97 @c @macro option{entry}
98 @c @quote-arg
99 @c @opindex{--\entry\}
100 @c @value{\entry\}
101 @c @end macro
102
103 @macro GNUTAR
104 @acronym{GNU} @command{tar}
105 @end macro
106
107 @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
108 @set ref-absolute-names @ref{absolute}
109 @set xref-absolute-names @xref{absolute}
110 @set pxref-absolute-names @pxref{absolute}
111
112 @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
113 @set ref-after-date @ref{after}
114 @set xref-after-date @xref{after}
115 @set pxref-after-date @pxref{after}
116
117 @set op-append @kbd{--append} (@kbd{-r})
118 @set ref-append @ref{add}
119 @set xref-append @xref{add}
120 @set pxref-append @pxref{add}
121
122 @set op-atime-preserve @kbd{--atime-preserve}
123 @set ref-atime-preserve @ref{Attributes}
124 @set xref-atime-preserve @xref{Attributes}
125 @set pxref-atime-preserve @pxref{Attributes}
126
127 @set op-backup @kbd{--backup}
128 @set ref-backup @ref{Backup options}
129 @set xref-backup @xref{Backup options}
130 @set pxref-backup @pxref{Backup options}
131
132 @set op-block-number @kbd{--block-number} (@kbd{-R})
133 @set ref-block-number @ref{verbose}
134 @set xref-block-number @xref{verbose}
135 @set pxref-block-number @pxref{verbose}
136
137 @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
138 @set ref-blocking-factor @ref{Blocking Factor}
139 @set xref-blocking-factor @xref{Blocking Factor}
140 @set pxref-blocking-factor @pxref{Blocking Factor}
141
142 @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
143 @set ref-bzip2 @ref{gzip}
144 @set xref-bzip2 @xref{gzip}
145 @set pxref-bzip2 @pxref{gzip}
146
147 @set op-check-links @kbd{--check-links} (@kbd{-l})
148 @set ref-check-links @ref{--check-links}
149 @set xref-check-links @xref{--check-links}
150 @set pxref-check-links @pxref{--check-links}
151
152 @set op-checkpoint @kbd{--checkpoint}
153 @set ref-checkpoint @ref{verbose}
154 @set xref-checkpoint @xref{verbose}
155 @set pxref-checkpoint @pxref{verbose}
156
157 @set op-check-links @kbd{--check-links}
158
159 @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
160 @set ref-compare @ref{compare}
161 @set xref-compare @xref{compare}
162 @set pxref-compare @pxref{compare}
163
164 @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
165 @set ref-compress @ref{gzip}
166 @set xref-compress @xref{gzip}
167 @set pxref-compress @pxref{gzip}
168
169 @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
170 @set ref-concatenate @ref{concatenate}
171 @set xref-concatenate @xref{concatenate}
172 @set pxref-concatenate @pxref{concatenate}
173
174 @set op-create @kbd{--create} (@kbd{-c})
175 @set ref-create @ref{create}
176 @set xref-create @xref{create}
177 @set pxref-create @pxref{create}
178
179 @set op-delete @kbd{--delete}
180 @set ref-delete @ref{delete}
181 @set xref-delete @xref{delete}
182 @set pxref-delete @pxref{delete}
183
184 @set op-dereference @kbd{--dereference} (@kbd{-h})
185 @set ref-dereference @ref{dereference}
186 @set xref-dereference @xref{dereference}
187 @set pxref-dereference @pxref{dereference}
188
189 @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
190 @set ref-directory @ref{directory}
191 @set xref-directory @xref{directory}
192 @set pxref-directory @pxref{directory}
193
194 @set op-exclude @kbd{--exclude=@var{pattern}}
195 @set ref-exclude @ref{exclude}
196 @set xref-exclude @xref{exclude}
197 @set pxref-exclude @pxref{exclude}
198
199 @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
200 @set ref-exclude-from @ref{exclude}
201 @set xref-exclude-from @xref{exclude}
202 @set pxref-exclude-from @pxref{exclude}
203
204 @set op-exclude-caches @kbd{--exclude-caches}
205 @set ref-exclude-from @ref{exclude-caches}
206 @set xref-exclude-from @xref{exclude-caches}
207 @set pxref-exclude-from @pxref{exclude-caches}
208
209 @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
210 @set ref-extract @ref{extract}
211 @set xref-extract @xref{extract}
212 @set pxref-extract @pxref{extract}
213
214 @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
215 @set ref-file @ref{file}
216 @set xref-file @xref{file}
217 @set pxref-file @pxref{file}
218
219 @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
220 @set ref-files-from @ref{files}
221 @set xref-files-from @xref{files}
222 @set pxref-files-from @pxref{files}
223
224 @set op-force-local @kbd{--force-local}
225 @set ref-force-local @ref{file}
226 @set xref-force-local @xref{file}
227 @set pxref-force-local @pxref{file}
228
229 @set op-group @kbd{--group=@var{group}}
230 @set ref-group @ref{Option Summary}
231 @set xref-group @xref{Option Summary}
232 @set pxref-group @pxref{Option Summary}
233
234 @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
235 @set ref-gzip @ref{gzip}
236 @set xref-gzip @xref{gzip}
237 @set pxref-gzip @pxref{gzip}
238
239 @set op-help @kbd{--help}
240 @set ref-help @ref{help}
241 @set xref-help @xref{help}
242 @set pxref-help @pxref{help}
243
244 @set op-ignore-failed-read @kbd{--ignore-failed-read}
245 @set ref-ignore-failed-read @ref{create options}
246 @set xref-ignore-failed-read @xref{create options}
247 @set pxref-ignore-failed-read @pxref{create options}
248
249 @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
250 @set ref-ignore-zeros @ref{Reading}
251 @set xref-ignore-zeros @xref{Reading}
252 @set pxref-ignore-zeros @pxref{Reading}
253
254 @set op-incremental @kbd{--incremental} (@kbd{-G})
255 @set ref-incremental @ref{Inc Dumps}
256 @set xref-incremental @xref{Inc Dumps}
257 @set pxref-incremental @pxref{Inc Dumps}
258
259 @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
260 @set ref-info-script @ref{Multi-Volume Archives}
261 @set xref-info-script @xref{Multi-Volume Archives}
262 @set pxref-info-script @pxref{Multi-Volume Archives}
263
264 @set op-interactive @kbd{--interactive} (@kbd{-w})
265 @set ref-interactive @ref{interactive}
266 @set xref-interactive @xref{interactive}
267 @set pxref-interactive @pxref{interactive}
268
269 @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
270 @set ref-keep-old-files @ref{Keep Old Files}
271 @set xref-keep-old-files @xref{Keep Old Files}
272 @set pxref-keep-old-files @pxref{Keep Old Files}
273
274 @set op-keep-newer-files @kbd{--keep-old-files}
275 @set ref-keep-newer-files @ref{Keep Newer Files}
276 @set xref-keep-newer-files @xref{Keep Newer Files}
277 @set pxref-keep-newer-files @pxref{Keep Newer Files}
278
279 @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
280 @set ref-label @ref{label}
281 @set xref-label @xref{label}
282 @set pxref-label @pxref{label}
283
284 @set op-list @kbd{--list} (@kbd{-t})
285 @set ref-list @ref{list}
286 @set xref-list @xref{list}
287 @set pxref-list @pxref{list}
288
289 @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
290 @set ref-listed-incremental @ref{Inc Dumps}
291 @set xref-listed-incremental @xref{Inc Dumps}
292 @set pxref-listed-incremental @pxref{Inc Dumps}
293
294 @set op-mode @kbd{--mode=@var{permissions}}
295 @set ref-mode @ref{Option Summary}
296 @set xref-mode @xref{Option Summary}
297 @set pxref-mode @pxref{Option Summary}
298
299 @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
300 @set ref-multi-volume @ref{Multi-Volume Archives}
301 @set xref-multi-volume @xref{Multi-Volume Archives}
302 @set pxref-multi-volume @pxref{Multi-Volume Archives}
303
304 @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
305 @set ref-newer-mtime @ref{after}
306 @set xref-newer-mtime @xref{after}
307 @set pxref-newer-mtime @pxref{after}
308
309 @set op-no-recursion @kbd{--no-recursion}
310 @set ref-no-recursion @ref{recurse}
311 @set xref-no-recursion @xref{recurse}
312 @set pxref-no-recursion @pxref{recurse}
313
314 @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
315 @set ref-no-same-owner @ref{Attributes}
316 @set xref-no-same-owner @xref{Attributes}
317 @set pxref-no-same-owner @pxref{Attributes}
318
319 @set op-no-same-permissions @kbd{--no-same-permissions}
320 @set ref-no-same-permissions @ref{Attributes}
321 @set xref-no-same-permissions @xref{Attributes}
322 @set pxref-no-same-permissions @pxref{Attributes}
323
324 @set op-null @kbd{--null}
325 @set ref-null @ref{files}
326 @set xref-null @xref{files}
327 @set pxref-null @pxref{files}
328
329 @set op-numeric-owner @kbd{--numeric-owner}
330 @set ref-numeric-owner @ref{Attributes}
331 @set xref-numeric-owner @xref{Attributes}
332 @set pxref-numeric-owner @pxref{Attributes}
333
334 @set op-occurrence @kbd{--occurrence}
335 @set ref-occurrence @ref{--occurrence}
336 @set xref-occurrence @xref{--occurrence}
337 @set pxref-occurrence @pxref{--occurrence}
338
339 @set op-old-archive @kbd{--old-archive} (@kbd{-o})
340 @set ref-old-archive @ref{old}
341 @set xref-old-archive @xref{old}
342 @set pxref-old-archive @pxref{old}
343
344 @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
345 @set ref-one-file-system @ref{one}
346 @set xref-one-file-system @xref{one}
347 @set pxref-one-file-system @pxref{one}
348
349 @set op-overwrite @kbd{--overwrite}
350 @set ref-overwrite @ref{Overwrite Old Files}
351 @set xref-overwrite @xref{Overwrite Old Files}
352 @set pxref-overwrite @pxref{Overwrite Old Files}
353
354 @set op-owner @kbd{--owner=@var{user}}
355 @set ref-owner @ref{Option Summary}
356 @set xref-owner @xref{Option Summary}
357 @set pxref-owner @pxref{Option Summary}
358
359 @set op-format @kbd{--format} (@kbd{-H})
360 @set ref-format @ref{format}
361 @set xref-format @xref{format}
362 @set pxref-format @pxref{format}
363
364 @set op-format-v7 @kbd{--format=v7}
365 @set op-format-gnu @kbd{--format=gnu}
366 @set op-format-oldgnu @kbd{--format=oldgnu}
367 @set op-format-posix @kbd{--format=posix}
368 @set op-format-ustar @kbd{--format=ustar}
369
370 @set op-posix @kbd{--posix}
371 @set ref-posix @ref{posix}
372 @set xref-posix @xref{posix}
373 @set pxref-posix @pxref{posix}
374
375 @set op-preserve @kbd{--preserve}
376 @set ref-preserve @ref{Attributes}
377 @set xref-preserve @xref{Attributes}
378 @set pxref-preserve @pxref{Attributes}
379
380 @set op-record-size @kbd{--record-size=@var{size}}
381 @set ref-record-size @ref{Blocking}
382 @set xref-record-size @xref{Blocking}
383 @set pxref-record-size @pxref{Blocking}
384
385 @set op-recursive-unlink @kbd{--recursive-unlink}
386 @set ref-recursive-unlink @ref{Writing}
387 @set xref-recursive-unlink @xref{Writing}
388 @set pxref-recursive-unlink @pxref{Writing}
389
390 @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
391 @set ref-read-full-records @ref{Blocking}
392 @set xref-read-full-records @xref{Blocking}
393 @set pxref-read-full-records @pxref{Blocking}
394 @c FIXME: or should it be Reading, or Blocking Factor
395
396 @set op-remove-files @kbd{--remove-files}
397 @set ref-remove-files @ref{Writing}
398 @set xref-remove-files @xref{Writing}
399 @set pxref-remove-files @pxref{Writing}
400
401 @set op-rmt-command @kbd{rmt-command=@var{command}}
402 @set op-rsh-command @kbd{rsh-command=@var{command}}
403
404 @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
405 @set ref-same-order @ref{Scarce}
406 @set xref-same-order @xref{Scarce}
407 @set pxref-same-order @pxref{Scarce}
408 @c FIXME: or should it be Reading, or Attributes?
409
410 @set op-same-owner @kbd{--same-owner}
411 @set ref-same-owner @ref{Attributes}
412 @set xref-same-owner @xref{Attributes}
413 @set pxref-same-owner @pxref{Attributes}
414
415 @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
416 @set ref-same-permissions @ref{Attributes}
417 @set xref-same-permissions @xref{Attributes}
418 @set pxref-same-permissions @pxref{Attributes}
419 @c FIXME: or should it be Writing?
420
421 @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
422 @set ref-show-omitted-dirs @ref{verbose}
423 @set xref-show-omitted-dirs @xref{verbose}
424 @set pxref-show-omitted-dirs @pxref{verbose}
425
426 @set op-sparse @kbd{--sparse} (@kbd{-S})
427 @set ref-sparse @ref{sparse}
428 @set xref-sparse @xref{sparse}
429 @set pxref-sparse @pxref{sparse}
430
431 @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
432 @set ref-starting-file @ref{Scarce}
433 @set xref-starting-file @xref{Scarce}
434 @set pxref-starting-file @pxref{Scarce}
435
436 @set op-strip-components @kbd{--strip-components}
437 @set ref-strip-components @ref{--strip-components}
438 @set xref-strip-components @xref{--strip-components}
439 @set pxref-strip-components @pxref{--strip-components}
440
441 @set op-suffix @kbd{--suffix=@var{suffix}}
442 @set ref-suffix @ref{Backup options}
443 @set xref-suffix @xref{Backup options}
444 @set pxref-suffix @pxref{Backup options}
445
446 @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
447 @set ref-tape-length @ref{Using Multiple Tapes}
448 @set xref-tape-length @xref{Using Multiple Tapes}
449 @set pxref-tape-length @pxref{Using Multiple Tapes}
450
451 @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
452 @set ref-to-stdout @ref{Writing}
453 @set xref-to-stdout @xref{Writing}
454 @set pxref-to-stdout @pxref{Writing}
455
456 @set op-totals @kbd{--totals}
457 @set ref-totals @ref{verbose}
458 @set xref-totals @xref{verbose}
459 @set pxref-totals @pxref{verbose}
460
461 @set op-touch @kbd{--touch} (@kbd{-m})
462 @set ref-touch @ref{Writing}
463 @set xref-touch @xref{Writing}
464 @set pxref-touch @pxref{Writing}
465
466 @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
467 @set ref-unlink-first @ref{Writing}
468 @set xref-unlink-first @xref{Writing}
469 @set pxref-unlink-first @pxref{Writing}
470
471 @set op-update @kbd{--update} (@kbd{-u})
472 @set ref-update @ref{update}
473 @set xref-update @xref{update}
474 @set pxref-update @pxref{update}
475
476 @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
477 @set ref-use-compress-prog @ref{gzip}
478 @set xref-use-compress-prog @xref{gzip}
479 @set pxref-use-compress-prog @pxref{gzip}
480
481 @set op-verbose @kbd{--verbose} (@kbd{-v})
482 @set ref-verbose @ref{verbose}
483 @set xref-verbose @xref{verbose}
484 @set pxref-verbose @pxref{verbose}
485
486 @set op-verify @kbd{--verify} (@kbd{-W})
487 @set ref-verify @ref{verify}
488 @set xref-verify @xref{verify}
489 @set pxref-verify @pxref{verify}
490
491 @set op-version @kbd{--version}
492 @set ref-version @ref{help}
493 @set xref-version @xref{help}
494 @set pxref-version @pxref{help}
495
496 @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
497 @set ref-volno-file @ref{Using Multiple Tapes}
498 @set xref-volno-file @xref{Using Multiple Tapes}
499 @set pxref-volno-file @pxref{Using Multiple Tapes}
500
501 @set op-seek @kbd{--seek}
502 @set ref-seek @ref{seek}
503 @set xref-seek @xref{seek}
504 @set pxref-seek @pxref{seek}
505
506 @c Put everything in one index (arbitrarily chosen to be the concept index).
507 @syncodeindex fn cp
508 @syncodeindex ky cp
509 @syncodeindex pg cp
510 @syncodeindex vr cp
511
512 @defindex op
513 @syncodeindex op cp
514
515 @copying
516
517 This manual is for @acronym{GNU} @command{tar} (version
518 @value{VERSION}, @value{UPDATED}), which creates and extracts files
519 from archives.
520
521 Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
522 2003, 2004 Free Software Foundation, Inc.
523
524 @quotation
525 Permission is granted to copy, distribute and/or modify this document
526 under the terms of the GNU Free Documentation License, Version 1.1 or
527 any later version published by the Free Software Foundation; with the
528 Invariant Sections being "GNU General Public License", with the
529 Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
530 as in (a) below. A copy of the license is included in the section
531 entitled "GNU Free Documentation License".
532
533 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
534 this GNU Manual. Buying copies from GNU Press supports the FSF in
535 developing GNU and promoting software freedom.''
536 @end quotation
537 @end copying
538
539 @dircategory Archiving
540 @direntry
541 * Tar: (tar). Making tape (or disk) archives.
542 @end direntry
543
544 @dircategory Individual utilities
545 @direntry
546 * tar: (tar)tar invocation. Invoking @GNUTAR{}.
547 @end direntry
548
549 @shorttitlepage @acronym{GNU} @command{tar}
550
551 @titlepage
552 @title @acronym{GNU} tar: an archiver tool
553 @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
554 @author Melissa Weisshaus, Jay Fenlason,
555 @author Thomas Bushnell, n/BSG, Amy Gorin
556 @c he said to remove it: Fran@,{c}ois Pinard
557 @c i'm thinking about how the author page *should* look. -mew 2may96
558
559 @page
560 @vskip 0pt plus 1filll
561 @insertcopying
562 @end titlepage
563
564 @ifnottex
565 @node Top
566 @top @acronym{GNU} tar: an archiver tool
567
568 @insertcopying
569
570 @cindex file archival
571 @cindex archiving files
572
573 The first part of this master menu lists the major nodes in this Info
574 document. The rest of the menu lists all the lower level nodes.
575 @end ifnottex
576
577 @c The master menu, created with texinfo-master-menu, goes here.
578 @c (However, getdate.texi's menu is interpolated by hand.)
579
580 @menu
581 * Introduction::
582 * Tutorial::
583 * tar invocation::
584 * operations::
585 * Backups::
586 * Choosing::
587 * Date input formats::
588 * Formats::
589 * Media::
590 * Free Software Needs Free Documentation::
591 * Copying This Manual::
592 * Index::
593
594 @detailmenu
595 --- The Detailed Node Listing ---
596
597 Introduction
598
599 * Book Contents:: What this Book Contains
600 * Definitions:: Some Definitions
601 * What tar Does:: What @command{tar} Does
602 * Naming tar Archives:: How @command{tar} Archives are Named
603 * Current status:: Current development status of @GNUTAR{}
604 * Authors:: @GNUTAR{} Authors
605 * Reports:: Reporting bugs or suggestions
606
607 Tutorial Introduction to @command{tar}
608
609 * assumptions::
610 * stylistic conventions::
611 * basic tar options:: Basic @command{tar} Operations and Options
612 * frequent operations::
613 * Two Frequent Options::
614 * create:: How to Create Archives
615 * list:: How to List Archives
616 * extract:: How to Extract Members from an Archive
617 * going further::
618
619 Two Frequently Used Options
620
621 * file tutorial::
622 * verbose tutorial::
623 * help tutorial::
624
625 How to Create Archives
626
627 * prepare for examples::
628 * Creating the archive::
629 * create verbose::
630 * short create::
631 * create dir::
632
633 How to List Archives
634
635 * list dir::
636
637 How to Extract Members from an Archive
638
639 * extracting archives::
640 * extracting files::
641 * extract dir::
642 * failing commands::
643
644 Invoking @GNUTAR{}
645
646 * Synopsis::
647 * using tar options::
648 * Styles::
649 * All Options::
650 * help::
651 * verbose::
652 * interactive::
653
654 The Three Option Styles
655
656 * Mnemonic Options:: Mnemonic Option Style
657 * Short Options:: Short Option Style
658 * Old Options:: Old Option Style
659 * Mixing:: Mixing Option Styles
660
661 All @command{tar} Options
662
663 * Operation Summary::
664 * Option Summary::
665 * Short Option Summary::
666
667 @GNUTAR{} Operations
668
669 * Basic tar::
670 * Advanced tar::
671 * create options::
672 * extract options::
673 * backup::
674 * Applications::
675 * looking ahead::
676
677 Advanced @GNUTAR{} Operations
678
679 * Operations::
680 * append::
681 * update::
682 * concatenate::
683 * delete::
684 * compare::
685
686 How to Add Files to Existing Archives: @code{--append}
687
688 * appending files:: Appending Files to an Archive
689 * multiple::
690
691 Updating an Archive
692
693 * how to update::
694
695 Options Used by @code{--create}
696
697 * Ignore Failed Read::
698
699 Options Used by @code{--extract}
700
701 * Reading:: Options to Help Read Archives
702 * Writing:: Changing How @command{tar} Writes Files
703 * Scarce:: Coping with Scarce Resources
704
705 Options to Help Read Archives
706
707 * read full records::
708 * Ignore Zeros::
709
710 Changing How @command{tar} Writes Files
711
712 * Dealing with Old Files::
713 * Overwrite Old Files::
714 * Keep Old Files::
715 * Keep Newer Files::
716 * Unlink First::
717 * Recursive Unlink::
718 * Modification Times::
719 * Setting Access Permissions::
720 * Writing to Standard Output::
721 * remove files::
722
723 Coping with Scarce Resources
724
725 * Starting File::
726 * Same Order::
727
728 Performing Backups and Restoring Files
729
730 * Full Dumps:: Using @command{tar} to Perform Full Dumps
731 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
732 * incremental and listed-incremental:: The Incremental Options
733 * Backup Levels:: Levels of Backups
734 * Backup Parameters:: Setting Parameters for Backups and Restoration
735 * Scripted Backups:: Using the Backup Scripts
736 * Scripted Restoration:: Using the Restore Script
737
738 Setting Parameters for Backups and Restoration
739
740 * General-Purpose Variables::
741 * Magnetic Tape Control::
742 * User Hooks::
743 * backup-specs example:: An Example Text of @file{Backup-specs}
744
745 Choosing Files and Names for @command{tar}
746
747 * file:: Choosing the Archive's Name
748 * Selecting Archive Members::
749 * files:: Reading Names from a File
750 * exclude:: Excluding Some Files
751 * Wildcards::
752 * after:: Operating Only on New Files
753 * recurse:: Descending into Directories
754 * one:: Crossing Filesystem Boundaries
755
756 Reading Names from a File
757
758 * nul::
759
760 Excluding Some Files
761
762 * controlling pattern-patching with exclude::
763 * problems with exclude::
764
765 Crossing Filesystem Boundaries
766
767 * directory:: Changing Directory
768 * absolute:: Absolute File Names
769
770 Date input formats
771
772 * General date syntax:: Common rules.
773 * Calendar date items:: 19 Dec 1994.
774 * Time of day items:: 9:20pm.
775 * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
776 * Day of week items:: Monday and others.
777 * Relative items in date strings:: next tuesday, 2 years ago.
778 * Pure numbers in date strings:: 19931219, 1440.
779 * Seconds since the Epoch:: @@1078100502.
780 * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
781
782 Controlling the Archive Format
783
784 * Portability:: Making @command{tar} Archives More Portable
785 * Compression:: Using Less Space through Compression
786 * Attributes:: Handling File Attributes
787 * Standard:: The Standard Format
788 * Extensions:: @acronym{GNU} Extensions to the Archive Format
789 * cpio:: Comparison of @command{tar} and @command{cpio}
790
791 Making @command{tar} Archives More Portable
792
793 * Portable Names:: Portable Names
794 * dereference:: Symbolic Links
795 * old:: Old V7 Archives
796 * posix:: @acronym{POSIX} archives
797 * Checksumming:: Checksumming Problems
798 * Large or Negative Values:: Large files, negative time stamps, etc.
799
800 Using Less Space through Compression
801
802 * gzip:: Creating and Reading Compressed Archives
803 * sparse:: Archiving Sparse Files
804
805 Tapes and Other Archive Media
806
807 * Device:: Device selection and switching
808 * Remote Tape Server::
809 * Common Problems and Solutions::
810 * Blocking:: Blocking
811 * Many:: Many archives on one tape
812 * Using Multiple Tapes:: Using Multiple Tapes
813 * label:: Including a Label in the Archive
814 * verify::
815 * Write Protection::
816
817 Blocking
818
819 * Format Variations:: Format Variations
820 * Blocking Factor:: The Blocking Factor of an Archive
821
822 Many Archives on One Tape
823
824 * Tape Positioning:: Tape Positions and Tape Marks
825 * mt:: The @command{mt} Utility
826
827 Using Multiple Tapes
828
829 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
830 * Tape Files:: Tape Files
831
832 Copying This Manual
833
834 * GNU Free Documentation License:: License for copying this manual
835
836 @end detailmenu
837 @end menu
838
839 @node Introduction
840 @chapter Introduction
841
842 @GNUTAR{} creates
843 and manipulates @dfn{archives} which are actually collections of
844 many other files; the program provides users with an organized and
845 systematic method for controlling a large amount of data.
846 The name ``tar'' originally came from the phrase ``Tape ARchive'', but
847 archives need not (and these days, typically do not) reside on tapes.
848
849 @menu
850 * Book Contents:: What this Book Contains
851 * Definitions:: Some Definitions
852 * What tar Does:: What @command{tar} Does
853 * Naming tar Archives:: How @command{tar} Archives are Named
854 * Current status:: Current development status of @GNUTAR{}
855 * Authors:: @GNUTAR{} Authors
856 * Reports:: Reporting bugs or suggestions
857 @end menu
858
859 @node Book Contents
860 @section What this Book Contains
861
862 The first part of this chapter introduces you to various terms that will
863 recur throughout the book. It also tells you who has worked on @GNUTAR{}
864 and its documentation, and where you should send bug reports
865 or comments.
866
867 The second chapter is a tutorial (@pxref{Tutorial}) which provides a
868 gentle introduction for people who are new to using @command{tar}. It is
869 meant to be self contained, not requiring any reading from subsequent
870 chapters to make sense. It moves from topic to topic in a logical,
871 progressive order, building on information already explained.
872
873 Although the tutorial is paced and structured to allow beginners to
874 learn how to use @command{tar}, it is not intended solely for beginners.
875 The tutorial explains how to use the three most frequently used
876 operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
877 two frequently used options (@samp{file} and @samp{verbose}). The other
878 chapters do not refer to the tutorial frequently; however, if a section
879 discusses something which is a complex variant of a basic concept, there
880 may be a cross reference to that basic concept. (The entire book,
881 including the tutorial, assumes that the reader understands some basic
882 concepts of using a Unix-type operating system; @pxref{Tutorial}.)
883
884 The third chapter presents the remaining five operations, and
885 information about using @command{tar} options and option syntax.
886
887 @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
888 than the reality. should think about whether this makes sense to say
889 here, or not.} The other chapters are meant to be used as a
890 reference. Each chapter presents everything that needs to be said
891 about a specific topic.
892
893 One of the chapters (@pxref{Date input formats}) exists in its
894 entirety in other @acronym{GNU} manuals, and is mostly self-contained.
895 In addition, one section of this manual (@pxref{Standard}) contains a
896 big quote which is taken directly from @command{tar} sources.
897
898 In general, we give both long and short (abbreviated) option names
899 at least once in each section where the relevant option is covered, so
900 that novice readers will become familiar with both styles. (A few
901 options have no short versions, and the relevant sections will
902 indicate this.)
903
904 @node Definitions
905 @section Some Definitions
906
907 @cindex archive
908 @cindex tar archive
909 The @command{tar} program is used to create and manipulate @command{tar}
910 archives. An @dfn{archive} is a single file which contains the contents
911 of many files, while still identifying the names of the files, their
912 owner(s), and so forth. (In addition, archives record access
913 permissions, user and group, size in bytes, and last modification time.
914 Some archives also record the file names in each archived directory, as
915 well as other file and directory information.) You can use @command{tar}
916 to @dfn{create} a new archive in a specified directory.
917
918 @cindex member
919 @cindex archive member
920 @cindex file name
921 @cindex member name
922 The files inside an archive are called @dfn{members}. Within this
923 manual, we use the term @dfn{file} to refer only to files accessible in
924 the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
925 @dfn{member} to refer only to the members of an archive. Similarly, a
926 @dfn{file name} is the name of a file, as it resides in the filesystem,
927 and a @dfn{member name} is the name of an archive member within the
928 archive.
929
930 @cindex extraction
931 @cindex unpacking
932 The term @dfn{extraction} refers to the process of copying an archive
933 member (or multiple members) into a file in the filesystem. Extracting
934 all the members of an archive is often called @dfn{extracting the
935 archive}. The term @dfn{unpack} can also be used to refer to the
936 extraction of many or all the members of an archive. Extracting an
937 archive does not destroy the archive's structure, just as creating an
938 archive does not destroy the copies of the files that exist outside of
939 the archive. You may also @dfn{list} the members in a given archive
940 (this is often thought of as ``printing'' them to the standard output,
941 or the command line), or @dfn{append} members to a pre-existing archive.
942 All of these operations can be performed using @command{tar}.
943
944 @node What tar Does
945 @section What @command{tar} Does
946
947 @cindex tar
948 The @command{tar} program provides the ability to create @command{tar}
949 archives, as well as various other kinds of manipulation. For example,
950 you can use @command{tar} on previously created archives to extract files,
951 to store additional files, or to update or list files which were already
952 stored.
953
954 Initially, @command{tar} archives were used to store files conveniently on
955 magnetic tape. The name @command{tar} comes from this use; it stands for
956 @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
957 direct its output to available devices, files, or other programs (using
958 pipes). @command{tar} may even access remote devices or files (as archives).
959
960 @FIXME{the following table entries need a bit of work..}
961
962 You can use @command{tar} archives in many ways. We want to stress a few
963 of them: storage, backup, and transportation.
964
965 @table @asis
966 @item Storage
967 Often, @command{tar} archives are used to store related files for
968 convenient file transfer over a network. For example, the
969 @acronym{GNU} Project distributes its software bundled into
970 @command{tar} archives, so that all the files relating to a particular
971 program (or set of related programs) can be transferred as a single
972 unit.
973
974 A magnetic tape can store several files in sequence. However, the tape
975 has no names for these files; it only knows their relative position on
976 the tape. One way to store several files on one tape and retain their
977 names is by creating a @command{tar} archive. Even when the basic transfer
978 mechanism can keep track of names, as FTP can, the nuisance of handling
979 multiple files, directories, and multiple links makes @command{tar}
980 archives useful.
981
982 Archive files are also used for long-term storage. You can think of
983 this as transportation from the present into the future. (It is a
984 science-fiction idiom that you can move through time as well as in
985 space; the idea here is that @command{tar} can be used to move archives in
986 all dimensions, even time!)
987
988 @item Backup
989 Because the archive created by @command{tar} is capable of preserving
990 file information and directory structure, @command{tar} is commonly
991 used for performing full and incremental backups of disks. A backup
992 puts a collection of files (possibly pertaining to many users and
993 projects) together on a disk or a tape. This guards against
994 accidental destruction of the information in those files.
995 @GNUTAR{} has special features that allow it to be
996 used to make incremental and full dumps of all the files in a
997 filesystem.
998
999 @item Transportation
1000 You can create an archive on one system, transfer it to another system,
1001 and extract the contents there. This allows you to transport a group of
1002 files from one system to another.
1003 @end table
1004
1005 @node Naming tar Archives
1006 @section How @command{tar} Archives are Named
1007
1008 Conventionally, @command{tar} archives are given names ending with
1009 @samp{.tar}. This is not necessary for @command{tar} to operate properly,
1010 but this manual follows that convention in order to accustom readers to
1011 it and to make examples more clear.
1012
1013 @cindex tar file
1014 @cindex entry
1015 @cindex tar entry
1016 Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
1017 archive members as ``files'' or ``entries''. For people familiar with
1018 the operation of @command{tar}, this causes no difficulty. However, in
1019 this manual, we consistently refer to ``archives'' and ``archive
1020 members'' to make learning to use @command{tar} easier for novice users.
1021
1022 @node Current status
1023 @section Current development status of @GNUTAR{}
1024
1025 @GNUTAR{} is currently in the process of active development, whose
1026 primary aims are:
1027
1028 @itemize @bullet
1029 @item Improve compatibility between @GNUTAR{} and other @command{tar}
1030 implementations.
1031 @item Switch to using @acronym{POSIX} archives.
1032 @item Revise sparse file handling and multiple volume processing.
1033 @item Merge with the @acronym{GNU} @code{paxutils} project.
1034 @end itemize
1035
1036 Some of these aims are already attained, while others are still
1037 being worked upon. From the point of view of an end user, the
1038 following issues need special mentioning:
1039
1040 @table @asis
1041 @item Use of short option @option{-o}.
1042
1043 Earlier versions of @GNUTAR{} understood @option{-o} command line
1044 option as a synonym for @option{--old-archive}.
1045
1046 @GNUTAR{} starting from version 1.13.90 understands this option as
1047 a synonym for @option{--no-same-owner}. This is compatible with
1048 UNIX98 @command{tar} implementations.
1049
1050 However, to facilitate transition, @option{-o} option retains its
1051 old semantics when it is used with one of archive-creation commands.
1052 Users are encouraged to use @value{op-format-oldgnu} instead.
1053
1054 It is especially important, since versions of @acronym{GNU} Automake
1055 up to and including 1.8.4 invoke tar with this option to produce
1056 distribution tarballs. @xref{Formats,v7}, for the detailed discussion
1057 of this issue and its implications.
1058
1059 Future versions of @GNUTAR{} will understand @option{-o} only as a
1060 synonym for @option{--no-same-owner}.
1061
1062 @item Use of short option @option{-l}
1063
1064 Earlier versions of @GNUTAR{} understood @option{-l} option as a
1065 synonym for @samp{--one-file-system}. Such usage is deprecated.
1066 For compatibility with other implementations future versions of
1067 @GNUTAR{} will understand this option as a synonym for
1068 @option{--check-links}.
1069
1070 @item Use of options @option{--portability} and @option{--old-archive}
1071
1072 These options are deprecated. Please use @option{--format=v7} instead.
1073
1074 @item Use of option @option{--posix}
1075
1076 This option is deprecated. Please use @option{--format=posix} instead.
1077 @end table
1078
1079 @node Authors
1080 @section @GNUTAR{} Authors
1081
1082 @GNUTAR{} was originally written by John Gilmore,
1083 and modified by many people. The @acronym{GNU} enhancements were
1084 written by Jay Fenlason, then Joy Kendall, and the whole package has
1085 been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
1086 Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
1087 numerous and kind users.
1088
1089 We wish to stress that @command{tar} is a collective work, and owes much to
1090 all those people who reported problems, offered solutions and other
1091 insights, or shared their thoughts and suggestions. An impressive, yet
1092 partial list of those contributors can be found in the @file{THANKS}
1093 file from the @GNUTAR{} distribution.
1094
1095 @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
1096 sure i want to spell out the history in this detail, at least not for
1097 the printed book. i'm just not sure it needs to be said this way.
1098 i'll think about it.}
1099
1100 @FIXME{History is more important, and surely more interesting, than
1101 actual names. Quoting names without history would be meaningless. FP}
1102
1103 Jay Fenlason put together a draft of a @GNUTAR{}
1104 manual, borrowing notes from the original man page from John Gilmore.
1105 This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
1106 Gorin worked on a tutorial and manual for @GNUTAR{}.
1107 Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
1108 taking information from all these sources and merging them. Melissa
1109 Weisshaus finally edited and redesigned the book to create version
1110 1.12. @FIXME{update version number as necessary; i'm being
1111 optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
1112 maybe melissa? maybe julie sussman?] needs to properly index the
1113 thing.}
1114
1115 For version 1.12, Daniel Hagerty contributed a great deal of technical
1116 consulting. In particular, he is the primary author of @ref{Backups}.
1117
1118 In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
1119 (see @url{http://savannah.gnu.org/projects/tar}), and
1120 active development and maintenance work has started
1121 again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
1122 Poznyakoff and Jeff Bailey.
1123
1124 Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
1125
1126 @node Reports
1127 @section Reporting bugs or suggestions
1128
1129 @cindex bug reports
1130 @cindex reporting bugs
1131 If you find problems or have suggestions about this program or manual,
1132 please report them to @file{bug-tar@@gnu.org}.
1133
1134 When reporting a bug, please be sure to include as much detail as
1135 possible, in order to reproduce it. @FIXME{Be more specific, I'd
1136 like to make this node as detailed as 'Bug reporting' node in Emacs
1137 manual}.
1138
1139 @node Tutorial
1140 @chapter Tutorial Introduction to @command{tar}
1141
1142 This chapter guides you through some basic examples of three @command{tar}
1143 operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
1144 you already know how to use some other version of @command{tar}, then you
1145 may not need to read this chapter. This chapter omits most complicated
1146 details about how @command{tar} works.
1147
1148 @menu
1149 * assumptions::
1150 * stylistic conventions::
1151 * basic tar options:: Basic @command{tar} Operations and Options
1152 * frequent operations::
1153 * Two Frequent Options::
1154 * create:: How to Create Archives
1155 * list:: How to List Archives
1156 * extract:: How to Extract Members from an Archive
1157 * going further::
1158 @end menu
1159
1160 @node assumptions
1161 @section Assumptions this Tutorial Makes
1162
1163 This chapter is paced to allow beginners to learn about @command{tar}
1164 slowly. At the same time, we will try to cover all the basic aspects of
1165 these three operations. In order to accomplish both of these tasks, we
1166 have made certain assumptions about your knowledge before reading this
1167 manual, and the hardware you will be using:
1168
1169 @itemize @bullet
1170 @item
1171 Before you start to work through this tutorial, you should understand
1172 what the terms ``archive'' and ``archive member'' mean
1173 (@pxref{Definitions}). In addition, you should understand something
1174 about how Unix-type operating systems work, and you should know how to
1175 use some basic utilities. For example, you should know how to create,
1176 list, copy, rename, edit, and delete files and directories; how to
1177 change between directories; and how to figure out where you are in the
1178 filesystem. You should have some basic understanding of directory
1179 structure and how files are named according to which directory they are
1180 in. You should understand concepts such as standard output and standard
1181 input, what various definitions of the term ``argument'' mean, and the
1182 differences between relative and absolute path names. @FIXME{and what
1183 else?}
1184
1185 @item
1186 This manual assumes that you are working from your own home directory
1187 (unless we state otherwise). In this tutorial, you will create a
1188 directory to practice @command{tar} commands in. When we show path names,
1189 we will assume that those paths are relative to your home directory.
1190 For example, my home directory path is @file{/home/fsf/melissa}. All of
1191 my examples are in a subdirectory of the directory named by that path
1192 name; the subdirectory is called @file{practice}.
1193
1194 @item
1195 In general, we show examples of archives which exist on (or can be
1196 written to, or worked with from) a directory on a hard disk. In most
1197 cases, you could write those archives to, or work with them on any other
1198 device, such as a tape drive. However, some of the later examples in
1199 the tutorial and next chapter will not work on tape drives.
1200 Additionally, working with tapes is much more complicated than working
1201 with hard disks. For these reasons, the tutorial does not cover working
1202 with tape drives. @xref{Media}, for complete information on using
1203 @command{tar} archives with tape drives.
1204
1205 @FIXME{this is a cop out. need to add some simple tape drive info.}
1206 @end itemize
1207
1208 @node stylistic conventions
1209 @section Stylistic Conventions
1210
1211 In the examples, @samp{$} represents a typical shell prompt. It
1212 precedes lines you should type; to make this more clear, those lines are
1213 shown in @kbd{this font}, as opposed to lines which represent the
1214 computer's response; those lines are shown in @code{this font}, or
1215 sometimes @samp{like this}.
1216
1217 @c When we have lines which are too long to be
1218 @c displayed in any other way, we will show them like this:
1219
1220 @node basic tar options
1221 @section Basic @command{tar} Operations and Options
1222
1223 @command{tar} can take a wide variety of arguments which specify and define
1224 the actions it will have on the particular set of files or the archive.
1225 The main types of arguments to @command{tar} fall into one of two classes:
1226 operations, and options.
1227
1228 Some arguments fall into a class called @dfn{operations}; exactly one of
1229 these is both allowed and required for any instance of using @command{tar};
1230 you may @emph{not} specify more than one. People sometimes speak of
1231 @dfn{operating modes}. You are in a particular operating mode when you
1232 have specified the operation which specifies it; there are eight
1233 operations in total, and thus there are eight operating modes.
1234
1235 The other arguments fall into the class known as @dfn{options}. You are
1236 not required to specify any options, and you are allowed to specify more
1237 than one at a time (depending on the way you are using @command{tar} at
1238 that time). Some options are used so frequently, and are so useful for
1239 helping you type commands more carefully that they are effectively
1240 ``required''. We will discuss them in this chapter.
1241
1242 You can write most of the @command{tar} operations and options in any
1243 of three forms: long (mnemonic) form, short form, and old style. Some
1244 of the operations and options have no short or ``old'' forms; however,
1245 the operations and options which we will cover in this tutorial have
1246 corresponding abbreviations. @FIXME{make sure this is still the case,
1247 at the end}We will indicate those abbreviations appropriately to get
1248 you used to seeing them. (Note that the ``old style'' option forms
1249 exist in @GNUTAR{} for compatibility with Unix
1250 @command{tar}. We present a full discussion of this way of writing
1251 options and operations appears in @ref{Old Options}, and we discuss
1252 the other two styles of writing options in @ref{Mnemonic Options}, and
1253 @ref{Short Options}.)
1254
1255 In the examples and in the text of this tutorial, we usually use the
1256 long forms of operations and options; but the ``short'' forms produce
1257 the same result and can make typing long @command{tar} commands easier.
1258 For example, instead of typing
1259
1260 @smallexample
1261 @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
1262 @end smallexample
1263
1264 @noindent
1265 you can type
1266 @smallexample
1267 @kbd{tar -c -v -f afiles.tar apple angst aspic}
1268 @end smallexample
1269
1270 @noindent
1271 or even
1272 @smallexample
1273 @kbd{tar -cvf afiles.tar apple angst aspic}
1274 @end smallexample
1275
1276 @noindent
1277 For more information on option syntax, see @ref{Advanced tar}. In
1278 discussions in the text, when we name an option by its long form, we
1279 also give the corresponding short option in parentheses.
1280
1281 The term, ``option'', can be confusing at times, since ``operations''
1282 are often lumped in with the actual, @emph{optional} ``options'' in certain
1283 general class statements. For example, we just talked about ``short and
1284 long forms of options and operations''. However, experienced @command{tar}
1285 users often refer to these by shorthand terms such as, ``short and long
1286 options''. This term assumes that the ``operations'' are included, also.
1287 Context will help you determine which definition of ``options'' to use.
1288
1289 Similarly, the term ``command'' can be confusing, as it is often used in
1290 two different ways. People sometimes refer to @command{tar} ``commands''.
1291 A @command{tar} @dfn{command} is the entire command line of user input
1292 which tells @command{tar} what to do --- including the operation, options,
1293 and any arguments (file names, pipes, other commands, etc). However,
1294 you will also sometimes hear the term ``the @command{tar} command''. When
1295 the word ``command'' is used specifically like this, a person is usually
1296 referring to the @command{tar} @emph{operation}, not the whole line.
1297 Again, use context to figure out which of the meanings the speaker
1298 intends.
1299
1300 @node frequent operations
1301 @section The Three Most Frequently Used Operations
1302
1303 Here are the three most frequently used operations (both short and long
1304 forms), as well as a brief description of their meanings. The rest of
1305 this chapter will cover how to use these operations in detail. We will
1306 present the rest of the operations in the next chapter.
1307
1308 @table @kbd
1309 @item --create
1310 @itemx -c
1311 Create a new @command{tar} archive.
1312 @item --list
1313 @itemx -t
1314 List the contents of an archive.
1315 @item --extract
1316 @itemx -x
1317 Extract one or more members from an archive.
1318 @end table
1319
1320 @node Two Frequent Options
1321 @section Two Frequently Used Options
1322
1323 To understand how to run @command{tar} in the three operating modes listed
1324 previously, you also need to understand how to use two of the options to
1325 @command{tar}: @samp{--file} (which takes an archive file as an argument)
1326 and @samp{--verbose}. (You are usually not @emph{required} to specify
1327 either of these options when you run @command{tar}, but they can be very
1328 useful in making things more clear and helping you avoid errors.)
1329
1330 @menu
1331 * file tutorial::
1332 * verbose tutorial::
1333 * help tutorial::
1334 @end menu
1335
1336 @node file tutorial
1337 @unnumberedsubsec The @samp{--file} Option
1338
1339 @table @kbd
1340 @item --file=@var{archive-name}
1341 @itemx -f @var{archive-name}
1342 Specify the name of an archive file.
1343 @end table
1344
1345 You can specify an argument for the @value{op-file} option whenever you
1346 use @command{tar}; this option determines the name of the archive file
1347 that @command{tar} will work on.
1348
1349 If you don't specify this argument, then @command{tar} will use a
1350 default, usually some physical tape drive attached to your machine.
1351 If there is no tape drive attached, or the default is not meaningful,
1352 then @command{tar} will print an error message. The error message might
1353 look roughly like one of the following:
1354
1355 @smallexample
1356 tar: can't open /dev/rmt8 : No such device or address
1357 tar: can't open /dev/rsmt0 : I/O error
1358 @end smallexample
1359
1360 @noindent
1361 To avoid confusion, we recommend that you always specify an archive file
1362 name by using @value{op-file} when writing your @command{tar} commands.
1363 For more information on using the @value{op-file} option, see
1364 @ref{file}.
1365
1366 @node verbose tutorial
1367 @unnumberedsubsec The @samp{--verbose} Option
1368
1369 @table @kbd
1370 @item --verbose
1371 @itemx -v
1372 Show the files being worked on as @command{tar} is running.
1373 @end table
1374
1375 @value{op-verbose} shows details about the results of running
1376 @command{tar}. This can be especially useful when the results might not be
1377 obvious. For example, if you want to see the progress of @command{tar} as
1378 it writes files into the archive, you can use the @samp{--verbose}
1379 option. In the beginning, you may find it useful to use
1380 @samp{--verbose} at all times; when you are more accustomed to
1381 @command{tar}, you will likely want to use it at certain times but not at
1382 others. We will use @samp{--verbose} at times to help make something
1383 clear, and we will give many examples both using and not using
1384 @samp{--verbose} to show the differences.
1385
1386 Sometimes, a single instance of @samp{--verbose} on the command line
1387 will show a full, @samp{ls} style listing of an archive or files,
1388 @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
1389 giving sizes, owners, and similar information. Other times,
1390 @samp{--verbose} will only show files or members that the particular
1391 operation is operating on at the time. In the latter case, you can
1392 use @samp{--verbose} twice in a command to get a listing such as that
1393 in the former case. For example, instead of saying
1394
1395 @smallexample
1396 @kbd{tar -cvf afiles.tar apple angst aspic}
1397 @end smallexample
1398
1399 @noindent
1400 above, you might say
1401
1402 @smallexample
1403 @kbd{tar -cvvf afiles.tar apple angst aspic}
1404 @end smallexample
1405
1406 @noindent
1407 This works equally well using short or long forms of options. Using
1408 long forms, you would simply write out the mnemonic form of the option
1409 twice, like this:
1410
1411 @smallexample
1412 $ @kbd{tar --create --verbose --verbose @dots{}}
1413 @end smallexample
1414
1415 @noindent
1416 Note that you must double the hyphens properly each time.
1417
1418 Later in the tutorial, we will give examples using @w{@samp{--verbose
1419 --verbose}}.
1420
1421 @node help tutorial
1422 @unnumberedsubsec Getting Help: Using the @code{--help} Option
1423
1424 @table @kbd
1425 @item --help
1426
1427 The @samp{--help} option to @command{tar} prints out a very brief list of
1428 all operations and option available for the current version of
1429 @command{tar} available on your system.
1430 @end table
1431
1432 @node create
1433 @section How to Create Archives
1434 @UNREVISED
1435
1436 One of the basic operations of @command{tar} is @value{op-create}, which
1437 you use to create a @command{tar} archive. We will explain
1438 @samp{--create} first because, in order to learn about the other
1439 operations, you will find it useful to have an archive available to
1440 practice on.
1441
1442 To make this easier, in this section you will first create a directory
1443 containing three files. Then, we will show you how to create an
1444 @emph{archive} (inside the new directory). Both the directory, and
1445 the archive are specifically for you to practice on. The rest of this
1446 chapter and the next chapter will show many examples using this
1447 directory and the files you will create: some of those files may be
1448 other directories and other archives.
1449
1450 The three files you will archive in this example are called
1451 @file{blues}, @file{folk}, and @file{jazz}. The archive is called
1452 @file{collection.tar}.
1453
1454 This section will proceed slowly, detailing how to use @samp{--create}
1455 in @code{verbose} mode, and showing examples using both short and long
1456 forms. In the rest of the tutorial, and in the examples in the next
1457 chapter, we will proceed at a slightly quicker pace. This section
1458 moves more slowly to allow beginning users to understand how
1459 @command{tar} works.
1460
1461 @menu
1462 * prepare for examples::
1463 * Creating the archive::
1464 * create verbose::
1465 * short create::
1466 * create dir::
1467 @end menu
1468
1469 @node prepare for examples
1470 @subsection Preparing a Practice Directory for Examples
1471
1472 To follow along with this and future examples, create a new directory
1473 called @file{practice} containing files called @file{blues}, @file{folk}
1474 and @file{jazz}. The files can contain any information you like:
1475 ideally, they should contain information which relates to their names,
1476 and be of different lengths. Our examples assume that @file{practice}
1477 is a subdirectory of your home directory.
1478
1479 Now @command{cd} to the directory named @file{practice}; @file{practice}
1480 is now your @dfn{working directory}. (@emph{Please note}: Although
1481 the full path name of this directory is
1482 @file{/@var{homedir}/practice}, in our examples we will refer to
1483 this directory as @file{practice}; the @var{homedir} is presumed.
1484
1485 In general, you should check that the files to be archived exist where
1486 you think they do (in the working directory) by running @command{ls}.
1487 Because you just created the directory and the files and have changed to
1488 that directory, you probably don't need to do that this time.
1489
1490 It is very important to make sure there isn't already a file in the
1491 working directory with the archive name you intend to use (in this case,
1492 @samp{collection.tar}), or that you don't care about its contents.
1493 Whenever you use @samp{create}, @command{tar} will erase the current
1494 contents of the file named by @value{op-file} if it exists. @command{tar}
1495 will not tell you if you are about to overwrite an archive unless you
1496 specify an option which does this. @FIXME{xref to the node for
1497 --backup!}To add files to an existing archive, you need to use a
1498 different option, such as @value{op-append}; see @ref{append} for
1499 information on how to do this.
1500
1501 @node Creating the archive
1502 @subsection Creating the Archive
1503
1504 To place the files @file{blues}, @file{folk}, and @file{jazz} into an
1505 archive named @file{collection.tar}, use the following command:
1506
1507 @smallexample
1508 $ @kbd{tar --create --file=collection.tar blues folk jazz}
1509 @end smallexample
1510
1511 The order of the arguments is not very important, @emph{when using long
1512 option forms}. You could also say:
1513
1514 @smallexample
1515 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1516 @end smallexample
1517
1518 @noindent
1519 However, you can see that this order is harder to understand; this is
1520 why we will list the arguments in the order that makes the commands
1521 easiest to understand (and we encourage you to do the same when you use
1522 @command{tar}, to avoid errors).
1523
1524 Note that the part of the command which says,
1525 @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
1526 If you substituted any other string of characters for
1527 @kbd{collection.tar}, then that string would become the name of the
1528 archive file you create.
1529
1530 The order of the options becomes more important when you begin to use
1531 short forms. With short forms, if you type commands in the wrong order
1532 (even if you type them correctly in all other ways), you may end up with
1533 results you don't expect. For this reason, it is a good idea to get
1534 into the habit of typing options in the order that makes inherent sense.
1535 @xref{short create}, for more information on this.
1536
1537 In this example, you type the command as shown above: @samp{--create}
1538 is the operation which creates the new archive
1539 (@file{collection.tar}), and @samp{--file} is the option which lets
1540 you give it the name you chose. The files, @file{blues}, @file{folk},
1541 and @file{jazz}, are now members of the archive, @file{collection.tar}
1542 (they are @dfn{file name arguments} to the @samp{--create} operation).
1543 @FIXME{xref here to the discussion of file name args?}Now that they are
1544 in the archive, they are called @emph{archive members}, not files.
1545 (@pxref{Definitions,members}).
1546
1547 When you create an archive, you @emph{must} specify which files you
1548 want placed in the archive. If you do not specify any archive
1549 members, @GNUTAR{} will complain.
1550
1551 If you now list the contents of the working directory (@kbd{ls}), you will
1552 find the archive file listed as well as the files you saw previously:
1553
1554 @smallexample
1555 blues folk jazz collection.tar
1556 @end smallexample
1557
1558 @noindent
1559 Creating the archive @samp{collection.tar} did not destroy the copies of
1560 the files in the directory.
1561
1562 Keep in mind that if you don't indicate an operation, @command{tar} will not
1563 run and will prompt you for one. If you don't name any files, @command{tar}
1564 will complain. You must have write access to the working directory,
1565 or else you will not be able to create an archive in that directory.
1566
1567 @emph{Caution}: Do not attempt to use @value{op-create} to add files to
1568 an existing archive; it will delete the archive and write a new one.
1569 Use @value{op-append} instead. @xref{append}.
1570
1571 @node create verbose
1572 @subsection Running @samp{--create} with @samp{--verbose}
1573
1574 If you include the @value{op-verbose} option on the command line,
1575 @command{tar} will list the files it is acting on as it is working. In
1576 verbose mode, the @code{create} example above would appear as:
1577
1578 @smallexample
1579 $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
1580 blues
1581 folk
1582 jazz
1583 @end smallexample
1584
1585 This example is just like the example we showed which did not use
1586 @samp{--verbose}, except that @command{tar} generated the remaining lines
1587 @iftex
1588 (note the different font styles).
1589 @end iftex
1590 @ifinfo
1591 .
1592 @end ifinfo
1593
1594 In the rest of the examples in this chapter, we will frequently use
1595 @code{verbose} mode so we can show actions or @command{tar} responses that
1596 you would otherwise not see, and which are important for you to
1597 understand.
1598
1599 @node short create
1600 @subsection Short Forms with @samp{create}
1601
1602 As we said before, the @value{op-create} operation is one of the most
1603 basic uses of @command{tar}, and you will use it countless times.
1604 Eventually, you will probably want to use abbreviated (or ``short'')
1605 forms of options. A full discussion of the three different forms that
1606 options can take appears in @ref{Styles}; for now, here is what the
1607 previous example (including the @value{op-verbose} option) looks like
1608 using short option forms:
1609
1610 @smallexample
1611 $ @kbd{tar -cvf collection.tar blues folk jazz}
1612 blues
1613 folk
1614 jazz
1615 @end smallexample
1616
1617 @noindent
1618 As you can see, the system responds the same no matter whether you use
1619 long or short option forms.
1620
1621 @FIXME{i don't like how this is worded:} One difference between using
1622 short and long option forms is that, although the exact placement of
1623 arguments following options is no more specific when using short forms,
1624 it is easier to become confused and make a mistake when using short
1625 forms. For example, suppose you attempted the above example in the
1626 following way:
1627
1628 @smallexample
1629 $ @kbd{tar -cfv collection.tar blues folk jazz}
1630 @end smallexample
1631
1632 @noindent
1633 In this case, @command{tar} will make an archive file called @file{v},
1634 containing the files @file{blues}, @file{folk}, and @file{jazz}, because
1635 the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
1636 is thus taken to be the chosen archive file name. @command{tar} will try
1637 to add a file called @file{collection.tar} to the @file{v} archive file;
1638 if the file @file{collection.tar} did not already exist, @command{tar} will
1639 report an error indicating that this file does not exist. If the file
1640 @file{collection.tar} does already exist (e.g., from a previous command
1641 you may have run), then @command{tar} will add this file to the archive.
1642 Because the @samp{-v} option did not get registered, @command{tar} will not
1643 run under @samp{verbose} mode, and will not report its progress.
1644
1645 The end result is that you may be quite confused about what happened,
1646 and possibly overwrite a file. To illustrate this further, we will show
1647 you how an example we showed previously would look using short forms.
1648
1649 This example,
1650
1651 @smallexample
1652 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1653 @end smallexample
1654
1655 @noindent
1656 is confusing as it is. When shown using short forms, however, it
1657 becomes much more so:
1658
1659 @smallexample
1660 $ @kbd{tar blues -c folk -f collection.tar jazz}
1661 @end smallexample
1662
1663 @noindent
1664 It would be very easy to put the wrong string of characters
1665 immediately following the @samp{-f}, but doing that could sacrifice
1666 valuable data.
1667
1668 For this reason, we recommend that you pay very careful attention to
1669 the order of options and placement of file and archive names,
1670 especially when using short option forms. Not having the option name
1671 written out mnemonically can affect how well you remember which option
1672 does what, and therefore where different names have to be placed.
1673 (Placing options in an unusual order can also cause @command{tar} to
1674 report an error if you have set the shell environment variable
1675 @env{POSIXLY_CORRECT}.)
1676
1677 @node create dir
1678 @subsection Archiving Directories
1679
1680 @cindex Archiving Directories
1681 @cindex Directories, Archiving
1682 You can archive a directory by specifying its directory name as a
1683 file name argument to @command{tar}. The files in the directory will be
1684 archived relative to the working directory, and the directory will be
1685 re-created along with its contents when the archive is extracted.
1686
1687 To archive a directory, first move to its superior directory. If you
1688 have followed the previous instructions in this tutorial, you should
1689 type:
1690
1691 @smallexample
1692 $ @kbd{cd ..}
1693 $
1694 @end smallexample
1695
1696 @noindent
1697 This will put you into the directory which contains @file{practice},
1698 i.e. your home directory. Once in the superior directory, you can
1699 specify the subdirectory, @file{practice}, as a file name argument. To
1700 store @file{practice} in the new archive file @file{music.tar}, type:
1701
1702 @smallexample
1703 $ @kbd{tar --create --verbose --file=music.tar practice}
1704 @end smallexample
1705
1706 @noindent
1707 @command{tar} should output:
1708
1709 @smallexample
1710 practice/
1711 practice/blues
1712 practice/folk
1713 practice/jazz
1714 practice/collection.tar
1715 @end smallexample
1716
1717 Note that the archive thus created is not in the subdirectory
1718 @file{practice}, but rather in the current working directory---the
1719 directory from which @command{tar} was invoked. Before trying to archive a
1720 directory from its superior directory, you should make sure you have
1721 write access to the superior directory itself, not only the directory
1722 you are trying archive with @command{tar}. For example, you will probably
1723 not be able to store your home directory in an archive by invoking
1724 @command{tar} from the root directory; @value{xref-absolute-names}. (Note
1725 also that @file{collection.tar}, the original archive file, has itself
1726 been archived. @command{tar} will accept any file as a file to be
1727 archived, regardless of its content. When @file{music.tar} is
1728 extracted, the archive file @file{collection.tar} will be re-written
1729 into the file system).
1730
1731 If you give @command{tar} a command such as
1732
1733 @smallexample
1734 $ @kbd{tar --create --file=foo.tar .}
1735 @end smallexample
1736
1737 @noindent
1738 @command{tar} will report @samp{tar: ./foo.tar is the archive; not
1739 dumped}. This happens because @command{tar} creates the archive
1740 @file{foo.tar} in the current directory before putting any files into
1741 it. Then, when @command{tar} attempts to add all the files in the
1742 directory @file{.} to the archive, it notices that the file
1743 @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
1744 it. (It makes no sense to put an archive into itself.) @GNUTAR{}
1745 will continue in this case, and create the archive
1746 normally, except for the exclusion of that one file. (@emph{Please
1747 note:} Other versions of @command{tar} are not so clever; they will
1748 enter an infinite loop when this happens, so you should not depend on
1749 this behavior unless you are certain you are running @GNUTAR{}.)
1750 @FIXME{bob doesn't like this sentence, since he does
1751 it all the time, and we've been doing it in the editing passes for
1752 this manual: In general, make sure that the archive is not inside a
1753 directory being dumped.}
1754
1755 @node list
1756 @section How to List Archives
1757
1758 Frequently, you will find yourself wanting to determine exactly what a
1759 particular archive contains. You can use the @value{op-list} operation
1760 to get the member names as they currently appear in the archive, as well
1761 as various attributes of the files at the time they were archived. For
1762 example, you can examine the archive @file{collection.tar} that you
1763 created in the last section with the command,
1764
1765 @smallexample
1766 $ @kbd{tar --list --file=collection.tar}
1767 @end smallexample
1768
1769 @noindent
1770 The output of @command{tar} would then be:
1771
1772 @smallexample
1773 blues
1774 folk
1775 jazz
1776 @end smallexample
1777
1778 @FIXME{we hope this will change. if it doesn't, need to show the
1779 creation of bfiles somewhere above!!! : }
1780
1781 @noindent
1782 The archive @file{bfiles.tar} would list as follows:
1783
1784 @smallexample
1785 ./birds
1786 baboon
1787 ./box
1788 @end smallexample
1789
1790 @noindent
1791 Be sure to use a @value{op-file} option just as with @value{op-create}
1792 to specify the name of the archive.
1793
1794 If you use the @value{op-verbose} option with @samp{--list}, then
1795 @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
1796 showing owner, file size, and so forth.
1797
1798 If you had used @value{op-verbose} mode, the example above would look
1799 like:
1800
1801 @smallexample
1802 $ @kbd{tar --list --verbose --file=collection.tar folk}
1803 -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
1804 @end smallexample
1805
1806 @cindex File name arguments, using @code{--list} with
1807 @cindex @code{--list} with file name arguments
1808 You can specify one or more individual member names as arguments when
1809 using @samp{list}. In this case, @command{tar} will only list the
1810 names of members you identify. For example, @w{@kbd{tar --list
1811 --file=afiles.tar apple}} would only print @file{apple}.
1812
1813 @FIXME{we hope the relevant aspects of this will change:}Because
1814 @command{tar} preserves paths, file names must be specified as they appear
1815 in the archive (ie., relative to the directory from which the archive
1816 was created). Therefore, it is essential when specifying member names
1817 to @command{tar} that you give the exact member names. For example,
1818 @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
1819 something like @samp{tar: birds: Not found in archive}, because there is
1820 no member named @file{birds}, only one named @file{./birds}. While the
1821 names @file{birds} and @file{./birds} name the same file, @emph{member}
1822 names are compared using a simplistic name comparison, in which an exact
1823 match is necessary. @xref{absolute}.
1824
1825 However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
1826 with @file{folk}, because @file{folk} is in the archive file
1827 @file{collection.tar}. If you are not sure of the exact file name, try
1828 listing all the files in the archive and searching for the one you
1829 expect to find; remember that if you use @samp{--list} with no file
1830 names as arguments, @command{tar} will print the names of all the members
1831 stored in the specified archive.
1832
1833 @menu
1834 * list dir::
1835 @end menu
1836
1837 @node list dir
1838 @unnumberedsubsec Listing the Contents of a Stored Directory
1839
1840 To get information about the contents of an archived directory,
1841 use the directory name as a file name argument in conjunction with
1842 @value{op-list}. To find out file attributes, include the
1843 @value{op-verbose} option.
1844
1845 For example, to find out about files in the directory @file{practice}, in
1846 the archive file @file{music.tar}, type:
1847
1848 @smallexample
1849 $ @kbd{tar --list --verbose --file=music.tar practice}
1850 @end smallexample
1851
1852 @command{tar} responds:
1853
1854 @smallexample
1855 drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
1856 -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
1857 -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
1858 -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
1859 -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
1860 @end smallexample
1861
1862 When you use a directory name as a file name argument, @command{tar} acts on
1863 all the files (including sub-directories) in that directory.
1864
1865 @node extract
1866 @section How to Extract Members from an Archive
1867 @UNREVISED
1868 @cindex Extraction
1869 @cindex Retrieving files from an archive
1870 @cindex Resurrecting files from an archive
1871
1872 Creating an archive is only half the job---there is no point in storing
1873 files in an archive if you can't retrieve them. The act of retrieving
1874 members from an archive so they can be used and manipulated as
1875 unarchived files again is called @dfn{extraction}. To extract files
1876 from an archive, use the @value{op-extract} operation. As with
1877 @value{op-create}, specify the name of the archive with @value{op-file}.
1878 Extracting an archive does not modify the archive in any way; you can
1879 extract it multiple times if you want or need to.
1880
1881 Using @samp{--extract}, you can extract an entire archive, or specific
1882 files. The files can be directories containing other files, or not. As
1883 with @value{op-create} and @value{op-list}, you may use the short or the
1884 long form of the operation without affecting the performance.
1885
1886 @menu
1887 * extracting archives::
1888 * extracting files::
1889 * extract dir::
1890 * extracting untrusted archives::
1891 * failing commands::
1892 @end menu
1893
1894 @node extracting archives
1895 @subsection Extracting an Entire Archive
1896
1897 To extract an entire archive, specify the archive file name only, with
1898 no individual file names as arguments. For example,
1899
1900 @smallexample
1901 $ @kbd{tar -xvf collection.tar}
1902 @end smallexample
1903
1904 @noindent
1905 produces this:
1906
1907 @smallexample
1908 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
1909 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
1910 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
1911 @end smallexample
1912
1913 @node extracting files
1914 @subsection Extracting Specific Files
1915
1916 To extract specific archive members, give their exact member names as
1917 arguments, as printed by @value{op-list}. If you had mistakenly deleted
1918 one of the files you had placed in the archive @file{collection.tar}
1919 earlier (say, @file{blues}), you can extract it from the archive without
1920 changing the archive's structure. It will be identical to the original
1921 file @file{blues} that you deleted. @FIXME{At the time of this
1922 writing, atime and ctime are not restored. Since this is a tutorial
1923 for a beginnig user, it should hardly be mentioned here. Maybe in
1924 a footnote? --gray}.
1925
1926 First, make sure you are in the @file{practice} directory, and list the
1927 files in the directory. Now, delete the file, @samp{blues}, and list
1928 the files in the directory again.
1929
1930 You can now extract the member @file{blues} from the archive file
1931 @file{collection.tar} like this:
1932
1933 @smallexample
1934 $ @kbd{tar --extract --file=collection.tar blues}
1935 @end smallexample
1936
1937 @noindent
1938 If you list the files in the directory again, you will see that the file
1939 @file{blues} has been restored, with its original permissions, creation
1940 times, and owner.@FIXME{This is only accidentally true, but not in
1941 general. In most cases, one has to be root for restoring the owner, and
1942 use a special option for restoring permissions. Here, it just happens
1943 that the restoring user is also the owner of the archived members, and
1944 that the current @code{umask} is compatible with original permissions.}
1945 (These parameters will be identical to those which
1946 the file had when you originally placed it in the archive; any changes
1947 you may have made before deleting the file from the file system,
1948 however, will @emph{not} have been made to the archive member.) The
1949 archive file, @samp{collection.tar}, is the same as it was before you
1950 extracted @samp{blues}. You can confirm this by running @command{tar} with
1951 @value{op-list}.
1952
1953 @FIXME{we hope this will change:}Remember that as with other operations,
1954 specifying the exact member name is important. @w{@kbd{tar --extract
1955 --file=bfiles.tar birds}} will fail, because there is no member named
1956 @file{birds}. To extract the member named @file{./birds}, you must
1957 specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
1958 exact member names of the members of an archive, use @value{op-list}
1959 (@pxref{list}).
1960
1961 You can extract a file to standard output by combining the above options
1962 with the @value{op-to-stdout} option (@pxref{Writing to Standard
1963 Output}).
1964
1965 If you give the @value{op-verbose} option, then @value{op-extract} will
1966 print the names of the archive members as it extracts them.
1967
1968 @node extract dir
1969 @subsection Extracting Files that are Directories
1970
1971 Extracting directories which are members of an archive is similar to
1972 extracting other files. The main difference to be aware of is that if
1973 the extracted directory has the same name as any directory already in
1974 the working directory, then files in the extracted directory will be
1975 placed into the directory of the same name. Likewise, if there are
1976 files in the pre-existing directory with the same names as the members
1977 which you extract, the files from the extracted archive will replace
1978 the files already in the working directory (and possible
1979 subdirectories). This will happen regardless of whether or not the
1980 files in the working directory were more recent than those extracted
1981 (there exist, however, special options that alter this behavior
1982 @pxref{Writing}).
1983
1984 However, if a file was stored with a directory name as part of its file
1985 name, and that directory does not exist under the working directory when
1986 the file is extracted, @command{tar} will create the directory.
1987
1988 We can demonstrate how to use @samp{--extract} to extract a directory
1989 file with an example. Change to the @file{practice} directory if you
1990 weren't there, and remove the files @file{folk} and @file{jazz}. Then,
1991 go back to the parent directory and extract the archive
1992 @file{music.tar}. You may either extract the entire archive, or you may
1993 extract only the files you just deleted. To extract the entire archive,
1994 don't give any file names as arguments after the archive name
1995 @file{music.tar}. To extract only the files you deleted, use the
1996 following command:
1997
1998 @smallexample
1999 $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
2000 practice/folk
2001 practice/jazz
2002 @end smallexample
2003
2004 @noindent
2005 If you were to specify two @value{op-verbose} options, @command{tar}
2006 would have displayed more detail about the extracted files, as shown
2007 in the example below:
2008
2009 @smallexample
2010 $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
2011 -rw-rw-rw- me user 28 1996-10-18 16:31 practice/jazz
2012 -rw-rw-rw- me user 20 1996-09-23 16:44 practice/folk
2013 @end smallexample
2014
2015 @noindent
2016 Because you created the directory with @file{practice} as part of the
2017 file names of each of the files by archiving the @file{practice}
2018 directory as @file{practice}, you must give @file{practice} as part
2019 of the file names when you extract those files from the archive.
2020
2021 @FIXME{IMPORTANT! show the final structure, here. figure out what it
2022 will be.}
2023
2024 @node extracting untrusted archives
2025 @subsection Extracting Archives from Untrusted Sources
2026
2027 Extracting files from archives can overwrite files that already exist.
2028 If you receive an archive from an untrusted source, you should make a
2029 new directory and extract into that directory, so that you don't have
2030 to worry about the extraction overwriting one of your existing files.
2031 For example, if @file{untrusted.tar} came from somewhere else on the
2032 Internet, and you don't necessarily trust its contents, you can
2033 extract it as follows:
2034
2035 @smallexample
2036 $ @kbd{mkdir newdir}
2037 $ @kbd{cd newdir}
2038 $ @kbd{tar -xvf ../untrusted.tar}
2039 @end smallexample
2040
2041 It is also a good practice to examine contents of the archive
2042 before extracting it, using @value{op-list} option, possibly combined
2043 with @value{op-verbose}.
2044
2045 @node failing commands
2046 @subsection Commands That Will Fail
2047
2048 Here are some sample commands you might try which will not work, and why
2049 they won't work.
2050
2051 If you try to use this command,
2052
2053 @smallexample
2054 $ @kbd{tar -xvf music.tar folk jazz}
2055 @end smallexample
2056
2057 @noindent
2058 you will get the following response:
2059
2060 @smallexample
2061 tar: folk: Not found in archive
2062 tar: jazz: Not found in archive
2063 $
2064 @end smallexample
2065
2066 @noindent
2067 This is because these files were not originally @emph{in} the parent
2068 directory @file{..}, where the archive is located; they were in the
2069 @file{practice} directory, and their file names reflect this:
2070
2071 @smallexample
2072 $ @kbd{tar -tvf music.tar}
2073 practice/folk
2074 practice/jazz
2075 practice/rock
2076 @end smallexample
2077
2078 @FIXME{make sure the above works when going through the examples in
2079 order...}
2080
2081 @noindent
2082 Likewise, if you try to use this command,
2083
2084 @smallexample
2085 $ @kbd{tar -tvf music.tar folk jazz}
2086 @end smallexample
2087
2088 @noindent
2089 you would get a similar response. Members with those names are not in the
2090 archive. You must use the correct member names in order to extract the
2091 files from the archive.
2092
2093 If you have forgotten the correct names of the files in the archive,
2094 use @w{@kbd{tar --list --verbose}} to list them correctly.
2095
2096 @FIXME{more examples, here? hag thinks it's a good idea.}
2097
2098 @node going further
2099 @section Going Further Ahead in this Manual
2100
2101 @FIXME{need to write up a node here about the things that are going to
2102 be in the rest of the manual.}
2103
2104 @node tar invocation
2105 @chapter Invoking @GNUTAR{}
2106 @UNREVISED
2107
2108 This chapter is about how one invokes the @GNUTAR{}
2109 command, from the command synopsis (@pxref{Synopsis}). There are
2110 numerous options, and many styles for writing them. One mandatory
2111 option specifies the operation @command{tar} should perform
2112 (@pxref{Operation Summary}), other options are meant to detail how
2113 this operation should be performed (@pxref{Option Summary}).
2114 Non-option arguments are not always interpreted the same way,
2115 depending on what the operation is.
2116
2117 You will find in this chapter everything about option styles and rules for
2118 writing them (@pxref{Styles}). On the other hand, operations and options
2119 are fully described elsewhere, in other chapters. Here, you will find
2120 only synthetic descriptions for operations and options, together with
2121 pointers to other parts of the @command{tar} manual.
2122
2123 Some options are so special they are fully described right in this
2124 chapter. They have the effect of inhibiting the normal operation of
2125 @command{tar} or else, they globally alter the amount of feedback the user
2126 receives about what is going on. These are the @value{op-help} and
2127 @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
2128 and @value{op-interactive} options (@pxref{interactive}).
2129
2130 @menu
2131 * Synopsis::
2132 * using tar options::
2133 * Styles::
2134 * All Options::
2135 * help::
2136 * verbose::
2137 * interactive::
2138 @end menu
2139
2140 @node Synopsis
2141 @section General Synopsis of @command{tar}
2142
2143 The @GNUTAR{} program is invoked as either one of:
2144
2145 @smallexample
2146 @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
2147 @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
2148 @end smallexample
2149
2150 The second form is for when old options are being used.
2151
2152 You can use @command{tar} to store files in an archive, to extract them from
2153 an archive, and to do other types of archive manipulation. The primary
2154 argument to @command{tar}, which is called the @dfn{operation}, specifies
2155 which action to take. The other arguments to @command{tar} are either
2156 @dfn{options}, which change the way @command{tar} performs an operation,
2157 or file names or archive members, which specify the files or members
2158 @command{tar} is to act on.
2159
2160 You can actually type in arguments in any order, even if in this manual
2161 the options always precede the other arguments, to make examples easier
2162 to understand. Further, the option stating the main operation mode
2163 (the @command{tar} main command) is usually given first.
2164
2165 Each @var{name} in the synopsis above is interpreted as an archive member
2166 name when the main command is one of @value{op-compare}, @value{op-delete},
2167 @value{op-extract}, @value{op-list} or @value{op-update}. When naming
2168 archive members, you must give the exact name of the member in the
2169 archive, as it is printed by @value{op-list}. For @value{op-append}
2170 and @value{op-create}, these @var{name} arguments specify the names
2171 of either files or directory hierarchies to place in the archive.
2172 These files or hierarchies should already exist in the file system,
2173 prior to the execution of the @command{tar} command.
2174
2175 @command{tar} interprets relative file names as being relative to the
2176 working directory. @command{tar} will make all file names relative
2177 (by removing leading slashes when archiving or restoring files),
2178 unless you specify otherwise (using the @value{op-absolute-names}
2179 option). @value{xref-absolute-names}, for more information about
2180 @value{op-absolute-names}.
2181
2182 If you give the name of a directory as either a file name or a member
2183 name, then @command{tar} acts recursively on all the files and directories
2184 beneath that directory. For example, the name @file{/} identifies all
2185 the files in the filesystem to @command{tar}.
2186
2187 The distinction between file names and archive member names is especially
2188 important when shell globbing is used, and sometimes a source of confusion
2189 for newcomers. @xref{Wildcards}, for more information about globbing.
2190 The problem is that shells may only glob using existing files in the
2191 file system. Only @command{tar} itself may glob on archive members, so when
2192 needed, you must ensure that wildcard characters reach @command{tar} without
2193 being interpreted by the shell first. Using a backslash before @samp{*}
2194 or @samp{?}, or putting the whole argument between quotes, is usually
2195 sufficient for this.
2196
2197 Even if @var{name}s are often specified on the command line, they
2198 can also be read from a text file in the file system, using the
2199 @value{op-files-from} option.
2200
2201 If you don't use any file name arguments, @value{op-append},
2202 @value{op-delete} and @value{op-concatenate} will do nothing, while
2203 @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
2204 execution. The other operations of @command{tar} (@value{op-list},
2205 @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
2206 on the entire contents of the archive.
2207
2208 @cindex exit status
2209 @cindex return status
2210 Besides successful exits, @GNUTAR{} may fail for
2211 many reasons. Some reasons correspond to bad usage, that is, when the
2212 @command{tar} command is improperly written. Errors may be
2213 encountered later, while encountering an error processing the archive
2214 or the files. Some errors are recoverable, in which case the failure
2215 is delayed until @command{tar} has completed all its work. Some
2216 errors are such that it would not meaningful, or at least risky, to
2217 continue processing: @command{tar} then aborts processing immediately.
2218 All abnormal exits, whether immediate or delayed, should always be
2219 clearly diagnosed on @code{stderr}, after a line stating the nature of
2220 the error.
2221
2222 @GNUTAR{} returns only a few exit statuses. I'm really
2223 aiming simplicity in that area, for now. If you are not using the
2224 @value{op-compare} option, zero means that everything went well, besides
2225 maybe innocuous warnings. Nonzero means that something went wrong.
2226 Right now, as of today, ``nonzero'' is almost always 2, except for
2227 remote operations, where it may be 128.
2228
2229 @node using tar options
2230 @section Using @command{tar} Options
2231
2232 @GNUTAR{} has a total of eight operating modes which
2233 allow you to perform a variety of tasks. You are required to choose
2234 one operating mode each time you employ the @command{tar} program by
2235 specifying one, and only one operation as an argument to the
2236 @command{tar} command (two lists of four operations each may be found
2237 at @ref{frequent operations} and @ref{Operations}). Depending on
2238 circumstances, you may also wish to customize how the chosen operating
2239 mode behaves. For example, you may wish to change the way the output
2240 looks, or the format of the files that you wish to archive may require
2241 you to do something special in order to make the archive look right.
2242
2243 You can customize and control @command{tar}'s performance by running
2244 @command{tar} with one or more options (such as @value{op-verbose}, which
2245 we used in the tutorial). As we said in the tutorial, @dfn{options} are
2246 arguments to @command{tar} which are (as their name suggests) optional.
2247 Depending on the operating mode, you may specify one or more options.
2248 Different options will have different effects, but in general they all
2249 change details of the operation, such as archive format, archive name,
2250 or level of user interaction. Some options make sense with all
2251 operating modes, while others are meaningful only with particular modes.
2252 You will likely use some options frequently, while you will only use
2253 others infrequently, or not at all. (A full list of options is
2254 available in @pxref{All Options}.)
2255
2256 The @env{TAR_OPTIONS} environment variable specifies default options to
2257 be placed in front of any explicit options. For example, if
2258 @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
2259 if the two options @option{-v} and @option{--unlink-first} had been
2260 specified before any explicit options. Option specifications are
2261 separated by whitespace. A backslash escapes the next character, so it
2262 can be used to specify an option containing whitespace or a backslash.
2263
2264 Note that @command{tar} options are case sensitive. For example, the
2265 options @samp{-T} and @samp{-t} are different; the first requires an
2266 argument for stating the name of a file providing a list of @var{name}s,
2267 while the second does not require an argument and is another way to
2268 write @value{op-list}.
2269
2270 In addition to the eight operations, there are many options to
2271 @command{tar}, and three different styles for writing both: long (mnemonic)
2272 form, short form, and old style. These styles are discussed below.
2273 Both the options and the operations can be written in any of these three
2274 styles.
2275
2276 @FIXME{menu at end of this node. need to think of an actual outline
2277 for this chapter; probably do that after stuff from chap. 4 is
2278 incorporated.}
2279
2280 @node Styles
2281 @section The Three Option Styles
2282
2283 There are three styles for writing operations and options to the command
2284 line invoking @command{tar}. The different styles were developed at
2285 different times during the history of @command{tar}. These styles will be
2286 presented below, from the most recent to the oldest.
2287
2288 Some options must take an argument. (For example, @value{op-file} takes
2289 the name of an archive file as an argument. If you do not supply an
2290 archive file name, @command{tar} will use a default, but this can be
2291 confusing; thus, we recommend that you always supply a specific archive
2292 file name.) Where you @emph{place} the arguments generally depends on
2293 which style of options you choose. We will detail specific information
2294 relevant to each option style in the sections on the different option
2295 styles, below. The differences are subtle, yet can often be very
2296 important; incorrect option placement can cause you to overwrite a
2297 number of important files. We urge you to note these differences, and
2298 only use the option style(s) which makes the most sense to you until you
2299 feel comfortable with the others.
2300
2301 Some options @emph{may} take an argument (currently, there are
2302 two such options: @value{op-backup} and @value{op-occurrence}). Such
2303 options may have at most long and short forms, they do not have old style
2304 equivalent. The rules for specifying an argument for such options
2305 are stricter than those for specifying mandatory arguments. Please,
2306 pay special attention to them.
2307
2308 @menu
2309 * Mnemonic Options:: Mnemonic Option Style
2310 * Short Options:: Short Option Style
2311 * Old Options:: Old Option Style
2312 * Mixing:: Mixing Option Styles
2313 @end menu
2314
2315 @node Mnemonic Options
2316 @subsection Mnemonic Option Style
2317
2318 @FIXME{have to decide whether or not to replace other occurrences of
2319 "mnemonic" with "long", or *ugh* vice versa.}
2320
2321 Each option has at least one long (or mnemonic) name starting with two
2322 dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
2323 their corresponding short or old names. It sometimes happens that a
2324 single mnemonic option has many different different names which are
2325 synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
2326 long option names can be given unique abbreviations. For example,
2327 @samp{--cre} can be used in place of @samp{--create} because there is no
2328 other mnemonic option which begins with @samp{cre}. (One way to find
2329 this out is by trying it and seeing what happens; if a particular
2330 abbreviation could represent more than one option, @command{tar} will tell
2331 you that that abbreviation is ambiguous and you'll know that that
2332 abbreviation won't work. You may also choose to run @samp{tar --help}
2333 to see a list of options. Be aware that if you run @command{tar} with a
2334 unique abbreviation for the long name of an option you didn't want to
2335 use, you are stuck; @command{tar} will perform the command as ordered.)
2336
2337 Mnemonic options are meant to be obvious and easy to remember, and their
2338 meanings are generally easier to discern than those of their
2339 corresponding short options (see below). For example:
2340
2341 @smallexample
2342 $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
2343 @end smallexample
2344
2345 @noindent
2346 gives a fairly good set of hints about what the command does, even
2347 for those not fully acquainted with @command{tar}.
2348
2349 Mnemonic options which require arguments take those arguments
2350 immediately following the option name. There are two ways of
2351 specifying a mandatory argument. It can be separated from the
2352 option name either by an equal sign, or by any amount of
2353 white space characters. For example, the @samp{--file} option (which
2354 tells the name of the @command{tar} archive) is given a file such as
2355 @file{archive.tar} as argument by using any of the following notations:
2356 @samp{--file=archive.tar} or @samp{--file archive.tar}.
2357
2358 In contrast, optional arguments must always be introduced using
2359 an equal sign. For example, the @samp{--backup} option takes
2360 an optional argument specifying backup type. It must be used
2361 as @samp{--backup=@var{backup-type}}.
2362
2363 @node Short Options
2364 @subsection Short Option Style
2365
2366 Most options also have a short option name. Short options start with
2367 a single dash, and are followed by a single character, e.g.@: @samp{-t}
2368 (which is equivalent to @samp{--list}). The forms are absolutely
2369 identical in function; they are interchangeable.
2370
2371 The short option names are faster to type than long option names.
2372
2373 Short options which require arguments take their arguments immediately
2374 following the option, usually separated by white space. It is also
2375 possible to stick the argument right after the short option name, using
2376 no intervening space. For example, you might write @w{@samp{-f
2377 archive.tar}} or @samp{-farchive.tar} instead of using
2378 @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
2379 @w{@samp{-f @var{archive-name}}} denote the option which indicates a
2380 specific archive, here named @file{archive.tar}.
2381
2382 Short options which take optional arguments take their arguments
2383 immediately following the option letter, @emph{without any intervening
2384 white space characters}.
2385
2386 Short options' letters may be clumped together, but you are not
2387 required to do this (as compared to old options; see below). When
2388 short options are clumped as a set, use one (single) dash for them
2389 all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
2390 such a set is allowed to have an argument@footnote{Clustering many
2391 options, the last of which has an argument, is a rather opaque way to
2392 write options. Some wonder if @acronym{GNU} @code{getopt} should not
2393 even be made helpful enough for considering such usages as invalid.}.
2394
2395 When the options are separated, the argument for each option which requires
2396 an argument directly follows that option, as is usual for Unix programs.
2397 For example:
2398
2399 @smallexample
2400 $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
2401 @end smallexample
2402
2403 If you reorder short options' locations, be sure to move any arguments
2404 that belong to them. If you do not move the arguments properly, you may
2405 end up overwriting files.
2406
2407 @node Old Options
2408 @subsection Old Option Style
2409 @UNREVISED
2410
2411 Like short options, old options are single letters. However, old options
2412 must be written together as a single clumped set, without spaces separating
2413 them or dashes preceding them@footnote{Beware that if you precede options
2414 with a dash, you are announcing the short option style instead of the
2415 old option style; short options are decoded differently.}. This set
2416 of letters must be the first to appear on the command line, after the
2417 @command{tar} program name and some white space; old options cannot appear
2418 anywhere else. The letter of an old option is exactly the same letter as
2419 the corresponding short option. For example, the old option @samp{t} is
2420 the same as the short option @samp{-t}, and consequently, the same as the
2421 mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
2422 cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
2423
2424 @FIXME{bob suggests having an uglier example. :-) }
2425
2426 When options that need arguments are given together with the command,
2427 all the associated arguments follow, in the same order as the options.
2428 Thus, the example given previously could also be written in the old
2429 style as follows:
2430
2431 @smallexample
2432 $ @kbd{tar cvbf 20 /dev/rmt0}
2433 @end smallexample
2434
2435 @noindent
2436 Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
2437 the argument of @samp{-f}.
2438
2439 On the other hand, this old style syntax makes it difficult to match
2440 option letters with their corresponding arguments, and is often
2441 confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
2442 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
2443 argument for @samp{-f}, and @samp{-v} does not have a corresponding
2444 argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
2445 /dev/rmt0}} is clearer, putting all arguments next to the option they
2446 pertain to.
2447
2448 If you want to reorder the letters in the old option argument, be
2449 sure to reorder any corresponding argument appropriately.
2450
2451 This old way of writing @command{tar} options can surprise even experienced
2452 users. For example, the two commands:
2453
2454 @smallexample
2455 @kbd{tar cfz archive.tar.gz file}
2456 @kbd{tar -cfz archive.tar.gz file}
2457 @end smallexample
2458
2459 @noindent
2460 are quite different. The first example uses @file{archive.tar.gz} as
2461 the value for option @samp{f} and recognizes the option @samp{z}. The
2462 second example, however, uses @file{z} as the value for option
2463 @samp{f} --- probably not what was intended.
2464
2465 Old options are kept for compatibility with old versions of @command{tar}.
2466
2467 This second example could be corrected in many ways, among which the
2468 following are equivalent:
2469
2470 @smallexample
2471 @kbd{tar -czf archive.tar.gz file}
2472 @kbd{tar -cf archive.tar.gz -z file}
2473 @kbd{tar cf archive.tar.gz -z file}
2474 @end smallexample
2475
2476 @FIXME{still could explain this better; it's redundant:}
2477
2478 @cindex option syntax, traditional
2479 As far as we know, all @command{tar} programs, @acronym{GNU} and
2480 non-@acronym{GNU}, support old options. @GNUTAR{}
2481 supports them not only for historical reasons, but also because many
2482 people are used to them. For compatibility with Unix @command{tar},
2483 the first argument is always treated as containing command and option
2484 letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
2485 equivalent to @w{@samp{tar -c}:} both of them specify the
2486 @value{op-create} command to create an archive.
2487
2488 @node Mixing
2489 @subsection Mixing Option Styles
2490
2491 All three styles may be intermixed in a single @command{tar} command,
2492 so long as the rules for each style are fully
2493 respected@footnote{Before @GNUTAR{} version 1.11.6,
2494 a bug prevented intermixing old style options with mnemonic options in
2495 some cases.}. Old style options and either of the modern styles of
2496 options may be mixed within a single @command{tar} command. However,
2497 old style options must be introduced as the first arguments only,
2498 following the rule for old options (old options must appear directly
2499 after the @command{tar} command and some white space). Modern options
2500 may be given only after all arguments to the old options have been
2501 collected. If this rule is not respected, a modern option might be
2502 falsely interpreted as the value of the argument to one of the old
2503 style options.
2504
2505 For example, all the following commands are wholly equivalent, and
2506 illustrate the many combinations and orderings of option styles.
2507
2508 @smallexample
2509 @kbd{tar --create --file=archive.tar}
2510 @kbd{tar --create -f archive.tar}
2511 @kbd{tar --create -farchive.tar}
2512 @kbd{tar --file=archive.tar --create}
2513 @kbd{tar --file=archive.tar -c}
2514 @kbd{tar -c --file=archive.tar}
2515 @kbd{tar -c -f archive.tar}
2516 @kbd{tar -c -farchive.tar}
2517 @kbd{tar -cf archive.tar}
2518 @kbd{tar -cfarchive.tar}
2519 @kbd{tar -f archive.tar --create}
2520 @kbd{tar -f archive.tar -c}
2521 @kbd{tar -farchive.tar --create}
2522 @kbd{tar -farchive.tar -c}
2523 @kbd{tar c --file=archive.tar}
2524 @kbd{tar c -f archive.tar}
2525 @kbd{tar c -farchive.tar}
2526 @kbd{tar cf archive.tar}
2527 @kbd{tar f archive.tar --create}
2528 @kbd{tar f archive.tar -c}
2529 @kbd{tar fc archive.tar}
2530 @end smallexample
2531
2532 On the other hand, the following commands are @emph{not} equivalent to
2533 the previous set:
2534
2535 @smallexample
2536 @kbd{tar -f -c archive.tar}
2537 @kbd{tar -fc archive.tar}
2538 @kbd{tar -fcarchive.tar}
2539 @kbd{tar -farchive.tarc}
2540 @kbd{tar cfarchive.tar}
2541 @end smallexample
2542
2543 @noindent
2544 These last examples mean something completely different from what the
2545 user intended (judging based on the example in the previous set which
2546 uses long options, whose intent is therefore very clear). The first
2547 four specify that the @command{tar} archive would be a file named
2548 @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
2549 respectively. The first two examples also specify a single non-option,
2550 @var{name} argument having the value @samp{archive.tar}. The last
2551 example contains only old style option letters (repeating option
2552 @samp{c} twice), not all of which are meaningful (eg., @samp{.},
2553 @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
2554 the first sentence of this paragraph..}
2555
2556 @node All Options
2557 @section All @command{tar} Options
2558
2559 The coming manual sections contain an alphabetical listing of all
2560 @command{tar} operations and options, with brief descriptions and cross
2561 references to more in-depth explanations in the body of the manual.
2562 They also contain an alphabetically arranged table of the short option
2563 forms with their corresponding long option. You can use this table as
2564 a reference for deciphering @command{tar} commands in scripts.
2565
2566 @menu
2567 * Operation Summary::
2568 * Option Summary::
2569 * Short Option Summary::
2570 @end menu
2571
2572 @node Operation Summary
2573 @subsection Operations
2574
2575 @table @kbd
2576
2577 @item --append
2578 @itemx -r
2579
2580 Appends files to the end of the archive. @xref{append}.
2581
2582 @item --catenate
2583 @itemx -A
2584
2585 Same as @samp{--concatenate}. @xref{concatenate}.
2586
2587 @item --compare
2588 @itemx -d
2589
2590 Compares archive members with their counterparts in the file
2591 system, and reports differences in file size, mode, owner,
2592 modification date and contents. @xref{compare}.
2593
2594 @item --concatenate
2595 @itemx -A
2596
2597 Appends other @command{tar} archives to the end of the archive.
2598 @xref{concatenate}.
2599
2600 @item --create
2601 @itemx -c
2602
2603 Creates a new @command{tar} archive. @xref{create}.
2604
2605 @item --delete
2606
2607 Deletes members from the archive. Don't try this on a archive on a
2608 tape! @xref{delete}.
2609
2610 @item --diff
2611 @itemx -d
2612
2613 Same @samp{--compare}. @xref{compare}.
2614
2615 @item --extract
2616 @itemx -x
2617
2618 Extracts members from the archive into the file system. @xref{extract}.
2619
2620 @item --get
2621 @itemx -x
2622
2623 Same as @samp{--extract}. @xref{extract}.
2624
2625 @item --list
2626 @itemx -t
2627
2628 Lists the members in an archive. @xref{list}.
2629
2630 @item --update
2631 @itemx -u
2632
2633 @FIXME{It was: A combination of the @samp{--compare} and
2634 @samp{--append} operations. This is not true and rather misleading,
2635 as @value{op-compare} does a lot more than @value{op-update} for
2636 ensuring files are identical.} Adds files to the end of the archive,
2637 but only if they are newer than their counterparts already in the
2638 archive, or if they do not already exist in the archive.
2639 @xref{update}.
2640
2641 @end table
2642
2643 @node Option Summary
2644 @subsection @command{tar} Options
2645
2646 @table @kbd
2647
2648 @item --absolute-names
2649 @itemx -P
2650
2651 Normally when creating an archive, @command{tar} strips an initial
2652 @samp{/} from member names. This option disables that behavior.
2653 @FIXME-xref{}
2654
2655 @item --after-date
2656
2657 (See @samp{--newer}.) @FIXME-pxref{}
2658
2659 @item --anchored
2660 An exclude pattern must match an initial subsequence of the name's components.
2661 @FIXME-xref{}
2662
2663 @item --atime-preserve
2664
2665 Tells @command{tar} to preserve the access time field in a file's inode when
2666 reading it. Due to limitations in the @code{utimes} system call, the
2667 modification time field is also preserved, which may cause problems if
2668 the file is simultaneously being modified by another program.
2669 This option is incompatible with incremental backups, because
2670 preserving the access time involves updating the last-changed time.
2671 Also, this option does not work on files that you do not own,
2672 unless you're root.
2673 @FIXME-xref{}
2674
2675 @item --backup=@var{backup-type}
2676
2677 Rather than deleting files from the file system, @command{tar} will
2678 back them up using simple or numbered backups, depending upon
2679 @var{backup-type}. @FIXME-xref{}
2680
2681 @item --block-number
2682 @itemx -R
2683
2684 With this option present, @command{tar} prints error messages for read errors
2685 with the block number in the archive file. @FIXME-xref{}
2686
2687 @item --blocking-factor=@var{blocking}
2688 @itemx -b @var{blocking}
2689
2690 Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
2691 record. @FIXME-xref{}
2692
2693 @item --bzip2
2694 @itemx -j
2695
2696 This option tells @command{tar} to read or write archives through
2697 @code{bzip2}. @FIXME-xref{}
2698
2699 @item --checkpoint
2700
2701 This option directs @command{tar} to print periodic checkpoint messages as it
2702 reads through the archive. Its intended for when you want a visual
2703 indication that @command{tar} is still running, but don't want to see
2704 @samp{--verbose} output. @FIXME-xref{}
2705
2706 @item --check-links
2707 @itemx -l
2708 If this option was given, @command{tar} will check the number of links
2709 dumped for each processed file. If this number does not match the
2710 total number of hard links for the file, a warning message will be
2711 output.
2712
2713 Future versions will take @option{-l} as a short version of
2714 @option{--check-links}. However, current release still retains the old
2715 semantics for @option{-l}.
2716
2717 @xref{Current status}, for more information.
2718
2719 @item --compress
2720 @itemx --uncompress
2721 @itemx -Z
2722
2723 @command{tar} will use the @command{compress} program when reading or
2724 writing the archive. This allows you to directly act on archives
2725 while saving space. @FIXME-xref{}
2726
2727 @item --confirmation
2728
2729 (See @samp{--interactive}.) @FIXME-pxref{}
2730
2731 @item --dereference
2732 @itemx -h
2733
2734 When creating a @command{tar} archive, @command{tar} will archive the
2735 file that a symbolic link points to, rather than archiving the
2736 symlink. @FIXME-xref{}
2737
2738 @item --directory=@var{dir}
2739 @itemx -C @var{dir}
2740
2741 When this option is specified, @command{tar} will change its current directory
2742 to @var{dir} before performing any operations. When this option is used
2743 during archive creation, it is order sensitive. @FIXME-xref{}
2744
2745 @item --exclude=@var{pattern}
2746
2747 When performing operations, @command{tar} will skip files that match
2748 @var{pattern}. @FIXME-xref{}
2749
2750 @item --exclude-from=@var{file}
2751 @itemx -X @var{file}
2752
2753 Similar to @samp{--exclude}, except @command{tar} will use the list of
2754 patterns in the file @var{file}. @FIXME-xref{}
2755
2756 @item --exclude-caches
2757
2758 Automatically excludes all directories
2759 containing a cache directory tag. @FIXME-xref{}
2760
2761 @item --file=@var{archive}
2762 @itemx -f @var{archive}
2763
2764 @command{tar} will use the file @var{archive} as the @command{tar} archive it
2765 performs operations on, rather than @command{tar}'s compilation dependent
2766 default. @FIXME-xref{}
2767
2768 @item --files-from=@var{file}
2769 @itemx -T @var{file}
2770
2771 @command{tar} will use the contents of @var{file} as a list of archive members
2772 or files to operate on, in addition to those specified on the
2773 command-line. @FIXME-xref{}
2774
2775 @item --force-local
2776
2777 Forces @command{tar} to interpret the filename given to @samp{--file}
2778 as a local file, even if it looks like a remote tape drive name.
2779 @FIXME-xref{}
2780
2781 @item --format=@var{format}
2782
2783 Selects output archive format. @var{Format} may be one of the
2784 following:
2785
2786 @table @samp
2787 @item v7
2788 Creates an archive that is compatible with Unix V7 @command{tar}.
2789
2790 @item oldgnu
2791 Creates an archive that is compatible with GNU @command{tar} version
2792 1.12 or earlier.
2793
2794 @item gnu
2795 Creates archive in GNU tar 1.13 format. Basically it is the same as
2796 @samp{oldgnu} with the only difference in the way it handles long
2797 numeric fields.
2798
2799 @item ustar
2800 Creates a @acronym{POSIX.1-1988} compatible archive.
2801
2802 @item posix
2803 Creates a @acronym{POSIX.1-2001 archive}.
2804
2805 @end table
2806
2807 @xref{Formats}, for a detailed discussion of these formats.
2808
2809 @item --group=@var{group}
2810
2811 Files added to the @command{tar} archive will have a group id of @var{group},
2812 rather than the group from the source file. @var{group} is first decoded
2813 as a group symbolic name, but if this interpretation fails, it has to be
2814 a decimal numeric group ID. @FIXME-xref{}
2815
2816 Also see the comments for the @value{op-owner} option.
2817
2818 @item --gzip
2819 @itemx --gunzip
2820 @itemx --ungzip
2821 @itemx -z
2822
2823 This option tells @command{tar} to read or write archives through
2824 @command{gzip}, allowing @command{tar} to directly operate on several
2825 kinds of compressed archives transparently. @FIXME-xref{}
2826
2827 @item --help
2828
2829 @command{tar} will print out a short message summarizing the operations and
2830 options to @command{tar} and exit. @FIXME-xref{}
2831
2832 @item --ignore-case
2833 Ignore case when excluding files.
2834 @FIXME-xref{}
2835
2836 @item --ignore-failed-read
2837
2838 Do not exit unsuccessfully merely because an unreadable file was encountered.
2839 @xref{Reading}.
2840
2841 @item --ignore-zeros
2842 @itemx -i
2843
2844 With this option, @command{tar} will ignore zeroed blocks in the
2845 archive, which normally signals EOF. @xref{Reading}.
2846
2847 @item --incremental
2848 @itemx -G
2849
2850 Used to inform @command{tar} that it is working with an old
2851 @acronym{GNU}-format incremental backup archive. It is intended
2852 primarily for backwards compatibility only. @FIXME-xref{}
2853
2854 @item --index-file=@var{file}
2855
2856 Send verbose output to @var{file} instead of to standard output.
2857
2858 @item --info-script=@var{script-file}
2859 @itemx --new-volume-script=@var{script-file}
2860 @itemx -F @var{script-file}
2861
2862 When @command{tar} is performing multi-tape backups, @var{script-file} is run
2863 at the end of each tape. If @var{script-file} exits with nonzero status,
2864 @command{tar} fails immediately. @FIXME-xref{}
2865
2866 @item --interactive
2867 @itemx --confirmation
2868 @itemx -w
2869
2870 Specifies that @command{tar} should ask the user for confirmation before
2871 performing potentially destructive options, such as overwriting files.
2872 @FIXME-xref{}
2873
2874 @item --keep-newer-files
2875
2876 Do not replace existing files that are newer than their archive copies
2877 when extracting files from an archive.
2878
2879 @item --keep-old-files
2880 @itemx -k
2881
2882 Do not overwrite existing files when extracting files from an archive.
2883 @xref{Writing}.
2884
2885 @item --label=@var{name}
2886 @itemx -V @var{name}
2887
2888 When creating an archive, instructs @command{tar} to write @var{name}
2889 as a name record in the archive. When extracting or listing archives,
2890 @command{tar} will only operate on archives that have a label matching
2891 the pattern specified in @var{name}. @FIXME-xref{}
2892
2893 @item --listed-incremental=@var{snapshot-file}
2894 @itemx -g @var{snapshot-file}
2895
2896 During a @samp{--create} operation, specifies that the archive that
2897 @command{tar} creates is a new @acronym{GNU}-format incremental
2898 backup, using @var{snapshot-file} to determine which files to backup.
2899 With other operations, informs @command{tar} that the archive is in
2900 incremental format. @FIXME-xref{}
2901
2902 @item --mode=@var{permissions}
2903
2904 When adding files to an archive, @command{tar} will use
2905 @var{permissions} for the archive members, rather than the permissions
2906 from the files. The program @command{chmod} and this @command{tar}
2907 option share the same syntax for what @var{permissions} might be.
2908 @xref{File permissions, Permissions, File permissions, fileutils,
2909 @acronym{GNU} file utilities}. This reference also has useful
2910 information for those not being overly familiar with the Unix
2911 permission system.
2912
2913 Of course, @var{permissions} might be plainly specified as an octal number.
2914 However, by using generic symbolic modifications to mode bits, this allows
2915 more flexibility. For example, the value @samp{a+rw} adds read and write
2916 permissions for everybody, while retaining executable bits on directories
2917 or on any other file already marked as executable.
2918
2919 @item --multi-volume
2920 @itemx -M
2921
2922 Informs @command{tar} that it should create or otherwise operate on a
2923 multi-volume @command{tar} archive. @FIXME-xref{}
2924
2925 @item --new-volume-script
2926
2927 (see --info-script)
2928
2929 @item -n
2930 @itemx --seek
2931
2932 Assume that the archive media supports seeks to arbitrary
2933 locations. Usually @command{tar} determines automatically whether
2934 the archive can be seeked or not. This option is intended for use
2935 in cases when such recognition fails.
2936
2937 @item --newer=@var{date}
2938 @itemx --after-date=@var{date}
2939 @itemx -N
2940
2941 When creating an archive, @command{tar} will only add files that have changed
2942 since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
2943 is taken to be the name of a file whose last-modified time specifies
2944 the date. @FIXME-xref{}
2945
2946 @item --newer-mtime=@var{date}
2947
2948 Like @samp{--newer}, but add only files whose
2949 contents have changed (as opposed to just @samp{--newer}, which will
2950 also back up files for which any status information has changed).
2951
2952 @item --no-anchored
2953 An exclude pattern can match any subsequence of the name's components.
2954 @FIXME-xref{}
2955
2956 @item --no-ignore-case
2957 Use case-sensitive matching when excluding files.
2958 @FIXME-xref{}
2959
2960 @item --no-recursion
2961
2962 With this option, @command{tar} will not recurse into directories.
2963 @FIXME-xref{}
2964
2965 @item --no-same-owner
2966 @itemx -o
2967
2968 When extracting an archive, do not attempt to preserve the owner
2969 specified in the @command{tar} archive. This the default behavior
2970 for ordinary users; this option has an effect only for the superuser.
2971
2972 @item --no-same-permissions
2973
2974 When extracting an archive, subtract the user's umask from files from
2975 the permissions specified in the archive. This is the default behavior
2976 for ordinary users; this option has an effect only for the superuser.
2977
2978 @item --no-wildcards
2979 Do not use wildcards when excluding files.
2980 @FIXME-xref{}
2981
2982 @item --no-wildcards-match-slash
2983 Wildcards do not match @samp{/} when excluding files.
2984 @FIXME-xref{}
2985
2986 @item --null
2987
2988 When @command{tar} is using the @samp{--files-from} option, this option
2989 instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
2990 @command{tar} can correctly work with file names that contain newlines.
2991 @FIXME-xref{}
2992
2993 @item --numeric-owner
2994
2995 This option will notify @command{tar} that it should use numeric user
2996 and group IDs when creating a @command{tar} file, rather than names.
2997 @FIXME-xref{}
2998
2999 @item -o
3000 When extracting files, this option is a synonym for
3001 @option{--no-same-owner}, i.e. it prevents @command{tar} from
3002 restoring ownership of files being extracted.
3003
3004 When creating an archive, @option{-o} is a synonym for
3005 @option{--old-archive}. This behavior is for compatibility
3006 with previous versions of @GNUTAR{}, and will be
3007 removed in the future releases.
3008
3009 @xref{Current status}, for more information.
3010
3011 @item --occurrence[=@var{number}]
3012
3013 This option can be used in conjunction with one of the subcommands
3014 @option{--delete}, @option{--diff}, @option{--extract} or
3015 @option{--list} when a list of files is given either on the command
3016 line or via @option{-T} option.
3017
3018 This option instructs @command{tar} to process only the @var{number}th
3019 occurrence of each named file. @var{Number} defaults to 1, so
3020
3021 @smallexample
3022 tar -x -f archive.tar --occurrence filename
3023 @end smallexample
3024
3025 @noindent
3026 will extract the first occurrence of @file{filename} from @file{archive.tar}
3027 and will terminate without scanning to the end of the archive.
3028
3029 @item --old-archive
3030 Synonym for @option{--format=v7}.
3031
3032 @item --one-file-system
3033 @itemx -l
3034 Used when creating an archive. Prevents @command{tar} from recursing into
3035 directories that are on different file systems from the current
3036 directory.
3037
3038 Earlier versions of @GNUTAR{} understood @option{-l} as a
3039 synonym for @option{--one-file-system}. Although such usage is still
3040 allowed in the present version, it is @emph{strongly discouraged}.
3041 The future versions of @GNUTAR{} will use @option{-l} as
3042 a synonym for @option{--check-links}.
3043
3044 @xref{Current status}, for more information.
3045
3046 @item --overwrite
3047
3048 Overwrite existing files and directory metadata when extracting files
3049 from an archive. @xref{Overwrite Old Files}.
3050
3051 @item --overwrite-dir
3052
3053 Overwrite the metadata of existing directories when extracting files
3054 from an archive. @xref{Overwrite Old Files}.
3055
3056 @item --owner=@var{user}
3057
3058 Specifies that @command{tar} should use @var{user} as the owner of members
3059 when creating archives, instead of the user associated with the source
3060 file. @var{user} is first decoded as a user symbolic name, but if
3061 this interpretation fails, it has to be a decimal numeric user ID.
3062 @FIXME-xref{}
3063
3064 There is no value indicating a missing number, and @samp{0} usually means
3065 @code{root}. Some people like to force @samp{0} as the value to offer in
3066 their distributions for the owner of files, because the @code{root} user is
3067 anonymous anyway, so that might as well be the owner of anonymous archives.
3068
3069 This option does not affect extraction from archives.
3070
3071 @item --pax-option=@var{keyword-list}
3072
3073 This option is meaningful only with @acronym{POSIX.1-2001} archives
3074 (@FIXME-xref{}). It modifies the way @command{tar} handles the
3075 extended header keywords. @var{Keyword-list} is a comma-separated
3076 list of keyword options, each keyword option taking one of
3077 the following forms:
3078
3079 @table @asis
3080 @item delete=@var{pattern}
3081 When used with one of archive-creation command (@FIXME-xref{}),
3082 this option instructs @command{tar} to omit from extended header records
3083 that it produces any keywords matching the string @var{pattern}.
3084
3085 When used in extract or list mode, this option instructs tar
3086 to ignore any keywords matching the given @var{pattern} in the extended
3087 header records. In both cases, matching is performed using the pattern
3088 matching notation described in @acronym{POSIX 1003.2}, 3.13 @FIXME-xref{see
3089 man 7 glob}. For example:
3090
3091 @smallexample
3092 --pax-option delete=security.*
3093 @end smallexample
3094
3095 would suppress security-related information.
3096
3097 @item exthdr.name=@var{string}
3098
3099 This keyword allows user control over the name that is written into the
3100 ustar header blocks for the extended headers. The name is obtained
3101 from @var{string} after substituting the following meta-characters:
3102
3103 @multitable @columnfractions .30 .70
3104 @item Meta-character @tab Replaced By
3105 @item %d @tab The directory name of the file, equivalent to the
3106 result of the @command{dirname} utility on the translated pathname.
3107 @item %f @tab The filename of the file, equivalent to the result
3108 of the @command{basename} utility on the translated pathname.
3109 @item %p @tab The process ID of the @command{tar} process.
3110 @item %% @tab A @samp{%} character.
3111 @end multitable
3112
3113 Any other @samp{%} characters in @var{string} produce undefined
3114 results.
3115
3116 If no option @samp{exthdr.name=string} is specified, @command{tar}
3117 will use the following default value:
3118
3119 @smallexample
3120 %d/PaxHeaders.%p/%f
3121 @end smallexample
3122
3123 @item globexthdr.name=@var{string}
3124 This keyword allows user control over the name that is written into
3125 the ustar header blocks for global extended header records. The name
3126 shall will be obtained from the contents of @var{string}, after the
3127 following character substitutions have been made:
3128
3129 @multitable @columnfractions .30 .70
3130 @item Meta-character @tab Replaced By
3131 @item %n @tab An integer that represents the
3132 sequence number of the global extended header record in the archive,
3133 starting at 1.
3134 @item %p @tab The process ID of the @command{tar} process.
3135 @item %% @tab A @samp{%} character.
3136 @end multitable
3137
3138 Any other @samp{%} characters in string produce undefined results.
3139
3140 If no option @samp{globexthdr.name=string} is specified, @command{tar}
3141 will use the following default value:
3142
3143 @smallexample
3144 $TMPDIR/GlobalHead.%p.%n
3145 @end smallexample
3146
3147 @noindent
3148 where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
3149 environment variable. If @var{TMPDIR} is not set, @command{tar}
3150 uses @samp{/tmp}.
3151
3152 @item @var{keyword}=@var{value}
3153 When used with one of archive-creation commands, these keyword/value pairs
3154 will be included at the beginning of the archive in a global extended
3155 header record. When used with one of archive-reading commands,
3156 @command{tar} will behave as if it has encountered these keyword/value
3157 pairs at the beginning of the archive in a global extended header
3158 record.
3159
3160 @item @var{keyword}:=@var{value}
3161 When used with one of archive-creation commands, these keyword/value pairs
3162 will be included as records at the beginning of an extended header for
3163 each file. This is effectively equivalent to @var{keyword}=@var{value}
3164 form except that it creates no global extended header records.
3165
3166 When used with one of archive-reading commands, @command{tar} will
3167 behave as if these keyword/value pairs were included as records at the
3168 end of each extended header; thus, they will override any global or
3169 file-specific extended header record keywords of the same names.
3170 For example, in the command:
3171
3172 @smallexample
3173 tar --format=posix --create \
3174 --file archive --pax-option gname:=user .
3175 @end smallexample
3176
3177 the group name will be forced to a new value for all files
3178 stored in the archive.
3179 @end table
3180
3181 @item --portability
3182 @itemx --old-archive
3183 Synonym for @option{--format=v7}.
3184
3185 @item --posix
3186 Same as @option{--format=posix}.
3187
3188 @item --preserve
3189
3190 Synonymous with specifying both @samp{--preserve-permissions} and
3191 @samp{--same-order}. @FIXME-xref{}
3192
3193 @item --preserve-order
3194
3195 (See @samp{--same-order}; @pxref{Reading}.)
3196
3197 @item --preserve-permissions
3198 @itemx --same-permissions
3199 @itemx -p
3200
3201 When @command{tar} is extracting an archive, it normally subtracts the
3202 users' umask from the permissions specified in the archive and uses
3203 that number as the permissions to create the destination file.
3204 Specifying this option instructs @command{tar} that it should use the
3205 permissions directly from the archive. @xref{Writing}.
3206
3207 @item --read-full-records
3208 @itemx -B
3209
3210 Specifies that @command{tar} should reblock its input, for reading
3211 from pipes on systems with buggy implementations. @xref{Reading}.
3212
3213 @item --record-size=@var{size}
3214
3215 Instructs @command{tar} to use @var{size} bytes per record when accessing the
3216 archive. @FIXME-xref{}
3217
3218 @item --recursion
3219
3220 With this option, @command{tar} recurses into directories.
3221 @FIXME-xref{}
3222
3223 @item --recursive-unlink
3224
3225 Remove existing
3226 directory hierarchies before extracting directories of the same name
3227 from the archive. @xref{Writing}.
3228
3229 @item --remove-files
3230
3231 Directs @command{tar} to remove the source file from the file system after
3232 appending it to an archive. @FIXME-xref{}
3233
3234 @item --rmt-command=@var{cmd}
3235
3236 Notifies @command{tar} that it should use @var{cmd} instead of
3237 the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
3238
3239 @item --rsh-command=@var{cmd}
3240
3241 Notifies @command{tar} that is should use @var{cmd} to communicate with remote
3242 devices. @FIXME-xref{}
3243
3244 @item --same-order
3245 @itemx --preserve-order
3246 @itemx -s
3247
3248 This option is an optimization for @command{tar} when running on machines with
3249 small amounts of memory. It informs @command{tar} that the list of file
3250 arguments has already been sorted to match the order of files in the
3251 archive. @xref{Reading}.
3252
3253 @item --same-owner
3254
3255 When extracting an archive, @command{tar} will attempt to preserve the owner
3256 specified in the @command{tar} archive with this option present.
3257 This is the default behavior for the superuser; this option has an
3258 effect only for ordinary users. @FIXME-xref{}
3259
3260 @item --same-permissions
3261
3262 (See @samp{--preserve-permissions}; @pxref{Writing}.)
3263
3264 @item --show-defaults
3265
3266 Displays the default options used by @command{tar} and exits
3267 successfully. This option is intended for use in shell scripts.
3268 Here is an example of what you can see using this option:
3269
3270 @smallexample
3271 $ tar --show-defaults
3272 --format=gnu -f- -b20
3273 @end smallexample
3274
3275 @item --show-omitted-dirs
3276
3277 Instructs @command{tar} to mention directories its skipping over when
3278 operating on a @command{tar} archive. @FIXME-xref{}
3279
3280 @item --sparse
3281 @itemx -S
3282
3283 Invokes a @acronym{GNU} extension when adding files to an archive that handles
3284 sparse files efficiently. @FIXME-xref{}
3285
3286 @item --starting-file=@var{name}
3287 @itemx -K @var{name}
3288
3289 This option affects extraction only; @command{tar} will skip extracting
3290 files in the archive until it finds one that matches @var{name}.
3291 @xref{Scarce}.
3292
3293 @item --strip-components=@var{number}
3294 Strip given @var{number} of leading components from file names before
3295 extraction.@footnote{This option was called @option{--strip-path} in
3296 version 1.14.} For example, if archive @file{archive.tar} contained
3297 @file{/some/file/name}, then running
3298
3299 @smallexample
3300 tar --extract --file archive.tar --strip-components=2
3301 @end smallexample
3302
3303 @noindent
3304 would extracted this file to file @file{name}.
3305
3306 @item --suffix=@var{suffix}
3307
3308 Alters the suffix @command{tar} uses when backing up files from the default
3309 @samp{~}. @FIXME-xref{}
3310
3311 @item --tape-length=@var{num}
3312 @itemx -L @var{num}
3313
3314 Specifies the length of tapes that @command{tar} is writing as being
3315 @w{@var{num} x 1024} bytes long. @FIXME-xref{}
3316
3317 @item --to-stdout
3318 @itemx -O
3319
3320 During extraction, @command{tar} will extract files to stdout rather
3321 than to the file system. @xref{Writing}.
3322
3323 @item --totals
3324
3325 Displays the total number of bytes written after creating an archive.
3326 @FIXME-xref{}
3327
3328 @item --touch
3329 @itemx -m
3330
3331 Sets the modification time of extracted files to the extraction time,
3332 rather than the modification time stored in the archive.
3333 @xref{Writing}.
3334
3335 @item --uncompress
3336
3337 (See @samp{--compress}.) @FIXME-pxref{}
3338
3339 @item --ungzip
3340
3341 (See @samp{--gzip}.) @FIXME-pxref{}
3342
3343 @item --unlink-first
3344 @itemx -U
3345
3346 Directs @command{tar} to remove the corresponding file from the file
3347 system before extracting it from the archive. @xref{Writing}.
3348
3349 @item --use-compress-program=@var{prog}
3350
3351 Instructs @command{tar} to access the archive through @var{prog}, which is
3352 presumed to be a compression program of some sort. @FIXME-xref{}
3353
3354 @item --utc
3355
3356 Display file modification dates in @acronym{UTC}. This option implies
3357 @samp{--verbose}.
3358
3359 @item --verbose
3360 @itemx -v
3361
3362 Specifies that @command{tar} should be more verbose about the operations its
3363 performing. This option can be specified multiple times for some
3364 operations to increase the amount of information displayed. @FIXME-xref{}
3365
3366 @item --verify
3367 @itemx -W
3368
3369 Verifies that the archive was correctly written when creating an
3370 archive. @FIXME-xref{}
3371
3372 @item --version
3373
3374 @command{tar} will print an informational message about what version
3375 it is and a copyright message, some credits, and then exit.
3376 @FIXME-xref{}
3377
3378 @item --volno-file=@var{file}
3379
3380 Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
3381 of which volume of a multi-volume archive its working in @var{file}.
3382 @FIXME-xref{}
3383
3384 @item --wildcards
3385 Use wildcards when excluding files.
3386 @FIXME-xref{}
3387
3388 @item --wildcards-match-slash
3389 Wildcards match @samp{/} when excluding files.
3390 @FIXME-xref{}
3391 @end table
3392
3393 @node Short Option Summary
3394 @subsection Short Options Cross Reference
3395
3396 Here is an alphabetized list of all of the short option forms, matching
3397 them with the equivalent long option.
3398
3399 @table @kbd
3400
3401 @item -A
3402
3403 @samp{--concatenate}
3404
3405 @item -B
3406
3407 @samp{--read-full-records}
3408
3409 @item -C
3410
3411 @samp{--directory}
3412
3413 @item -F
3414
3415 @samp{--info-script}
3416
3417 @item -G
3418
3419 @samp{--incremental}
3420
3421 @item -K
3422
3423 @samp{--starting-file}
3424
3425 @item -L
3426
3427 @samp{--tape-length}
3428
3429 @item -M
3430
3431 @samp{--multi-volume}
3432
3433 @item -N
3434
3435 @samp{--newer}
3436
3437 @item -O
3438
3439 @samp{--to-stdout}
3440
3441 @item -P
3442
3443 @samp{--absolute-names}
3444
3445 @item -R
3446
3447 @samp{--block-number}
3448
3449 @item -S
3450
3451 @samp{--sparse}
3452
3453 @item -T
3454
3455 @samp{--files-from}
3456
3457 @item -U
3458
3459 @samp{--unlink-first}
3460
3461 @item -V
3462
3463 @samp{--label}
3464
3465 @item -W
3466
3467 @samp{--verify}
3468
3469 @item -X
3470
3471 @samp{--exclude-from}
3472
3473 @item -Z
3474
3475 @samp{--compress}
3476
3477 @item -b
3478
3479 @samp{--blocking-factor}
3480
3481 @item -c
3482
3483 @samp{--create}
3484
3485 @item -d
3486
3487 @samp{--compare}
3488
3489 @item -f
3490
3491 @samp{--file}
3492
3493 @item -g
3494
3495 @samp{--listed-incremental}
3496
3497 @item -h
3498
3499 @samp{--dereference}
3500
3501 @item -i
3502
3503 @samp{--ignore-zeros}
3504
3505 @item -j
3506
3507 @samp{--bzip2}
3508
3509 @item -k
3510
3511 @samp{--keep-old-files}
3512
3513 @item -l
3514
3515 @samp{--one-file-system}. Use of this short option is deprecated. It
3516 is retained for compatibility with the earlier versions of GNU
3517 @command{tar}, and will be changed in future releases.
3518
3519 @xref{Current status}, for more information.
3520
3521 @item -m
3522
3523 @samp{--touch}
3524
3525 @item -o
3526
3527 When creating --- @samp{--no-same-owner}, when extracting ---
3528 @samp{--portability}.
3529
3530 The later usage is deprecated. It is retained for compatibility with
3531 the earlier versions of @GNUTAR{}. In the future releases
3532 @option{-o} will be equivalent to @samp{--no-same-owner} only.
3533
3534 @item -p
3535
3536 @samp{--preserve-permissions}
3537
3538 @item -r
3539
3540 @samp{--append}
3541
3542 @item -s
3543
3544 @samp{--same-order}
3545
3546 @item -t
3547
3548 @samp{--list}
3549
3550 @item -u
3551
3552 @samp{--update}
3553
3554 @item -v
3555
3556 @samp{--verbose}
3557
3558 @item -w
3559
3560 @samp{--interactive}
3561
3562 @item -x
3563
3564 @samp{--extract}
3565
3566 @item -z
3567
3568 @samp{--gzip}
3569
3570 @end table
3571
3572 @node help
3573 @section @GNUTAR{} documentation
3574
3575 Being careful, the first thing is really checking that you are using
3576 @GNUTAR{}, indeed. The @value{op-version} option
3577 will generate a message giving confirmation that you are using
3578 @GNUTAR{}, with the precise version of @GNUTAR{}
3579 you are using. @command{tar} identifies itself and
3580 prints the version number to the standard output, then immediately
3581 exits successfully, without doing anything else, ignoring all other
3582 options. For example, @w{@samp{tar --version}} might return:
3583
3584 @smallexample
3585 tar (@acronym{GNU} tar) @value{VERSION}
3586 @end smallexample
3587
3588 @noindent
3589 The first occurrence of @samp{tar} in the result above is the program
3590 name in the package (for example, @command{rmt} is another program),
3591 while the second occurrence of @samp{tar} is the name of the package
3592 itself, containing possibly many programs. The package is currently
3593 named @samp{tar}, after the name of the main program it
3594 contains@footnote{There are plans to merge the @command{cpio} and
3595 @command{tar} packages into a single one which would be called
3596 @code{paxutils}. So, who knows if, one of this days, the
3597 @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
3598 paxutils) 3.2}}}.
3599
3600 Another thing you might want to do is checking the spelling or meaning
3601 of some particular @command{tar} option, without resorting to this
3602 manual, for once you have carefully read it. @GNUTAR{}
3603 has a short help feature, triggerable through the
3604 @value{op-help} option. By using this option, @command{tar} will
3605 print a usage message listing all available options on standard
3606 output, then exit successfully, without doing anything else and
3607 ignoring all other options. Even if this is only a brief summary, it
3608 may be several screens long. So, if you are not using some kind of
3609 scrollable window, you might prefer to use something like:
3610
3611 @smallexample
3612 $ @kbd{tar --help | less}
3613 @end smallexample
3614
3615 @noindent
3616 presuming, here, that you like using @command{less} for a pager. Other
3617 popular pagers are @command{more} and @command{pg}. If you know about some
3618 @var{keyword} which interests you and do not want to read all the
3619 @value{op-help} output, another common idiom is doing:
3620
3621 @smallexample
3622 tar --help | grep @var{keyword}
3623 @end smallexample
3624
3625 @noindent
3626 for getting only the pertinent lines.
3627
3628 The perceptive reader would have noticed some contradiction in the
3629 previous paragraphs. It is written that both @value{op-version} and
3630 @value{op-help} print something, and have all other options ignored. In
3631 fact, they cannot ignore each other, and one of them has to win. We do
3632 not specify which is stronger, here; experiment if you really wonder!
3633
3634 The short help output is quite succinct, and you might have to get
3635 back to the full documentation for precise points. If you are reading
3636 this paragraph, you already have the @command{tar} manual in some
3637 form. This manual is available in printed form, as a kind of small
3638 book. It may printed out of the @GNUTAR{}
3639 distribution, provided you have @TeX{} already installed somewhere,
3640 and a laser printer around. Just configure the distribution, execute
3641 the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
3642 usual way (contact your local guru to know how). If @GNUTAR{}
3643 has been conveniently installed at your place, this
3644 manual is also available in interactive, hypertextual form as an Info
3645 file. Just call @w{@samp{info tar}} or, if you do not have the
3646 @command{info} program handy, use the Info reader provided within
3647 @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
3648
3649 There is currently no @code{man} page for @GNUTAR{}.
3650 If you observe such a @code{man} page on the system you are running,
3651 either it does not long to @GNUTAR{}, or it has not
3652 been produced by @acronym{GNU}. Currently, @GNUTAR{}
3653 documentation is provided in Texinfo format only, if we
3654 except, of course, the short result of @kbd{tar --help}.
3655
3656 @node verbose
3657 @section Checking @command{tar} progress
3658
3659 @cindex Progress information
3660 @cindex Status information
3661 @cindex Information on progress and status of operations
3662 @cindex Verbose operation
3663 @cindex Block number where error occurred
3664 @cindex Error message, block number of
3665 @cindex Version of the @command{tar} program
3666
3667 @cindex Getting more information during the operation
3668 @cindex Information during operation
3669 @cindex Feedback from @command{tar}
3670
3671 Typically, @command{tar} performs most operations without reporting any
3672 information to the user except error messages. When using @command{tar}
3673 with many options, particularly ones with complicated or
3674 difficult-to-predict behavior, it is possible to make serious mistakes.
3675 @command{tar} provides several options that make observing @command{tar}
3676 easier. These options cause @command{tar} to print information as it
3677 progresses in its job, and you might want to use them just for being
3678 more careful about what is going on, or merely for entertaining
3679 yourself. If you have encountered a problem when operating on an
3680 archive, however, you may need more information than just an error
3681 message in order to solve the problem. The following options can be
3682 helpful diagnostic tools.
3683
3684 Normally, the @value{op-list} command to list an archive prints just
3685 the file names (one per line) and the other commands are silent.
3686 When used with most operations, the @value{op-verbose} option causes
3687 @command{tar} to print the name of each file or archive member as it
3688 is processed. This and the other options which make @command{tar} print
3689 status information can be useful in monitoring @command{tar}.
3690
3691 With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
3692 just prints the names of the files or members as they are processed.
3693 Using it twice causes @command{tar} to print a longer listing (reminiscent
3694 of @samp{ls -l}) for each member. Since @value{op-list} already prints
3695 the names of the members, @value{op-verbose} used once with @value{op-list}
3696 causes @command{tar} to print an @samp{ls -l} type listing of the files
3697 in the archive. The following examples both extract members with
3698 long list output:
3699
3700 @smallexample
3701 $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
3702 $ @kbd{tar xvvf archive.tar}
3703 @end smallexample
3704
3705 Verbose output appears on the standard output except when an archive is
3706 being written to the standard output, as with @samp{tar --create
3707 --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
3708 installer let standard output be the default archive). In that case
3709 @command{tar} writes verbose output to the standard error stream.
3710
3711 If @option{--index-file=@var{file}} is specified, @command{tar} sends
3712 verbose output to @var{file} rather than to standard output or standard
3713 error.
3714
3715 The @value{op-totals} option---which is only meaningful when used with
3716 @value{op-create}---causes @command{tar} to print the total
3717 amount written to the archive, after it has been fully created.
3718
3719 The @value{op-checkpoint} option prints an occasional message
3720 as @command{tar} reads or writes the archive. In fact, it prints
3721 a message each 10 records read or written. It is designed for
3722 those who don't need the more detailed (and voluminous) output of
3723 @value{op-block-number}, but do want visual confirmation that @command{tar}
3724 is actually making forward progress.
3725
3726 @FIXME{There is some confusion here. It seems that -R once wrote a
3727 message at @samp{every} record read or written.}
3728
3729 The @value{op-show-omitted-dirs} option, when reading an archive---with
3730 @value{op-list} or @value{op-extract}, for example---causes a message
3731 to be printed for each directory in the archive which is skipped.
3732 This happens regardless of the reason for skipping: the directory might
3733 not have been named on the command line (implicitly or explicitly),
3734 it might be excluded by the use of the @value{op-exclude} option, or
3735 some other reason.
3736
3737 If @value{op-block-number} is used, @command{tar} prints, along with
3738 every message it would normally produce, the block number within the
3739 archive where the message was triggered. Also, supplementary messages
3740 are triggered when reading blocks full of NULs, or when hitting end of
3741 file on the archive. As of now, if the archive if properly terminated
3742 with a NUL block, the reading of the file may stop before end of file
3743 is met, so the position of end of file will not usually show when
3744 @value{op-block-number} is used. Note that @GNUTAR{}
3745 drains the archive before exiting when reading the
3746 archive from a pipe.
3747
3748 This option is especially useful when reading damaged archives, since
3749 it helps pinpoint the damaged sections. It can also be used with
3750 @value{op-list} when listing a file-system backup tape, allowing you to
3751 choose among several backup tapes when retrieving a file later, in
3752 favor of the tape where the file appears earliest (closest to the
3753 front of the tape). @FIXME-xref{when the node name is set and the
3754 backup section written.}
3755
3756 @node interactive
3757 @section Asking for Confirmation During Operations
3758 @cindex Interactive operation
3759
3760 Typically, @command{tar} carries out a command without stopping for
3761 further instructions. In some situations however, you may want to
3762 exclude some files and archive members from the operation (for instance
3763 if disk or storage space is tight). You can do this by excluding
3764 certain files automatically (@pxref{Choosing}), or by performing
3765 an operation interactively, using the @value{op-interactive} option.
3766 @command{tar} also accepts @samp{--confirmation} for this option.
3767
3768 When the @value{op-interactive} option is specified, before
3769 reading, writing, or deleting files, @command{tar} first prints a message
3770 for each such file, telling what operation it intends to take, then asks
3771 for confirmation on the terminal. The actions which require
3772 confirmation include adding a file to the archive, extracting a file
3773 from the archive, deleting a file from the archive, and deleting a file
3774 from disk. To confirm the action, you must type a line of input
3775 beginning with @samp{y}. If your input line begins with anything other
3776 than @samp{y}, @command{tar} skips that file.
3777
3778 If @command{tar} is reading the archive from the standard input,
3779 @command{tar} opens the file @file{/dev/tty} to support the interactive
3780 communications.
3781
3782 Verbose output is normally sent to standard output, separate from
3783 other error messages. However, if the archive is produced directly
3784 on standard output, then verbose output is mixed with errors on
3785 @code{stderr}. Producing the archive on standard output may be used
3786 as a way to avoid using disk space, when the archive is soon to be
3787 consumed by another process reading it, say. Some people felt the need
3788 of producing an archive on stdout, still willing to segregate between
3789 verbose output and error output. A possible approach would be using a
3790 named pipe to receive the archive, and having the consumer process to
3791 read from that named pipe. This has the advantage of letting standard
3792 output free to receive verbose output, all separate from errors.
3793
3794 @node operations
3795 @chapter @GNUTAR{} Operations
3796
3797 @menu
3798 * Basic tar::
3799 * Advanced tar::
3800 * create options::
3801 * extract options::
3802 * backup::
3803 * Applications::
3804 * looking ahead::
3805 @end menu
3806
3807 @node Basic tar
3808 @section Basic @GNUTAR{} Operations
3809
3810 The basic @command{tar} operations, @value{op-create}, @value{op-list} and
3811 @value{op-extract}, are currently presented and described in the tutorial
3812 chapter of this manual. This section provides some complementary notes
3813 for these operations.
3814
3815 @table @asis
3816 @item @value{op-create}
3817
3818 Creating an empty archive would have some kind of elegance. One can
3819 initialize an empty archive and later use @value{op-append} for adding
3820 all members. Some applications would not welcome making an exception
3821 in the way of adding the first archive member. On the other hand,
3822 many people reported that it is dangerously too easy for @command{tar}
3823 to destroy a magnetic tape with an empty archive@footnote{This is well
3824 described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
3825 Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
3826 common errors are:
3827
3828 @enumerate
3829 @item
3830 Mistakingly using @code{create} instead of @code{extract}, when the
3831 intent was to extract the full contents of an archive. This error
3832 is likely: keys @kbd{c} and @kbd{x} are right next to each other on
3833 the QWERTY keyboard. Instead of being unpacked, the archive then
3834 gets wholly destroyed. When users speak about @dfn{exploding} an
3835 archive, they usually mean something else :-).
3836
3837 @item
3838 Forgetting the argument to @code{file}, when the intent was to create
3839 an archive with a single file in it. This error is likely because a
3840 tired user can easily add the @kbd{f} key to the cluster of option
3841 letters, by the mere force of habit, without realizing the full
3842 consequence of doing so. The usual consequence is that the single
3843 file, which was meant to be saved, is rather destroyed.
3844 @end enumerate
3845
3846 So, recognizing the likelihood and the catastrophical nature of these
3847 errors, @GNUTAR{} now takes some distance from elegance, and
3848 cowardly refuses to create an archive when @value{op-create} option is
3849 given, there are no arguments besides options, and @value{op-files-from}
3850 option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
3851 and nevertheless create an archive with nothing in it,
3852 one may still use, as the value for the @value{op-files-from} option,
3853 a file with no names in it, as shown in the following commands:
3854
3855 @smallexample
3856 @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
3857 @kbd{tar cfT empty-archive.tar /dev/null}
3858 @end smallexample
3859
3860 @item @value{op-extract}
3861
3862 A socket is stored, within a @GNUTAR{} archive, as a pipe.
3863
3864 @item @value{op-list}
3865
3866 @GNUTAR{} now shows dates as @samp{1996-08-30},
3867 while it used to show them as @samp{Aug 30 1996}. (One can revert to
3868 the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
3869 before reinstalling.) But preferably, people should get used to ISO
3870 8601 dates. Local American dates should be made available again with
3871 full date localization support, once ready. In the meantime, programs
3872 not being localizable for dates should prefer international dates,
3873 that's really the way to go.
3874
3875 Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
3876 are curious, it contains a detailed explanation of the ISO 8601 standard.
3877
3878 @end table
3879
3880 @node Advanced tar
3881 @section Advanced @GNUTAR{} Operations
3882
3883 Now that you have learned the basics of using @GNUTAR{}, you may want
3884 to learn about further ways in which @command{tar} can help you.
3885
3886 This chapter presents five, more advanced operations which you probably
3887 won't use on a daily basis, but which serve more specialized functions.
3888 We also explain the different styles of options and why you might want
3889 to use one or another, or a combination of them in your @command{tar}
3890 commands. Additionally, this chapter includes options which allow you to
3891 define the output from @command{tar} more carefully, and provide help and
3892 error correction in special circumstances.
3893
3894 @FIXME{check this after the chapter is actually revised to make sure
3895 it still introduces the info in the chapter correctly : ).}
3896
3897 @menu
3898 * Operations::
3899 * append::
3900 * update::
3901 * concatenate::
3902 * delete::
3903 * compare::
3904 @end menu
3905
3906 @node Operations
3907 @subsection The Five Advanced @command{tar} Operations
3908 @UNREVISED
3909
3910 In the last chapter, you learned about the first three operations to
3911 @command{tar}. This chapter presents the remaining five operations to
3912 @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
3913 @samp{--delete}, and @samp{--compare}.
3914
3915 You are not likely to use these operations as frequently as those
3916 covered in the last chapter; however, since they perform specialized
3917 functions, they are quite useful when you do need to use them. We
3918 will give examples using the same directory and files that you created
3919 in the last chapter. As you may recall, the directory is called
3920 @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
3921 @samp{rock}, and the two archive files you created are
3922 @samp{collection.tar} and @samp{music.tar}.
3923
3924 We will also use the archive files @samp{afiles.tar} and
3925 @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
3926 @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
3927 @samp{./birds}, @samp{baboon}, and @samp{./box}.
3928
3929 Unless we state otherwise, all practicing you do and examples you follow
3930 in this chapter will take place in the @file{practice} directory that
3931 you created in the previous chapter; see @ref{prepare for examples}.
3932 (Below in this section, we will remind you of the state of the examples
3933 where the last chapter left them.)
3934
3935 The five operations that we will cover in this chapter are:
3936
3937 @table @kbd
3938 @item --append
3939 @itemx -r
3940 Add new entries to an archive that already exists.
3941 @item --update
3942 @itemx -r
3943 Add more recent copies of archive members to the end of an archive, if
3944 they exist.
3945 @item --concatenate
3946 @itemx --catenate
3947 @itemx -A
3948 Add one or more pre-existing archives to the end of another archive.
3949 @item --delete
3950 Delete items from an archive (does not work on tapes).
3951 @item --compare
3952 @itemx --diff
3953 @itemx -d
3954 Compare archive members to their counterparts in the file system.
3955 @end table
3956
3957 @node append
3958 @subsection How to Add Files to Existing Archives: @code{--append}
3959 @UNREVISED
3960
3961 If you want to add files to an existing archive, you don't need to
3962 create a new archive; you can use @value{op-append}. The archive must
3963 already exist in order to use @samp{--append}. (A related operation
3964 is the @samp{--update} operation; you can use this to add newer
3965 versions of archive members to an existing archive. To learn how to
3966 do this with @samp{--update}, @pxref{update}.)
3967
3968 If you use @value{op-append} to add a file that has the same name as an
3969 archive member to an archive containing that archive member, then the
3970 old member is not deleted. What does happen, however, is somewhat
3971 complex. @command{tar} @emph{allows} you to have infinite number of files
3972 with the same name. Some operations treat these same-named members no
3973 differently than any other set of archive members: for example, if you
3974 view an archive with @value{op-list}, you will see all of those members
3975 listed, with their modification times, owners, etc.
3976
3977 Other operations don't deal with these members as perfectly as you might
3978 prefer; if you were to use @value{op-extract} to extract the archive,
3979 only the most recently added copy of a member with the same name as four
3980 other members would end up in the working directory. This is because
3981 @samp{--extract} extracts an archive in the order the members appeared
3982 in the archive; the most recently archived members will be extracted
3983 last. Additionally, an extracted member will @emph{replace} a file of
3984 the same name which existed in the directory already, and @command{tar}
3985 will not prompt you about this@footnote{Unless you give it
3986 @option{--keep-old-files} option, or the disk copy is newer than the
3987 the one in the archive and you invoke @command{tar} with
3988 @option{--keep-newer-files} option}. Thus, only the most recently archived
3989 member will end up being extracted, as it will replace the one
3990 extracted before it, and so on.
3991
3992 There exists a special option that allows you to get around this
3993 behavior and extract (or list) only a particular copy of the file.
3994 This is @option{--occurrence} option. If you run @command{tar} with
3995 this option, it will extract only the first copy of the file. You
3996 may also give this option an argument specifying the number of
3997 copy to be extracted. Thus, for example if the archive
3998 @file{archive.tar} contained three copies of file @file{myfile}, then
3999 the command
4000
4001 @smallexample
4002 tar --extract --file archive.tar --occurrence=2 myfile
4003 @end smallexample
4004
4005 @noindent
4006 would extract only the second copy. @xref{Option Summary,---occurrence}, for the description of @value{op-occurrence} option.
4007
4008 @FIXME{ hag -- you might want to incorporate some of the above into the
4009 MMwtSN node; not sure. i didn't know how to make it simpler...
4010
4011 There are a few ways to get around this. (maybe xref Multiple Members
4012 with the Same Name.}
4013
4014 @cindex Members, replacing with other members
4015 @cindex Replacing members with other members
4016 If you want to replace an archive member, use @value{op-delete} to
4017 delete the member you want to remove from the archive, , and then use
4018 @samp{--append} to add the member you want to be in the archive. Note
4019 that you can not change the order of the archive; the most recently
4020 added member will still appear last. In this sense, you cannot truly
4021 ``replace'' one member with another. (Replacing one member with another
4022 will not work on certain types of media, such as tapes; see @ref{delete}
4023 and @ref{Media}, for more information.)
4024
4025 @menu
4026 * appending files:: Appending Files to an Archive
4027 * multiple::
4028 @end menu
4029
4030 @node appending files
4031 @subsubsection Appending Files to an Archive
4032 @UNREVISED
4033 @cindex Adding files to an Archive
4034 @cindex Appending files to an Archive
4035 @cindex Archives, Appending files to
4036
4037 The simplest way to add a file to an already existing archive is the
4038 @value{op-append} operation, which writes specified files into the
4039 archive whether or not they are already among the archived files.
4040 When you use @samp{--append}, you @emph{must} specify file name
4041 arguments, as there is no default. If you specify a file that already
4042 exists in the archive, another copy of the file will be added to the
4043 end of the archive. As with other operations, the member names of the
4044 newly added files will be exactly the same as their names given on the
4045 command line. The @value{op-verbose} option will print out the names
4046 of the files as they are written into the archive.
4047
4048 @samp{--append} cannot be performed on some tape drives, unfortunately,
4049 due to deficiencies in the formats those tape drives use. The archive
4050 must be a valid @command{tar} archive, or else the results of using this
4051 operation will be unpredictable. @xref{Media}.
4052
4053 To demonstrate using @samp{--append} to add a file to an archive,
4054 create a file called @file{rock} in the @file{practice} directory.
4055 Make sure you are in the @file{practice} directory. Then, run the
4056 following @command{tar} command to add @file{rock} to
4057 @file{collection.tar}:
4058
4059 @smallexample
4060 $ @kbd{tar --append --file=collection.tar rock}
4061 @end smallexample
4062
4063 @noindent
4064 If you now use the @value{op-list} operation, you will see that
4065 @file{rock} has been added to the archive:
4066
4067 @smallexample
4068 $ @kbd{tar --list --file=collection.tar}
4069 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
4070 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
4071 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
4072 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
4073 @end smallexample
4074
4075 @FIXME{in theory, dan will (soon) try to turn this node into what it's
4076 title claims it will become...}
4077
4078 @node multiple
4079 @subsubsection Multiple Files with the Same Name
4080
4081 You can use @value{op-append} to add copies of files which have been
4082 updated since the archive was created. (However, we do not recommend
4083 doing this since there is another @command{tar} option called
4084 @samp{--update}; @pxref{update} for more information. We describe this
4085 use of @samp{--append} here for the sake of completeness.) @FIXME{is
4086 this really a good idea, to give this whole description for something
4087 which i believe is basically a Stupid way of doing something? certain
4088 aspects of it show ways in which tar is more broken than i'd personally
4089 like to admit to, specifically the last sentence. On the other hand, i
4090 don't think it's a good idea to be saying that we explicitly don't
4091 recommend using something, but i can't see any better way to deal with
4092 the situation.}When you extract the archive, the older version will be
4093 effectively lost. This works because files are extracted from an
4094 archive in the order in which they were archived. Thus, when the
4095 archive is extracted, a file archived later in time will replace a
4096 file of the same name which was archived earlier, even though the older
4097 version of the file will remain in the archive unless you delete all
4098 versions of the file.
4099
4100 Supposing you change the file @file{blues} and then append the changed
4101 version to @file{collection.tar}. As you saw above, the original
4102 @file{blues} is in the archive @file{collection.tar}. If you change the
4103 file and append the new version of the file to the archive, there will
4104 be two copies in the archive. When you extract the archive, the older
4105 version of the file will be extracted first, and then replaced by the
4106 newer version when it is extracted.
4107
4108 You can append the new, changed copy of the file @file{blues} to the
4109 archive in this way:
4110
4111 @smallexample
4112 $ @kbd{tar --append --verbose --file=collection.tar blues}
4113 blues
4114 @end smallexample
4115
4116 @noindent
4117 Because you specified the @samp{--verbose} option, @command{tar} has
4118 printed the name of the file being appended as it was acted on. Now
4119 list the contents of the archive:
4120
4121 @smallexample
4122 $ @kbd{tar --list --verbose --file=collection.tar}
4123 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
4124 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
4125 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
4126 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
4127 -rw-rw-rw- me user 58 1996-10-24 18:30 blues
4128 @end smallexample
4129
4130 @noindent
4131 The newest version of @file{blues} is now at the end of the archive
4132 (note the different creation dates and file sizes). If you extract
4133 the archive, the older version of the file @file{blues} will be
4134 replaced by the newer version. You can confirm this by extracting
4135 the archive and running @samp{ls} on the directory.
4136
4137 If you wish to extract the first occurrence of the file @file{blues}
4138 from the archive, use @value{op-occurrence} option, as shown in
4139 the following example:
4140
4141 @smallexample
4142 $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
4143 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
4144 @end smallexample
4145
4146 @xref{Writing}, for more information on @value{op-extract} and
4147 @xref{Option Summary, --occurrence}, for the description of
4148 @value{op-occurrence} option.
4149
4150 @node update
4151 @subsection Updating an Archive
4152 @UNREVISED
4153 @cindex Updating an archive
4154
4155 In the previous section, you learned how to use @value{op-append} to add
4156 a file to an existing archive. A related operation is
4157 @value{op-update}. The @samp{--update} operation updates a @command{tar}
4158 archive by comparing the date of the specified archive members against
4159 the date of the file with the same name. If the file has been modified
4160 more recently than the archive member, then the newer version of the
4161 file is added to the archive (as with @value{op-append}).
4162
4163 Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
4164 The operation will fail.
4165
4166 @FIXME{other examples of media on which --update will fail? need to ask
4167 charles and/or mib/thomas/dave shevett..}
4168
4169 Both @samp{--update} and @samp{--append} work by adding to the end
4170 of the archive. When you extract a file from the archive, only the
4171 version stored last will wind up in the file system, unless you use
4172 the @value{op-backup} option. @FIXME-ref{Multiple Members with the
4173 Same Name}
4174
4175 @menu
4176 * how to update::
4177 @end menu
4178
4179 @node how to update
4180 @subsubsection How to Update an Archive Using @code{--update}
4181
4182 You must use file name arguments with the @value{op-update} operation.
4183 If you don't specify any files, @command{tar} won't act on any files and
4184 won't tell you that it didn't do anything (which may end up confusing
4185 you).
4186
4187 @FIXME{note: the above parenthetical added because in fact, this
4188 behavior just confused the author. :-) }
4189
4190 To see the @samp{--update} option at work, create a new file,
4191 @file{classical}, in your practice directory, and some extra text to the
4192 file @file{blues}, using any text editor. Then invoke @command{tar} with
4193 the @samp{update} operation and the @value{op-verbose} option specified,
4194 using the names of all the files in the practice directory as file name
4195 arguments:
4196
4197 @smallexample
4198 $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
4199 blues
4200 classical
4201 $
4202 @end smallexample
4203
4204 @noindent
4205 Because we have specified verbose mode, @command{tar} prints out the names
4206 of the files it is working on, which in this case are the names of the
4207 files that needed to be updated. If you run @samp{tar --list} and look
4208 at the archive, you will see @file{blues} and @file{classical} at its
4209 end. There will be a total of two versions of the member @samp{blues};
4210 the one at the end will be newer and larger, since you added text before
4211 updating it.
4212
4213 (The reason @command{tar} does not overwrite the older file when updating
4214 it is because writing to the middle of a section of tape is a difficult
4215 process. Tapes are not designed to go backward. @xref{Media}, for more
4216 information about tapes.
4217
4218 @value{op-update} is not suitable for performing backups for two
4219 reasons: it does not change directory content entries, and it
4220 lengthens the archive every time it is used. The @GNUTAR{}
4221 options intended specifically for backups are more
4222 efficient. If you need to run backups, please consult @ref{Backups}.
4223
4224 @node concatenate
4225 @subsection Combining Archives with @code{--concatenate}
4226
4227 @cindex Adding archives to an archive
4228 @cindex Concatenating Archives
4229 Sometimes it may be convenient to add a second archive onto the end of
4230 an archive rather than adding individual files to the archive. To add
4231 one or more archives to the end of another archive, you should use the
4232 @value{op-concatenate} operation.
4233
4234 To use @samp{--concatenate}, name the archives to be concatenated on the
4235 command line. (Nothing happens if you don't list any.) The members,
4236 and their member names, will be copied verbatim from those archives. If
4237 this causes multiple members to have the same name, it does not delete
4238 any members; all the members with the same name coexist. @FIXME-ref{For
4239 information on how this affects reading the archive, Multiple
4240 Members with the Same Name.}
4241
4242 To demonstrate how @samp{--concatenate} works, create two small archives
4243 called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
4244 files from @file{practice}:
4245
4246 @smallexample
4247 $ @kbd{tar -cvf bluesrock.tar blues rock}
4248 blues
4249 classical
4250 $ @kbd{tar -cvf folkjazz.tar folk jazz}
4251 folk
4252 jazz
4253 @end smallexample
4254
4255 @noindent
4256 If you like, You can run @samp{tar --list} to make sure the archives
4257 contain what they are supposed to:
4258
4259 @smallexample
4260 $ @kbd{tar -tvf bluesrock.tar}
4261 -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
4262 -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
4263 $ @kbd{tar -tvf folkjazz.tar}
4264 -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
4265 -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
4266 @end smallexample
4267
4268 We can concatenate these two archives with @command{tar}:
4269
4270 @smallexample
4271 $ @kbd{cd ..}
4272 $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
4273 @end smallexample
4274
4275 If you now list the contents of the @file{bluesclass.tar}, you will see
4276 that now it also contains the archive members of @file{jazzfolk.tar}:
4277
4278 @smallexample
4279 $ @kbd{tar --list --file=bluesrock.tar}
4280 blues
4281 rock
4282 jazz
4283 folk
4284 @end smallexample
4285
4286 When you use @samp{--concatenate}, the source and target archives must
4287 already exist and must have been created using compatible format
4288 parameters. @FIXME-pxref{Matching Format Parameters}The new,
4289 concatenated archive will be called by the same name as the first
4290 archive listed on the command line. @FIXME{is there a way to specify a
4291 new name?}
4292
4293 Like @value{op-append}, this operation cannot be performed on some
4294 tape drives, due to deficiencies in the formats those tape drives use.
4295
4296 @cindex @code{concatenate} vs @command{cat}
4297 @cindex @command{cat} vs @code{concatenate}
4298 It may seem more intuitive to you to want or try to use @command{cat} to
4299 concatenate two archives instead of using the @samp{--concatenate}
4300 operation; after all, @command{cat} is the utility for combining files.
4301
4302 However, @command{tar} archives incorporate an end-of-file marker which
4303 must be removed if the concatenated archives are to be read properly as
4304 one archive. @samp{--concatenate} removes the end-of-archive marker
4305 from the target archive before each new archive is appended. If you use
4306 @command{cat} to combine the archives, the result will not be a valid
4307 @command{tar} format archive. If you need to retrieve files from an
4308 archive that was added to using the @command{cat} utility, use the
4309 @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
4310 information on dealing with archives improperly combined using the
4311 @command{cat} shell utility.
4312
4313 @FIXME{this shouldn't go here. where should it go?} You must specify
4314 the source archives using @value{op-file} (@value{pxref-file}). If you
4315 do not specify the target archive, @command{tar} uses the value of the
4316 environment variable @env{TAPE}, or, if this has not been set, the
4317 default archive name.
4318
4319 @node delete
4320 @subsection Removing Archive Members Using @samp{--delete}
4321 @UNREVISED
4322 @cindex Deleting files from an archive
4323 @cindex Removing files from an archive
4324
4325 You can remove members from an archive by using the @value{op-delete}
4326 option. Specify the name of the archive with @value{op-file} and then
4327 specify the names of the members to be deleted; if you list no member
4328 names, nothing will be deleted. The @value{op-verbose} option will
4329 cause @command{tar} to print the names of the members as they are deleted.
4330 As with @value{op-extract}, you must give the exact member names when
4331 using @samp{tar --delete}. @samp{--delete} will remove all versions of
4332 the named file from the archive. The @samp{--delete} operation can run
4333 very slowly.
4334
4335 Unlike other operations, @samp{--delete} has no short form.
4336
4337 @cindex Tapes, using @code{--delete} and
4338 @cindex Deleting from tape archives
4339 This operation will rewrite the archive. You can only use
4340 @samp{--delete} on an archive if the archive device allows you to
4341 write to any point on the media, such as a disk; because of this, it
4342 does not work on magnetic tapes. Do not try to delete an archive member
4343 from a magnetic tape; the action will not succeed, and you will be
4344 likely to scramble the archive and damage your tape. There is no safe
4345 way (except by completely re-writing the archive) to delete files from
4346 most kinds of magnetic tape. @xref{Media}.
4347
4348 To delete all versions of the file @file{blues} from the archive
4349 @file{collection.tar} in the @file{practice} directory, make sure you
4350 are in that directory, and then,
4351
4352 @smallexample
4353 $ @kbd{tar --list --file=collection.tar}
4354 blues
4355 folk
4356 jazz
4357 rock
4358 practice/blues
4359 practice/folk
4360 practice/jazz
4361 practice/rock
4362 practice/blues
4363 $ @kbd{tar --delete --file=collection.tar blues}
4364 $ @kbd{tar --list --file=collection.tar}
4365 folk
4366 jazz
4367 rock
4368 $
4369 @end smallexample
4370
4371 @FIXME{I changed the order of these nodes around and haven't had a chance
4372 to fix the above example's results, yet. I have to play with this and
4373 follow it and see what it actually does!}
4374
4375 The @value{op-delete} option has been reported to work properly when
4376 @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
4377
4378 @node compare
4379 @subsection Comparing Archive Members with the File System
4380 @cindex Verifying the currency of an archive
4381 @UNREVISED
4382
4383 The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
4384 specified archive members against files with the same names, and then
4385 reports differences in file size, mode, owner, modification date and
4386 contents. You should @emph{only} specify archive member names, not file
4387 names. If you do not name any members, then @command{tar} will compare the
4388 entire archive. If a file is represented in the archive but does not
4389 exist in the file system, @command{tar} reports a difference.
4390
4391 You have to specify the record size of the archive when modifying an
4392 archive with a non-default record size.
4393
4394 @command{tar} ignores files in the file system that do not have
4395 corresponding members in the archive.
4396
4397 The following example compares the archive members @file{rock},
4398 @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
4399 files of the same name in the file system. (Note that there is no file,
4400 @file{funk}; @command{tar} will report an error message.)
4401
4402 @smallexample
4403 $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
4404 rock
4405 blues
4406 tar: funk not found in archive
4407 @end smallexample
4408
4409 @noindent
4410 @FIXME{what does this actually depend on? i'm making a guess,
4411 here.}Depending on the system where you are running @command{tar} and the
4412 version you are running, @command{tar} may have a different error message,
4413 such as:
4414
4415 @smallexample
4416 funk: does not exist
4417 @end smallexample
4418
4419 @FIXME-xref{somewhere, for more information about format parameters.
4420 Melissa says: such as "format variations"? But why? Clearly I don't
4421 get it yet; I'll deal when I get to that section.}
4422
4423 The spirit behind the @value{op-compare} option is to check whether the
4424 archive represents the current state of files on disk, more than validating
4425 the integrity of the archive media. For this later goal, @xref{verify}.
4426
4427 @node create options
4428 @section Options Used by @code{--create}
4429
4430 The previous chapter described the basics of how to use
4431 @value{op-create} to create an archive from a set of files.
4432 @xref{create}. This section described advanced options to be used with
4433 @samp{--create}.
4434
4435 @menu
4436 * Ignore Failed Read::
4437 @end menu
4438
4439 @node Ignore Failed Read
4440 @subsection Ignore Fail Read
4441
4442 @table @kbd
4443 @item --ignore-failed-read
4444 Do not exit with nonzero on unreadable files or directories.
4445 @end table
4446
4447 @node extract options
4448 @section Options Used by @code{--extract}
4449 @UNREVISED
4450
4451 @FIXME{i need to get dan to go over these options with me and see if
4452 there's a better way of organizing them.}
4453
4454 The previous chapter showed how to use @value{op-extract} to extract
4455 an archive into the filesystem. Various options cause @command{tar} to
4456 extract more information than just file contents, such as the owner,
4457 the permissions, the modification date, and so forth. This section
4458 presents options to be used with @samp{--extract} when certain special
4459 considerations arise. You may review the information presented in
4460 @ref{extract} for more basic information about the
4461 @samp{--extract} operation.
4462
4463 @menu
4464 * Reading:: Options to Help Read Archives
4465 * Writing:: Changing How @command{tar} Writes Files
4466 * Scarce:: Coping with Scarce Resources
4467 @end menu
4468
4469 @node Reading
4470 @subsection Options to Help Read Archives
4471 @cindex Options when reading archives
4472 @cindex Reading incomplete records
4473 @cindex Records, incomplete
4474 @cindex End-of-archive entries, ignoring
4475 @cindex Ignoring end-of-archive entries
4476 @cindex Large lists of file names on small machines
4477 @cindex Small memory
4478 @cindex Running out of space
4479 @UNREVISED
4480
4481 Normally, @command{tar} will request data in full record increments from
4482 an archive storage device. If the device cannot return a full record,
4483 @command{tar} will report an error. However, some devices do not always
4484 return full records, or do not require the last record of an archive to
4485 be padded out to the next record boundary. To keep reading until you
4486 obtain a full record, or to accept an incomplete record if it contains
4487 an end-of-archive marker, specify the @value{op-read-full-records} option
4488 in conjunction with the @value{op-extract} or @value{op-list} operations.
4489 @value{xref-read-full-records}.
4490
4491 The @value{op-read-full-records} option is turned on by default when
4492 @command{tar} reads an archive from standard input, or from a remote
4493 machine. This is because on BSD Unix systems, attempting to read a
4494 pipe returns however much happens to be in the pipe, even if it is
4495 less than was requested. If this option were not enabled, @command{tar}
4496 would fail as soon as it read an incomplete record from the pipe.
4497
4498 If you're not sure of the blocking factor of an archive, you can
4499 read the archive by specifying @value{op-read-full-records} and
4500 @value{op-blocking-factor}, using a blocking factor larger than what the
4501 archive uses. This lets you avoid having to determine the blocking factor
4502 of an archive. @value{xref-blocking-factor}.
4503
4504 @menu
4505 * read full records::
4506 * Ignore Zeros::
4507 @end menu
4508
4509 @node read full records
4510 @unnumberedsubsubsec Reading Full Records
4511
4512 @FIXME{need sentence or so of intro here}
4513
4514 @table @kbd
4515 @item --read-full-records
4516 @item -B
4517 Use in conjunction with @value{op-extract} to read an archive which
4518 contains incomplete records, or one which has a blocking factor less
4519 than the one specified.
4520 @end table
4521
4522 @node Ignore Zeros
4523 @unnumberedsubsubsec Ignoring Blocks of Zeros
4524
4525 Normally, @command{tar} stops reading when it encounters a block of zeros
4526 between file entries (which usually indicates the end of the archive).
4527 @value{op-ignore-zeros} allows @command{tar} to completely read an archive
4528 which contains a block of zeros before the end (i.e.@: a damaged
4529 archive, or one which was created by concatenating several archives
4530 together).
4531
4532 The @value{op-ignore-zeros} option is turned off by default because many
4533 versions of @command{tar} write garbage after the end-of-archive entry,
4534 since that part of the media is never supposed to be read. @GNUTAR{}
4535 does not write after the end of an archive, but seeks to
4536 maintain compatiblity among archiving utilities.
4537
4538 @table @kbd
4539 @item --ignore-zeros
4540 @itemx -i
4541 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
4542 encountered while reading an archive. Use in conjunction with
4543 @value{op-extract} or @value{op-list}.
4544 @end table
4545
4546 @node Writing
4547 @subsection Changing How @command{tar} Writes Files
4548 @cindex Overwriting old files, prevention
4549 @cindex Protecting old files
4550 @cindex Modification times of extracted files
4551 @cindex Permissions of extracted files
4552 @cindex Modes of extracted files
4553 @cindex Writing extracted files to standard output
4554 @cindex Standard output, writing extracted files to
4555 @UNREVISED
4556
4557 @FIXME{need to mention the brand new option, --backup}
4558
4559 @menu
4560 * Dealing with Old Files::
4561 * Overwrite Old Files::
4562 * Keep Old Files::
4563 * Keep Newer Files::
4564 * Unlink First::
4565 * Recursive Unlink::
4566 * Modification Times::
4567 * Setting Access Permissions::
4568 * Writing to Standard Output::
4569 * remove files::
4570 @end menu
4571
4572 @node Dealing with Old Files
4573 @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
4574
4575 When extracting files, if @command{tar} discovers that the extracted
4576 file already exists, it normally replaces the file by removing it before
4577 extracting it, to prevent confusion in the presence of hard or symbolic
4578 links. (If the existing file is a symbolic link, it is removed, not
4579 followed.) However, if a directory cannot be removed because it is
4580 nonempty, @command{tar} normally overwrites its metadata (ownership,
4581 permission, etc.). The @option{--overwrite-dir} option enables this
4582 default behavior. To be more cautious and preserve the metadata of
4583 such a directory, use the @option{--no-overwrite-dir} option.
4584
4585 To be even more cautious and prevent existing files from being replaced, use
4586 the @value{op-keep-old-files} option. It causes @command{tar} to refuse
4587 to replace or update a file that already exists, i.e., a file with the
4588 same name as an archive member prevents extraction of that archive
4589 member. Instead, it reports an error.
4590
4591 To be more aggressive about altering existing files, use the
4592 @value{op-overwrite} option. It causes @command{tar} to overwrite
4593 existing files and to follow existing symbolic links when extracting.
4594
4595 Some people argue that @GNUTAR{} should not hesitate
4596 to overwrite files with other files when extracting. When extracting
4597 a @command{tar} archive, they expect to see a faithful copy of the
4598 state of the filesystem when the archive was created. It is debatable
4599 that this would always be a proper behavior. For example, suppose one
4600 has an archive in which @file{usr/local} is a link to
4601 @file{usr/local2}. Since then, maybe the site removed the link and
4602 renamed the whole hierarchy from @file{/usr/local2} to
4603 @file{/usr/local}. Such things happen all the time. I guess it would
4604 not be welcome at all that @GNUTAR{} removes the
4605 whole hierarchy just to make room for the link to be reinstated
4606 (unless it @emph{also} simultaneously restores the full
4607 @file{/usr/local2}, of course!) @GNUTAR{} is indeed
4608 able to remove a whole hierarchy to reestablish a symbolic link, for
4609 example, but @emph{only if} @value{op-recursive-unlink} is specified
4610 to allow this behavior. In any case, single files are silently
4611 removed.
4612
4613 Finally, the @value{op-unlink-first} option can improve performance in
4614 some cases by causing @command{tar} to remove files unconditionally
4615 before extracting them.
4616
4617 @node Overwrite Old Files
4618 @unnumberedsubsubsec Overwrite Old Files
4619
4620 @table @kbd
4621 @item --overwrite
4622 Overwrite existing files and directory metadata when extracting files
4623 from an archive.
4624
4625 This
4626 causes @command{tar} to write extracted files into the file system without
4627 regard to the files already on the system; i.e., files with the same
4628 names as archive members are overwritten when the archive is extracted.
4629 It also causes @command{tar} to extract the ownership, permissions,
4630 and time stamps onto any preexisting files or directories.
4631 If the name of a corresponding file name is a symbolic link, the file
4632 pointed to by the symbolic link will be overwritten instead of the
4633 symbolic link itself (if this is possible). Moreover, special devices,
4634 empty directories and even symbolic links are automatically removed if
4635 they are in the way of extraction.
4636
4637 Be careful when using the @value{op-overwrite} option, particularly when
4638 combined with the @value{op-absolute-names} option, as this combination
4639 can change the contents, ownership or permissions of any file on your
4640 system. Also, many systems do not take kindly to overwriting files that
4641 are currently being executed.
4642
4643 @item --overwrite-dir
4644 Overwrite the metadata of directories when extracting files from an
4645 archive, but remove other files before extracting.
4646 @end table
4647
4648 @node Keep Old Files
4649 @unnumberedsubsubsec Keep Old Files
4650
4651 @table @kbd
4652 @item --keep-old-files
4653 @itemx -k
4654 Do not replace existing files from archive. The
4655 @value{op-keep-old-files} option prevents @command{tar} from replacing
4656 existing files with files with the same name from the archive.
4657 The @value{op-keep-old-files} option is meaningless with @value{op-list}.
4658 Prevents @command{tar} from replacing files in the file system during
4659 extraction.
4660 @end table
4661
4662 @node Keep Newer Files
4663 @unnumberedsubsubsec Keep Newer Files
4664
4665 @table @kbd
4666 @item --keep-newer-files
4667 Do not replace existing files that are newer than their archive
4668 copies. This option is meaningless with @value{op-list}.
4669 @end table
4670
4671 @node Unlink First
4672 @unnumberedsubsubsec Unlink First
4673
4674 @table @kbd
4675 @item --unlink-first
4676 @itemx -U
4677 Remove files before extracting over them.
4678 This can make @command{tar} run a bit faster if you know in advance
4679 that the extracted files all need to be removed. Normally this option
4680 slows @command{tar} down slightly, so it is disabled by default.
4681 @end table
4682
4683 @node Recursive Unlink
4684 @unnumberedsubsubsec Recursive Unlink
4685
4686 @table @kbd
4687 @item --recursive-unlink
4688 When this option is specified, try removing files and directory hierarchies
4689 before extracting over them. @emph{This is a dangerous option!}
4690 @end table
4691
4692 If you specify the @value{op-recursive-unlink} option,
4693 @command{tar} removes @emph{anything} that keeps you from extracting a file
4694 as far as current permissions will allow it. This could include removal
4695 of the contents of a full directory hierarchy.
4696
4697 @node Modification Times
4698 @unnumberedsubsubsec Setting Modification Times
4699
4700 Normally, @command{tar} sets the modification times of extracted files to
4701 the modification times recorded for the files in the archive, but
4702 limits the permissions of extracted files by the current @code{umask}
4703 setting.
4704
4705 To set the modification times of extracted files to the time when
4706 the files were extracted, use the @value{op-touch} option in
4707 conjunction with @value{op-extract}.
4708
4709 @table @kbd
4710 @item --touch
4711 @itemx -m
4712 Sets the modification time of extracted archive members to the time
4713 they were extracted, not the time recorded for them in the archive.
4714 Use in conjunction with @value{op-extract}.
4715 @end table
4716
4717 @node Setting Access Permissions
4718 @unnumberedsubsubsec Setting Access Permissions
4719
4720 To set the modes (access permissions) of extracted files to those
4721 recorded for those files in the archive, use @samp{--same-permissions}
4722 in conjunction with the @value{op-extract} operation. @FIXME{Should be
4723 aliased to ignore-umask.}
4724
4725 @table @kbd
4726 @item --preserve-permission
4727 @itemx --same-permission
4728 @itemx --ignore-umask
4729 @itemx -p
4730 Set modes of extracted archive members to those recorded in the
4731 archive, instead of current umask settings. Use in conjunction with
4732 @value{op-extract}.
4733 @end table
4734
4735 @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
4736 files together, why is this useful. is it really useful with
4737 more than one file?}
4738
4739 @node Writing to Standard Output
4740 @unnumberedsubsubsec Writing to Standard Output
4741
4742 To write the extracted files to the standard output, instead of
4743 creating the files on the file system, use @value{op-to-stdout} in
4744 conjunction with @value{op-extract}. This option is useful if you are
4745 extracting files to send them through a pipe, and do not need to
4746 preserve them in the file system. If you extract multiple members,
4747 they appear on standard output concatenated, in the order they are
4748 found in the archive.
4749
4750 @table @kbd
4751 @item --to-stdout
4752 @itemx -O
4753 Writes files to the standard output. Used in conjunction with
4754 @value{op-extract}. Extract files to standard output. When this option
4755 is used, instead of creating the files specified, @command{tar} writes
4756 the contents of the files extracted to its standard output. This may
4757 be useful if you are only extracting the files in order to send them
4758 through a pipe. This option is meaningless with @value{op-list}.
4759 @end table
4760
4761 This can be useful, for example, if you have a tar archive containing
4762 a big file and don't want to store the file on disk before processing
4763 it. You can use a command like this:
4764
4765 @smallexample
4766 tar -xOzf foo.tgz bigfile | process
4767 @end smallexample
4768
4769 or even like this if you want to process the concatenation of the files:
4770
4771 @smallexample
4772 tar -xOzf foo.tgz bigfile1 bigfile2 | process
4773 @end smallexample
4774
4775 @node remove files
4776 @unnumberedsubsubsec Removing Files
4777
4778 @FIXME{the various macros in the front of the manual think that this
4779 option goes in this section. i have no idea; i only know it's nowhere
4780 else in the book...}
4781
4782 @table @kbd
4783 @item --remove-files
4784 Remove files after adding them to the archive.
4785 @end table
4786
4787 @node Scarce
4788 @subsection Coping with Scarce Resources
4789 @cindex Middle of the archive, starting in the
4790 @cindex Running out of space during extraction
4791 @cindex Disk space, running out of
4792 @cindex Space on the disk, recovering from lack of
4793 @UNREVISED
4794
4795 @menu
4796 * Starting File::
4797 * Same Order::
4798 @end menu
4799
4800 @node Starting File
4801 @unnumberedsubsubsec Starting File
4802
4803 @table @kbd
4804 @item --starting-file=@var{name}
4805 @itemx -K @var{name}
4806 Starts an operation in the middle of an archive. Use in conjunction
4807 with @value{op-extract} or @value{op-list}.
4808 @end table
4809
4810 If a previous attempt to extract files failed due to lack of disk
4811 space, you can use @value{op-starting-file} to start extracting only
4812 after member @var{name} of the archive. This assumes, of course, that
4813 there is now free space, or that you are now extracting into a
4814 different file system. (You could also choose to suspend @command{tar},
4815 remove unnecessary files from the file system, and then restart the
4816 same @command{tar} operation. In this case, @value{op-starting-file} is
4817 not necessary. @value{xref-incremental}, @value{xref-interactive},
4818 and @value{ref-exclude}.)
4819
4820 @node Same Order
4821 @unnumberedsubsubsec Same Order
4822
4823 @table @kbd
4824 @item --same-order
4825 @itemx --preserve-order
4826 @itemx -s
4827 To process large lists of file names on machines with small amounts of
4828 memory. Use in conjunction with @value{op-compare},
4829 @value{op-list}
4830 or @value{op-extract}.
4831 @end table
4832
4833 @FIXME{we don't need/want --preserve to exist any more (from melissa:
4834 ie, don't want that *version* of the option to exist, or don't want
4835 the option to exist in either version?}
4836
4837 @FIXME{i think this explanation is lacking.}
4838
4839 The @value{op-same-order} option tells @command{tar} that the list of file
4840 names to be listed or extracted is sorted in the same order as the
4841 files in the archive. This allows a large list of names to be used,
4842 even on a small machine that would not otherwise be able to hold all
4843 the names in memory at the same time. Such a sorted list can easily be
4844 created by running @samp{tar -t} on the archive and editing its output.
4845
4846 This option is probably never needed on modern computer systems.
4847
4848 @node backup
4849 @section Backup options
4850
4851 @cindex backup options
4852
4853 @GNUTAR{} offers options for making backups of files
4854 before writing new versions. These options control the details of
4855 these backups. They may apply to the archive itself before it is
4856 created or rewritten, as well as individual extracted members. Other
4857 @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
4858 and @command{mv}, for example) offer similar options.
4859
4860 Backup options may prove unexpectedly useful when extracting archives
4861 containing many members having identical name, or when extracting archives
4862 on systems having file name limitations, making different members appear
4863 has having similar names through the side-effect of name truncation.
4864 (This is true only if we have a good scheme for truncated backup names,
4865 which I'm not sure at all: I suspect work is needed in this area.)
4866 When any existing file is backed up before being overwritten by extraction,
4867 then clashing files are automatically be renamed to be unique, and the
4868 true name is kept for only the last file of a series of clashing files.
4869 By using verbose mode, users may track exactly what happens.
4870
4871 At the detail level, some decisions are still experimental, and may
4872 change in the future, we are waiting comments from our users. So, please
4873 do not learn to depend blindly on the details of the backup features.
4874 For example, currently, directories themselves are never renamed through
4875 using these options, so, extracting a file over a directory still has
4876 good chances to fail. Also, backup options apply to created archives,
4877 not only to extracted members. For created archives, backups will not
4878 be attempted when the archive is a block or character device, or when it
4879 refers to a remote file.
4880
4881 For the sake of simplicity and efficiency, backups are made by renaming old
4882 files prior to creation or extraction, and not by copying. The original
4883 name is restored if the file creation fails. If a failure occurs after a
4884 partial extraction of a file, both the backup and the partially extracted
4885 file are kept.
4886
4887 @table @samp
4888
4889 @item --backup[=@var{method}]
4890 @opindex --backup
4891 @vindex VERSION_CONTROL
4892 @cindex backups
4893 Back up files that are about to be overwritten or removed.
4894 Without this option, the original versions are destroyed.
4895
4896 Use @var{method} to determine the type of backups made.
4897 If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
4898 environment variable. And if @env{VERSION_CONTROL} is not set,
4899 use the @samp{existing} method.
4900
4901 @vindex version-control @r{Emacs variable}
4902 This option corresponds to the Emacs variable @samp{version-control};
4903 the same values for @var{method} are accepted as in Emacs. This option
4904 also allows more descriptive names. The valid @var{method}s are:
4905
4906 @table @samp
4907 @item t
4908 @itemx numbered
4909 @opindex numbered @r{backup method}
4910 Always make numbered backups.
4911
4912 @item nil
4913 @itemx existing
4914 @opindex existing @r{backup method}
4915 Make numbered backups of files that already have them, simple backups
4916 of the others.
4917
4918 @item never
4919 @itemx simple
4920 @opindex simple @r{backup method}
4921 Always make simple backups.
4922
4923 @end table
4924
4925 @item --suffix=@var{suffix}
4926 @opindex --suffix
4927 @cindex backup suffix
4928 @vindex SIMPLE_BACKUP_SUFFIX
4929 Append @var{suffix} to each backup file made with @samp{--backup}. If this
4930 option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
4931 environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
4932 set, the default is @samp{~}, just as in Emacs.
4933
4934 @end table
4935
4936 Some people express the desire to @emph{always} use the @value{op-backup}
4937 option, by defining some kind of alias or script. This is not as easy
4938 as one may think, due to the fact that old style options should appear first
4939 and consume arguments a bit unpredictably for an alias or script. But,
4940 if you are ready to give up using old style options, you may resort to
4941 using something like (a Bourne shell function here):
4942
4943 @smallexample
4944 tar () @{ /usr/local/bin/tar --backup $*; @}
4945 @end smallexample
4946
4947 @node Applications
4948 @section Notable @command{tar} Usages
4949 @UNREVISED
4950
4951 @FIXME{Using Unix file linking capability to recreate directory
4952 structures---linking files into one subdirectory and then
4953 @command{tar}ring that directory.}
4954
4955 @FIXME{Nice hairy example using absolute-names, newer, etc.}
4956
4957 @findex uuencode
4958 You can easily use archive files to transport a group of files from
4959 one system to another: put all relevant files into an archive on one
4960 computer system, transfer the archive to another system, and extract
4961 the contents there. The basic transfer medium might be magnetic tape,
4962 Internet FTP, or even electronic mail (though you must encode the
4963 archive with @command{uuencode} in order to transport it properly by
4964 mail). Both machines do not have to use the same operating system, as
4965 long as they both support the @command{tar} program.
4966
4967 For example, here is how you might copy a directory's contents from
4968 one disk to another, while preserving the dates, modes, owners and
4969 link-structure of all the files therein. In this case, the transfer
4970 medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
4971
4972 @smallexample
4973 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
4974 @end smallexample
4975
4976 @noindent
4977 The command also works using short option forms:
4978
4979 @smallexample
4980 $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
4981 @end smallexample
4982
4983 @noindent
4984 This is one of the easiest methods to transfer a @command{tar} archive.
4985
4986 @node looking ahead
4987 @section Looking Ahead: The Rest of this Manual
4988
4989 You have now seen how to use all eight of the operations available to
4990 @command{tar}, and a number of the possible options. The next chapter
4991 explains how to choose and change file and archive names, how to use
4992 files to store names of other files which you can then call as
4993 arguments to @command{tar} (this can help you save time if you expect to
4994 archive the same list of files a number of times), and so forth.
4995 @FIXME{in case it's not obvious, i'm making this up in some sense
4996 based on my limited memory of what the next chapter *really* does. i
4997 just wanted to flesh out this final section a little bit so i'd
4998 remember to stick it in here. :-)}
4999
5000 If there are too many files to conveniently list on the command line,
5001 you can list the names in a file, and @command{tar} will read that file.
5002 @value{xref-files-from}.
5003
5004 There are various ways of causing @command{tar} to skip over some files,
5005 and not archive them. @xref{Choosing}.
5006
5007 @node Backups
5008 @chapter Performing Backups and Restoring Files
5009 @UNREVISED
5010
5011 @GNUTAR{} is distributed along with the scripts
5012 which the Free Software Foundation uses for performing backups. There
5013 is no corresponding scripts available yet for doing restoration of
5014 files. Even if there is a good chance those scripts may be satisfying
5015 to you, they are not the only scripts or methods available for doing
5016 backups and restore. You may well create your own, or use more
5017 sophisticated packages dedicated to that purpose.
5018
5019 Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
5020 Automatic Network Disk Archiver), a backup system developed by James
5021 da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
5022 This is free software, and it is available at these places:
5023
5024 @smallexample
5025 http://www.cs.umd.edu/projects/amanda/amanda.html
5026 ftp://ftp.cs.umd.edu/pub/amanda
5027 @end smallexample
5028
5029 @ifclear PUBLISH
5030
5031 Here is a possible plan for a future documentation about the backuping
5032 scripts which are provided within the @GNUTAR{}
5033 distribution.
5034
5035 @smallexample
5036 .* dumps
5037 . + what are dumps
5038
5039 . + different levels of dumps
5040 . - full dump = dump everything
5041 . - level 1, level 2 dumps etc, -
5042 A level n dump dumps everything changed since the last level
5043 n-1 dump (?)
5044
5045 . + how to use scripts for dumps (ie, the concept)
5046 . - scripts to run after editing backup specs (details)
5047
5048 . + Backup Specs, what is it.
5049 . - how to customize
5050 . - actual text of script [/sp/dump/backup-specs]
5051
5052 . + Problems
5053 . - rsh doesn't work
5054 . - rtape isn't installed
5055 . - (others?)
5056
5057 . + the --incremental option of tar
5058
5059 . + tapes
5060 . - write protection
5061 . - types of media
5062 . : different sizes and types, useful for different things
5063 . - files and tape marks
5064 one tape mark between files, two at end.
5065 . - positioning the tape
5066 MT writes two at end of write,
5067 backspaces over one when writing again.
5068 @end smallexample
5069
5070 @end ifclear
5071
5072 This chapter documents both the provided shell scripts and @command{tar}
5073 options which are more specific to usage as a backup tool.
5074
5075 To @dfn{back up} a file system means to create archives that contain
5076 all the files in that file system. Those archives can then be used to
5077 restore any or all of those files (for instance if a disk crashes or a
5078 file is accidentally deleted). File system @dfn{backups} are also
5079 called @dfn{dumps}.
5080
5081 @menu
5082 * Full Dumps:: Using @command{tar} to Perform Full Dumps
5083 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
5084 * incremental and listed-incremental:: The Incremental Options
5085 * Backup Levels:: Levels of Backups
5086 * Backup Parameters:: Setting Parameters for Backups and Restoration
5087 * Scripted Backups:: Using the Backup Scripts
5088 * Scripted Restoration:: Using the Restore Script
5089 @end menu
5090
5091 @node Full Dumps
5092 @section Using @command{tar} to Perform Full Dumps
5093 @UNREVISED
5094
5095 @cindex full dumps
5096 @cindex dumps, full
5097
5098 @cindex corrupted archives
5099 Full dumps should only be made when no other people or programs
5100 are modifying files in the filesystem. If files are modified while
5101 @command{tar} is making the backup, they may not be stored properly in
5102 the archive, in which case you won't be able to restore them if you
5103 have to. (Files not being modified are written with no trouble, and do
5104 not corrupt the entire archive.)
5105
5106 You will want to use the @value{op-label} option to give the archive a
5107 volume label, so you can tell what this archive is even if the label
5108 falls off the tape, or anything like that.
5109
5110 Unless the filesystem you are dumping is guaranteed to fit on
5111 one volume, you will need to use the @value{op-multi-volume} option.
5112 Make sure you have enough tapes on hand to complete the backup.
5113
5114 If you want to dump each filesystem separately you will need to use
5115 the @value{op-one-file-system} option to prevent @command{tar} from crossing
5116 filesystem boundaries when storing (sub)directories.
5117
5118 The @value{op-incremental} option is not needed, since this is a complete
5119 copy of everything in the filesystem, and a full restore from this
5120 backup would only be done onto a completely empty disk.
5121
5122 Unless you are in a hurry, and trust the @command{tar} program (and your
5123 tapes), it is a good idea to use the @value{op-verify} option, to make
5124 sure your files really made it onto the dump properly. This will
5125 also detect cases where the file was modified while (or just after)
5126 it was being archived. Not all media (notably cartridge tapes) are
5127 capable of being verified, unfortunately.
5128
5129 @value{op-listed-incremental} take a file name argument always. If the
5130 file doesn't exist, run a level zero dump, creating the file. If the
5131 file exists, uses that file to see what has changed.
5132
5133 @value{op-incremental} @FIXME{look it up}
5134
5135 @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
5136
5137 This option should only be used when creating an incremental backup of
5138 a filesystem. When the @value{op-incremental} option is used, @command{tar}
5139 writes, at the beginning of the archive, an entry for each of the
5140 directories that will be operated on. The entry for a directory
5141 includes a list of all the files in the directory at the time the
5142 dump was done, and a flag for each file indicating whether the file
5143 is going to be put in the archive. This information is used when
5144 doing a complete incremental restore.
5145
5146 Note that this option causes @command{tar} to create a non-standard
5147 archive that may not be readable by non-@acronym{GNU} versions of the
5148 @command{tar} program.
5149
5150 The @value{op-incremental} option means the archive is an incremental
5151 backup. Its meaning depends on the command that it modifies.
5152
5153 If the @value{op-incremental} option is used with @value{op-list},
5154 @command{tar} will list, for each directory in the archive, the list
5155 of files in that directory at the time the archive was created. This
5156 information is put out in a format that is not easy for humans to
5157 read, but which is unambiguous for a program: each file name is
5158 preceded by either a @samp{Y} if the file is present in the archive,
5159 an @samp{N} if the file is not included in the archive, or a @samp{D}
5160 if the file is a directory (and is included in the archive). Each
5161 file name is terminated by a null character. The last file is
5162 followed by an additional null and a newline to indicate the end of
5163 the data.
5164
5165 If the @value{op-incremental} option is used with @value{op-extract}, then
5166 when the entry for a directory is found, all files that currently
5167 exist in that directory but are not listed in the archive @emph{are
5168 deleted from the directory}.
5169
5170 This behavior is convenient when you are restoring a damaged file
5171 system from a succession of incremental backups: it restores the
5172 entire state of the file system to that which obtained when the backup
5173 was made. If you don't use @value{op-incremental}, the file system will
5174 probably fill up with files that shouldn't exist any more.
5175
5176 @value{op-listed-incremental} handle new @acronym{GNU}-format
5177 incremental backup. This option handles new @acronym{GNU}-format
5178 incremental backup. It has much the same effect as
5179 @value{op-incremental}, but also the time when the dump is done and
5180 the list of directories dumped is written to the given
5181 @var{file}. When restoring, only files newer than the saved time are
5182 restored, and the directory list is used to speed up operations.
5183
5184 @value{op-listed-incremental} acts like @value{op-incremental}, but when
5185 used in conjunction with @value{op-create} will also cause @command{tar} to
5186 use the file @var{file}, which contains information about the state
5187 of the filesystem at the time of the last backup, to decide which
5188 files to include in the archive being created. That file will then
5189 be updated by @command{tar}. If the file @var{file} does not exist when
5190 this option is specified, @command{tar} will create it, and include all
5191 appropriate files in the archive.
5192
5193 The file, which is archive independent, contains the date it was last
5194 modified and a list of devices, inode numbers and directory names.
5195 @command{tar} will archive files with newer mod dates or inode change
5196 times, and directories with an unchanged inode number and device but
5197 a changed directory name. The file is updated after the files to
5198 be archived are determined, but before the new archive is actually
5199 created.
5200
5201 @node Inc Dumps
5202 @section Using @command{tar} to Perform Incremental Dumps
5203 @UNREVISED
5204
5205 @cindex incremental dumps
5206 @cindex dumps, incremental
5207
5208 Performing incremental dumps is similar to performing full dumps,
5209 although a few more options will usually be needed.
5210
5211 A standard scheme is to do a @emph{monthly} (full) dump once a month,
5212 a @emph{weekly} dump once a week of everything since the last monthly
5213 and a @emph{daily} every day of everything since the last (weekly or
5214 monthly) dump.
5215
5216 Here is a sample script to dump the directory hierarchies @samp{/usr}
5217 and @samp{/var}.
5218
5219 @smallexample
5220 #! /bin/sh
5221 tar --create \
5222 --blocking-factor=126 \
5223 --file=/dev/rmt/0 \
5224 --label="`hostname` /usr /var `date +%Y-%m-%d`" \
5225 --listed-incremental=/var/log/usr-var.snar \
5226 --verbose \
5227 /usr /var
5228 @end smallexample
5229
5230 This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
5231 store information about the previous tar dump.
5232
5233 The blocking factor 126 is an attempt to make the tape drive stream.
5234 Some tape devices cannot handle 64 kB blocks or larger, and require the
5235 block size to be a multiple of 1 kB; for these devices, 126 is the
5236 largest blocking factor that can be used.
5237
5238 @node incremental and listed-incremental
5239 @section The Incremental Options
5240 @UNREVISED
5241
5242 @value{op-incremental} is used in conjunction with @value{op-create},
5243 @value{op-extract} or @value{op-list} when backing up and restoring file
5244 systems. An archive cannot be extracted or listed with the
5245 @value{op-incremental} option specified unless it was created with the
5246 option specified. This option should only be used by a script, not by
5247 the user, and is usually disregarded in favor of
5248 @value{op-listed-incremental}, which is described below.
5249
5250 @value{op-incremental} in conjunction with @value{op-create} causes
5251 @command{tar} to write, at the beginning of the archive, an entry for
5252 each of the directories that will be archived. The entry for a
5253 directory includes a list of all the files in the directory at the
5254 time the archive was created and a flag for each file indicating
5255 whether or not the file is going to be put in the archive.
5256
5257 Note that this option causes @command{tar} to create a non-standard
5258 archive that may not be readable by non-@acronym{GNU} versions of the
5259 @command{tar} program.
5260
5261 @value{op-incremental} in conjunction with @value{op-extract} causes
5262 @command{tar} to read the lists of directory contents previously stored
5263 in the archive, @emph{delete} files in the file system that did not
5264 exist in their directories when the archive was created, and then
5265 extract the files in the archive.
5266
5267 This behavior is convenient when restoring a damaged file system from
5268 a succession of incremental backups: it restores the entire state of
5269 the file system to that which obtained when the backup was made. If
5270 @value{op-incremental} isn't specified, the file system will probably
5271 fill up with files that shouldn't exist any more.
5272
5273 @value{op-incremental} in conjunction with @value{op-list} causes
5274 @command{tar} to print, for each directory in the archive, the list of
5275 files in that directory at the time the archive was created. This
5276 information is put out in a format that is not easy for humans to
5277 read, but which is unambiguous for a program: each file name is
5278 preceded by either a @samp{Y} if the file is present in the archive,
5279 an @samp{N} if the file is not included in the archive, or a @samp{D}
5280 if the file is a directory (and is included in the archive). Each
5281 file name is terminated by a null character. The last file is followed
5282 by an additional null and a newline to indicate the end of the data.
5283
5284 @value{op-listed-incremental} acts like @value{op-incremental}, but when
5285 used in conjunction with @value{op-create} will also cause @command{tar}
5286 to use the file @var{snapshot-file}, which contains information about
5287 the state of the file system at the time of the last backup, to decide
5288 which files to include in the archive being created. That file will
5289 then be updated by @command{tar}. If the file @var{file} does not exist
5290 when this option is specified, @command{tar} will create it, and include
5291 all appropriate files in the archive.
5292
5293 The file @var{file}, which is archive independent, contains the date
5294 it was last modified and a list of devices, inode numbers and
5295 directory names. @command{tar} will archive files with newer mod dates
5296 or inode change times, and directories with an unchanged inode number
5297 and device but a changed directory name. The file is updated after
5298 the files to be archived are determined, but before the new archive is
5299 actually created.
5300
5301 Incremental dumps depend crucially on time stamps, so the results are
5302 unreliable if you modify a file's time stamps during dumping (e.g.@:
5303 with the @samp{--atime-preserve} option), or if you set the clock
5304 backwards.
5305
5306 Despite it should be obvious that a device has a non-volatile value, NFS
5307 devices have non-dependable values when an automounter gets in the picture.
5308 This led to a great deal of spurious redumping in incremental dumps,
5309 so it is somewhat useless to compare two NFS devices numbers over time.
5310 So @command{tar} now considers all NFS devices as being equal when it comes
5311 to comparing directories; this is fairly gross, but there does not seem
5312 to be a better way to go.
5313
5314 @command{tar} doesn't access @var{snapshot-file} when
5315 @value{op-extract} or @value{op-list} are specified, but the
5316 @value{op-listed-incremental} option must still be given. A
5317 placeholder @var{snapshot-file} can be specified, e.g.,
5318 @file{/dev/null}.
5319
5320 @FIXME{this section needs to be written}
5321
5322 @node Backup Levels
5323 @section Levels of Backups
5324
5325 An archive containing all the files in the file system is called a
5326 @dfn{full backup} or @dfn{full dump}. You could insure your data by
5327 creating a full dump every day. This strategy, however, would waste a
5328 substantial amount of archive media and user time, as unchanged files
5329 are daily re-archived.
5330
5331 It is more efficient to do a full dump only occasionally. To back up
5332 files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
5333 one} dump archives all the files that have changed since the last full
5334 dump.
5335
5336 A typical dump strategy would be to perform a full dump once a week,
5337 and a level one dump once a day. This means some versions of files
5338 will in fact be archived more than once, but this dump strategy makes
5339 it possible to restore a file system to within one day of accuracy by
5340 only extracting two archives---the last weekly (full) dump and the
5341 last daily (level one) dump. The only information lost would be in
5342 files changed or created since the last daily backup. (Doing dumps
5343 more than once a day is usually not worth the trouble).
5344
5345 @GNUTAR{} comes with scripts you can use to do full
5346 and level-one (actually, even level-two and so on) dumps. Using
5347 scripts (shell programs) to perform backups and restoration is a
5348 convenient and reliable alternative to typing out file name lists
5349 and @command{tar} commands by hand.
5350
5351 Before you use these scripts, you need to edit the file
5352 @file{backup-specs}, which specifies parameters used by the backup
5353 scripts and by the restore script. This file is usually located
5354 in @file{/etc/backup} directory. @FIXME-xref{Script Syntax} Once the
5355 backup parameters are set, you can perform backups or restoration by
5356 running the appropriate script.
5357
5358 The name of the backup script is @code{backup}. The name of the
5359 restore script is @code{restore}. The following sections describe
5360 their use in detail.
5361
5362 @emph{Please Note:} The backup and restoration scripts are
5363 designed to be used together. While it is possible to restore files by
5364 hand from an archive which was created using a backup script, and to create
5365 an archive by hand which could then be extracted using the restore script,
5366 it is easier to use the scripts. @value{xref-incremental}, and
5367 @value{xref-listed-incremental}, before making such an attempt.
5368
5369 @node Backup Parameters
5370 @section Setting Parameters for Backups and Restoration
5371
5372 The file @file{backup-specs} specifies backup parameters for the
5373 backup and restoration scripts provided with @command{tar}. You must
5374 edit @file{backup-specs} to fit your system configuration and schedule
5375 before using these scripts.
5376
5377 Syntactically, @file{backup-specs} is a shell script, containing
5378 mainly variable assignments. However, any valid shell construct
5379 is allowed in this file. Particularly, you may wish to define
5380 functions within that script (e.g. see @code{RESTORE_BEGIN} below).
5381 For more information about shell script syntax, please refer to
5382 @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
5383 g_02, the definition of the Shell Command Language}. See also
5384 @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
5385
5386 The shell variables controlling behavior of @code{backup} and
5387 @code{restore} are described in the following subsections.
5388
5389 @menu
5390 * General-Purpose Variables::
5391 * Magnetic Tape Control::
5392 * User Hooks::
5393 * backup-specs example:: An Example Text of @file{Backup-specs}
5394 @end menu
5395
5396 @node General-Purpose Variables
5397 @subsection General-Purpose Variables
5398
5399 @defvr {Backup variable} ADMINISTRATOR
5400 The user name of the backup administrator. @code{Backup} scripts
5401 sends a backup report to this address.
5402 @end defvr
5403
5404 @defvr {Backup variable} BACKUP_HOUR
5405 The hour at which the backups are done. This can be a number from 0
5406 to 23, or the time specification in form @var{hours}:@var{minutes},
5407 or the string @samp{now}.
5408
5409 This variable is used by @code{backup}. Its value may be overridden
5410 using @option{--time} option (@pxref{Scripted Backups}).
5411 @end defvr
5412
5413 @defvr {Backup variable} TAPE_FILE
5414 The device @command{tar} writes the archive to. This device should be
5415 attached to the host on which the dump scripts are run.
5416 @end defvr
5417
5418 @defvr {Backup variable} BLOCKING
5419
5420 The blocking factor @command{tar} will use when writing the dump archive.
5421 @value{xref-blocking-factor}.
5422 @end defvr
5423
5424 @defvr {Backup variable} BACKUP_DIRS
5425
5426 A list of file systems to be dumped (for @code{backup}), or restored
5427 (for @code{restore}). You can include any directory
5428 name in the list --- subdirectories on that file system will be
5429 included, regardless of how they may look to other networked machines.
5430 Subdirectories on other file systems will be ignored.
5431
5432 The host name specifies which host to run @command{tar} on, and should
5433 normally be the host that actually contains the file system. However,
5434 the host machine must have @GNUTAR{} installed, and
5435 must be able to access the directory containing the backup scripts and
5436 their support files using the same file name that is used on the
5437 machine where the scripts are run (ie. what @command{pwd} will print
5438 when in that directory on that machine). If the host that contains
5439 the file system does not have this capability, you can specify another
5440 host as long as it can access the file system through NFS.
5441
5442 If the list of file systems is very long you may wish to put it
5443 in a separate file. This file is usually named
5444 @file{/etc/backup/dirs}, but this name may be overridden in
5445 @file{backup-specs} using @code{DIRLIST} variable.
5446 @end defvr
5447
5448 @defvr {Backup variable} DIRLIST
5449
5450 A path to the file containing the list of the filesystems to backup
5451 or restore. By default it is @file{/etc/backup/dirs}.
5452 @end defvr
5453
5454 @defvr {Backup variable} BACKUP_FILES
5455
5456 A list of individual files to be dumped (for @code{backup}), or restored
5457 (for @code{restore}). These should be accessible from the machine on
5458 which the backup script is run.
5459
5460 If the list of file systems is very long you may wish to store it
5461 in a separate file. This file is usually named
5462 @file{/etc/backup/files}, but this name may be overridden in
5463 @file{backup-specs} using @code{FILELIST} variable.
5464 @end defvr
5465
5466 @defvr {Backup variable} FILELIST
5467
5468 A path to the file containing the list of the individual files to backup
5469 or restore. By default it is @file{/etc/backup/files}.
5470 @end defvr
5471
5472 @defvr {Backup variable} RSH
5473
5474 Path to @code{rsh} binary or its equivalent. You may wish to
5475 set it to @code{ssh}, to improve security. In this case you will have
5476 to use public key authentication.
5477 @end defvr
5478
5479 @defvr {Backup variable} RSH_COMMAND
5480
5481 Path to rsh binary on remote mashines. This will be passed via
5482 @option{--rsh-command} option to the remote invocation of @GNUTAR{}.
5483 @end defvr
5484
5485 @defvr {Backup variable} VOLNO_FILE
5486
5487 Name of temporary file to hold volume numbers. This needs to be accessible
5488 by all the machines which have filesystems to be dumped.
5489 @end defvr
5490
5491 @defvr {Backup variable} XLIST
5492
5493 Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
5494 located on the remote machine and containing the list of files to
5495 be excluded from the backup. Exclude file lists are searched in
5496 /etc/tar-backup directory. A common use for exclude file lists
5497 is to exclude files containing security-sensitive information
5498 (e.g. @file{/etc/shadow} from backups).
5499
5500 This variable affects only @code{backup}.
5501 @end defvr
5502
5503 @defvr {Backup variable} SLEEP_TIME
5504
5505 Time to sleep between dumps of any two successive filesystems
5506
5507 This variable affects only @code{backup}.
5508 @end defvr
5509
5510 @defvr {Backup variable} DUMP_REMIND_SCRIPT
5511
5512 Script to be run when it's time to insert a new tape in for the next
5513 volume. Administrators may want to tailor this script for their site.
5514 If this variable isn't set, @GNUTAR{} will display its built-in prompt
5515 @FIXME-xref{describe it somewhere!}, and will expect confirmation from
5516 the console.
5517 @end defvr
5518
5519 @defvr {Backup variable} SLEEP_MESSAGE
5520
5521 Message to display on the terminal while waiting for dump time. Usually
5522 this will just be some literal text.
5523 @end defvr
5524
5525 @defvr {Backup variable} TAR
5526
5527 Pathname of the @GNUTAR{} executable. If this is not set, backup
5528 scripts will search @command{tar} in the current shell path.
5529 @end defvr
5530
5531 @node Magnetic Tape Control
5532 @subsection Magnetic Tape Control
5533
5534 Backup scripts access tape device using special @dfn{hook functions}.
5535 These functions take a single argument -- the name of the tape
5536 device. Their names are kept in the following variables:
5537
5538 @defvr {Backup variable} MT_BEGIN
5539 The name of @dfn{begin} function. This function is called before
5540 accessing the drive. By default it retensions the tape:
5541
5542 @smallexample
5543 MT_BEGIN=mt_begin
5544
5545 mt_begin() @{
5546 mt -f "$1" retension
5547 @}
5548 @end smallexample
5549 @end defvr
5550
5551 @defvr {Backup variable} MT_REWIND
5552 The name of @dfn{rewind} function. The default definition is as
5553 follows:
5554
5555 @smallexample
5556 MT_REWIND=mt_rewind
5557
5558 mt_rewind() @{
5559 mt -f "$1" rewind
5560 @}
5561 @end smallexample
5562
5563 @end defvr
5564
5565 @defvr {Backup variable} MT_OFFLINE
5566 The name of the function switching the tape off line. By default
5567 it is defined as follows:
5568
5569 @smallexample
5570 MT_OFFLINE=mt_offline
5571
5572 mt_offline() @{
5573 mt -f "$1" offl
5574 @}
5575 @end smallexample
5576 @end defvr
5577
5578 @defvr {Backup variable} MT_STATUS
5579 The name of the function used to obtain the status of the archive device,
5580 including error count. Default definition:
5581
5582 @smallexample
5583 MT_STATUS=mt_status
5584
5585 mt_status() @{
5586 mt -f "$1" status
5587 @}
5588 @end smallexample
5589 @end defvr
5590
5591 @node User Hooks
5592 @subsection User Hooks
5593
5594 @dfn{User hooks} are shell functions executed before and after
5595 each @command{tar} invocation. Thus, there are @dfn{backup
5596 hooks}, which are executed before and after dumping each file
5597 system, and @dfn{restore hooks}, executed before and
5598 after restoring a file system. Each user hook is a shell function
5599 taking four arguments:
5600
5601 @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
5602 Its arguments are:
5603
5604 @table @var
5605 @item level
5606 Current backup or restore level.
5607
5608 @item host
5609 Name or IP address of the host machine being dumped or restored.
5610
5611 @item fs
5612 Full path name to the filesystem being dumped or restored.
5613
5614 @item fsname
5615 Filesystem name with directory separators replaced with colons. This
5616 is useful e.g. for creating unique files.
5617 @end table
5618 @end deffn
5619
5620 Following variables keep the names of user hook functions
5621
5622 @defvr {Backup variable} DUMP_BEGIN
5623 Dump begin function. It is executed before dumping the filesystem.
5624 @end defvr
5625
5626 @defvr {Backup variable} DUMP_END
5627 Executed after dumping the filesystem.
5628 @end defvr
5629
5630 @defvr {Backup variable} RESTORE_BEGIN
5631 Executed before restoring the filesystem.
5632 @end defvr
5633
5634 @defvr {Backup variable} RESTORE_END
5635 Executed after restoring the filesystem.
5636 @end defvr
5637
5638 @node backup-specs example
5639 @subsection An Example Text of @file{Backup-specs}
5640
5641 The following is an example of @file{backup-specs}:
5642
5643 @smallexample
5644 # site-specific parameters for file system backup.
5645
5646 ADMINISTRATOR=friedman
5647 BACKUP_HOUR=1
5648 TAPE_FILE=/dev/nrsmt0
5649
5650 # Use @code{ssh} instead of the less secure @code{rsh}
5651 RSH=/usr/bin/ssh
5652 RSH_COMMAND=/usr/bin/ssh
5653
5654 # Override MT_STATUS function:
5655 my_status() @{
5656 mts -t $TAPE_FILE
5657 @}
5658 MT_STATUS=my_status
5659
5660 # Disable MT_OFFLINE function
5661 MT_OFFLINE=:
5662
5663 BLOCKING=124
5664 BACKUP_DIRS="
5665 albert:/fs/fsf
5666 apple-gunkies:/gd
5667 albert:/fs/gd2
5668 albert:/fs/gp
5669 geech:/usr/jla
5670 churchy:/usr/roland
5671 albert:/
5672 albert:/usr
5673 apple-gunkies:/
5674 apple-gunkies:/usr
5675 gnu:/hack
5676 gnu:/u
5677 apple-gunkies:/com/mailer/gnu
5678 apple-gunkies:/com/archive/gnu"
5679
5680 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
5681
5682 @end smallexample
5683
5684 @node Scripted Backups
5685 @section Using the Backup Scripts
5686
5687 The syntax for running a backup script is:
5688
5689 @smallexample
5690 backup --level=@var{level} --time=@var{time}
5691 @end smallexample
5692
5693 The @option{level} option requests the dump level. Thus, to produce
5694 a full dump, specify @code{--level=0} (this is the default, so
5695 @option{--level} may be omitted if its value is @code{0}).
5696 @footnote{For backward compatibility, the @code{backup} will also
5697 try to deduce the requested dump level from the name of the
5698 script itself. If the name consists of a string @samp{level-}
5699 followed by a single decimal digit, that digit is taken as
5700 the dump level number. Thus, you may create a link from @code{backup}
5701 to @code{level-1} and then run @code{level-1} whenever you need to
5702 create a level one dump.}
5703
5704 The @option{--time} option determines when should the backup be
5705 run. @var{Time} may take three forms:
5706
5707 @table @asis
5708 @item @var{hh}:@var{mm}
5709
5710 The dump must be run at @var{hh} hours @var{mm} minutes.
5711
5712 @item @var{hh}
5713
5714 The dump must be run at @var{hh} hours
5715
5716 @item now
5717
5718 The dump must be run immediately.
5719 @end table
5720
5721 You should start a script with a tape or disk mounted. Once you
5722 start a script, it prompts you for new tapes or disks as it
5723 needs them. Media volumes don't have to correspond to archive
5724 files --- a multi-volume archive can be started in the middle of a
5725 tape that already contains the end of another multi-volume archive.
5726 The @code{restore} script prompts for media by its archive volume,
5727 so to avoid an error message you should keep track of which tape
5728 (or disk) contains which volume of the archive (@pxref{Scripted
5729 Restoration}).
5730
5731 The backup scripts write two files on the file system. The first is a
5732 record file in @file{/etc/tar-backup/}, which is used by the scripts
5733 to store and retrieve information about which files were dumped. This
5734 file is not meant to be read by humans, and should not be deleted by
5735 them. @FIXME-xref{incremental and listed-incremental, for a more
5736 detailed explanation of this file.}
5737
5738 The second file is a log file containing the names of the file systems
5739 and files dumped, what time the backup was made, and any error
5740 messages that were generated, as well as how much space was left in
5741 the media volume after the last volume of the archive was written.
5742 You should check this log file after every backup. The file name is
5743 @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
5744 represents current date, and @var{n} represents current dump level number.
5745
5746 The script also prints the name of each system being dumped to the
5747 standard output.
5748
5749 Following is the full list of options accepted by @code{backup}
5750 script:
5751
5752 @table @option
5753 @item -l @var{level}
5754 @itemx --level=@var{level}
5755 Do backup level @var{level} (default 0).
5756
5757 @item -f
5758 @itemx --force
5759 Force backup even if today's log file already exists.
5760
5761 @item -v[@var{level}]
5762 @itemx --verbose[=@var{level}]
5763 Set verbosity level. The higher the level is, the more debugging
5764 information will be output during execution. Devault @var{level}
5765 is 100, which means the highest debugging level.
5766
5767 @item -t @var{start-time}
5768 @itemx --time=@var{start-time}
5769 Wait till @var{time}, then do backup.
5770
5771 @item -h
5772 @itemx --help
5773 Display short help message and exit.
5774
5775 @item -L
5776 @itemx --license
5777 Display program license and exit.
5778
5779 @item -V
5780 @itemx --version
5781 Display program version and exit.
5782 @end table
5783
5784
5785 @node Scripted Restoration
5786 @section Using the Restore Script
5787
5788 To restore files that were archived using a scripted backup, use the
5789 @code{restore} script. Its usage is quite straightforward. In the
5790 simplest form, invoke @code{restore --all}, it will
5791 then restore all the filesystems and files specified in
5792 @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
5793
5794 You may select the filesystems (and/or files) to restore by
5795 giving @code{restore} list of @dfn{patterns} in its command
5796 line. For example, running
5797
5798 @smallexample
5799 restore 'albert:*'
5800 @end smallexample
5801
5802 @noindent
5803 will restore all filesystems on the machine @samp{albert}. A more
5804 complicated example:
5805
5806 @smallexample
5807 restore 'albert:*' '*:/var'
5808 @end smallexample
5809
5810 @noindent
5811 This command will restore all filesystems on the machine @samp{albert}
5812 as well as @file{/var} filesystem on all machines.
5813
5814 By default @code{restore} will start restoring files from the lowest
5815 available dump level (usually zero) and will continue through
5816 all available dump levels. There may be situations where such a
5817 thorough restore is not necessary. For example, you may wish to
5818 restore only files from the recent level one backup. To do so,
5819 use @option{--level} option, as shown in the example below:
5820
5821 @smallexample
5822 restore --level=1
5823 @end smallexample
5824
5825 The full list of options accepted by @code{restore} follows:
5826
5827 @table @option
5828 @item -a
5829 @itemx --all
5830 Restore all filesystems and files specified in @file{backup-specs}
5831
5832 @item -l @var{level}
5833 @itemx --level=@var{level}
5834 Start restoring from the given backup level, instead of the default 0.
5835
5836 @item -v[@var{level}]
5837 @itemx --verbose[=@var{level}]
5838 Set verbosity level. The higher the level is, the more debugging
5839 information will be output during execution. Devault @var{level}
5840 is 100, which means the highest debugging level.
5841
5842 @item -h
5843 @itemx --help
5844 Display short help message and exit.
5845
5846 @item -L
5847 @itemx --license
5848 Display program license and exit.
5849
5850 @item -V
5851 @itemx --version
5852 Display program version and exit.
5853 @end table
5854
5855 You should start the restore script with the media containing the
5856 first volume of the archive mounted. The script will prompt for other
5857 volumes as they are needed. If the archive is on tape, you don't need
5858 to rewind the tape to to its beginning---if the tape head is
5859 positioned past the beginning of the archive, the script will rewind
5860 the tape as needed. @FIXME-xref{Media, for a discussion of tape
5861 positioning.}
5862
5863 @quotation
5864 @strong{Warning:} The script will delete files from the active file
5865 system if they were not in the file system when the archive was made.
5866 @end quotation
5867
5868 @value{xref-incremental}, and @value{ref-listed-incremental},
5869 for an explanation of how the script makes that determination.
5870
5871 @node Choosing
5872 @chapter Choosing Files and Names for @command{tar}
5873 @UNREVISED
5874
5875 @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
5876
5877 Certain options to @command{tar} enable you to specify a name for your
5878 archive. Other options let you decide which files to include or exclude
5879 from the archive, based on when or whether files were modified, whether
5880 the file names do or don't match specified patterns, or whether files
5881 are in specified directories.
5882
5883 @menu
5884 * file:: Choosing the Archive's Name
5885 * Selecting Archive Members::
5886 * files:: Reading Names from a File
5887 * exclude:: Excluding Some Files
5888 * Wildcards::
5889 * after:: Operating Only on New Files
5890 * recurse:: Descending into Directories
5891 * one:: Crossing Filesystem Boundaries
5892 @end menu
5893
5894 @node file
5895 @section Choosing and Naming Archive Files
5896 @cindex Naming an archive
5897 @cindex Archive Name
5898 @cindex Directing output
5899 @cindex Choosing an archive file
5900 @cindex Where is the archive?
5901 @UNREVISED
5902
5903 @FIXME{should the title of this section actually be, "naming an
5904 archive"?}
5905
5906 By default, @command{tar} uses an archive file name that was compiled when
5907 it was built on the system; usually this name refers to some physical
5908 tape drive on the machine. However, the person who installed @command{tar}
5909 on the system may not set the default to a meaningful value as far as
5910 most users are concerned. As a result, you will usually want to tell
5911 @command{tar} where to find (or create) the archive. The @value{op-file}
5912 option allows you to either specify or name a file to use as the archive
5913 instead of the default archive file location.
5914
5915 @table @kbd
5916 @item --file=@var{archive-name}
5917 @itemx -f @var{archive-name}
5918 Name the archive to create or operate on. Use in conjunction with
5919 any operation.
5920 @end table
5921
5922 For example, in this @command{tar} command,
5923
5924 @smallexample
5925 $ @kbd{tar -cvf collection.tar blues folk jazz}
5926 @end smallexample
5927
5928 @noindent
5929 @file{collection.tar} is the name of the archive. It must directly
5930 follow the @samp{-f} option, since whatever directly follows @samp{-f}
5931 @emph{will} end up naming the archive. If you neglect to specify an
5932 archive name, you may end up overwriting a file in the working directory
5933 with the archive you create since @command{tar} will use this file's name
5934 for the archive name.
5935
5936 An archive can be saved as a file in the file system, sent through a
5937 pipe or over a network, or written to an I/O device such as a tape,
5938 floppy disk, or CD write drive.
5939
5940 @cindex Writing new archives
5941 @cindex Archive creation
5942 If you do not name the archive, @command{tar} uses the value of the
5943 environment variable @env{TAPE} as the file name for the archive. If
5944 that is not available, @command{tar} uses a default, compiled-in archive
5945 name, usually that for tape unit zero (ie. @file{/dev/tu00}).
5946 @command{tar} always needs an archive name.
5947
5948 If you use @file{-} as an @var{archive-name}, @command{tar} reads the
5949 archive from standard input (when listing or extracting files), or
5950 writes it to standard output (when creating an archive). If you use
5951 @file{-} as an @var{archive-name} when modifying an archive,
5952 @command{tar} reads the original archive from its standard input and
5953 writes the entire new archive to its standard output.
5954
5955 @FIXME{might want a different example here; this is already used in
5956 "notable tar usages".}
5957
5958 @smallexample
5959 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
5960 @end smallexample
5961
5962 @FIXME{help!}
5963
5964 @cindex Standard input and output
5965 @cindex tar to standard input and output
5966 To specify an archive file on a device attached to a remote machine,
5967 use the following:
5968
5969 @smallexample
5970 @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
5971 @end smallexample
5972
5973 @noindent
5974 @command{tar} will complete the remote connection, if possible, and
5975 prompt you for a username and password. If you use
5976 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
5977 will complete the remote connection, if possible, using your username
5978 as the username on the remote machine.
5979
5980 If the archive file name includes a colon (@samp{:}), then it is assumed
5981 to be a file on another machine. If the archive file is
5982 @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
5983 host @var{host}. The remote host is accessed using the @command{rsh}
5984 program, with a username of @var{user}. If the username is omitted
5985 (along with the @samp{@@} sign), then your user name will be used.
5986 (This is the normal @command{rsh} behavior.) It is necessary for the
5987 remote machine, in addition to permitting your @command{rsh} access, to
5988 have the @file{rmt} program installed (This command is included in
5989 the @GNUTAR{} distribution and by default is installed under
5990 @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
5991 installation prefix). If you need to use a file whose name includes a
5992 colon, then the remote tape drive behavior
5993 can be inhibited by using the @value{op-force-local} option.
5994
5995 @FIXME{i know we went over this yesterday, but bob (and now i do again,
5996 too) thinks it's out of the middle of nowhere. it doesn't seem to tie
5997 into what came before it well enough <<i moved it now, is it better
5998 here?>>. bob also comments that if Amanda isn't free software, we
5999 shouldn't mention it..}
6000
6001 When the archive is being created to @file{/dev/null}, @GNUTAR{}
6002 tries to minimize input and output operations. The
6003 Amanda backup system, when used with @GNUTAR{}, has
6004 an initial sizing pass which uses this feature.
6005
6006 @node Selecting Archive Members
6007 @section Selecting Archive Members
6008 @cindex Specifying files to act on
6009 @cindex Specifying archive members
6010
6011 @dfn{File Name arguments} specify which files in the file system
6012 @command{tar} operates on, when creating or adding to an archive, or which
6013 archive members @command{tar} operates on, when reading or deleting from
6014 an archive. @xref{Operations}.
6015
6016 To specify file names, you can include them as the last arguments on
6017 the command line, as follows:
6018 @smallexample
6019 @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
6020 @end smallexample
6021
6022 If you specify a directory name as a file name argument, all the files
6023 in that directory are operated on by @command{tar}.
6024
6025 If you do not specify files when @command{tar} is invoked with
6026 @value{op-create}, @command{tar} operates on all the non-directory files in
6027 the working directory. If you specify either @value{op-list} or
6028 @value{op-extract}, @command{tar} operates on all the archive members in the
6029 archive. If you specify any operation other than one of these three,
6030 @command{tar} does nothing.
6031
6032 By default, @command{tar} takes file names from the command line. However,
6033 there are other ways to specify file or member names, or to modify the
6034 manner in which @command{tar} selects the files or members upon which to
6035 operate. @FIXME{add xref here}In general, these methods work both for
6036 specifying the names of files and archive members.
6037
6038 @node files
6039 @section Reading Names from a File
6040 @UNREVISED
6041
6042 @cindex Reading file names from a file
6043 @cindex Lists of file names
6044 @cindex File Name arguments, alternatives
6045 Instead of giving the names of files or archive members on the command
6046 line, you can put the names into a file, and then use the
6047 @value{op-files-from} option to @command{tar}. Give the name of the file
6048 which contains the list of files to include as the argument to
6049 @samp{--files-from}. In the list, the file names should be separated by
6050 newlines. You will frequently use this option when you have generated
6051 the list of files to archive with the @command{find} utility.
6052
6053 @table @kbd
6054 @item --files-from=@var{file name}
6055 @itemx -T @var{file name}
6056 Get names to extract or create from file @var{file name}.
6057 @end table
6058
6059 If you give a single dash as a file name for @samp{--files-from}, (i.e.,
6060 you specify either @samp{--files-from=-} or @samp{-T -}), then the file
6061 names are read from standard input.
6062
6063 Unless you are running @command{tar} with @samp{--create}, you can not use
6064 both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
6065 command.
6066
6067 @FIXME{add bob's example, from his message on 2-10-97}
6068
6069 The following example shows how to use @command{find} to generate a list of
6070 files smaller than 400K in length and put that list into a file
6071 called @file{small-files}. You can then use the @samp{-T} option to
6072 @command{tar} to specify the files from that file, @file{small-files}, to
6073 create the archive @file{little.tgz}. (The @samp{-z} option to
6074 @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
6075 more information.)
6076
6077 @smallexample
6078 $ @kbd{find . -size -400 -print > small-files}
6079 $ @kbd{tar -c -v -z -T small-files -f little.tgz}
6080 @end smallexample
6081
6082 @noindent
6083 @FIXME{say more here to conclude the example/section?}
6084
6085 @menu
6086 * nul::
6087 @end menu
6088
6089 @node nul
6090 @subsection @kbd{NUL} Terminated File Names
6091
6092 @cindex File names, terminated by @kbd{NUL}
6093 @cindex @kbd{NUL} terminated file names
6094 The @value{op-null} option causes @value{op-files-from} to read file
6095 names terminated by a @code{NUL} instead of a newline, so files whose
6096 names contain newlines can be archived using @samp{--files-from}.
6097
6098 @table @kbd
6099 @item --null
6100 Only consider @kbd{NUL} terminated file names, instead of files that
6101 terminate in a newline.
6102 @end table
6103
6104 The @samp{--null} option is just like the one in @acronym{GNU}
6105 @command{xargs} and @command{cpio}, and is useful with the
6106 @samp{-print0} predicate of @acronym{GNU} @command{find}. In
6107 @command{tar}, @samp{--null} also causes @value{op-directory} options
6108 to be treated as file names to archive, in case there are any files
6109 out there called @file{-C}.
6110
6111 This example shows how to use @command{find} to generate a list of files
6112 larger than 800K in length and put that list into a file called
6113 @file{long-files}. The @samp{-print0} option to @command{find} just just
6114 like @samp{-print}, except that it separates files with a @kbd{NUL}
6115 rather than with a newline. You can then run @command{tar} with both the
6116 @samp{--null} and @samp{-T} options to specify that @command{tar} get the
6117 files from that file, @file{long-files}, to create the archive
6118 @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
6119 @command{tar} to recognize the @kbd{NUL} separator between files.
6120
6121 @smallexample
6122 $ @kbd{find . -size +800 -print0 > long-files}
6123 $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
6124 @end smallexample
6125
6126 @FIXME{say anything else here to conclude the section?}
6127
6128 @node exclude
6129 @section Excluding Some Files
6130 @cindex File names, excluding files by
6131 @cindex Excluding files by name and pattern
6132 @cindex Excluding files by file system
6133 @UNREVISED
6134
6135 To avoid operating on files whose names match a particular pattern,
6136 use the @value{op-exclude} or @value{op-exclude-from} options.
6137
6138 @table @kbd
6139 @item --exclude=@var{pattern}
6140 Causes @command{tar} to ignore files that match the @var{pattern}.
6141 @end table
6142
6143 @findex exclude
6144 The @value{op-exclude} option prevents any file or member whose name
6145 matches the shell wildcard (@var{pattern}) from being operated on.
6146 For example, to create an archive with all the contents of the directory
6147 @file{src} except for files whose names end in @file{.o}, use the
6148 command @samp{tar -cf src.tar --exclude='*.o' src}.
6149
6150 You may give multiple @samp{--exclude} options.
6151
6152 @table @kbd
6153 @item --exclude-from=@var{file}
6154 @itemx -X @var{file}
6155 Causes @command{tar} to ignore files that match the patterns listed in
6156 @var{file}.
6157 @end table
6158
6159 @findex exclude-from
6160 Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
6161 list of patterns, one per line, from @var{file}; @command{tar} will
6162 ignore files matching those patterns. Thus if @command{tar} is
6163 called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
6164 single line @file{*.o}, no files whose names end in @file{.o} will be
6165 added to the archive.
6166
6167 @FIXME{do the exclude options files need to have stuff separated by
6168 newlines the same as the files-from option does?}
6169
6170 @table @kbd
6171 @item --exclude-caches
6172 Causes @command{tar} to ignore directories containing a cache directory tag.
6173 @end table
6174
6175 @findex exclude-caches
6176 When creating an archive,
6177 the @samp{--exclude-caches} option
6178 causes @command{tar} to exclude all directories
6179 that contain a @dfn{cache directory tag}.
6180 A cache directory tag is a short file
6181 with the well-known name @file{CACHEDIR.TAG}
6182 and having a standard header
6183 specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
6184 Various applications write cache directory tags
6185 into directories they use to hold regenerable, non-precious data,
6186 so that such data can be more easily excluded from backups.
6187
6188 @menu
6189 * controlling pattern-patching with exclude::
6190 * problems with exclude::
6191 @end menu
6192
6193 @node controlling pattern-patching with exclude
6194 @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
6195
6196 Normally, a pattern matches a name if an initial subsequence of the
6197 name's components matches the pattern, where @samp{*}, @samp{?}, and
6198 @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
6199 and wildcards can match @samp{/}.
6200
6201 Other than optionally stripping leading @samp{/} from names
6202 (@pxref{absolute}), patterns and names are used as-is. For
6203 example, trailing @samp{/} is not trimmed from a user-specified name
6204 before deciding whether to exclude it.
6205
6206 However, this matching procedure can be altered by the options listed
6207 below. These options accumulate. For example:
6208
6209 @smallexample
6210 --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
6211 @end smallexample
6212
6213 ignores case when excluding @samp{makefile}, but not when excluding
6214 @samp{readme}.
6215
6216 @table @option
6217 @item --anchored
6218 @itemx --no-anchored
6219 If anchored, a pattern must match an initial subsequence
6220 of the name's components. Otherwise, the pattern can match any
6221 subsequence. Default is @option{--no-anchored}.
6222
6223 @item --ignore-case
6224 @itemx --no-ignore-case
6225 When ignoring case, upper-case patterns match lower-case names and vice versa.
6226 When not ignoring case (the default), matching is case-sensitive.
6227
6228 @item --wildcards
6229 @itemx --no-wildcards
6230 When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
6231 are the usual shell wildcards, and @samp{\} escapes wildcards.
6232 Otherwise, none of these characters are special, and patterns must match
6233 names literally.
6234
6235 @item --wildcards-match-slash
6236 @itemx --no-wildcards-match-slash
6237 When wildcards match slash (the default), a wildcard like @samp{*} in
6238 the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
6239 matched only by @samp{/}.
6240
6241 @end table
6242
6243 The @option{--recursion} and @option{--no-recursion} options
6244 (@pxref{recurse}) also affect how exclude patterns are interpreted. If
6245 recursion is in effect, a pattern excludes a name if it matches any of
6246 the name's parent directories.
6247
6248 @node problems with exclude
6249 @unnumberedsubsec Problems with Using the @code{exclude} Options
6250
6251 Some users find @samp{exclude} options confusing. Here are some common
6252 pitfalls:
6253
6254 @itemize @bullet
6255 @item
6256 The main operating mode of @command{tar} does not act on a path name
6257 explicitly listed on the command line if one of its file name
6258 components is excluded. In the example above, if
6259 you create an archive and exclude files that end with @samp{*.o}, but
6260 explicitly name the file @samp{dir.o/foo} after all the options have been
6261 listed, @samp{dir.o/foo} will be excluded from the archive.
6262
6263 @item
6264 You can sometimes confuse the meanings of @value{op-exclude} and
6265 @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
6266 to be excluded are given as a pattern on the command line. Use
6267 @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
6268 file which contains a list of patterns, one per line; each of these
6269 patterns can exclude zero, one, or many files.
6270
6271 @item
6272 When you use @value{op-exclude}, be sure to quote the @var{pattern}
6273 parameter, so @GNUTAR{} sees wildcard characters
6274 like @samp{*}. If you do not do this, the shell might expand the
6275 @samp{*} itself using files at hand, so @command{tar} might receive a
6276 list of files instead of one pattern, or none at all, making the
6277 command somewhat illegal. This might not correspond to what you want.
6278
6279 For example, write:
6280
6281 @smallexample
6282 $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
6283 @end smallexample
6284
6285 @noindent
6286 rather than:
6287
6288 @smallexample
6289 $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
6290 @end smallexample
6291
6292 @item
6293 You must use use shell syntax, or globbing, rather than @code{regexp}
6294 syntax, when using exclude options in @command{tar}. If you try to use
6295 @code{regexp} syntax to describe files to be excluded, your command
6296 might fail.
6297
6298 @item
6299 In earlier versions of @command{tar}, what is now the
6300 @samp{--exclude-from=@var{file-of-patterns}} option was called
6301 @samp{--exclude=@var{pattern}} instead. Now,
6302 @samp{--exclude=@var{pattern}} applies to patterns listed on the command
6303 line and @samp{--exclude-from=@var{file-of-patterns}} applies to
6304 patterns listed in a file.
6305
6306 @end itemize
6307
6308 @node Wildcards
6309 @section Wildcards Patterns and Matching
6310
6311 @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
6312 @samp{*} or @samp{?} for example, are replaced and expanded into all
6313 existing files matching the given pattern. However, @command{tar} often
6314 uses wildcard patterns for matching (or globbing) archive members instead
6315 of actual files in the filesystem. Wildcard patterns are also used for
6316 verifying volume labels of @command{tar} archives. This section has the
6317 purpose of explaining wildcard syntax for @command{tar}.
6318
6319 @FIXME{the next few paragraphs need work.}
6320
6321 A @var{pattern} should be written according to shell syntax, using wildcard
6322 characters to effect globbing. Most characters in the pattern stand
6323 for themselves in the matched string, and case is significant: @samp{a}
6324 will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
6325 pattern matches any single character in the matched string. The character
6326 @samp{*} in the pattern matches zero, one, or more single characters in
6327 the matched string. The character @samp{\} says to take the following
6328 character of the pattern @emph{literally}; it is useful when one needs to
6329 match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
6330
6331 The character @samp{[}, up to the matching @samp{]}, introduces a character
6332 class. A @dfn{character class} is a list of acceptable characters
6333 for the next single character of the matched string. For example,
6334 @samp{[abcde]} would match any of the first five letters of the alphabet.
6335 Note that within a character class, all of the ``special characters''
6336 listed above other than @samp{\} lose their special meaning; for example,
6337 @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
6338 @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
6339 the characters @samp{-} and @samp{]} must either come @emph{first} or
6340 @emph{last} in a character class.)
6341
6342 @cindex Excluding characters from a character class
6343 @cindex Character class, excluding characters from
6344 If the first character of the class after the opening @samp{[}
6345 is @samp{!} or @samp{^}, then the meaning of the class is reversed.
6346 Rather than listing character to match, it lists those characters which
6347 are @emph{forbidden} as the next single character of the matched string.
6348
6349 Other characters of the class stand for themselves. The special
6350 construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
6351 letters, is meant to represent all characters between @var{a} and
6352 @var{e}, inclusive.
6353
6354 @FIXME{need to add a sentence or so here to make this clear for those
6355 who don't have dan around.}
6356
6357 Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
6358 special for wildcard matches. However, if a pattern completely matches
6359 a directory prefix of a matched string, then it matches the full matched
6360 string: excluding a directory also excludes all the files beneath it.
6361
6362 @node after
6363 @section Operating Only on New Files
6364 @cindex Excluding file by age
6365 @cindex Modification time, excluding files by
6366 @cindex Age, excluding files by
6367 @UNREVISED
6368
6369 The @value{op-after-date} option causes @command{tar} to only work on files
6370 whose modification or inode-changed times are newer than the @var{date}
6371 given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
6372 be a file name; the last-modified time of that file is used as the date.
6373 If you use this option when creating or appending to an archive,
6374 the archive will only include new files. If you use @samp{--after-date}
6375 when extracting an archive, @command{tar} will only extract files newer
6376 than the @var{date} you specify.
6377
6378 If you only want @command{tar} to make the date comparison based on
6379 modification of the actual contents of the file (rather than inode
6380 changes), then use the @value{op-newer-mtime} option.
6381
6382 You may use these options with any operation. Note that these options
6383 differ from the @value{op-update} operation in that they allow you to
6384 specify a particular date against which @command{tar} can compare when
6385 deciding whether or not to archive the files.
6386
6387 @table @kbd
6388 @item --after-date=@var{date}
6389 @itemx --newer=@var{date}
6390 @itemx -N @var{date}
6391 Only store files newer than @var{date}.
6392
6393 Acts on files only if their modification or inode-changed times are
6394 later than @var{date}. Use in conjunction with any operation.
6395
6396 If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
6397 name; the last-modified time of that file is used as the date.
6398
6399 @item --newer-mtime=@var{date}
6400 Acts like @value{op-after-date}, but only looks at modification times.
6401 @end table
6402
6403 These options limit @command{tar} to only operating on files which have
6404 been modified after the date specified. A file is considered to have
6405 changed if the contents have been modified, or if the owner,
6406 permissions, and so forth, have been changed. (For more information on
6407 how to specify a date, see @ref{Date input formats}; remember that the
6408 entire date argument must be quoted if it contains any spaces.)
6409
6410 Gurus would say that @value{op-after-date} tests both the @code{mtime}
6411 (time the contents of the file were last modified) and @code{ctime}
6412 (time the file's status was last changed: owner, permissions, etc)
6413 fields, while @value{op-newer-mtime} tests only @code{mtime} field.
6414
6415 To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
6416 @code{ctime} and processes the file if either one is more recent than
6417 @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
6418 disregards @code{ctime}. Neither uses @code{atime} (the last time the
6419 contents of the file were looked at).
6420
6421 Date specifiers can have embedded spaces. Because of this, you may need
6422 to quote date arguments to keep the shell from parsing them as separate
6423 arguments.
6424
6425 @FIXME{Need example of --newer-mtime with quoted argument.}
6426
6427 @quotation
6428 @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
6429 should not be used for incremental backups. Some files (such as those
6430 in renamed directories) are not selected properly by these options.
6431 @xref{incremental and listed-incremental}.
6432 @end quotation
6433
6434 @noindent
6435 @FIXME{which tells -- need to fill this in!}
6436
6437 @node recurse
6438 @section Descending into Directories
6439 @cindex Avoiding recursion in directories
6440 @cindex Descending directories, avoiding
6441 @cindex Directories, avoiding recursion
6442 @cindex Recursion in directories, avoiding
6443 @UNREVISED
6444
6445 @FIXME{arrggh! this is still somewhat confusing to me. :-< }
6446
6447 @FIXME{show dan bob's comments, from 2-10-97}
6448
6449 Usually, @command{tar} will recursively explore all directories (either
6450 those given on the command line or through the @value{op-files-from}
6451 option) for the various files they contain. However, you may not always
6452 want @command{tar} to act this way.
6453
6454 The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
6455 into specified directories. If you specify @samp{--no-recursion}, you can
6456 use the @command{find} utility for hunting through levels of directories to
6457 construct a list of file names which you could then pass to @command{tar}.
6458 @command{find} allows you to be more selective when choosing which files to
6459 archive; see @ref{files} for more information on using @command{find} with
6460 @command{tar}, or look.
6461
6462 @table @kbd
6463 @item --no-recursion
6464 Prevents @command{tar} from recursively descending directories.
6465
6466 @item --recursion
6467 Requires @command{tar} to recursively descend directories.
6468 This is the default.
6469 @end table
6470
6471 When you use @samp{--no-recursion}, @GNUTAR{} grabs
6472 directory entries themselves, but does not descend on them
6473 recursively. Many people use @command{find} for locating files they
6474 want to back up, and since @command{tar} @emph{usually} recursively
6475 descends on directories, they have to use the @samp{@w{! -d}} option
6476 to @command{find} @FIXME{needs more explanation or a cite to another
6477 info file}as they usually do not want all the files in a directory.
6478 They then use the @value{op-files-from} option to archive the files
6479 located via @command{find}.
6480
6481 The problem when restoring files archived in this manner is that the
6482 directories themselves are not in the archive; so the
6483 @value{op-same-permissions} option does not affect them---while users
6484 might really like it to. Specifying @value{op-no-recursion} is a way to
6485 tell @command{tar} to grab only the directory entries given to it, adding
6486 no new files on its own.
6487
6488 The @value{op-no-recursion} option also applies when extracting: it
6489 causes @command{tar} to extract only the matched directory entries, not
6490 the files under those directories.
6491
6492 The @value{op-no-recursion} option also affects how exclude patterns
6493 are interpreted (@pxref{controlling pattern-patching with exclude}).
6494
6495 The @option{--no-recursion} and @option{--recursion} options apply to
6496 later options and operands, and can be overridden by later occurrences
6497 of @option{--no-recursion} and @option{--recursion}. For example:
6498
6499 @smallexample
6500 $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
6501 @end smallexample
6502
6503 @noindent
6504 creates an archive with one entry for @file{grape}, and the recursive
6505 contents of @file{grape/concord}, but no entries under @file{grape}
6506 other than @file{grape/concord}.
6507
6508 @node one
6509 @section Crossing Filesystem Boundaries
6510 @cindex File system boundaries, not crossing
6511 @UNREVISED
6512
6513 @command{tar} will normally automatically cross file system boundaries in
6514 order to archive files which are part of a directory tree. You can
6515 change this behavior by running @command{tar} and specifying
6516 @value{op-one-file-system}. This option only affects files that are
6517 archived because they are in a directory that is being archived;
6518 @command{tar} will still archive files explicitly named on the command line
6519 or through @value{op-files-from}, regardless of where they reside.
6520
6521 @table @kbd
6522 @item --one-file-system
6523 @itemx -l
6524 Prevents @command{tar} from crossing file system boundaries when
6525 archiving. Use in conjunction with any write operation.
6526 @end table
6527
6528 The @samp{--one-file-system} option causes @command{tar} to modify its
6529 normal behavior in archiving the contents of directories. If a file in
6530 a directory is not on the same filesystem as the directory itself, then
6531 @command{tar} will not archive that file. If the file is a directory
6532 itself, @command{tar} will not archive anything beneath it; in other words,
6533 @command{tar} will not cross mount points.
6534
6535 It is reported that using this option, the mount point is is archived,
6536 but nothing under it.
6537
6538 This option is useful for making full or incremental archival backups of
6539 a file system. If this option is used in conjunction with
6540 @value{op-verbose}, files that are excluded are mentioned by name on the
6541 standard error.
6542
6543 @menu
6544 * directory:: Changing Directory
6545 * absolute:: Absolute File Names
6546 @end menu
6547
6548 @node directory
6549 @subsection Changing the Working Directory
6550
6551 @FIXME{need to read over this node now for continuity; i've switched
6552 things around some.}
6553
6554 @cindex Changing directory mid-stream
6555 @cindex Directory, changing mid-stream
6556 @cindex Working directory, specifying
6557 @UNREVISED
6558
6559 To change the working directory in the middle of a list of file names,
6560 either on the command line or in a file specified using
6561 @value{op-files-from}, use @value{op-directory}. This will change the
6562 working directory to the directory @var{directory} after that point in
6563 the list.
6564
6565 @table @kbd
6566 @item --directory=@var{directory}
6567 @itemx -C @var{directory}
6568 Changes the working directory in the middle of a command line.
6569 @end table
6570
6571 For example,
6572
6573 @smallexample
6574 $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
6575 @end smallexample
6576
6577 @noindent
6578 will place the files @file{grape} and @file{prune} from the current
6579 directory into the archive @file{jams.tar}, followed by the file
6580 @file{cherry} from the directory @file{food}. This option is especially
6581 useful when you have several widely separated files that you want to
6582 store in the same archive.
6583
6584 Note that the file @file{cherry} is recorded in the archive under the
6585 precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
6586 archive will contain three files that all appear to have come from the
6587 same directory; if the archive is extracted with plain @samp{tar
6588 --extract}, all three files will be written in the current directory.
6589
6590 Contrast this with the command,
6591
6592 @smallexample
6593 $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
6594 @end smallexample
6595
6596 @noindent
6597 which records the third file in the archive under the name
6598 @file{red/cherry} so that, if the archive is extracted using
6599 @samp{tar --extract}, the third file will be written in a subdirectory
6600 named @file{orange-colored}.
6601
6602 You can use the @samp{--directory} option to make the archive
6603 independent of the original name of the directory holding the files.
6604 The following command places the files @file{/etc/passwd},
6605 @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
6606 @file{foo.tar}:
6607
6608 @smallexample
6609 $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
6610 @end smallexample
6611
6612 @noindent
6613 However, the names of the archive members will be exactly what they were
6614 on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
6615 They will not appear to be related by file name to the original
6616 directories where those files were located.
6617
6618 Note that @samp{--directory} options are interpreted consecutively. If
6619 @samp{--directory} specifies a relative file name, it is interpreted
6620 relative to the then current directory, which might not be the same as
6621 the original current working directory of @command{tar}, due to a previous
6622 @samp{--directory} option.
6623
6624 When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
6625 options in the file list. Notice, however, that in this case the
6626 option and its argument must occupy two consecutive lines. For
6627 instance, the file list for the above example will be:
6628
6629 @smallexample
6630 @group
6631 -C
6632 /etc
6633 passwd
6634 hosts
6635 -C
6636 /lib
6637 libc.a
6638 @end group
6639 @end smallexample
6640
6641 @noindent
6642 To use it, you would invoke @command{tar} as follows:
6643
6644 @smallexample
6645 $ @kbd{tar -c -f foo.tar --files-from list}
6646 @end smallexample
6647
6648 Notice also that you can only use the short option variant in the file
6649 list, i.e. always use @option{-C}, not @option{--directory}.
6650
6651 The interpretation of @value{op-directory} is disabled by
6652 @value{op-null} option.
6653
6654 @node absolute
6655 @subsection Absolute File Names
6656 @UNREVISED
6657
6658 @table @kbd
6659 @item -P
6660 @itemx --absolute-names
6661 Do not strip leading slashes from file names, and permit file names
6662 containing a @file{..} file name component.
6663 @end table
6664
6665 By default, @GNUTAR{} drops a leading @samp{/} on
6666 input or output, and complains about file names containing a @file{..}
6667 component. This option turns off this behavior.
6668
6669 When @command{tar} extracts archive members from an archive, it strips any
6670 leading slashes (@samp{/}) from the member name. This causes absolute
6671 member names in the archive to be treated as relative file names. This
6672 allows you to have such members extracted wherever you want, instead of
6673 being restricted to extracting the member in the exact directory named
6674 in the archive. For example, if the archive member has the name
6675 @file{/etc/passwd}, @command{tar} will extract it as if the name were
6676 really @file{etc/passwd}.
6677
6678 File names containing @file{..} can cause problems when extracting, so
6679 @command{tar} normally warns you about such files when creating an
6680 archive, and rejects attempts to extracts such files.
6681
6682 Other @command{tar} programs do not do this. As a result, if you
6683 create an archive whose member names start with a slash, they will be
6684 difficult for other people with a non-@GNUTAR{}
6685 program to use. Therefore, @GNUTAR{} also strips
6686 leading slashes from member names when putting members into the
6687 archive. For example, if you ask @command{tar} to add the file
6688 @file{/bin/ls} to an archive, it will do so, but the member name will
6689 be @file{bin/ls}.
6690
6691 If you use the @value{op-absolute-names} option, @command{tar} will do
6692 none of these transformations.
6693
6694 To archive or extract files relative to the root directory, specify
6695 the @value{op-absolute-names} option.
6696
6697 Normally, @command{tar} acts on files relative to the working
6698 directory---ignoring superior directory names when archiving, and
6699 ignoring leading slashes when extracting.
6700
6701 When you specify @value{op-absolute-names}, @command{tar} stores file names
6702 including all superior directory names, and preserves leading slashes.
6703 If you only invoked @command{tar} from the root directory you would never
6704 need the @value{op-absolute-names} option, but using this option may be
6705 more convenient than switching to root.
6706
6707 @FIXME{Should be an example in the tutorial/wizardry section using this
6708 to transfer files between systems.}
6709
6710 @FIXME{Is write access an issue?}
6711
6712 @table @kbd
6713 @item --absolute-names
6714 Preserves full file names (including superior directory names) when
6715 archiving files. Preserves leading slash when extracting files.
6716
6717 @end table
6718
6719 @FIXME{this is still horrible; need to talk with dan on monday.}
6720
6721 @command{tar} prints out a message about removing the @samp{/} from
6722 file names. This message appears once per @GNUTAR{}
6723 invocation. It represents something which ought to be told; ignoring
6724 what it means can cause very serious surprises, later.
6725
6726 Some people, nevertheless, do not want to see this message. Wanting to
6727 play really dangerously, one may of course redirect @command{tar} standard
6728 error to the sink. For example, under @command{sh}:
6729
6730 @smallexample
6731 $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
6732 @end smallexample
6733
6734 @noindent
6735 Another solution, both nicer and simpler, would be to change to
6736 the @file{/} directory first, and then avoid absolute notation.
6737 For example:
6738
6739 @smallexample
6740 $ @kbd{(cd / && tar -c -f archive.tar home)}
6741 $ @kbd{tar -c -f archive.tar -C / home}
6742 @end smallexample
6743
6744 @include getdate.texi
6745
6746 @node Formats
6747 @chapter Controlling the Archive Format
6748
6749 Due to historical reasons, there are several formats of tar archives.
6750 All of them are based on the same principles, but have some subtle
6751 differences that often make them incompatible with each other.
6752
6753 GNU tar is able to create and handle archives in a variety of formats.
6754 The most frequently used formats are (in alphabetical order):
6755
6756 @table @asis
6757 @item gnu
6758 Format used by @GNUTAR{} versions up to 1.13.25. This format derived
6759 from an early @acronym{POSIX} standard, adding some improvements such as
6760 sparse file handling and incremental archives. Unfortunately these
6761 features were implemented in a way incompatible with other archive
6762 formats.
6763
6764 Archives in @samp{gnu} format are able to hold pathnames of unlimited
6765 length.
6766
6767 @item oldgnu
6768 Format used by @GNUTAR{} of versions prior to 1.12.
6769
6770 @item v7
6771 Archive format, compatible with the V7 implementation of tar. This
6772 format imposes a number of limitations. The most important of them
6773 are:
6774
6775 @enumerate
6776 @item The maximum length of a file name is limited to 99 characters.
6777 @item The maximum length of a symbolic link is limited to 99 characters.
6778 @item It is impossible to store special files (block and character
6779 devices, fifos etc.)
6780 @item Maximum value of user or group ID is limited to 2097151 (7777777
6781 octal)
6782 @item V7 archives do not contain symbolic ownership information (user
6783 and group name of the file owner).
6784 @end enumerate
6785
6786 This format has traditionally been used by Automake when producing
6787 Makefiles. This practice will change in the future, in the meantime,
6788 however this means that projects containing filenames more than 99
6789 characters long will not be able to use @GNUTAR{} @value{VERSION} and
6790 Automake prior to 1.9.
6791
6792 @item ustar
6793 Archive format defined by @acronym{POSIX.1-1988} specification. It stores
6794 symbolic ownership information. It is also able to store
6795 special files. However, it imposes several restrictions as well:
6796
6797 @enumerate
6798 @item The maximum length of a file name is limited to 256 characters,
6799 provided that the filename can be split at directory separator in
6800 two parts, first of them being at most 155 bytes long. So, in most
6801 cases the maximum file name length will be shorter than 256
6802 characters.
6803 @item The maximum length of a symbolic link name is limited to
6804 100 characters.
6805 @item Maximum size of a file the archive is able to accomodate
6806 is 8GB
6807 @item Maximum value of UID/GID is 2097151.
6808 @item Maximum number of bits in device major and minor numbers is 21.
6809 @end enumerate
6810
6811 @item star
6812 Format used by J@"org Schilling @command{star}
6813 implementation. @GNUTAR{} is able to read @samp{star} archives but
6814 currently does not produce them.
6815
6816 @item posix
6817 Archive format defined by @acronym{POSIX.1-2001} specification. This is the
6818 most flexible and feature-rich format. It does not impose any
6819 restrictions on file sizes or filename lengths. This format is quite
6820 recent, so not all tar implementations are able to handle it properly.
6821 However, this format is designed in such a way that any tar
6822 implementation able to read @samp{ustar} archives will be able to read
6823 most @samp{posix} archives as well, with the only exception that any
6824 additional information (such as long file names etc.) will in such
6825 case be extracted as plain text files along with the files it refers to.
6826
6827 This archive format will be the default format for future versions
6828 of @GNUTAR{}.
6829
6830 @end table
6831
6832 The following table summarizes the limitations of each of these
6833 formats:
6834
6835 @multitable @columnfractions .10 .20 .20 .20 .20
6836 @item Format @tab UID @tab File Size @tab Path Name @tab Devn
6837 @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
6838 @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
6839 @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
6840 @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
6841 @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
6842 @end multitable
6843
6844 The default format for @GNUTAR{} is defined at compilation
6845 time. You may check it by running @command{tar --help}, and examining
6846 the last lines of its output. Usually, @GNUTAR{} is configured
6847 to create archives in @samp{gnu} format, however, future version will
6848 switch to @samp{posix}.
6849
6850 @menu
6851 * Portability:: Making @command{tar} Archives More Portable
6852 * Compression:: Using Less Space through Compression
6853 * Attributes:: Handling File Attributes
6854 * Standard:: The Standard Format
6855 * Extensions:: @acronym{GNU} Extensions to the Archive Format
6856 * cpio:: Comparison of @command{tar} and @command{cpio}
6857 @end menu
6858
6859 @node Portability
6860 @section Making @command{tar} Archives More Portable
6861
6862 Creating a @command{tar} archive on a particular system that is meant to be
6863 useful later on many other machines and with other versions of @command{tar}
6864 is more challenging than you might think. @command{tar} archive formats
6865 have been evolving since the first versions of Unix. Many such formats
6866 are around, and are not always compatible with each other. This section
6867 discusses a few problems, and gives some advice about making @command{tar}
6868 archives more portable.
6869
6870 One golden rule is simplicity. For example, limit your @command{tar}
6871 archives to contain only regular files and directories, avoiding
6872 other kind of special files. Do not attempt to save sparse files or
6873 contiguous files as such. Let's discuss a few more problems, in turn.
6874
6875 @menu
6876 * Portable Names:: Portable Names
6877 * dereference:: Symbolic Links
6878 * old:: Old V7 Archives
6879 * ustar:: Ustar Archives
6880 * gnu:: GNU and old GNU format archives.
6881 * posix:: @acronym{POSIX} archives
6882 * Checksumming:: Checksumming Problems
6883 * Large or Negative Values:: Large files, negative time stamps, etc.
6884 @end menu
6885
6886 @node Portable Names
6887 @subsection Portable Names
6888
6889 Use portable file and member names. A name is portable if it contains
6890 only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
6891 @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
6892 contain @samp{/-}. Avoid deep directory nesting. For portability to
6893 old Unix hosts, limit your file name components to 14 characters or
6894 less.
6895
6896 If you intend to have your @command{tar} archives to be read under
6897 MSDOS, you should not rely on case distinction for file names, and you
6898 might use the @acronym{GNU} @command{doschk} program for helping you
6899 further diagnosing illegal MSDOS names, which are even more limited
6900 than System V's.
6901
6902 @node dereference
6903 @subsection Symbolic Links
6904 @cindex File names, using symbolic links
6905 @cindex Symbolic link as file name
6906
6907 Normally, when @command{tar} archives a symbolic link, it writes a
6908 block to the archive naming the target of the link. In that way, the
6909 @command{tar} archive is a faithful record of the filesystem contents.
6910 @value{op-dereference} is used with @value{op-create}, and causes
6911 @command{tar} to archive the files symbolic links point to, instead of
6912 the links themselves. When this option is used, when @command{tar}
6913 encounters a symbolic link, it will archive the linked-to file,
6914 instead of simply recording the presence of a symbolic link.
6915
6916 The name under which the file is stored in the file system is not
6917 recorded in the archive. To record both the symbolic link name and
6918 the file name in the system, archive the file under both names. If
6919 all links were recorded automatically by @command{tar}, an extracted file
6920 might be linked to a file name that no longer exists in the file
6921 system.
6922
6923 If a linked-to file is encountered again by @command{tar} while creating
6924 the same archive, an entire second copy of it will be stored. (This
6925 @emph{might} be considered a bug.)
6926
6927 So, for portable archives, do not archive symbolic links as such,
6928 and use @value{op-dereference}: many systems do not support
6929 symbolic links, and moreover, your distribution might be unusable if
6930 it contains unresolved symbolic links.
6931
6932 @node old
6933 @subsection Old V7 Archives
6934 @cindex Format, old style
6935 @cindex Old style format
6936 @cindex Old style archives
6937
6938 Certain old versions of @command{tar} cannot handle additional
6939 information recorded by newer @command{tar} programs. To create an
6940 archive in V7 format (not ANSI), which can be read by these old
6941 versions, specify the @value{op-format-v7} option in
6942 conjunction with the @value{op-create} (@command{tar} also
6943 accepts @samp{--portability} or @samp{op-old-archive} for this
6944 option). When you specify it,
6945 @command{tar} leaves out information about directories, pipes, fifos,
6946 contiguous files, and device files, and specifies file ownership by
6947 group and user IDs instead of group and user names.
6948
6949 When updating an archive, do not use @value{op-format-v7}
6950 unless the archive was created using this option.
6951
6952 In most cases, a @emph{new} format archive can be read by an @emph{old}
6953 @command{tar} program without serious trouble, so this option should
6954 seldom be needed. On the other hand, most modern @command{tar}s are
6955 able to read old format archives, so it might be safer for you to
6956 always use @value{op-format-v7} for your distributions.
6957
6958 @node ustar
6959 @subsection Ustar Archive Format
6960
6961 Archive format defined by @acronym{POSIX}.1-1988 specification is called
6962 @code{ustar}. Although it is more flexible than the V7 format, it
6963 still has many restrictions (@xref{Formats,ustar}, for the detailed
6964 description of @code{ustar} format). Along with V7 format,
6965 @code{ustar} format is a good choice for archives intended to be read
6966 with other implementations of @command{tar}.
6967
6968 To create archive in @code{ustar} format, use @value{op-format-ustar}
6969 option in conjunction with the @value{op-create}.
6970
6971 @node gnu
6972 @subsection @acronym{GNU} and old @GNUTAR{} format
6973
6974 @GNUTAR{} was based on an early draft of the
6975 @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
6976 @command{tar}, such as the support for file names longer than 100
6977 characters, use portions of the @command{tar} header record which were
6978 specified in that @acronym{POSIX} draft as unused. Subsequent changes in
6979 @acronym{POSIX} have allocated the same parts of the header record for
6980 other purposes. As a result, @GNUTAR{} format is
6981 incompatible with the current @acronym{POSIX} specification, and with
6982 @command{tar} programs that follow it.
6983
6984 In the majority of cases, @command{tar} will be configured to create
6985 this format by default. This will change in the future releases, since
6986 we plan to make @samp{posix} format the default.
6987
6988 To force creation a @GNUTAR{} archive, use option
6989 @value{op-format-gnu}.
6990
6991 Some @command{tar} options are currently basing on @GNUTAR{}
6992 format, and can therefore be used only with @samp{gnu}
6993 or @samp{oldgnu} archive formats. The list of such options follows:
6994
6995 @itemize @bullet
6996 @item @value{op-label}, when used with @value{op-create}.
6997 @item @value{op-incremental}
6998 @item @value{op-multi-volume}
6999 @end itemize
7000
7001 These options will be re-implemented for the @samp{posix} archive
7002 format in the future.
7003
7004 @node posix
7005 @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
7006
7007 The version @value{VERSION} of @GNUTAR{} is able
7008 to read and create archives conforming to @acronym{POSIX.1-2001} standard.
7009
7010 A @acronym{POSIX} conformant archive will be created if @command{tar}
7011 was given @value{op-format-posix} option.
7012 Notice, that currently @acronym{GNU} extensions are not
7013 allowed with this format. Following is the list of options that
7014 cannot be used with @value{op-format-posix}:
7015
7016 @itemize @bullet
7017 @item @value{op-label}, when used with @value{op-create}.
7018 @item @value{op-incremental}
7019 @item @value{op-multi-volume}
7020 @end itemize
7021
7022 This restriction will disappear in the future versions.
7023
7024 @node Checksumming
7025 @subsection Checksumming Problems
7026
7027 SunOS and HP-UX @command{tar} fail to accept archives created using
7028 @GNUTAR{} and containing non-ASCII file names, that
7029 is, file names having characters with the eight bit set, because they
7030 use signed checksums, while @GNUTAR{} uses unsigned
7031 checksums while creating archives, as per @acronym{POSIX} standards. On
7032 reading, @GNUTAR{} computes both checksums and
7033 accept any. It is somewhat worrying that a lot of people may go
7034 around doing backup of their files using faulty (or at least
7035 non-standard) software, not learning about it until it's time to
7036 restore their missing files with an incompatible file extractor, or
7037 vice versa.
7038
7039 @GNUTAR{} compute checksums both ways, and accept
7040 any on read, so @acronym{GNU} tar can read Sun tapes even with their
7041 wrong checksums. @GNUTAR{} produces the standard
7042 checksum, however, raising incompatibilities with Sun. That is to
7043 say, @GNUTAR{} has not been modified to
7044 @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
7045 I've been told that more recent Sun @command{tar} now read standard
7046 archives, so maybe Sun did a similar patch, after all?
7047
7048 The story seems to be that when Sun first imported @command{tar}
7049 sources on their system, they recompiled it without realizing that
7050 the checksums were computed differently, because of a change in
7051 the default signing of @code{char}'s in their compiler. So they
7052 started computing checksums wrongly. When they later realized their
7053 mistake, they merely decided to stay compatible with it, and with
7054 themselves afterwards. Presumably, but I do not really know, HP-UX
7055 has chosen that their @command{tar} archives to be compatible with Sun's.
7056 The current standards do not favor Sun @command{tar} format. In any
7057 case, it now falls on the shoulders of SunOS and HP-UX users to get
7058 a @command{tar} able to read the good archives they receive.
7059
7060 @node Large or Negative Values
7061 @subsection Large or Negative Values
7062 @cindex large values
7063 @cindex future time stamps
7064 @cindex negative time stamps
7065
7066 @acronym{POSIX} @command{tar} format uses fixed-sized unsigned octal strings
7067 to represent numeric values. User and group IDs and device major and
7068 minor numbers have unsigned 21-bit representations, and file sizes and
7069 times have unsigned 33-bit representations. @GNUTAR{}
7070 generates @acronym{POSIX} representations when possible, but for values
7071 outside the @acronym{POSIX} range it generates two's-complement base-256
7072 strings: uids, gids, and device numbers have signed 57-bit
7073 representations, and file sizes and times have signed 89-bit
7074 representations. These representations are an extension to @acronym{POSIX}
7075 @command{tar} format, so they are not universally portable.
7076
7077 The most common portability problems with out-of-range numeric values
7078 are large files and future or negative time stamps.
7079
7080 Portable archives should avoid members of 8 GB or larger, as @acronym{POSIX}
7081 @command{tar} format cannot represent them.
7082
7083 Portable archives should avoid time stamps from the future. @acronym{POSIX}
7084 @command{tar} format can represent time stamps in the range 1970-01-01
7085 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
7086 hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
7087 and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
7088 portable archives must avoid these time stamps for many years to come.
7089
7090 Portable archives should also avoid time stamps before 1970. These time
7091 stamps are a common @acronym{POSIX} extension but their @code{time_t}
7092 representations are negative. Many traditional @command{tar}
7093 implementations generate a two's complement representation for negative
7094 time stamps that assumes a signed 32-bit @code{time_t}; hence they
7095 generate archives that are not portable to hosts with differing
7096 @code{time_t} representations. @GNUTAR{} recognizes this
7097 situation when it is run on host with a signed 32-bit @code{time_t}, but
7098 it issues a warning, as these time stamps are nonstandard and unportable.
7099
7100 @node Compression
7101 @section Using Less Space through Compression
7102
7103 @menu
7104 * gzip:: Creating and Reading Compressed Archives
7105 * sparse:: Archiving Sparse Files
7106 @end menu
7107
7108 @node gzip
7109 @subsection Creating and Reading Compressed Archives
7110 @cindex Compressed archives
7111 @cindex Storing archives in compressed format
7112 @UNREVISED
7113
7114 @table @kbd
7115 @item -z
7116 @itemx --gzip
7117 @itemx --ungzip
7118 Filter the archive through @command{gzip}.
7119 @end table
7120
7121 @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
7122 format parameters must be taken into consideration when modifying an
7123 archive.@FIXME{???} Compressed archives cannot be modified.
7124
7125 You can use @samp{--gzip} and @samp{--gunzip} on physical devices
7126 (tape drives, etc.) and remote files as well as on normal files; data
7127 to or from such devices or remote files is reblocked by another copy
7128 of the @command{tar} program to enforce the specified (or default) record
7129 size. The default compression parameters are used; if you need to
7130 override them, avoid the @value{op-gzip} option and run @command{gzip}
7131 explicitly. (Or set the @env{GZIP} environment variable.)
7132
7133 The @value{op-gzip} option does not work with the @value{op-multi-volume}
7134 option, or with the @value{op-update}, @value{op-append},
7135 @value{op-concatenate}, or @value{op-delete} operations.
7136
7137 It is not exact to say that @GNUTAR{} is to work in concert
7138 with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
7139 possible that @command{tar} and @command{gzip} be done with a single call,
7140 like in:
7141
7142 @smallexample
7143 $ @kbd{tar cfz archive.tar.gz subdir}
7144 @end smallexample
7145
7146 @noindent
7147 to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
7148 can do:
7149
7150 @smallexample
7151 $ @kbd{tar xfz archive.tar.gz}
7152 @end smallexample
7153
7154 @noindent
7155 to explode and unpack.
7156
7157 The difference is that the whole archive is compressed. With
7158 @command{zip}, archive members are archived individually. @command{tar}'s
7159 method yields better compression. On the other hand, one can view the
7160 contents of a @command{zip} archive without having to decompress it. As
7161 for the @command{tar} and @command{gzip} tandem, you need to decompress the
7162 archive to see its contents. However, this may be done without needing
7163 disk space, by using pipes internally:
7164
7165 @smallexample
7166 $ @kbd{tar tfz archive.tar.gz}
7167 @end smallexample
7168
7169 @cindex corrupted archives
7170 About corrupted compressed archives: @command{gzip}'ed files have no
7171 redundancy, for maximum compression. The adaptive nature of the
7172 compression scheme means that the compression tables are implicitly
7173 spread all over the archive. If you lose a few blocks, the dynamic
7174 construction of the compression tables becomes unsynchronized, and there
7175 is little chance that you could recover later in the archive.
7176
7177 There are pending suggestions for having a per-volume or per-file
7178 compression in @GNUTAR{}. This would allow for viewing the
7179 contents without decompression, and for resynchronizing decompression at
7180 every volume or file, in case of corrupted archives. Doing so, we might
7181 lose some compressibility. But this would have make recovering easier.
7182 So, there are pros and cons. We'll see!
7183
7184 @table @kbd
7185 @item -j
7186 @itemx --bzip2
7187 Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
7188
7189 @item -Z
7190 @itemx --compress
7191 @itemx --uncompress
7192 Filter the archive through @command{compress}. Otherwise like
7193 @value{op-gzip}.
7194
7195 @item --use-compress-program=@var{prog}
7196 Filter through @var{prog} (must accept @samp{-d}).
7197 @end table
7198
7199 @value{op-compress} stores an archive in compressed format. This
7200 option is useful in saving time over networks and space in pipes, and
7201 when storage space is at a premium. @value{op-compress} causes
7202 @command{tar} to compress when writing the archive, or to uncompress when
7203 reading the archive.
7204
7205 To perform compression and uncompression on the archive, @command{tar}
7206 runs the @command{compress} utility. @command{tar} uses the default
7207 compression parameters; if you need to override them, avoid the
7208 @value{op-compress} option and run the @command{compress} utility
7209 explicitly. It is useful to be able to call the @command{compress}
7210 utility from within @command{tar} because the @command{compress} utility by
7211 itself cannot access remote tape drives.
7212
7213 The @value{op-compress} option will not work in conjunction with the
7214 @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
7215 and @value{op-delete} operations. @xref{Operations}, for
7216 more information on these operations.
7217
7218 If there is no compress utility available, @command{tar} will report an error.
7219 @strong{Please note} that the @command{compress} program may be covered by
7220 a patent, and therefore we recommend you stop using it.
7221
7222 @value{op-bzip2} acts like @value{op-compress}, except that it uses
7223 the @code{bzip2} utility.
7224
7225 @table @kbd
7226 @item --compress
7227 @itemx --uncompress
7228 @itemx -z
7229 @itemx -Z
7230 When this option is specified, @command{tar} will compress (when
7231 writing an archive), or uncompress (when reading an archive). Used in
7232 conjunction with the @value{op-create}, @value{op-extract},
7233 @value{op-list} and @value{op-compare} operations.
7234 @end table
7235
7236 You can have archives be compressed by using the @value{op-gzip} option.
7237 This will arrange for @command{tar} to use the @command{gzip} program to be
7238 used to compress or uncompress the archive wren writing or reading it.
7239
7240 To use the older, obsolete, @command{compress} program, use the
7241 @value{op-compress} option. The @acronym{GNU} Project recommends you not use
7242 @command{compress}, because there is a patent covering the algorithm it
7243 uses. You could be sued for patent infringement merely by running
7244 @command{compress}.
7245
7246 @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
7247 to do it now. I would like to use @value{op-gzip}, but I'd also like
7248 the output to be fed through a program like @acronym{GNU}
7249 @command{ecc} (actually, right now that's @samp{exactly} what I'd like
7250 to use :-)), basically adding ECC protection on top of compression.
7251 It seems as if this should be quite easy to do, but I can't work out
7252 exactly how to go about it. Of course, I can pipe the standard output
7253 of @command{tar} through @command{ecc}, but then I lose (though I
7254 haven't started using it yet, I confess) the ability to have
7255 @command{tar} use @command{rmt} for it's I/O (I think).
7256
7257 I think the most straightforward thing would be to let me specify a
7258 general set of filters outboard of compression (preferably ordered,
7259 so the order can be automatically reversed on input operations, and
7260 with the options they require specifiable), but beggars shouldn't be
7261 choosers and anything you decide on would be fine with me.
7262
7263 By the way, I like @command{ecc} but if (as the comments say) it can't
7264 deal with loss of block sync, I'm tempted to throw some time at adding
7265 that capability. Supposing I were to actually do such a thing and
7266 get it (apparently) working, do you accept contributed changes to
7267 utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
7268
7269 Isn't that exactly the role of the @value{op-use-compress-prog} option?
7270 I never tried it myself, but I suspect you may want to write a
7271 @var{prog} script or program able to filter stdin to stdout to
7272 way you want. It should recognize the @samp{-d} option, for when
7273 extraction is needed rather than creation.
7274
7275 It has been reported that if one writes compressed data (through the
7276 @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
7277 the DLT compression mode, the data will actually get bigger and one will
7278 end up with less space on the tape.}
7279
7280 @node sparse
7281 @subsection Archiving Sparse Files
7282 @cindex Sparse Files
7283 @UNREVISED
7284
7285 @table @kbd
7286 @item -S
7287 @itemx --sparse
7288 Handle sparse files efficiently.
7289 @end table
7290
7291 This option causes all files to be put in the archive to be tested for
7292 sparseness, and handled specially if they are. The @value{op-sparse}
7293 option is useful when many @code{dbm} files, for example, are being
7294 backed up. Using this option dramatically decreases the amount of
7295 space needed to store such a file.
7296
7297 In later versions, this option may be removed, and the testing and
7298 treatment of sparse files may be done automatically with any special
7299 @acronym{GNU} options. For now, it is an option needing to be specified on
7300 the command line with the creation or updating of an archive.
7301
7302 Files in the filesystem occasionally have ``holes.'' A hole in a file
7303 is a section of the file's contents which was never written. The
7304 contents of a hole read as all zeros. On many operating systems,
7305 actual disk storage is not allocated for holes, but they are counted
7306 in the length of the file. If you archive such a file, @command{tar}
7307 could create an archive longer than the original. To have @command{tar}
7308 attempt to recognize the holes in a file, use @value{op-sparse}. When
7309 you use the @value{op-sparse} option, then, for any file using less
7310 disk space than would be expected from its length, @command{tar} searches
7311 the file for consecutive stretches of zeros. It then records in the
7312 archive for the file where the consecutive stretches of zeros are, and
7313 only archives the ``real contents'' of the file. On extraction (using
7314 @value{op-sparse} is not needed on extraction) any such files have
7315 holes created wherever the continuous stretches of zeros were found.
7316 Thus, if you use @value{op-sparse}, @command{tar} archives won't take
7317 more space than the original.
7318
7319 A file is sparse if it contains blocks of zeros whose existence is
7320 recorded, but that have no space allocated on disk. When you specify
7321 the @value{op-sparse} option in conjunction with the @value{op-create}
7322 operation, @command{tar} tests all files for sparseness while archiving.
7323 If @command{tar} finds a file to be sparse, it uses a sparse representation of
7324 the file in the archive. @value{xref-create}, for more information
7325 about creating archives.
7326
7327 @value{op-sparse} is useful when archiving files, such as dbm files,
7328 likely to contain many nulls. This option dramatically
7329 decreases the amount of space needed to store such an archive.
7330
7331 @quotation
7332 @strong{Please Note:} Always use @value{op-sparse} when performing file
7333 system backups, to avoid archiving the expanded forms of files stored
7334 sparsely in the system.
7335
7336 Even if your system has no sparse files currently, some may be
7337 created in the future. If you use @value{op-sparse} while making file
7338 system backups as a matter of course, you can be assured the archive
7339 will never take more space on the media than the files take on disk
7340 (otherwise, archiving a disk filled with sparse files might take
7341 hundreds of tapes). @FIXME-xref{incremental when node name is set.}
7342 @end quotation
7343
7344 @command{tar} ignores the @value{op-sparse} option when reading an archive.
7345
7346 @table @kbd
7347 @item --sparse
7348 @itemx -S
7349 Files stored sparsely in the file system are represented sparsely in
7350 the archive. Use in conjunction with write operations.
7351 @end table
7352
7353 However, users should be well aware that at archive creation time,
7354 @GNUTAR{} still has to read whole disk file to
7355 locate the @dfn{holes}, and so, even if sparse files use little space
7356 on disk and in the archive, they may sometimes require inordinate
7357 amount of time for reading and examining all-zero blocks of a file.
7358 Although it works, it's painfully slow for a large (sparse) file, even
7359 though the resulting tar archive may be small. (One user reports that
7360 dumping a @file{core} file of over 400 megabytes, but with only about
7361 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
7362 ELC, with full CPU utilization.)
7363
7364 This reading is required in all cases and is not related to the fact
7365 the @value{op-sparse} option is used or not, so by merely @emph{not}
7366 using the option, you are not saving time@footnote{Well! We should say
7367 the whole truth, here. When @value{op-sparse} is selected while creating
7368 an archive, the current @command{tar} algorithm requires sparse files to be
7369 read twice, not once. We hope to develop a new archive format for saving
7370 sparse files in which one pass will be sufficient.}.
7371
7372 Programs like @command{dump} do not have to read the entire file; by
7373 examining the file system directly, they can determine in advance
7374 exactly where the holes are and thus avoid reading through them. The
7375 only data it need read are the actual allocated data blocks.
7376 @GNUTAR{} uses a more portable and straightforward
7377 archiving approach, it would be fairly difficult that it does
7378 otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
7379 1990-12-10:
7380
7381 @quotation
7382 What I did say is that you cannot tell the difference between a hole and an
7383 equivalent number of nulls without reading raw blocks. @code{st_blocks} at
7384 best tells you how many holes there are; it doesn't tell you @emph{where}.
7385 Just as programs may, conceivably, care what @code{st_blocks} is (care
7386 to name one that does?), they may also care where the holes are (I have
7387 no examples of this one either, but it's equally imaginable).
7388
7389 I conclude from this that good archivers are not portable. One can
7390 arguably conclude that if you want a portable program, you can in good
7391 conscience restore files with as many holes as possible, since you can't
7392 get it right.
7393 @end quotation
7394
7395 @node Attributes
7396 @section Handling File Attributes
7397 @UNREVISED
7398
7399 When @command{tar} reads files, this causes them to have the access
7400 times updated. To have @command{tar} attempt to set the access times
7401 back to what they were before they were read, use the
7402 @value{op-atime-preserve} option.
7403
7404 Handling of file attributes
7405
7406 @table @kbd
7407 @item --atime-preserve
7408 Preserve access times on files that are read.
7409 This doesn't work for files that
7410 you don't own, unless you're root, and it doesn't interact with
7411 incremental dumps nicely (@pxref{Backups}), and it can set access or
7412 modification times incorrectly if other programs access the file while
7413 @command{tar} is running; but it is good enough for some purposes.
7414
7415 @item -m
7416 @itemx --touch
7417 Do not extract file modified time.
7418
7419 When this option is used, @command{tar} leaves the modification times
7420 of the files it extracts as the time when the files were extracted,
7421 instead of setting it to the time recorded in the archive.
7422
7423 This option is meaningless with @value{op-list}.
7424
7425 @item --same-owner
7426 Create extracted files with the same ownership they have in the
7427 archive.
7428
7429 This is the default behavior for the superuser,
7430 so this option is meaningful only for non-root users, when @command{tar}
7431 is executed on those systems able to give files away. This is
7432 considered as a security flaw by many people, at least because it
7433 makes quite difficult to correctly account users for the disk space
7434 they occupy. Also, the @code{suid} or @code{sgid} attributes of
7435 files are easily and silently lost when files are given away.
7436
7437 When writing an archive, @command{tar} writes the user id and user name
7438 separately. If it can't find a user name (because the user id is not
7439 in @file{/etc/passwd}), then it does not write one. When restoring,
7440 and doing a @code{chmod} like when you use @value{op-same-permissions},
7441 @FIXME{same-owner?}it tries to look the name (if one was written)
7442 up in @file{/etc/passwd}. If it fails, then it uses the user id
7443 stored in the archive instead.
7444
7445 @item --no-same-owner
7446 @itemx -o
7447 Do not attempt to restore ownership when extracting. This is the
7448 default behavior for ordinary users, so this option has an effect
7449 only for the superuser.
7450
7451 @item --numeric-owner
7452 The @value{op-numeric-owner} option allows (ANSI) archives to be written
7453 without user/group name information or such information to be ignored
7454 when extracting. It effectively disables the generation and/or use
7455 of user/group name information. This option forces extraction using
7456 the numeric ids from the archive, ignoring the names.
7457
7458 This is useful in certain circumstances, when restoring a backup from
7459 an emergency floppy with different passwd/group files for example.
7460 It is otherwise impossible to extract files with the right ownerships
7461 if the password file in use during the extraction does not match the
7462 one belonging to the filesystem(s) being extracted. This occurs,
7463 for example, if you are restoring your files after a major crash and
7464 had booted from an emergency floppy with no password file or put your
7465 disk into another machine to do the restore.
7466
7467 The numeric ids are @emph{always} saved into @command{tar} archives.
7468 The identifying names are added at create time when provided by the
7469 system, unless @value{op-old-archive} is used. Numeric ids could be
7470 used when moving archives between a collection of machines using
7471 a centralized management for attribution of numeric ids to users
7472 and groups. This is often made through using the NIS capabilities.
7473
7474 When making a @command{tar} file for distribution to other sites, it
7475 is sometimes cleaner to use a single owner for all files in the
7476 distribution, and nicer to specify the write permission bits of the
7477 files as stored in the archive independently of their actual value on
7478 the file system. The way to prepare a clean distribution is usually
7479 to have some Makefile rule creating a directory, copying all needed
7480 files in that directory, then setting ownership and permissions as
7481 wanted (there are a lot of possible schemes), and only then making a
7482 @command{tar} archive out of this directory, before cleaning
7483 everything out. Of course, we could add a lot of options to
7484 @GNUTAR{} for fine tuning permissions and ownership.
7485 This is not the good way, I think. @GNUTAR{} is
7486 already crowded with options and moreover, the approach just explained
7487 gives you a great deal of control already.
7488
7489 @item -p
7490 @itemx --same-permissions
7491 @itemx --preserve-permissions
7492 Extract all protection information.
7493
7494 This option causes @command{tar} to set the modes (access permissions) of
7495 extracted files exactly as recorded in the archive. If this option
7496 is not used, the current @code{umask} setting limits the permissions
7497 on extracted files.
7498
7499 This option is meaningless with @value{op-list}.
7500
7501 @item --preserve
7502 Same as both @value{op-same-permissions} and @value{op-same-order}.
7503
7504 The @value{op-preserve} option has no equivalent short option name.
7505 It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
7506
7507 @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
7508
7509 @end table
7510
7511 @node Standard
7512 @section Basic Tar Format
7513 @UNREVISED
7514
7515 While an archive may contain many files, the archive itself is a
7516 single ordinary file. Like any other file, an archive file can be
7517 written to a storage device such as a tape or disk, sent through a
7518 pipe or over a network, saved on the active file system, or even
7519 stored in another archive. An archive file is not easy to read or
7520 manipulate without using the @command{tar} utility or Tar mode in
7521 @acronym{GNU} Emacs.
7522
7523 Physically, an archive consists of a series of file entries terminated
7524 by an end-of-archive entry, which consists of two 512 blocks of zero
7525 bytes. A file
7526 entry usually describes one of the files in the archive (an
7527 @dfn{archive member}), and consists of a file header and the contents
7528 of the file. File headers contain file names and statistics, checksum
7529 information which @command{tar} uses to detect file corruption, and
7530 information about file types.
7531
7532 Archives are permitted to have more than one member with the same
7533 member name. One way this situation can occur is if more than one
7534 version of a file has been stored in the archive. For information
7535 about adding new versions of a file to an archive, see @ref{update}.
7536 @FIXME-xref{To learn more about having more than one archive member with the
7537 same name, see -backup node, when it's written.}
7538
7539 In addition to entries describing archive members, an archive may
7540 contain entries which @command{tar} itself uses to store information.
7541 @value{xref-label}, for an example of such an archive entry.
7542
7543 A @command{tar} archive file contains a series of blocks. Each block
7544 contains @code{BLOCKSIZE} bytes. Although this format may be thought
7545 of as being on magnetic tape, other media are often used.
7546
7547 Each file archived is represented by a header block which describes
7548 the file, followed by zero or more blocks which give the contents
7549 of the file. At the end of the archive file there are two 512-byte blocks
7550 filled with binary zeros as an end-of-file marker. A reasonable system
7551 should write such end-of-file marker at the end of an archive, but
7552 must not assume that such a block exists when reading an archive. In
7553 particular @GNUTAR{} always issues a warning if it does not encounter it.
7554
7555 The blocks may be @dfn{blocked} for physical I/O operations.
7556 Each record of @var{n} blocks (where @var{n} is set by the
7557 @value{op-blocking-factor} option to @command{tar}) is written with a single
7558 @w{@samp{write ()}} operation. On magnetic tapes, the result of
7559 such a write is a single record. When writing an archive,
7560 the last record of blocks should be written at the full size, with
7561 blocks after the zero block containing all zeros. When reading
7562 an archive, a reasonable system should properly handle an archive
7563 whose last record is shorter than the rest, or which contains garbage
7564 records after a zero block.
7565
7566 The header block is defined in C as follows. In the @GNUTAR{}
7567 distribution, this is part of file @file{src/tar.h}:
7568
7569 @smallexample
7570 @include header.texi
7571 @end smallexample
7572
7573 All characters in header blocks are represented by using 8-bit
7574 characters in the local variant of ASCII. Each field within the
7575 structure is contiguous; that is, there is no padding used within
7576 the structure. Each character on the archive medium is stored
7577 contiguously.
7578
7579 Bytes representing the contents of files (after the header block
7580 of each file) are not translated in any way and are not constrained
7581 to represent characters in any character set. The @command{tar} format
7582 does not distinguish text files from binary files, and no translation
7583 of file contents is performed.
7584
7585 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
7586 @code{gname} are null-terminated character strings. All other fields
7587 are zero-filled octal numbers in ASCII. Each numeric field of width
7588 @var{w} contains @var{w} minus 1 digits, and a null.
7589
7590 The @code{name} field is the file name of the file, with directory names
7591 (if any) preceding the file name, separated by slashes.
7592
7593 @FIXME{how big a name before field overflows?}
7594
7595 The @code{mode} field provides nine bits specifying file permissions
7596 and three bits to specify the Set UID, Set GID, and Save Text
7597 (@dfn{sticky}) modes. Values for these bits are defined above.
7598 When special permissions are required to create a file with a given
7599 mode, and the user restoring files from the archive does not hold such
7600 permissions, the mode bit(s) specifying those special permissions
7601 are ignored. Modes which are not supported by the operating system
7602 restoring files from the archive will be ignored. Unsupported modes
7603 should be faked up when creating or updating an archive; e.g.@: the
7604 group permission could be copied from the @emph{other} permission.
7605
7606 The @code{uid} and @code{gid} fields are the numeric user and group
7607 ID of the file owners, respectively. If the operating system does
7608 not support numeric user or group IDs, these fields should be ignored.
7609
7610 The @code{size} field is the size of the file in bytes; linked files
7611 are archived with this field specified as zero. @FIXME-xref{Modifiers, in
7612 particular the @value{op-incremental} option.}
7613
7614 The @code{mtime} field is the modification time of the file at the time
7615 it was archived. It is the ASCII representation of the octal value of
7616 the last time the file was modified, represented as an integer number of
7617 seconds since January 1, 1970, 00:00 Coordinated Universal Time.
7618
7619 The @code{chksum} field is the ASCII representation of the octal value
7620 of the simple sum of all bytes in the header block. Each 8-bit
7621 byte in the header is added to an unsigned integer, initialized to
7622 zero, the precision of which shall be no less than seventeen bits.
7623 When calculating the checksum, the @code{chksum} field is treated as
7624 if it were all blanks.
7625
7626 The @code{typeflag} field specifies the type of file archived. If a
7627 particular implementation does not recognize or permit the specified
7628 type, the file will be extracted as if it were a regular file. As this
7629 action occurs, @command{tar} issues a warning to the standard error.
7630
7631 The @code{atime} and @code{ctime} fields are used in making incremental
7632 backups; they store, respectively, the particular file's access time
7633 and last inode-change time.
7634
7635 The @code{offset} is used by the @value{op-multi-volume} option, when
7636 making a multi-volume archive. The offset is number of bytes into
7637 the file that we need to restart at to continue the file on the next
7638 tape, i.e., where we store the location that a continued file is
7639 continued at.
7640
7641 The following fields were added to deal with sparse files. A file
7642 is @dfn{sparse} if it takes in unallocated blocks which end up being
7643 represented as zeros, i.e., no useful data. A test to see if a file
7644 is sparse is to look at the number blocks allocated for it versus the
7645 number of characters in the file; if there are fewer blocks allocated
7646 for the file than would normally be allocated for a file of that
7647 size, then the file is sparse. This is the method @command{tar} uses to
7648 detect a sparse file, and once such a file is detected, it is treated
7649 differently from non-sparse files.
7650
7651 Sparse files are often @code{dbm} files, or other database-type files
7652 which have data at some points and emptiness in the greater part of
7653 the file. Such files can appear to be very large when an @samp{ls
7654 -l} is done on them, when in truth, there may be a very small amount
7655 of important data contained in the file. It is thus undesirable
7656 to have @command{tar} think that it must back up this entire file, as
7657 great quantities of room are wasted on empty blocks, which can lead
7658 to running out of room on a tape far earlier than is necessary.
7659 Thus, sparse files are dealt with so that these empty blocks are
7660 not written to the tape. Instead, what is written to the tape is a
7661 description, of sorts, of the sparse file: where the holes are, how
7662 big the holes are, and how much data is found at the end of the hole.
7663 This way, the file takes up potentially far less room on the tape,
7664 and when the file is extracted later on, it will look exactly the way
7665 it looked beforehand. The following is a description of the fields
7666 used to handle a sparse file:
7667
7668 The @code{sp} is an array of @code{struct sparse}. Each @code{struct
7669 sparse} contains two 12-character strings which represent an offset
7670 into the file and a number of bytes to be written at that offset.
7671 The offset is absolute, and not relative to the offset in preceding
7672 array element.
7673
7674 The header can hold four of these @code{struct sparse} at the moment;
7675 if more are needed, they are not stored in the header.
7676
7677 The @code{isextended} flag is set when an @code{extended_header}
7678 is needed to deal with a file. Note that this means that this flag
7679 can only be set when dealing with a sparse file, and it is only set
7680 in the event that the description of the file will not fit in the
7681 allotted room for sparse structures in the header. In other words,
7682 an extended_header is needed.
7683
7684 The @code{extended_header} structure is used for sparse files which
7685 need more sparse structures than can fit in the header. The header can
7686 fit 4 such structures; if more are needed, the flag @code{isextended}
7687 gets set and the next block is an @code{extended_header}.
7688
7689 Each @code{extended_header} structure contains an array of 21
7690 sparse structures, along with a similar @code{isextended} flag
7691 that the header had. There can be an indeterminate number of such
7692 @code{extended_header}s to describe a sparse file.
7693
7694 @table @asis
7695
7696 @item @code{REGTYPE}
7697 @itemx @code{AREGTYPE}
7698 These flags represent a regular file. In order to be compatible
7699 with older versions of @command{tar}, a @code{typeflag} value of
7700 @code{AREGTYPE} should be silently recognized as a regular file.
7701 New archives should be created using @code{REGTYPE}. Also, for
7702 backward compatibility, @command{tar} treats a regular file whose name
7703 ends with a slash as a directory.
7704
7705 @item @code{LNKTYPE}
7706 This flag represents a file linked to another file, of any type,
7707 previously archived. Such files are identified in Unix by each
7708 file having the same device and inode number. The linked-to name is
7709 specified in the @code{linkname} field with a trailing null.
7710
7711 @item @code{SYMTYPE}
7712 This represents a symbolic link to another file. The linked-to name
7713 is specified in the @code{linkname} field with a trailing null.
7714
7715 @item @code{CHRTYPE}
7716 @itemx @code{BLKTYPE}
7717 These represent character special files and block special files
7718 respectively. In this case the @code{devmajor} and @code{devminor}
7719 fields will contain the major and minor device numbers respectively.
7720 Operating systems may map the device specifications to their own
7721 local specification, or may ignore the entry.
7722
7723 @item @code{DIRTYPE}
7724 This flag specifies a directory or sub-directory. The directory
7725 name in the @code{name} field should end with a slash. On systems where
7726 disk allocation is performed on a directory basis, the @code{size} field
7727 will contain the maximum number of bytes (which may be rounded to
7728 the nearest disk block allocation unit) which the directory may
7729 hold. A @code{size} field of zero indicates no such limiting. Systems
7730 which do not support limiting in this manner should ignore the
7731 @code{size} field.
7732
7733 @item @code{FIFOTYPE}
7734 This specifies a FIFO special file. Note that the archiving of a
7735 FIFO file archives the existence of this file and not its contents.
7736
7737 @item @code{CONTTYPE}
7738 This specifies a contiguous file, which is the same as a normal
7739 file except that, in operating systems which support it, all its
7740 space is allocated contiguously on the disk. Operating systems
7741 which do not allow contiguous allocation should silently treat this
7742 type as a normal file.
7743
7744 @item @code{A} @dots{} @code{Z}
7745 These are reserved for custom implementations. Some of these are
7746 used in the @acronym{GNU} modified format, as described below.
7747
7748 @end table
7749
7750 Other values are reserved for specification in future revisions of
7751 the P1003 standard, and should not be used by any @command{tar} program.
7752
7753 The @code{magic} field indicates that this archive was output in
7754 the P1003 archive format. If this field contains @code{TMAGIC},
7755 the @code{uname} and @code{gname} fields will contain the ASCII
7756 representation of the owner and group of the file respectively.
7757 If found, the user and group IDs are used rather than the values in
7758 the @code{uid} and @code{gid} fields.
7759
7760 For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
7761 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
7762 IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
7763 (section E.4.48) for @cite{pax - Portable archive interchange}.
7764
7765 @node Extensions
7766 @section @acronym{GNU} Extensions to the Archive Format
7767 @UNREVISED
7768
7769 The @acronym{GNU} format uses additional file types to describe new types of
7770 files in an archive. These are listed below.
7771
7772 @table @code
7773 @item GNUTYPE_DUMPDIR
7774 @itemx 'D'
7775 This represents a directory and a list of files created by the
7776 @value{op-incremental} option. The @code{size} field gives the total
7777 size of the associated list of files. Each file name is preceded by
7778 either a @samp{Y} (the file should be in this archive) or an @samp{N}.
7779 (The file is a directory, or is not stored in the archive.) Each file
7780 name is terminated by a null. There is an additional null after the
7781 last file name.
7782
7783 @item GNUTYPE_MULTIVOL
7784 @itemx 'M'
7785 This represents a file continued from another volume of a multi-volume
7786 archive created with the @value{op-multi-volume} option. The original
7787 type of the file is not given here. The @code{size} field gives the
7788 maximum size of this piece of the file (assuming the volume does
7789 not end before the file is written out). The @code{offset} field
7790 gives the offset from the beginning of the file where this part of
7791 the file begins. Thus @code{size} plus @code{offset} should equal
7792 the original size of the file.
7793
7794 @item GNUTYPE_SPARSE
7795 @itemx 'S'
7796 This flag indicates that we are dealing with a sparse file. Note
7797 that archiving a sparse file requires special operations to find
7798 holes in the file, which mark the positions of these holes, along
7799 with the number of bytes of data to be found after the hole.
7800
7801 @item GNUTYPE_VOLHDR
7802 @itemx 'V'
7803 This file type is used to mark the volume header that was given with
7804 the @value{op-label} option when the archive was created. The @code{name}
7805 field contains the @code{name} given after the @value{op-label} option.
7806 The @code{size} field is zero. Only the first file in each volume
7807 of an archive should have this type.
7808
7809 @end table
7810
7811 You may have trouble reading a @acronym{GNU} format archive on a
7812 non-@acronym{GNU} system if the options @value{op-incremental},
7813 @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
7814 used when writing the archive. In general, if @command{tar} does not
7815 use the @acronym{GNU}-added fields of the header, other versions of
7816 @command{tar} should be able to read the archive. Otherwise, the
7817 @command{tar} program will give an error, the most likely one being a
7818 checksum error.
7819
7820 @node cpio
7821 @section Comparison of @command{tar} and @command{cpio}
7822 @UNREVISED
7823
7824 @FIXME{Reorganize the following material}
7825
7826 The @command{cpio} archive formats, like @command{tar}, do have maximum
7827 pathname lengths. The binary and old ASCII formats have a max path
7828 length of 256, and the new ASCII and CRC ASCII formats have a max
7829 path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
7830 with arbitrary pathname lengths, but other @command{cpio} implementations
7831 may crash unexplainedly trying to read them.
7832
7833 @command{tar} handles symbolic links in the form in which it comes in BSD;
7834 @command{cpio} doesn't handle symbolic links in the form in which it comes
7835 in System V prior to SVR4, and some vendors may have added symlinks
7836 to their system without enhancing @command{cpio} to know about them.
7837 Others may have enhanced it in a way other than the way I did it
7838 at Sun, and which was adopted by AT&T (and which is, I think, also
7839 present in the @command{cpio} that Berkeley picked up from AT&T and put
7840 into a later BSD release---I think I gave them my changes).
7841
7842 (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
7843 can handle @command{tar} format input, and write it on output, and it
7844 probably handles symbolic links. They may not have bothered doing
7845 anything to enhance @command{tar} as a result.)
7846
7847 @command{cpio} handles special files; traditional @command{tar} doesn't.
7848
7849 @command{tar} comes with V7, System III, System V, and BSD source;
7850 @command{cpio} comes only with System III, System V, and later BSD
7851 (4.3-tahoe and later).
7852
7853 @command{tar}'s way of handling multiple hard links to a file can handle
7854 file systems that support 32-bit inumbers (e.g., the BSD file system);
7855 @command{cpio}s way requires you to play some games (in its "binary"
7856 format, i-numbers are only 16 bits, and in its "portable ASCII" format,
7857 they're 18 bits---it would have to play games with the "file system ID"
7858 field of the header to make sure that the file system ID/i-number pairs
7859 of different files were always different), and I don't know which
7860 @command{cpio}s, if any, play those games. Those that don't might get
7861 confused and think two files are the same file when they're not, and
7862 make hard links between them.
7863
7864 @command{tar}s way of handling multiple hard links to a file places only
7865 one copy of the link on the tape, but the name attached to that copy
7866 is the @emph{only} one you can use to retrieve the file; @command{cpio}s
7867 way puts one copy for every link, but you can retrieve it using any
7868 of the names.
7869
7870 @quotation
7871 What type of check sum (if any) is used, and how is this calculated.
7872 @end quotation
7873
7874 See the attached manual pages for @command{tar} and @command{cpio} format.
7875 @command{tar} uses a checksum which is the sum of all the bytes in the
7876 @command{tar} header for a file; @command{cpio} uses no checksum.
7877
7878 @quotation
7879 If anyone knows why @command{cpio} was made when @command{tar} was present
7880 at the unix scene,
7881 @end quotation
7882
7883 It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
7884 generally-available version of UNIX had @command{tar} at the time. I don't
7885 know whether any version that was generally available @emph{within AT&T}
7886 had @command{tar}, or, if so, whether the people within AT&T who did
7887 @command{cpio} knew about it.
7888
7889 On restore, if there is a corruption on a tape @command{tar} will stop at
7890 that point, while @command{cpio} will skip over it and try to restore the
7891 rest of the files.
7892
7893 The main difference is just in the command syntax and header format.
7894
7895 @command{tar} is a little more tape-oriented in that everything is blocked
7896 to start on a record boundary.
7897
7898 @quotation
7899 Is there any differences between the ability to recover crashed
7900 archives between the two of them. (Is there any chance of recovering
7901 crashed archives at all.)
7902 @end quotation
7903
7904 Theoretically it should be easier under @command{tar} since the blocking
7905 lets you find a header with some variation of @samp{dd skip=@var{nn}}.
7906 However, modern @command{cpio}'s and variations have an option to just
7907 search for the next file header after an error with a reasonable chance
7908 of resyncing. However, lots of tape driver software won't allow you to
7909 continue past a media error which should be the only reason for getting
7910 out of sync unless a file changed sizes while you were writing the
7911 archive.
7912
7913 @quotation
7914 If anyone knows why @command{cpio} was made when @command{tar} was present
7915 at the unix scene, please tell me about this too.
7916 @end quotation
7917
7918 Probably because it is more media efficient (by not blocking everything
7919 and using only the space needed for the headers where @command{tar}
7920 always uses 512 bytes per file header) and it knows how to archive
7921 special files.
7922
7923 You might want to look at the freely available alternatives. The
7924 major ones are @command{afio}, @GNUTAR{}, and
7925 @command{pax}, each of which have their own extensions with some
7926 backwards compatibility.
7927
7928 Sparse files were @command{tar}red as sparse files (which you can
7929 easily test, because the resulting archive gets smaller, and
7930 @acronym{GNU} @command{cpio} can no longer read it).
7931
7932 @node Media
7933 @chapter Tapes and Other Archive Media
7934 @UNREVISED
7935
7936 A few special cases about tape handling warrant more detailed
7937 description. These special cases are discussed below.
7938
7939 Many complexities surround the use of @command{tar} on tape drives. Since
7940 the creation and manipulation of archives located on magnetic tape was
7941 the original purpose of @command{tar}, it contains many features making
7942 such manipulation easier.
7943
7944 Archives are usually written on dismountable media---tape cartridges,
7945 mag tapes, or floppy disks.
7946
7947 The amount of data a tape or disk holds depends not only on its size,
7948 but also on how it is formatted. A 2400 foot long reel of mag tape
7949 holds 40 megabytes of data when formatted at 1600 bits per inch. The
7950 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
7951
7952 Magnetic media are re-usable---once the archive on a tape is no longer
7953 needed, the archive can be erased and the tape or disk used over.
7954 Media quality does deteriorate with use, however. Most tapes or disks
7955 should be discarded when they begin to produce data errors. EXABYTE
7956 tape cartridges should be discarded when they generate an @dfn{error
7957 count} (number of non-usable bits) of more than 10k.
7958
7959 Magnetic media are written and erased using magnetic fields, and
7960 should be protected from such fields to avoid damage to stored data.
7961 Sticking a floppy disk to a filing cabinet using a magnet is probably
7962 not a good idea.
7963
7964 @menu
7965 * Device:: Device selection and switching
7966 * Remote Tape Server::
7967 * Common Problems and Solutions::
7968 * Blocking:: Blocking
7969 * Many:: Many archives on one tape
7970 * Using Multiple Tapes:: Using Multiple Tapes
7971 * label:: Including a Label in the Archive
7972 * verify::
7973 * Write Protection::
7974 @end menu
7975
7976 @node Device
7977 @section Device Selection and Switching
7978 @UNREVISED
7979
7980 @table @kbd
7981 @item -f [@var{hostname}:]@var{file}
7982 @itemx --file=[@var{hostname}:]@var{file}
7983 Use archive file or device @var{file} on @var{hostname}.
7984 @end table
7985
7986 This option is used to specify the file name of the archive @command{tar}
7987 works on.
7988
7989 If the file name is @samp{-}, @command{tar} reads the archive from standard
7990 input (when listing or extracting), or writes it to standard output
7991 (when creating). If the @samp{-} file name is given when updating an
7992 archive, @command{tar} will read the original archive from its standard
7993 input, and will write the entire new archive to its standard output.
7994
7995 If the file name contains a @samp{:}, it is interpreted as
7996 @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
7997 sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
7998 either case, @command{tar} will invoke the command @command{rsh} (or
7999 @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
8000 machine. If you give an alternate login name, it will be given to the
8001 @command{rsh}.
8002 Naturally, the remote machine must have an executable
8003 @command{/usr/libexec/rmt}. This program is free software from the
8004 University of California, and a copy of the source code can be found
8005 with the sources for @command{tar}; it's compiled and installed by default.
8006 The exact path to this utility is determined when configuring the package.
8007 It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
8008 your installation prefix. This location may also be overridden at
8009 runtime by using @value{op-rmt-command} option (@xref{Option Summary,
8010 ---rmt-command}, for detailed description of this option. @xref{Remote
8011 Tape Server}, for the description of @command{rmt} command).
8012
8013 If this option is not given, but the environment variable @env{TAPE}
8014 is set, its value is used; otherwise, old versions of @command{tar}
8015 used a default archive name (which was picked when @command{tar} was
8016 compiled). The default is normally set up to be the @dfn{first} tape
8017 drive or other transportable I/O medium on the system.
8018
8019 Starting with version 1.11.5, @GNUTAR{} uses
8020 standard input and standard output as the default device, and I will
8021 not try anymore supporting automatic device detection at installation
8022 time. This was failing really in too many cases, it was hopeless.
8023 This is now completely left to the installer to override standard
8024 input and standard output for default device, if this seems
8025 preferable. Further, I think @emph{most} actual usages of
8026 @command{tar} are done with pipes or disks, not really tapes,
8027 cartridges or diskettes.
8028
8029 Some users think that using standard input and output is running
8030 after trouble. This could lead to a nasty surprise on your screen if
8031 you forget to specify an output file name---especially if you are going
8032 through a network or terminal server capable of buffering large amounts
8033 of output. We had so many bug reports in that area of configuring
8034 default tapes automatically, and so many contradicting requests, that
8035 we finally consider the problem to be portably intractable. We could
8036 of course use something like @samp{/dev/tape} as a default, but this
8037 is @emph{also} running after various kind of trouble, going from hung
8038 processes to accidental destruction of real tapes. After having seen
8039 all this mess, using standard input and output as a default really
8040 sounds like the only clean choice left, and a very useful one too.
8041
8042 @GNUTAR{} reads and writes archive in records, I
8043 suspect this is the main reason why block devices are preferred over
8044 character devices. Most probably, block devices are more efficient
8045 too. The installer could also check for @samp{DEFTAPE} in
8046 @file{<sys/mtio.h>}.
8047
8048 @table @kbd
8049 @item --force-local
8050 Archive file is local even if it contains a colon.
8051
8052 @item --rsh-command=@var{command}
8053 Use remote @var{command} instead of @command{rsh}. This option exists
8054 so that people who use something other than the standard @command{rsh}
8055 (e.g., a Kerberized @command{rsh}) can access a remote device.
8056
8057 When this command is not used, the shell command found when
8058 the @command{tar} program was installed is used instead. This is
8059 the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
8060 @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
8061 The installer may have overridden this by defining the environment
8062 variable @env{RSH} @emph{at installation time}.
8063
8064 @item -[0-7][lmh]
8065 Specify drive and density.
8066
8067 @item -M
8068 @itemx --multi-volume
8069 Create/list/extract multi-volume archive.
8070
8071 This option causes @command{tar} to write a @dfn{multi-volume} archive---one
8072 that may be larger than will fit on the medium used to hold it.
8073 @xref{Multi-Volume Archives}.
8074
8075 @item -L @var{num}
8076 @itemx --tape-length=@var{num}
8077 Change tape after writing @var{num} x 1024 bytes.
8078
8079 This option might be useful when your tape drivers do not properly
8080 detect end of physical tapes. By being slightly conservative on the
8081 maximum tape length, you might avoid the problem entirely.
8082
8083 @item -F @var{file}
8084 @itemx --info-script=@var{file}
8085 @itemx --new-volume-script=@var{file}
8086 Execute @file{file} at end of each tape. If @file{file} exits with
8087 nonzero status, exit. This implies @value{op-multi-volume}.
8088 @end table
8089
8090 @node Remote Tape Server
8091 @section The Remote Tape Server
8092
8093 @cindex remote tape drive
8094 @pindex rmt
8095 In order to access the tape drive on a remote machine, @command{tar}
8096 uses the remote tape server written at the University of California at
8097 Berkeley. The remote tape server must be installed as
8098 @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
8099 want to use. @command{tar} calls @command{rmt} by running an
8100 @command{rsh} or @command{remsh} to the remote machine, optionally
8101 using a different login name if one is supplied.
8102
8103 A copy of the source for the remote tape server is provided. It is
8104 Copyright @copyright{} 1983 by the Regents of the University of
8105 California, but can be freely distributed. It is compiled and
8106 installed by default.
8107
8108 @cindex absolute file names
8109 Unless you use the @value{op-absolute-names} option, @GNUTAR{}
8110 will not allow you to create an archive that contains
8111 absolute file names (a file name beginning with @samp{/}.) If you try,
8112 @command{tar} will automatically remove the leading @samp{/} from the
8113 file names it stores in the archive. It will also type a warning
8114 message telling you what it is doing.
8115
8116 When reading an archive that was created with a different
8117 @command{tar} program, @GNUTAR{} automatically
8118 extracts entries in the archive which have absolute file names as if
8119 the file names were not absolute. This is an important feature. A
8120 visitor here once gave a @command{tar} tape to an operator to restore;
8121 the operator used Sun @command{tar} instead of @GNUTAR{},
8122 and the result was that it replaced large portions of
8123 our @file{/bin} and friends with versions from the tape; needless to
8124 say, we were unhappy about having to recover the file system from
8125 backup tapes.
8126
8127 For example, if the archive contained a file @file{/usr/bin/computoy},
8128 @GNUTAR{} would extract the file to @file{usr/bin/computoy},
8129 relative to the current directory. If you want to extract the files in
8130 an archive to the same absolute names that they had when the archive
8131 was created, you should do a @samp{cd /} before extracting the files
8132 from the archive, or you should either use the @value{op-absolute-names}
8133 option, or use the command @samp{tar -C / @dots{}}.
8134
8135 @cindex Ultrix 3.1 and write failure
8136 Some versions of Unix (Ultrix 3.1 is known to have this problem),
8137 can claim that a short write near the end of a tape succeeded,
8138 when it actually failed. This will result in the -M option not
8139 working correctly. The best workaround at the moment is to use a
8140 significantly larger blocking factor than the default 20.
8141
8142 In order to update an archive, @command{tar} must be able to backspace the
8143 archive in order to reread or rewrite a record that was just read (or
8144 written). This is currently possible only on two kinds of files: normal
8145 disk files (or any other file that can be backspaced with @samp{lseek}),
8146 and industry-standard 9-track magnetic tape (or any other kind of tape
8147 that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
8148
8149 This means that the @value{op-append}, @value{op-update},
8150 @value{op-concatenate}, and @value{op-delete} commands will not work on any
8151 other kind of file. Some media simply cannot be backspaced, which
8152 means these commands and options will never be able to work on them.
8153 These non-backspacing media include pipes and cartridge tape drives.
8154
8155 Some other media can be backspaced, and @command{tar} will work on them
8156 once @command{tar} is modified to do so.
8157
8158 Archives created with the @value{op-multi-volume}, @value{op-label}, and
8159 @value{op-incremental} options may not be readable by other version
8160 of @command{tar}. In particular, restoring a file that was split over
8161 a volume boundary will require some careful work with @command{dd}, if
8162 it can be done at all. Other versions of @command{tar} may also create
8163 an empty file whose name is that of the volume header. Some versions
8164 of @command{tar} may create normal files instead of directories archived
8165 with the @value{op-incremental} option.
8166
8167 @node Common Problems and Solutions
8168 @section Some Common Problems and their Solutions
8169
8170 @ifclear PUBLISH
8171
8172 @format
8173 errors from system:
8174 permission denied
8175 no such file or directory
8176 not owner
8177
8178 errors from @command{tar}:
8179 directory checksum error
8180 header format error
8181
8182 errors from media/system:
8183 i/o error
8184 device busy
8185 @end format
8186
8187 @end ifclear
8188
8189 @node Blocking
8190 @section Blocking
8191 @UNREVISED
8192
8193 @dfn{Block} and @dfn{record} terminology is rather confused, and it
8194 is also confusing to the expert reader. On the other hand, readers
8195 who are new to the field have a fresh mind, and they may safely skip
8196 the next two paragraphs, as the remainder of this manual uses those
8197 two terms in a quite consistent way.
8198
8199 John Gilmore, the writer of the public domain @command{tar} from which
8200 @GNUTAR{} was originally derived, wrote (June 1995):
8201
8202 @quotation
8203 The nomenclature of tape drives comes from IBM, where I believe
8204 they were invented for the IBM 650 or so. On IBM mainframes, what
8205 is recorded on tape are tape blocks. The logical organization of
8206 data is into records. There are various ways of putting records into
8207 blocks, including @code{F} (fixed sized records), @code{V} (variable
8208 sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
8209 to a block), @code{VB} (variable size records, @var{n} to a block),
8210 @code{VSB} (variable spanned blocked: variable sized records that can
8211 occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
8212 parameter specified this to the operating system.
8213
8214 The Unix man page on @command{tar} was totally confused about this.
8215 When I wrote @code{PD TAR}, I used the historically correct terminology
8216 (@command{tar} writes data records, which are grouped into blocks).
8217 It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
8218 here), and now Fran@,{c}ois has migrated that terminology back
8219 into the source code too.
8220 @end quotation
8221
8222 The term @dfn{physical block} means the basic transfer chunk from or
8223 to a device, after which reading or writing may stop without anything
8224 being lost. In this manual, the term @dfn{block} usually refers to
8225 a disk physical block, @emph{assuming} that each disk block is 512
8226 bytes in length. It is true that some disk devices have different
8227 physical blocks, but @command{tar} ignore these differences in its own
8228 format, which is meant to be portable, so a @command{tar} block is always
8229 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
8230 The term @dfn{logical block} often represents the basic chunk of
8231 allocation of many disk blocks as a single entity, which the operating
8232 system treats somewhat atomically; this concept is only barely used
8233 in @GNUTAR{}.
8234
8235 The term @dfn{physical record} is another way to speak of a physical
8236 block, those two terms are somewhat interchangeable. In this manual,
8237 the term @dfn{record} usually refers to a tape physical block,
8238 @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
8239 It is true that archives may be put on disk or used with pipes,
8240 but nevertheless, @command{tar} tries to read and write the archive one
8241 @dfn{record} at a time, whatever the medium in use. One record is made
8242 up of an integral number of blocks, and this operation of putting many
8243 disk blocks into a single tape block is called @dfn{reblocking}, or
8244 more simply, @dfn{blocking}. The term @dfn{logical record} refers to
8245 the logical organization of many characters into something meaningful
8246 to the application. The term @dfn{unit record} describes a small set
8247 of characters which are transmitted whole to or by the application,
8248 and often refers to a line of text. Those two last terms are unrelated
8249 to what we call a @dfn{record} in @GNUTAR{}.
8250
8251 When writing to tapes, @command{tar} writes the contents of the archive
8252 in chunks known as @dfn{records}. To change the default blocking
8253 factor, use the @value{op-blocking-factor} option. Each record will
8254 then be composed of @var{512-size} blocks. (Each @command{tar} block is
8255 512 bytes. @xref{Standard}.) Each file written to the archive uses
8256 at least one full record. As a result, using a larger record size
8257 can result in more wasted space for small files. On the other hand, a
8258 larger record size can often be read and written much more efficiently.
8259
8260 Further complicating the problem is that some tape drives ignore the
8261 blocking entirely. For these, a larger record size can still improve
8262 performance (because the software layers above the tape drive still
8263 honor the blocking), but not as dramatically as on tape drives that
8264 honor blocking.
8265
8266 When reading an archive, @command{tar} can usually figure out the
8267 record size on itself. When this is the case, and a non-standard
8268 record size was used when the archive was created, @command{tar} will
8269 print a message about a non-standard blocking factor, and then operate
8270 normally. On some tape devices, however, @command{tar} cannot figure
8271 out the record size itself. On most of those, you can specify a
8272 blocking factor (with @value{op-blocking-factor}) larger than the
8273 actual blocking factor, and then use the @value{op-read-full-records}
8274 option. (If you specify a blocking factor with
8275 @value{op-blocking-factor} and don't use the
8276 @value{op-read-full-records} option, then @command{tar} will not
8277 attempt to figure out the recording size itself.) On some devices,
8278 you must always specify the record size exactly with
8279 @value{op-blocking-factor} when reading, because @command{tar} cannot
8280 figure it out. In any case, use @value{op-list} before doing any
8281 extractions to see whether @command{tar} is reading the archive
8282 correctly.
8283
8284 @command{tar} blocks are all fixed size (512 bytes), and its scheme for
8285 putting them into records is to put a whole number of them (one or
8286 more) into each record. @command{tar} records are all the same size;
8287 at the end of the file there's a block containing all zeros, which
8288 is how you tell that the remainder of the last record(s) are garbage.
8289
8290 In a standard @command{tar} file (no options), the block size is 512
8291 and the record size is 10240, for a blocking factor of 20. What the
8292 @value{op-blocking-factor} option does is sets the blocking factor,
8293 changing the record size while leaving the block size at 512 bytes.
8294 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
8295 most tape drives these days prefer much bigger records in order to
8296 stream and not waste tape. When writing tapes for myself, some tend
8297 to use a factor of the order of 2048, say, giving a record size of
8298 around one megabyte.
8299
8300 If you use a blocking factor larger than 20, older @command{tar}
8301 programs might not be able to read the archive, so we recommend this
8302 as a limit to use in practice. @GNUTAR{}, however,
8303 will support arbitrarily large record sizes, limited only by the
8304 amount of virtual memory or the physical characteristics of the tape
8305 device.
8306
8307 @menu
8308 * Format Variations:: Format Variations
8309 * Blocking Factor:: The Blocking Factor of an Archive
8310 @end menu
8311
8312 @node Format Variations
8313 @subsection Format Variations
8314 @cindex Format Parameters
8315 @cindex Format Options
8316 @cindex Options, archive format specifying
8317 @cindex Options, format specifying
8318 @UNREVISED
8319
8320 Format parameters specify how an archive is written on the archive
8321 media. The best choice of format parameters will vary depending on
8322 the type and number of files being archived, and on the media used to
8323 store the archive.
8324
8325 To specify format parameters when accessing or creating an archive,
8326 you can use the options described in the following sections.
8327 If you do not specify any format parameters, @command{tar} uses
8328 default parameters. You cannot modify a compressed archive.
8329 If you create an archive with the @value{op-blocking-factor} option
8330 specified (@value{pxref-blocking-factor}), you must specify that
8331 blocking-factor when operating on the archive. @xref{Formats}, for other
8332 examples of format parameter considerations.
8333
8334 @node Blocking Factor
8335 @subsection The Blocking Factor of an Archive
8336 @cindex Blocking Factor
8337 @cindex Record Size
8338 @cindex Number of blocks per record
8339 @cindex Number of bytes per record
8340 @cindex Bytes per record
8341 @cindex Blocks per record
8342 @UNREVISED
8343
8344 The data in an archive is grouped into blocks, which are 512 bytes.
8345 Blocks are read and written in whole number multiples called
8346 @dfn{records}. The number of blocks in a record (ie. the size of a
8347 record in units of 512 bytes) is called the @dfn{blocking factor}.
8348 The @value{op-blocking-factor} option specifies the blocking factor of
8349 an archive. The default blocking factor is typically 20 (ie.@:
8350 10240 bytes), but can be specified at installation. To find out
8351 the blocking factor of an existing archive, use @samp{tar --list
8352 --file=@var{archive-name}}. This may not work on some devices.
8353
8354 Records are separated by gaps, which waste space on the archive media.
8355 If you are archiving on magnetic tape, using a larger blocking factor
8356 (and therefore larger records) provides faster throughput and allows you
8357 to fit more data on a tape (because there are fewer gaps). If you are
8358 archiving on cartridge, a very large blocking factor (say 126 or more)
8359 greatly increases performance. A smaller blocking factor, on the other
8360 hand, may be useful when archiving small files, to avoid archiving lots
8361 of nulls as @command{tar} fills out the archive to the end of the record.
8362 In general, the ideal record size depends on the size of the
8363 inter-record gaps on the tape you are using, and the average size of the
8364 files you are archiving. @xref{create}, for information on
8365 writing archives.
8366
8367 @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
8368
8369 Archives with blocking factors larger than 20 cannot be read
8370 by very old versions of @command{tar}, or by some newer versions
8371 of @command{tar} running on old machines with small address spaces.
8372 With @GNUTAR{}, the blocking factor of an archive is limited
8373 only by the maximum record size of the device containing the archive,
8374 or by the amount of available virtual memory.
8375
8376 Also, on some systems, not using adequate blocking factors, as sometimes
8377 imposed by the device drivers, may yield unexpected diagnostics. For
8378 example, this has been reported:
8379
8380 @smallexample
8381 Cannot write to /dev/dlt: Invalid argument
8382 @end smallexample
8383
8384 @noindent
8385 In such cases, it sometimes happen that the @command{tar} bundled by
8386 the system is aware of block size idiosyncrasies, while @GNUTAR{}
8387 requires an explicit specification for the block size,
8388 which it cannot guess. This yields some people to consider
8389 @GNUTAR{} is misbehaving, because by comparison,
8390 @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
8391 for example, might resolve the problem.
8392
8393 If you use a non-default blocking factor when you create an archive, you
8394 must specify the same blocking factor when you modify that archive. Some
8395 archive devices will also require you to specify the blocking factor when
8396 reading that archive, however this is not typically the case. Usually, you
8397 can use @value{op-list} without specifying a blocking factor---@command{tar}
8398 reports a non-default record size and then lists the archive members as
8399 it would normally. To extract files from an archive with a non-standard
8400 blocking factor (particularly if you're not sure what the blocking factor
8401 is), you can usually use the @value{op-read-full-records} option while
8402 specifying a blocking factor larger then the blocking factor of the archive
8403 (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
8404 @xref{list}, for more information on the @value{op-list}
8405 operation. @xref{Reading}, for a more detailed explanation of that option.
8406
8407 @table @kbd
8408 @item --blocking-factor=@var{number}
8409 @itemx -b @var{number}
8410 Specifies the blocking factor of an archive. Can be used with any
8411 operation, but is usually not necessary with @value{op-list}.
8412 @end table
8413
8414 Device blocking
8415
8416 @table @kbd
8417 @item -b @var{blocks}
8418 @itemx --blocking-factor=@var{blocks}
8419 Set record size to @math{@var{blocks} * 512} bytes.
8420
8421 This option is used to specify a @dfn{blocking factor} for the archive.
8422 When reading or writing the archive, @command{tar}, will do reads and writes
8423 of the archive in records of @math{@var{block}*512} bytes. This is true
8424 even when the archive is compressed. Some devices requires that all
8425 write operations be a multiple of a certain size, and so, @command{tar}
8426 pads the archive out to the next record boundary.
8427
8428 The default blocking factor is set when @command{tar} is compiled, and is
8429 typically 20. Blocking factors larger than 20 cannot be read by very
8430 old versions of @command{tar}, or by some newer versions of @command{tar}
8431 running on old machines with small address spaces.
8432
8433 With a magnetic tape, larger records give faster throughput and fit
8434 more data on a tape (because there are fewer inter-record gaps).
8435 If the archive is in a disk file or a pipe, you may want to specify
8436 a smaller blocking factor, since a large one will result in a large
8437 number of null bytes at the end of the archive.
8438
8439 When writing cartridge or other streaming tapes, a much larger
8440 blocking factor (say 126 or more) will greatly increase performance.
8441 However, you must specify the same blocking factor when reading or
8442 updating the archive.
8443
8444 Apparently, Exabyte drives have a physical block size of 8K bytes.
8445 If we choose our blocksize as a multiple of 8k bytes, then the problem
8446 seems to disappear. Id est, we are using block size of 112 right
8447 now, and we haven't had the problem since we switched@dots{}
8448
8449 With @GNUTAR{} the blocking factor is limited only
8450 by the maximum record size of the device containing the archive, or by
8451 the amount of available virtual memory.
8452
8453 However, deblocking or reblocking is virtually avoided in a special
8454 case which often occurs in practice, but which requires all the
8455 following conditions to be simultaneously true:
8456 @itemize @bullet
8457 @item
8458 the archive is subject to a compression option,
8459 @item
8460 the archive is not handled through standard input or output, nor
8461 redirected nor piped,
8462 @item
8463 the archive is directly handled to a local disk, instead of any special
8464 device,
8465 @item
8466 @value{op-blocking-factor} is not explicitly specified on the @command{tar}
8467 invocation.
8468 @end itemize
8469
8470 If the output goes directly to a local disk, and not through
8471 stdout, then the last write is not extended to a full record size.
8472 Otherwise, reblocking occurs. Here are a few other remarks on this
8473 topic:
8474
8475 @itemize @bullet
8476
8477 @item
8478 @command{gzip} will complain about trailing garbage if asked to
8479 uncompress a compressed archive on tape, there is an option to turn
8480 the message off, but it breaks the regularity of simply having to use
8481 @samp{@var{prog} -d} for decompression. It would be nice if gzip was
8482 silently ignoring any number of trailing zeros. I'll ask Jean-loup
8483 Gailly, by sending a copy of this message to him.
8484
8485 @item
8486 @command{compress} does not show this problem, but as Jean-loup pointed
8487 out to Michael, @samp{compress -d} silently adds garbage after
8488 the result of decompression, which tar ignores because it already
8489 recognized its end-of-file indicator. So this bug may be safely
8490 ignored.
8491
8492 @item
8493 @samp{gzip -d -q} will be silent about the trailing zeros indeed,
8494 but will still return an exit status of 2 which tar reports in turn.
8495 @command{tar} might ignore the exit status returned, but I hate doing
8496 that, as it weakens the protection @command{tar} offers users against
8497 other possible problems at decompression time. If @command{gzip} was
8498 silently skipping trailing zeros @emph{and} also avoiding setting the
8499 exit status in this innocuous case, that would solve this situation.
8500
8501 @item
8502 @command{tar} should become more solid at not stopping to read a pipe at
8503 the first null block encountered. This inelegantly breaks the pipe.
8504 @command{tar} should rather drain the pipe out before exiting itself.
8505 @end itemize
8506
8507 @item -i
8508 @itemx --ignore-zeros
8509 Ignore blocks of zeros in archive (means EOF).
8510
8511 The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
8512 of zeros in the archive. Normally a block of zeros indicates the
8513 end of the archive, but when reading a damaged archive, or one which
8514 was created by concatenating several archives together, this option
8515 allows @command{tar} to read the entire archive. This option is not on
8516 by default because many versions of @command{tar} write garbage after
8517 the zeroed blocks.
8518
8519 Note that this option causes @command{tar} to read to the end of the
8520 archive file, which may sometimes avoid problems when multiple files
8521 are stored on a single physical tape.
8522
8523 @item -B
8524 @itemx --read-full-records
8525 Reblock as we read (for reading 4.2BSD pipes).
8526
8527 If @value{op-read-full-records} is used, @command{tar} will not panic if an
8528 attempt to read a record from the archive does not return a full record.
8529 Instead, @command{tar} will keep reading until it has obtained a full
8530 record.
8531
8532 This option is turned on by default when @command{tar} is reading
8533 an archive from standard input, or from a remote machine. This is
8534 because on BSD Unix systems, a read of a pipe will return however
8535 much happens to be in the pipe, even if it is less than @command{tar}
8536 requested. If this option was not used, @command{tar} would fail as
8537 soon as it read an incomplete record from the pipe.
8538
8539 This option is also useful with the commands for updating an archive.
8540
8541 @end table
8542
8543 Tape blocking
8544
8545 @FIXME{Appropriate options should be moved here from elsewhere.}
8546
8547 @cindex blocking factor
8548 @cindex tape blocking
8549
8550 When handling various tapes or cartridges, you have to take care of
8551 selecting a proper blocking, that is, the number of disk blocks you
8552 put together as a single tape block on the tape, without intervening
8553 tape gaps. A @dfn{tape gap} is a small landing area on the tape
8554 with no information on it, used for decelerating the tape to a
8555 full stop, and for later regaining the reading or writing speed.
8556 When the tape driver starts reading a record, the record has to
8557 be read whole without stopping, as a tape gap is needed to stop the
8558 tape motion without loosing information.
8559
8560 @cindex Exabyte blocking
8561 @cindex DAT blocking
8562 Using higher blocking (putting more disk blocks per tape block) will use
8563 the tape more efficiently as there will be less tape gaps. But reading
8564 such tapes may be more difficult for the system, as more memory will be
8565 required to receive at once the whole record. Further, if there is a
8566 reading error on a huge record, this is less likely that the system will
8567 succeed in recovering the information. So, blocking should not be too
8568 low, nor it should be too high. @command{tar} uses by default a blocking of
8569 20 for historical reasons, and it does not really matter when reading or
8570 writing to disk. Current tape technology would easily accommodate higher
8571 blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
8572 We were told that for some DLT drives, the blocking should be a multiple
8573 of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
8574 Other manufacturers may use different recommendations for the same tapes.
8575 This might also depends of the buffering techniques used inside modern
8576 tape controllers. Some imposes a minimum blocking, or a maximum blocking.
8577 Others request blocking to be some exponent of two.
8578
8579 So, there is no fixed rule for blocking. But blocking at read time
8580 should ideally be the same as blocking used at write time. At one place
8581 I know, with a wide variety of equipment, they found it best to use a
8582 blocking of 32 to guarantee that their tapes are fully interchangeable.
8583
8584 I was also told that, for recycled tapes, prior erasure (by the same
8585 drive unit that will be used to create the archives) sometimes lowers
8586 the error rates observed at rewriting time.
8587
8588 I might also use @samp{--number-blocks} instead of
8589 @samp{--block-number}, so @samp{--block} will then expand to
8590 @samp{--blocking-factor} unambiguously.
8591
8592 @node Many
8593 @section Many Archives on One Tape
8594
8595 @FIXME{Appropriate options should be moved here from elsewhere.}
8596
8597 @findex ntape @r{device}
8598 Most tape devices have two entries in the @file{/dev} directory, or
8599 entries that come in pairs, which differ only in the minor number for
8600 this device. Let's take for example @file{/dev/tape}, which often
8601 points to the only or usual tape device of a given system. There might
8602 be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
8603 name is the @emph{rewinding} version of the device, while the name
8604 having @samp{nr} in it is the @emph{no rewinding} version of the same
8605 device.
8606
8607 A rewinding tape device will bring back the tape to its beginning point
8608 automatically when this device is opened or closed. Since @command{tar}
8609 opens the archive file before using it and closes it afterwards, this
8610 means that a simple:
8611
8612 @smallexample
8613 $ @kbd{tar cf /dev/tape @var{directory}}
8614 @end smallexample
8615
8616 @noindent
8617 will reposition the tape to its beginning both prior and after saving
8618 @var{directory} contents to it, thus erasing prior tape contents and
8619 making it so that any subsequent write operation will destroy what has
8620 just been saved.
8621
8622 @cindex tape positioning
8623 So, a rewinding device is normally meant to hold one and only one file.
8624 If you want to put more than one @command{tar} archive on a given tape, you
8625 will need to avoid using the rewinding version of the tape device. You
8626 will also have to pay special attention to tape positioning. Errors in
8627 positioning may overwrite the valuable data already on your tape. Many
8628 people, burnt by past experiences, will only use rewinding devices and
8629 limit themselves to one file per tape, precisely to avoid the risk of
8630 such errors. Be fully aware that writing at the wrong position on a
8631 tape loses all information past this point and most probably until the
8632 end of the tape, and this destroyed information @emph{cannot} be
8633 recovered.
8634
8635 To save @var{directory-1} as a first archive at the beginning of a
8636 tape, and leave that tape ready for a second archive, you should use:
8637
8638 @smallexample
8639 $ @kbd{mt -f /dev/nrtape rewind}
8640 $ @kbd{tar cf /dev/nrtape @var{directory-1}}
8641 @end smallexample
8642
8643 @cindex tape marks
8644 @dfn{Tape marks} are special magnetic patterns written on the tape
8645 media, which are later recognizable by the reading hardware. These
8646 marks are used after each file, when there are many on a single tape.
8647 An empty file (that is to say, two tape marks in a row) signal the
8648 logical end of the tape, after which no file exist. Usually,
8649 non-rewinding tape device drivers will react to the close request issued
8650 by @command{tar} by first writing two tape marks after your archive, and by
8651 backspacing over one of these. So, if you remove the tape at that time
8652 from the tape drive, it is properly terminated. But if you write
8653 another file at the current position, the second tape mark will be
8654 erased by the new information, leaving only one tape mark between files.
8655
8656 So, you may now save @var{directory-2} as a second archive after the
8657 first on the same tape by issuing the command:
8658
8659 @smallexample
8660 $ @kbd{tar cf /dev/nrtape @var{directory-2}}
8661 @end smallexample
8662
8663 @noindent
8664 and so on for all the archives you want to put on the same tape.
8665
8666 Another usual case is that you do not write all the archives the same
8667 day, and you need to remove and store the tape between two archive
8668 sessions. In general, you must remember how many files are already
8669 saved on your tape. Suppose your tape already has 16 files on it, and
8670 that you are ready to write the 17th. You have to take care of skipping
8671 the first 16 tape marks before saving @var{directory-17}, say, by using
8672 these commands:
8673
8674 @smallexample
8675 $ @kbd{mt -f /dev/nrtape rewind}
8676 $ @kbd{mt -f /dev/nrtape fsf 16}
8677 $ @kbd{tar cf /dev/nrtape @var{directory-17}}
8678 @end smallexample
8679
8680 In all the previous examples, we put aside blocking considerations, but
8681 you should do the proper things for that as well. @xref{Blocking}.
8682
8683 @menu
8684 * Tape Positioning:: Tape Positions and Tape Marks
8685 * mt:: The @command{mt} Utility
8686 @end menu
8687
8688 @node Tape Positioning
8689 @subsection Tape Positions and Tape Marks
8690 @UNREVISED
8691
8692 Just as archives can store more than one file from the file system,
8693 tapes can store more than one archive file. To keep track of where
8694 archive files (or any other type of file stored on tape) begin and
8695 end, tape archive devices write magnetic @dfn{tape marks} on the
8696 archive media. Tape drives write one tape mark between files,
8697 two at the end of all the file entries.
8698
8699 If you think of data as a series of records "rrrr"'s, and tape marks as
8700 "*"'s, a tape might look like the following:
8701
8702 @smallexample
8703 rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
8704 @end smallexample
8705
8706 Tape devices read and write tapes using a read/write @dfn{tape
8707 head}---a physical part of the device which can only access one
8708 point on the tape at a time. When you use @command{tar} to read or
8709 write archive data from a tape device, the device will begin reading
8710 or writing from wherever on the tape the tape head happens to be,
8711 regardless of which archive or what part of the archive the tape
8712 head is on. Before writing an archive, you should make sure that no
8713 data on the tape will be overwritten (unless it is no longer needed).
8714 Before reading an archive, you should make sure the tape head is at
8715 the beginning of the archive you want to read. (The @code{restore}
8716 script will find the archive automatically. @FIXME-xref{Scripted Restoration}@xref{mt}, for
8717 an explanation of the tape moving utility.
8718
8719 If you want to add new archive file entries to a tape, you should
8720 advance the tape to the end of the existing file entries, backspace
8721 over the last tape mark, and write the new archive file. If you were
8722 to add two archives to the example above, the tape might look like the
8723 following:
8724
8725 @smallexample
8726 rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
8727 @end smallexample
8728
8729 @node mt
8730 @subsection The @command{mt} Utility
8731 @UNREVISED
8732
8733 @FIXME{Is it true that this only works on non-block devices?
8734 should explain the difference, (fixed or variable).}
8735 @value{xref-blocking-factor}.
8736
8737 You can use the @command{mt} utility to advance or rewind a tape past a
8738 specified number of archive files on the tape. This will allow you
8739 to move to the beginning of an archive before extracting or reading
8740 it, or to the end of all the archives before writing a new one.
8741 @FIXME{Why isn't there an "advance 'til you find two tape marks
8742 together"?}
8743
8744 The syntax of the @command{mt} command is:
8745
8746 @smallexample
8747 @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
8748 @end smallexample
8749
8750 where @var{tapename} is the name of the tape device, @var{number} is
8751 the number of times an operation is performed (with a default of one),
8752 and @var{operation} is one of the following:
8753
8754 @FIXME{is there any use for record operations?}
8755
8756 @table @kbd
8757 @item eof
8758 @itemx weof
8759 Writes @var{number} tape marks at the current position on the tape.
8760
8761 @item fsf
8762 Moves tape position forward @var{number} files.
8763
8764 @item bsf
8765 Moves tape position back @var{number} files.
8766
8767 @item rewind
8768 Rewinds the tape. (Ignores @var{number}).
8769
8770 @item offline
8771 @itemx rewoff1
8772 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
8773
8774 @item status
8775 Prints status information about the tape unit.
8776
8777 @end table
8778
8779 @FIXME{Is there a better way to frob the spacing on the list?}
8780
8781 If you don't specify a @var{tapename}, @command{mt} uses the environment
8782 variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
8783 @file{/dev/rmt12}.
8784
8785 @command{mt} returns a 0 exit status when the operation(s) were
8786 successful, 1 if the command was unrecognized, and 2 if an operation
8787 failed.
8788
8789 @FIXME{New node on how to find an archive?}
8790
8791 If you use @value{op-extract} with the @value{op-label} option specified,
8792 @command{tar} will read an archive label (the tape head has to be positioned
8793 on it) and print an error if the archive label doesn't match the
8794 @var{archive-name} specified. @var{archive-name} can be any regular
8795 expression. If the labels match, @command{tar} extracts the archive.
8796 @value{xref-label}.
8797 @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
8798 references}@samp{tar --list --label} will cause @command{tar} to print the
8799 label.
8800
8801 @FIXME{Program to list all the labels on a tape?}
8802
8803 @node Using Multiple Tapes
8804 @section Using Multiple Tapes
8805 @UNREVISED
8806
8807 Often you might want to write a large archive, one larger than will fit
8808 on the actual tape you are using. In such a case, you can run multiple
8809 @command{tar} commands, but this can be inconvenient, particularly if you
8810 are using options like @value{op-exclude} or dumping entire filesystems.
8811 Therefore, @command{tar} supports multiple tapes automatically.
8812
8813 Use @value{op-multi-volume} on the command line, and then @command{tar} will,
8814 when it reaches the end of the tape, prompt for another tape, and
8815 continue the archive. Each tape will have an independent archive, and
8816 can be read without needing the other. (As an exception to this, the
8817 file that @command{tar} was archiving when it ran out of tape will usually
8818 be split between the two archives; in this case you need to extract from
8819 the first archive, using @value{op-multi-volume}, and then put in the
8820 second tape when prompted, so @command{tar} can restore both halves of the
8821 file.)
8822
8823 @GNUTAR{} multi-volume archives do not use a truly
8824 portable format. You need @GNUTAR{} at both end to
8825 process them properly.
8826
8827 When prompting for a new tape, @command{tar} accepts any of the following
8828 responses:
8829
8830 @table @kbd
8831 @item ?
8832 Request @command{tar} to explain possible responses
8833 @item q
8834 Request @command{tar} to exit immediately.
8835 @item n @var{file name}
8836 Request @command{tar} to write the next volume on the file @var{file name}.
8837 @item !
8838 Request @command{tar} to run a subshell.
8839 @item y
8840 Request @command{tar} to begin writing the next volume.
8841 @end table
8842
8843 (You should only type @samp{y} after you have changed the tape;
8844 otherwise @command{tar} will write over the volume it just finished.)
8845
8846 If you want more elaborate behavior than this, give @command{tar} the
8847 @value{op-info-script} option. The file @var{script-name} is expected
8848 to be a program (or shell script) to be run instead of the normal
8849 prompting procedure. If the program fails, @command{tar} exits;
8850 otherwise, @command{tar} begins writing the next volume. The behavior
8851 of the
8852 @samp{n} response to the normal tape-change prompt is not available
8853 if you use @value{op-info-script}.
8854
8855 The method @command{tar} uses to detect end of tape is not perfect, and
8856 fails on some operating systems or on some devices. You can use the
8857 @value{op-tape-length} option if @command{tar} can't detect the end of the
8858 tape itself. This option selects @value{op-multi-volume} automatically.
8859 The @var{size} argument should then be the usable size of the tape.
8860 But for many devices, and floppy disks in particular, this option is
8861 never required for real, as far as we know.
8862
8863 The volume number used by @command{tar} in its tape-change prompt
8864 can be changed; if you give the @value{op-volno-file} option, then
8865 @var{file-of-number} should be an unexisting file to be created, or else,
8866 a file already containing a decimal number. That number will be used
8867 as the volume number of the first volume written. When @command{tar} is
8868 finished, it will rewrite the file with the now-current volume number.
8869 (This does not change the volume number written on a tape label, as
8870 per @value{ref-label}, it @emph{only} affects the number used in
8871 the prompt.)
8872
8873 If you want @command{tar} to cycle through a series of tape drives, then
8874 you can use the @samp{n} response to the tape-change prompt. This is
8875 error prone, however, and doesn't work at all with @value{op-info-script}.
8876 Therefore, if you give @command{tar} multiple @value{op-file} options, then
8877 the specified files will be used, in sequence, as the successive volumes
8878 of the archive. Only when the first one in the sequence needs to be
8879 used again will @command{tar} prompt for a tape change (or run the info
8880 script).
8881
8882 Multi-volume archives
8883
8884 With @value{op-multi-volume}, @command{tar} will not abort when it cannot
8885 read or write any more data. Instead, it will ask you to prepare a new
8886 volume. If the archive is on a magnetic tape, you should change tapes
8887 now; if the archive is on a floppy disk, you should change disks, etc.
8888
8889 Each volume of a multi-volume archive is an independent @command{tar}
8890 archive, complete in itself. For example, you can list or extract any
8891 volume alone; just don't specify @value{op-multi-volume}. However, if one
8892 file in the archive is split across volumes, the only way to extract
8893 it successfully is with a multi-volume extract command @samp{--extract
8894 --multi-volume} (@samp{-xM}) starting on or before the volume where
8895 the file begins.
8896
8897 For example, let's presume someone has two tape drives on a system
8898 named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
8899 to switch to the second drive when it needs to write the
8900 second tape, and then back to the first tape, etc., just do either of:
8901
8902 @smallexample
8903 $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
8904 $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
8905 @end smallexample
8906
8907 @menu
8908 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
8909 * Tape Files:: Tape Files
8910 @end menu
8911
8912 @node Multi-Volume Archives
8913 @subsection Archives Longer than One Tape or Disk
8914 @cindex Multi-volume archives
8915 @UNREVISED
8916
8917 To create an archive that is larger than will fit on a single unit of
8918 the media, use the @value{op-multi-volume} option in conjunction with
8919 the @value{op-create} option (@pxref{create}). A
8920 @dfn{multi-volume} archive can be manipulated like any other archive
8921 (provided the @value{op-multi-volume} option is specified), but is
8922 stored on more than one tape or disk.
8923
8924 When you specify @value{op-multi-volume}, @command{tar} does not report an
8925 error when it comes to the end of an archive volume (when reading), or
8926 the end of the media (when writing). Instead, it prompts you to load
8927 a new storage volume. If the archive is on a magnetic tape, you
8928 should change tapes when you see the prompt; if the archive is on a
8929 floppy disk, you should change disks; etc.
8930
8931 You can read each individual volume of a multi-volume archive as if it
8932 were an archive by itself. For example, to list the contents of one
8933 volume, use @value{op-list}, without @value{op-multi-volume} specified.
8934 To extract an archive member from one volume (assuming it is described
8935 that volume), use @value{op-extract}, again without
8936 @value{op-multi-volume}.
8937
8938 If an archive member is split across volumes (ie. its entry begins on
8939 one volume of the media and ends on another), you need to specify
8940 @value{op-multi-volume} to extract it successfully. In this case, you
8941 should load the volume where the archive member starts, and use
8942 @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
8943 volumes as it needs them. @xref{extracting archives}, for more
8944 information about extracting archives.
8945
8946 @value{op-info-script} is like @value{op-multi-volume}, except that
8947 @command{tar} does not prompt you directly to change media volumes when
8948 a volume is full---instead, @command{tar} runs commands you have stored
8949 in @var{script-name}. For example, this option can be used to eject
8950 cassettes, or to broadcast messages such as @samp{Someone please come
8951 change my tape} when performing unattended backups. When @var{script-name}
8952 is done, @command{tar} will assume that the media has been changed.
8953
8954 Multi-volume archives can be modified like any other archive. To add
8955 files to a multi-volume archive, you need to only mount the last
8956 volume of the archive media (and new volumes, if needed). For all
8957 other operations, you need to use the entire archive.
8958
8959 If a multi-volume archive was labeled using @value{op-label}
8960 (@value{pxref-label}) when it was created, @command{tar} will not
8961 automatically label volumes which are added later. To label subsequent
8962 volumes, specify @value{op-label} again in conjunction with the
8963 @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
8964
8965 @cindex Labeling multi-volume archives
8966 @FIXME{example}
8967
8968 @FIXME{There should be a sample program here, including an exit
8969 before end. Is the exit status even checked in tar? :-(}
8970
8971 @table @kbd
8972 @item --multi-volume
8973 @itemx -M
8974 Creates a multi-volume archive, when used in conjunction with
8975 @value{op-create}. To perform any other operation on a multi-volume
8976 archive, specify @value{op-multi-volume} in conjunction with that
8977 operation.
8978
8979 @item --info-script=@var{program-file}
8980 @itemx -F @var{program-file}
8981 Creates a multi-volume archive via a script. Used in conjunction with
8982 @value{op-create}.
8983 @end table
8984
8985 Beware that there is @emph{no} real standard about the proper way, for
8986 a @command{tar} archive, to span volume boundaries. If you have a
8987 multi-volume created by some vendor's @command{tar}, there is almost
8988 no chance you could read all the volumes with @GNUTAR{}.
8989 The converse is also true: you may not expect
8990 multi-volume archives created by @GNUTAR{} to be
8991 fully recovered by vendor's @command{tar}. Since there is little
8992 chance that, in mixed system configurations, some vendor's
8993 @command{tar} will work on another vendor's machine, and there is a
8994 great chance that @GNUTAR{} will work on most of
8995 them, your best bet is to install @GNUTAR{} on all
8996 machines between which you know exchange of files is possible.
8997
8998 @node Tape Files
8999 @subsection Tape Files
9000 @UNREVISED
9001
9002 To give the archive a name which will be recorded in it, use the
9003 @value{op-label} option. This will write a special block identifying
9004 @var{volume-label} as the name of the archive to the front of the archive
9005 which will be displayed when the archive is listed with @value{op-list}.
9006 If you are creating a multi-volume archive with
9007 @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
9008 volume label will have
9009 @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
9010 the number of the volume of the archive. (If you use the @value{op-label}
9011 option when reading an archive, it checks to make sure the label on the
9012 tape matches the one you give. @value{xref-label}.
9013
9014 When @command{tar} writes an archive to tape, it creates a single
9015 tape file. If multiple archives are written to the same tape, one
9016 after the other, they each get written as separate tape files. When
9017 extracting, it is necessary to position the tape at the right place
9018 before running @command{tar}. To do this, use the @command{mt} command.
9019 For more information on the @command{mt} command and on the organization
9020 of tapes into a sequence of tape files, see @ref{mt}.
9021
9022 People seem to often do:
9023
9024 @smallexample
9025 @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
9026 @end smallexample
9027
9028 or such, for pushing a common date in all volumes or an archive set.
9029
9030 @node label
9031 @section Including a Label in the Archive
9032 @cindex Labeling an archive
9033 @cindex Labels on the archive media
9034 @UNREVISED
9035
9036 @table @kbd
9037 @item -V @var{name}
9038 @itemx --label=@var{name}
9039 Create archive with volume name @var{name}.
9040 @end table
9041
9042 This option causes @command{tar} to write out a @dfn{volume header} at
9043 the beginning of the archive. If @value{op-multi-volume} is used, each
9044 volume of the archive will have a volume header of @samp{@var{name}
9045 Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
9046 next, and so on.
9047
9048 @FIXME{Should the arg to --label be a quoted string?? No.}
9049
9050 To avoid problems caused by misplaced paper labels on the archive
9051 media, you can include a @dfn{label} entry---an archive member which
9052 contains the name of the archive---in the archive itself. Use the
9053 @value{op-label} option in conjunction with the @value{op-create} operation
9054 to include a label entry in the archive as it is being created.
9055
9056 If you create an archive using both @value{op-label} and
9057 @value{op-multi-volume}, each volume of the archive will have an
9058 archive label of the form @samp{@var{archive-label} Volume @var{n}},
9059 where @var{n} is 1 for the first volume, 2 for the next, and so on.
9060 @FIXME-xref{Multi-Volume Archives, for information on creating multiple
9061 volume archives.}
9062
9063 If you list or extract an archive using @value{op-label}, @command{tar} will
9064 print an error if the archive label doesn't match the @var{archive-label}
9065 specified, and will then not list nor extract the archive. In those cases,
9066 @var{archive-label} argument is interpreted as a globbing-style pattern
9067 which must match the actual magnetic volume label. @xref{exclude}, for
9068 a precise description of how match is attempted@footnote{Previous versions
9069 of @command{tar} used full regular expression matching, or before that, only
9070 exact string matching, instead of wildcard matchers. We decided for the
9071 sake of simplicity to use a uniform matching device through @command{tar}.}.
9072 If the switch @value{op-multi-volume} is being used, the volume label
9073 matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
9074 if the initial match fails, before giving up. Since the volume numbering
9075 is automatically added in labels at creation time, it sounded logical to
9076 equally help the user taking care of it when the archive is being read.
9077
9078 The @value{op-label} was once called @samp{--volume}, but is not available
9079 under that name anymore.
9080
9081 To find out an archive's label entry (or to find out if an archive has
9082 a label at all), use @samp{tar --list --verbose}. @command{tar} will
9083 print the label first, and then print archive member information, as
9084 in the example below:
9085
9086 @smallexample
9087 $ @kbd{tar --verbose --list --file=iamanarchive}
9088 V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
9089 -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
9090 @end smallexample
9091
9092 @table @kbd
9093 @item --label=@var{archive-label}
9094 @itemx -V @var{archive-label}
9095 Includes an @dfn{archive-label} at the beginning of the archive when
9096 the archive is being created, when used in conjunction with the
9097 @value{op-create} option. Checks to make sure the archive label
9098 matches the one specified (when used in conjunction with the
9099 @value{op-extract} option.
9100 @end table
9101
9102 To get a common information on all tapes of a series, use the
9103 @value{op-label} option. For having this information different in each
9104 series created through a single script used on a regular basis, just
9105 manage to get some date string as part of the label. For example:
9106
9107 @smallexample
9108 $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
9109 $ @kbd{tar --create --file=/dev/tape --multi-volume \
9110 --volume="Daily backup for `date +%Y-%m-%d`"}
9111 @end smallexample
9112
9113 Also note that each label has its own date and time, which corresponds
9114 to when @GNUTAR{} initially attempted to write it,
9115 often soon after the operator launches @command{tar} or types the
9116 carriage return telling that the next tape is ready. Comparing date
9117 labels does give an idea of tape throughput only if the delays for
9118 rewinding tapes and the operator switching them were negligible, which
9119 is usually not the case.
9120
9121 @FIXME{was --volume}
9122
9123 @node verify
9124 @section Verifying Data as It is Stored
9125 @cindex Verifying a write operation
9126 @cindex Double-checking a write operation
9127
9128 @table @kbd
9129 @item -W
9130 @itemx --verify
9131 Attempt to verify the archive after writing.
9132 @end table
9133
9134 This option causes @command{tar} to verify the archive after writing it.
9135 Each volume is checked after it is written, and any discrepancies
9136 are recorded on the standard error output.
9137
9138 Verification requires that the archive be on a back-space-able medium.
9139 This means pipes, some cartridge tape drives, and some other devices
9140 cannot be verified.
9141
9142 You can insure the accuracy of an archive by comparing files in the
9143 system with archive members. @command{tar} can compare an archive to the
9144 file system as the archive is being written, to verify a write
9145 operation, or can compare a previously written archive, to insure that
9146 it is up to date.
9147
9148 To check for discrepancies in an archive immediately after it is
9149 written, use the @value{op-verify} option in conjunction with
9150 the @value{op-create} operation. When this option is
9151 specified, @command{tar} checks archive members against their counterparts
9152 in the file system, and reports discrepancies on the standard error.
9153
9154 To verify an archive, you must be able to read it from before the end
9155 of the last written entry. This option is useful for detecting data
9156 errors on some tapes. Archives written to pipes, some cartridge tape
9157 drives, and some other devices cannot be verified.
9158
9159 One can explicitly compare an already made archive with the file system
9160 by using the @value{op-compare} option, instead of using the more automatic
9161 @value{op-verify} option. @value{xref-compare}.
9162
9163 Note that these two options have a slightly different intent. The
9164 @value{op-compare} option how identical are the logical contents of some
9165 archive with what is on your disks, while the @value{op-verify} option is
9166 really for checking if the physical contents agree and if the recording
9167 media itself is of dependable quality. So, for the @value{op-verify}
9168 operation, @command{tar} tries to defeat all in-memory cache pertaining to
9169 the archive, while it lets the speed optimization undisturbed for the
9170 @value{op-compare} option. If you nevertheless use @value{op-compare} for
9171 media verification, you may have to defeat the in-memory cache yourself,
9172 maybe by opening and reclosing the door latch of your recording unit,
9173 forcing some doubt in your operating system about the fact this is really
9174 the same volume as the one just written or read.
9175
9176 The @value{op-verify} option would not be necessary if drivers were indeed
9177 able to detect dependably all write failures. This sometimes require many
9178 magnetic heads, some able to read after the writes occurred. One would
9179 not say that drivers unable to detect all cases are necessarily flawed,
9180 as long as programming is concerned.
9181
9182 The @value{op-verify} option will not work in conjunction with the
9183 @value{op-multi-volume} option or the @value{op-append},
9184 @value{op-update} and @value{op-delete} operations. @xref{Operations},
9185 for more information on these operations.
9186
9187 Also, since @command{tar} normally strips leading @samp{/} from file
9188 names (@pxref{absolute}), a command like @samp{tar --verify -cf
9189 /tmp/foo.tar /etc} will work as desired only if the working directory is
9190 @file{/}, as @command{tar} uses the archive's relative member names
9191 (e.g., @file{etc/motd}) when verifying the archive.
9192
9193 @node Write Protection
9194 @section Write Protection
9195
9196 Almost all tapes and diskettes, and in a few rare cases, even disks can
9197 be @dfn{write protected}, to protect data on them from being changed.
9198 Once an archive is written, you should write protect the media to prevent
9199 the archive from being accidentally overwritten or deleted. (This will
9200 protect the archive from being changed with a tape or floppy drive---it
9201 will not protect it from magnet fields or other physical hazards).
9202
9203 The write protection device itself is usually an integral part of the
9204 physical media, and can be a two position (write enabled/write
9205 disabled) switch, a notch which can be popped out or covered, a ring
9206 which can be removed from the center of a tape reel, or some other
9207 changeable feature.
9208
9209 @node Free Software Needs Free Documentation
9210 @appendix Free Software Needs Free Documentation
9211 @include freemanuals.texi
9212
9213 @node Copying This Manual
9214 @appendix Copying This Manual
9215
9216 @menu
9217 * GNU Free Documentation License:: License for copying this manual
9218 @end menu
9219
9220 @include fdl.texi
9221
9222 @node Index
9223 @appendix Index
9224
9225 @printindex cp
9226
9227 @summarycontents
9228 @contents
9229 @bye
9230
9231 @c Local variables:
9232 @c texinfo-column-for-description: 32
9233 @c End:
This page took 0.41655 seconds and 5 git commands to generate.