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