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