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