1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
5 @settitle GNU tar @value{VERSION}
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 ======================================================================
32 @set RENDITION The book, version
36 @set RENDITION FTP release, version
40 @set RENDITION Proof reading version
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 ---------------------------------------------------------------------
52 @c Output marks for nodes needing revision, but not in PUBLISH rendition.
57 @emph{(This message will disappear, once this node revised.)}
62 @c Output various FIXME information only in PROOF rendition.
68 @strong{<FIXME>} \string\ @strong{</>}
73 @macro FIXME-ref{string}
76 @strong{<REF>} \string\ @strong{</>}
81 @macro FIXME-pxref{string}
84 @strong{<PXREF>} \string\ @strong{</>}
89 @macro FIXME-xref{string}
92 @strong{<XREF>} \string\ @strong{</>}
97 @c @macro option{entry}
99 @c @opindex{--\entry\}
104 @acronym{GNU} @command{tar}
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}
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}
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}
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}
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}
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}
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}
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}
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}
152 @set op-checkpoint @kbd{--checkpoint}
153 @set ref-checkpoint @ref{verbose}
154 @set xref-checkpoint @xref{verbose}
155 @set pxref-checkpoint @pxref{verbose}
157 @set op-check-links @kbd{--check-links}
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}
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}
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}
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}
179 @set op-delete @kbd{--delete}
180 @set ref-delete @ref{delete}
181 @set xref-delete @xref{delete}
182 @set pxref-delete @pxref{delete}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
234 @set op-help @kbd{--help}
235 @set ref-help @ref{help}
236 @set xref-help @xref{help}
237 @set pxref-help @pxref{help}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
314 @set op-null @kbd{--null}
315 @set ref-null @ref{files}
316 @set xref-null @xref{files}
317 @set pxref-null @pxref{files}
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}
324 @set op-occurrence @kbd{--occurrence}
325 @set ref-occurrence @ref{--occurrence}
326 @set xref-occurrence @xref{--occurrence}
327 @set pxref-occurrence @pxref{--occurrence}
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}
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}
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}
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}
349 @set op-format @kbd{--format}
350 @set ref-format @ref{format}
351 @set xref-format @xref{format}
352 @set pxref-format @pxref{format}
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 @set op-format-ustar @kbd{--format=ustar}
360 @set op-posix @kbd{--posix}
361 @set ref-posix @ref{posix}
362 @set xref-posix @xref{posix}
363 @set pxref-posix @pxref{posix}
365 @set op-preserve @kbd{--preserve}
366 @set ref-preserve @ref{Attributes}
367 @set xref-preserve @xref{Attributes}
368 @set pxref-preserve @pxref{Attributes}
370 @set op-record-size @kbd{--record-size=@var{size}}
371 @set ref-record-size @ref{Blocking}
372 @set xref-record-size @xref{Blocking}
373 @set pxref-record-size @pxref{Blocking}
375 @set op-recursive-unlink @kbd{--recursive-unlink}
376 @set ref-recursive-unlink @ref{Writing}
377 @set xref-recursive-unlink @xref{Writing}
378 @set pxref-recursive-unlink @pxref{Writing}
380 @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
381 @set ref-read-full-records @ref{Blocking}
382 @set xref-read-full-records @xref{Blocking}
383 @set pxref-read-full-records @pxref{Blocking}
384 @c FIXME: or should it be Reading, or Blocking Factor
386 @set op-remove-files @kbd{--remove-files}
387 @set ref-remove-files @ref{Writing}
388 @set xref-remove-files @xref{Writing}
389 @set pxref-remove-files @pxref{Writing}
391 @set op-rsh-command @kbd{rsh-command=@var{command}}
393 @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
394 @set ref-same-order @ref{Scarce}
395 @set xref-same-order @xref{Scarce}
396 @set pxref-same-order @pxref{Scarce}
397 @c FIXME: or should it be Reading, or Attributes?
399 @set op-same-owner @kbd{--same-owner}
400 @set ref-same-owner @ref{Attributes}
401 @set xref-same-owner @xref{Attributes}
402 @set pxref-same-owner @pxref{Attributes}
404 @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
405 @set ref-same-permissions @ref{Attributes}
406 @set xref-same-permissions @xref{Attributes}
407 @set pxref-same-permissions @pxref{Attributes}
408 @c FIXME: or should it be Writing?
410 @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
411 @set ref-show-omitted-dirs @ref{verbose}
412 @set xref-show-omitted-dirs @xref{verbose}
413 @set pxref-show-omitted-dirs @pxref{verbose}
415 @set op-sparse @kbd{--sparse} (@kbd{-S})
416 @set ref-sparse @ref{sparse}
417 @set xref-sparse @xref{sparse}
418 @set pxref-sparse @pxref{sparse}
420 @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
421 @set ref-starting-file @ref{Scarce}
422 @set xref-starting-file @xref{Scarce}
423 @set pxref-starting-file @pxref{Scarce}
425 @set op-strip-path @kbd{--strip-path}
426 @set ref-strip-path @ref{--strip-path}
427 @set xref-strip-path @xref{--strip-path}
428 @set pxref-strip-path @pxref{--strip-path}
430 @set op-suffix @kbd{--suffix=@var{suffix}}
431 @set ref-suffix @ref{Backup options}
432 @set xref-suffix @xref{Backup options}
433 @set pxref-suffix @pxref{Backup options}
435 @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
436 @set ref-tape-length @ref{Using Multiple Tapes}
437 @set xref-tape-length @xref{Using Multiple Tapes}
438 @set pxref-tape-length @pxref{Using Multiple Tapes}
440 @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
441 @set ref-to-stdout @ref{Writing}
442 @set xref-to-stdout @xref{Writing}
443 @set pxref-to-stdout @pxref{Writing}
445 @set op-totals @kbd{--totals}
446 @set ref-totals @ref{verbose}
447 @set xref-totals @xref{verbose}
448 @set pxref-totals @pxref{verbose}
450 @set op-touch @kbd{--touch} (@kbd{-m})
451 @set ref-touch @ref{Writing}
452 @set xref-touch @xref{Writing}
453 @set pxref-touch @pxref{Writing}
455 @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
456 @set ref-unlink-first @ref{Writing}
457 @set xref-unlink-first @xref{Writing}
458 @set pxref-unlink-first @pxref{Writing}
460 @set op-update @kbd{--update} (@kbd{-u})
461 @set ref-update @ref{update}
462 @set xref-update @xref{update}
463 @set pxref-update @pxref{update}
465 @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
466 @set ref-use-compress-prog @ref{gzip}
467 @set xref-use-compress-prog @xref{gzip}
468 @set pxref-use-compress-prog @pxref{gzip}
470 @set op-verbose @kbd{--verbose} (@kbd{-v})
471 @set ref-verbose @ref{verbose}
472 @set xref-verbose @xref{verbose}
473 @set pxref-verbose @pxref{verbose}
475 @set op-verify @kbd{--verify} (@kbd{-W})
476 @set ref-verify @ref{verify}
477 @set xref-verify @xref{verify}
478 @set pxref-verify @pxref{verify}
480 @set op-version @kbd{--version}
481 @set ref-version @ref{help}
482 @set xref-version @xref{help}
483 @set pxref-version @pxref{help}
485 @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
486 @set ref-volno-file @ref{Using Multiple Tapes}
487 @set xref-volno-file @xref{Using Multiple Tapes}
488 @set pxref-volno-file @pxref{Using Multiple Tapes}
490 @c Put everything in one index (arbitrarily chosen to be the concept index).
501 This manual is for @acronym{GNU} @command{tar} (version
502 @value{VERSION}, @value{UPDATED}), which creates and extracts files
505 Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
506 2003 Free Software Foundation, Inc.
509 Permission is granted to copy, distribute and/or modify this document
510 under the terms of the GNU Free Documentation License, Version 1.1 or
511 any later version published by the Free Software Foundation; with the
512 Invariant Sections being "GNU General Public License", with the
513 Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
514 as in (a) below. A copy of the license is included in the section
515 entitled "GNU Free Documentation License".
517 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
518 this GNU Manual. Buying copies from GNU Press supports the FSF in
519 developing GNU and promoting software freedom.''
523 @dircategory Archiving
525 * Tar: (tar). Making tape (or disk) archives.
528 @dircategory Individual utilities
530 * tar: (tar)tar invocation. Invoking @GNUTAR{}
533 @shorttitlepage @acronym{GNU} @command{tar}
536 @title @acronym{GNU} tar: an archiver tool
537 @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
538 @author Melissa Weisshaus, Jay Fenlason,
539 @author Thomas Bushnell, n/BSG, Amy Gorin
540 @c he said to remove it: Fran@,{c}ois Pinard
541 @c i'm thinking about how the author page *should* look. -mew 2may96
544 @vskip 0pt plus 1filll
550 @top @acronym{GNU} tar: an archiver tool
554 @cindex file archival
555 @cindex archiving files
557 The first part of this master menu lists the major nodes in this Info
558 document. The rest of the menu lists all the lower level nodes.
561 @c The master menu, created with texinfo-master-menu, goes here.
562 @c (However, getdate.texi's menu is interpolated by hand.)
571 * Date input formats::
574 * Free Software Needs Free Documentation::
575 * Copying This Manual::
579 --- The Detailed Node Listing ---
583 * Book Contents:: What this Book Contains
584 * Definitions:: Some Definitions
585 * What tar Does:: What @command{tar} Does
586 * Naming tar Archives:: How @command{tar} Archives are Named
588 * Current status:: Current development status of @GNUTAR{}
589 * Authors:: @GNUTAR{} Authors
590 * Reports:: Reporting bugs or suggestions
592 Tutorial Introduction to @command{tar}
595 * stylistic conventions::
596 * basic tar options:: Basic @command{tar} Operations and Options
597 * frequent operations::
598 * Two Frequent Options::
599 * create:: How to Create Archives
600 * list:: How to List Archives
601 * extract:: How to Extract Members from an Archive
604 Two Frequently Used Options
610 How to Create Archives
612 * prepare for examples::
613 * Creating the archive::
622 How to Extract Members from an Archive
624 * extracting archives::
632 * using tar options::
639 The Three Option Styles
641 * Mnemonic Options:: Mnemonic Option Style
642 * Short Options:: Short Option Style
643 * Old Options:: Old Option Style
644 * Mixing:: Mixing Option Styles
646 All @command{tar} Options
648 * Operation Summary::
650 * Short Option Summary::
662 Advanced @GNUTAR{} Operations
671 How to Add Files to Existing Archives: @code{--append}
673 * appending files:: Appending Files to an Archive
680 Options Used by @code{--create}
682 * Ignore Failed Read::
684 Options Used by @code{--extract}
686 * Reading:: Options to Help Read Archives
687 * Writing:: Changing How @command{tar} Writes Files
688 * Scarce:: Coping with Scarce Resources
690 Options to Help Read Archives
692 * read full records::
695 Changing How @command{tar} Writes Files
697 * Dealing with Old Files::
698 * Overwrite Old Files::
702 * Modification Times::
703 * Setting Access Permissions::
704 * Writing to Standard Output::
707 Coping with Scarce Resources
712 Performing Backups and Restoring Files
714 * Full Dumps:: Using @command{tar} to Perform Full Dumps
715 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
716 * incremental and listed-incremental:: The Incremental Options
717 * Backup Levels:: Levels of Backups
718 * Backup Parameters:: Setting Parameters for Backups and Restoration
719 * Scripted Backups:: Using the Backup Scripts
720 * Scripted Restoration:: Using the Restore Script
722 Setting Parameters for Backups and Restoration
724 * backup-specs example:: An Example Text of @file{Backup-specs}
725 * Script Syntax:: Syntax for @file{Backup-specs}
727 Choosing Files and Names for @command{tar}
729 * file:: Choosing the Archive's Name
730 * Selecting Archive Members::
731 * files:: Reading Names from a File
732 * exclude:: Excluding Some Files
734 * after:: Operating Only on New Files
735 * recurse:: Descending into Directories
736 * one:: Crossing Filesystem Boundaries
738 Reading Names from a File
744 * controlling pattern-patching with exclude::
745 * problems with exclude::
747 Crossing Filesystem Boundaries
749 * directory:: Changing Directory
750 * absolute:: Absolute File Names
754 * General date syntax:: Common rules.
755 * Calendar date items:: 19 Dec 1994.
756 * Time of day items:: 9:20pm.
757 * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
758 * Day of week items:: Monday and others.
759 * Relative items in date strings:: next tuesday, 2 years ago.
760 * Pure numbers in date strings:: 19931219, 1440.
761 * Authors of getdate:: Bellovin, Eggert, Salz, Berets, et al.
763 Controlling the Archive Format
765 * Portability:: Making @command{tar} Archives More Portable
766 * Compression:: Using Less Space through Compression
767 * Attributes:: Handling File Attributes
768 * Standard:: The Standard Format
769 * Extensions:: @acronym{GNU} Extensions to the Archive Format
770 * cpio:: Comparison of @command{tar} and @command{cpio}
772 Making @command{tar} Archives More Portable
774 * Portable Names:: Portable Names
775 * dereference:: Symbolic Links
776 * old:: Old V7 Archives
777 * posix:: @sc{posix} archives
778 * Checksumming:: Checksumming Problems
779 * Large or Negative Values:: Large files, negative time stamps, etc.
781 Using Less Space through Compression
783 * gzip:: Creating and Reading Compressed Archives
784 * sparse:: Archiving Sparse Files
786 Tapes and Other Archive Media
788 * Device:: Device selection and switching
789 * Remote Tape Server::
790 * Common Problems and Solutions::
791 * Blocking:: Blocking
792 * Many:: Many archives on one tape
793 * Using Multiple Tapes:: Using Multiple Tapes
794 * label:: Including a Label in the Archive
800 * Format Variations:: Format Variations
801 * Blocking Factor:: The Blocking Factor of an Archive
803 Many Archives on One Tape
805 * Tape Positioning:: Tape Positions and Tape Marks
806 * mt:: The @command{mt} Utility
810 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
811 * Tape Files:: Tape Files
815 * GNU Free Documentation License:: License for copying this manual
821 @chapter Introduction
824 and manipulates (@dfn{archives}) which are actually collections of
825 many other files; the program provides users with an organized and
826 systematic method for controlling a large amount of data.
827 The name ``tar'' originally came from the phrase ``Tape ARchive'', but
828 archives need not (and these days, typically do not) reside on tapes.
831 * Book Contents:: What this Book Contains
832 * Definitions:: Some Definitions
833 * What tar Does:: What @command{tar} Does
834 * Naming tar Archives:: How @command{tar} Archives are Named
836 * Current status:: Current development status of @GNUTAR{}
837 * Authors:: @GNUTAR{} Authors
838 * Reports:: Reporting bugs or suggestions
842 @section What this Book Contains
844 The first part of this chapter introduces you to various terms that will
845 recur throughout the book. It also tells you who has worked on @GNUTAR{}
846 and its documentation, and where you should send bug reports
849 The second chapter is a tutorial (@pxref{Tutorial}) which provides a
850 gentle introduction for people who are new to using @command{tar}. It is
851 meant to be self contained, not requiring any reading from subsequent
852 chapters to make sense. It moves from topic to topic in a logical,
853 progressive order, building on information already explained.
855 Although the tutorial is paced and structured to allow beginners to
856 learn how to use @command{tar}, it is not intended solely for beginners.
857 The tutorial explains how to use the three most frequently used
858 operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
859 two frequently used options (@samp{file} and @samp{verbose}). The other
860 chapters do not refer to the tutorial frequently; however, if a section
861 discusses something which is a complex variant of a basic concept, there
862 may be a cross reference to that basic concept. (The entire book,
863 including the tutorial, assumes that the reader understands some basic
864 concepts of using a Unix-type operating system; @pxref{Tutorial}.)
866 The third chapter presents the remaining five operations, and
867 information about using @command{tar} options and option syntax.
869 @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
870 than the reality. should think about whether this makes sense to say
871 here, or not.} The other chapters are meant to be used as a
872 reference. Each chapter presents everything that needs to be said
873 about a specific topic.
875 One of the chapters (@pxref{Date input formats}) exists in its
876 entirety in other @acronym{GNU} manuals, and is mostly self-contained.
877 In addition, one section of this manual (@pxref{Standard}) contains a
878 big quote which is taken directly from @command{tar} sources.
880 In general, we give both the long and short (abbreviated) option names
881 at least once in each section where the relevant option is covered, so
882 that novice readers will become familiar with both styles. (A few
883 options have no short versions, and the relevant sections will
887 @section Some Definitions
891 The @command{tar} program is used to create and manipulate @command{tar}
892 archives. An @dfn{archive} is a single file which contains the contents
893 of many files, while still identifying the names of the files, their
894 owner(s), and so forth. (In addition, archives record access
895 permissions, user and group, size in bytes, and last modification time.
896 Some archives also record the file names in each archived directory, as
897 well as other file and directory information.) You can use @command{tar}
898 to @dfn{create} a new archive in a specified directory.
901 @cindex archive member
904 The files inside an archive are called @dfn{members}. Within this
905 manual, we use the term @dfn{file} to refer only to files accessible in
906 the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
907 @dfn{member} to refer only to the members of an archive. Similarly, a
908 @dfn{file name} is the name of a file, as it resides in the filesystem,
909 and a @dfn{member name} is the name of an archive member within the
914 The term @dfn{extraction} refers to the process of copying an archive
915 member (or multiple members) into a file in the filesystem. Extracting
916 all the members of an archive is often called @dfn{extracting the
917 archive}. The term @dfn{unpack} can also be used to refer to the
918 extraction of many or all the members of an archive. Extracting an
919 archive does not destroy the archive's structure, just as creating an
920 archive does not destroy the copies of the files that exist outside of
921 the archive. You may also @dfn{list} the members in a given archive
922 (this is often thought of as ``printing'' them to the standard output,
923 or the command line), or @dfn{append} members to a pre-existing archive.
924 All of these operations can be performed using @command{tar}.
927 @section What @command{tar} Does
930 The @command{tar} program provides the ability to create @command{tar}
931 archives, as well as various other kinds of manipulation. For example,
932 you can use @command{tar} on previously created archives to extract files,
933 to store additional files, or to update or list files which were already
936 Initially, @command{tar} archives were used to store files conveniently on
937 magnetic tape. The name @command{tar} comes from this use; it stands for
938 @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
939 direct its output to available devices, files, or other programs (using
940 pipes). @command{tar} may even access remote devices or files (as archives).
942 @FIXME{the following table entries need a bit of work..}
944 You can use @command{tar} archives in many ways. We want to stress a few
945 of them: storage, backup, and transportation.
949 Often, @command{tar} archives are used to store related files for
950 convenient file transfer over a network. For example, the
951 @acronym{GNU} Project distributes its software bundled into
952 @command{tar} archives, so that all the files relating to a particular
953 program (or set of related programs) can be transferred as a single
956 A magnetic tape can store several files in sequence. However, the tape
957 has no names for these files; it only knows their relative position on
958 the tape. One way to store several files on one tape and retain their
959 names is by creating a @command{tar} archive. Even when the basic transfer
960 mechanism can keep track of names, as FTP can, the nuisance of handling
961 multiple files, directories, and multiple links makes @command{tar}
964 Archive files are also used for long-term storage. You can think of
965 this as transportation from the present into the future. (It is a
966 science-fiction idiom that you can move through time as well as in
967 space; the idea here is that @command{tar} can be used to move archives in
968 all dimensions, even time!)
971 Because the archive created by @command{tar} is capable of preserving
972 file information and directory structure, @command{tar} is commonly
973 used for performing full and incremental backups of disks. A backup
974 puts a collection of files (possibly pertaining to many users and
975 projects) together on a disk or a tape. This guards against
976 accidental destruction of the information in those files.
977 @GNUTAR{} has special features that allow it to be
978 used to make incremental and full dumps of all the files in a
982 You can create an archive on one system, transfer it to another system,
983 and extract the contents there. This allows you to transport a group of
984 files from one system to another.
987 @node Naming tar Archives
988 @section How @command{tar} Archives are Named
990 Conventionally, @command{tar} archives are given names ending with
991 @samp{.tar}. This is not necessary for @command{tar} to operate properly,
992 but this manual follows that convention in order to accustom readers to
993 it and to make examples more clear.
998 Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
999 archive members as ``files'' or ``entries''. For people familiar with
1000 the operation of @command{tar}, this causes no difficulty. However, in
1001 this manual, we consistently refer to ``archives'' and ``archive
1002 members'' to make learning to use @command{tar} easier for novice users.
1004 @node posix compliance
1005 @section @sc{posix} Compliance
1008 @FIXME{must ask franc,ois about this. dan hagerty thinks this might
1009 be an issue, but we're not really sure at this time. dan just tried a
1010 test case of mixing up options' orders while the variable was set, and
1011 there was no problem...}
1012 @FIXME{I did not notice any problems either. Besides, the only piece
1013 of code that really uses POSIXLY_CORRECT is the one that forces
1014 creation of POSIX archives. I guess this paragraph should be removed.
1019 We make some of our recommendations throughout this book for one
1020 reason in addition to what we think of as ``good sense''. The main
1021 additional reason for a recommendation is to be compliant with the
1022 @sc{posix} standards. If you set the shell environment variable
1023 @env{POSIXLY_CORRECT}, @GNUTAR{} will force you to
1024 adhere to these standards. Therefore, if this variable is set and you
1025 violate one of the @sc{posix} standards in the way you phrase a
1026 command, for example, @GNUTAR{} will not allow the
1027 command and will signal an error message. You would then have to
1028 reorder the options or rephrase the command to comply with the
1029 @sc{posix} standards.
1031 Notice also, that if this environment variable is set, @GNUTAR{}
1032 will create @acronym{POSIX} archives. Currently this means that
1033 no @acronym{GNU} extensions will be allowed (@pxref{posix}).
1035 @node Current status
1036 @section Current development status of @GNUTAR{}
1038 @GNUTAR{} is currently in the process of active development, whose
1042 @item Improve compatibility between @GNUTAR{} and other @command{tar}
1044 @item Switch to using @acronym{POSIX} archives.
1045 @item Revise sparse file handling.
1046 @item Revise multiple volume processing.
1049 The following issues need mentioning:
1052 @item Use of short option @option{-o}.
1053 Earlier versions of @GNUTAR{} understood @option{-o} command line
1054 option as a synonym for @option{--old-archive}.
1056 @GNUTAR{} starting from version 1.13.90 understands this option as
1057 a synonym for @option{--no-same-owner}. This is compatible with
1058 UNIX98 @command{tar} implementations.
1060 However, to facilitate transition, @option{-o} option retains its
1061 old semantics when it is used with one of archive-creation commands.
1062 Users are encouraged to use @value{op-format-oldgnu} instead.
1064 Future versions of @GNUTAR{} will understand @option{-o} only as a
1065 synonym for @option{--no-same-owner}.
1067 @item Use of short option @option{-l}
1068 Earlier versions of @GNUTAR{} understood @option{-l} option as a
1069 synonym for @samp{--one-file-system}. Such usage is deprecated.
1070 For compatibility with other implementations future versions of
1071 @GNUTAR{} will understand this option as a synonym for
1072 @option{--check-links}.
1074 @item Use of options @option{--portability} and @option{--old-archive}
1075 These options are deprecated. Please use @option{--format=v7} instead.
1077 @item Use of option @option{--posix}
1078 This option is deprecated. Please use @option{--format=posix} instead.
1082 @section @GNUTAR{} Authors
1084 @GNUTAR{} was originally written by John Gilmore,
1085 and modified by many people. The @acronym{GNU} enhancements were
1086 written by Jay Fenlason, then Joy Kendall, and the whole package has
1087 been further maintained by Thomas Bushnell, n/BSG, and finally
1088 Fran@,{c}ois Pinard, with the help of numerous and kind users.
1090 We wish to stress that @command{tar} is a collective work, and owes much to
1091 all those people who reported problems, offered solutions and other
1092 insights, or shared their thoughts and suggestions. An impressive, yet
1093 partial list of those contributors can be found in the @file{THANKS}
1094 file from the @GNUTAR{} distribution.
1096 @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
1097 sure i want to spell out the history in this detail, at least not for
1098 the printed book. i'm just not sure it needs to be said this way.
1099 i'll think about it.}
1101 @FIXME{History is more important, and surely more interesting, than
1102 actual names. Quoting names without history would be meaningless. FP}
1104 Jay Fenlason put together a draft of a @GNUTAR{}
1105 manual, borrowing notes from the original man page from John Gilmore.
1106 This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
1107 Gorin worked on a tutorial and manual for @GNUTAR{}.
1108 Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
1109 taking information from all these sources and merging them. Melissa
1110 Weisshaus finally edited and redesigned the book to create version
1111 1.12. @FIXME{update version number as necessary; i'm being
1112 optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
1113 maybe melissa? maybe julie sussman?] needs to properly index the
1116 For version 1.12, Daniel Hagerty contributed a great deal of technical
1117 consulting. In particular, he is the primary author of @ref{Backups}.
1119 In July, 2003 @GNUTAR{} was put on CVS at @url{savannah.gnu.org}, and
1120 an active development and maintenance work has started
1121 again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
1122 Poznyakoff and Jeff Bailey.
1124 Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
1127 @section Reporting bugs or suggestions
1130 @cindex reporting bugs
1131 If you find problems or have suggestions about this program or manual,
1132 please report them to @file{bug-tar@@gnu.org}.
1135 @chapter Tutorial Introduction to @command{tar}
1137 This chapter guides you through some basic examples of three @command{tar}
1138 operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
1139 you already know how to use some other version of @command{tar}, then you
1140 may not need to read this chapter. This chapter omits most complicated
1141 details about how @command{tar} works.
1145 * stylistic conventions::
1146 * basic tar options:: Basic @command{tar} Operations and Options
1147 * frequent operations::
1148 * Two Frequent Options::
1149 * create:: How to Create Archives
1150 * list:: How to List Archives
1151 * extract:: How to Extract Members from an Archive
1156 @section Assumptions this Tutorial Makes
1158 This chapter is paced to allow beginners to learn about @command{tar}
1159 slowly. At the same time, we will try to cover all the basic aspects of
1160 these three operations. In order to accomplish both of these tasks, we
1161 have made certain assumptions about your knowledge before reading this
1162 manual, and the hardware you will be using:
1166 Before you start to work through this tutorial, you should understand
1167 what the terms ``archive'' and ``archive member'' mean
1168 (@pxref{Definitions}). In addition, you should understand something
1169 about how Unix-type operating systems work, and you should know how to
1170 use some basic utilities. For example, you should know how to create,
1171 list, copy, rename, edit, and delete files and directories; how to
1172 change between directories; and how to figure out where you are in the
1173 filesystem. You should have some basic understanding of directory
1174 structure and how files are named according to which directory they are
1175 in. You should understand concepts such as standard output and standard
1176 input, what various definitions of the term ``argument'' mean, and the
1177 differences between relative and absolute path names. @FIXME{and what
1181 This manual assumes that you are working from your own home directory
1182 (unless we state otherwise). In this tutorial, you will create a
1183 directory to practice @command{tar} commands in. When we show path names,
1184 we will assume that those paths are relative to your home directory.
1185 For example, my home directory path is @file{/home/fsf/melissa}. All of
1186 my examples are in a subdirectory of the directory named by that path
1187 name; the subdirectory is called @file{practice}.
1190 In general, we show examples of archives which exist on (or can be
1191 written to, or worked with from) a directory on a hard disk. In most
1192 cases, you could write those archives to, or work with them on any other
1193 device, such as a tape drive. However, some of the later examples in
1194 the tutorial and next chapter will not work on tape drives.
1195 Additionally, working with tapes is much more complicated than working
1196 with hard disks. For these reasons, the tutorial does not cover working
1197 with tape drives. @xref{Media}, for complete information on using
1198 @command{tar} archives with tape drives.
1200 @FIXME{this is a cop out. need to add some simple tape drive info.}
1203 @node stylistic conventions
1204 @section Stylistic Conventions
1206 In the examples, @samp{$} represents a typical shell prompt. It
1207 precedes lines you should type; to make this more clear, those lines are
1208 shown in @kbd{this font}, as opposed to lines which represent the
1209 computer's response; those lines are shown in @code{this font}, or
1210 sometimes @samp{like this}. When we have lines which are too long to be
1211 displayed in any other way, we will show them like this:
1214 This is an example of a line which would otherwise not fit in this space.
1217 @FIXME{how often do we use smallexample?}
1219 @node basic tar options
1220 @section Basic @command{tar} Operations and Options
1222 @command{tar} can take a wide variety of arguments which specify and define
1223 the actions it will have on the particular set of files or the archive.
1224 The main types of arguments to @command{tar} fall into one of two classes:
1225 operations, and options.
1227 Some arguments fall into a class called @dfn{operations}; exactly one of
1228 these is both allowed and required for any instance of using @command{tar};
1229 you may @emph{not} specify more than one. People sometimes speak of
1230 @dfn{operating modes}. You are in a particular operating mode when you
1231 have specified the operation which specifies it; there are eight
1232 operations in total, and thus there are eight operating modes.
1234 The other arguments fall into the class known as @dfn{options}. You are
1235 not required to specify any options, and you are allowed to specify more
1236 than one at a time (depending on the way you are using @command{tar} at
1237 that time). Some options are used so frequently, and are so useful for
1238 helping you type commands more carefully that they are effectively
1239 ``required''. We will discuss them in this chapter.
1241 You can write most of the @command{tar} operations and options in any
1242 of three forms: long (mnemonic) form, short form, and old style. Some
1243 of the operations and options have no short or ``old'' forms; however,
1244 the operations and options which we will cover in this tutorial have
1245 corresponding abbreviations. @FIXME{make sure this is still the case,
1246 at the end}We will indicate those abbreviations appropriately to get
1247 you used to seeing them. (Note that the ``old style'' option forms
1248 exist in @GNUTAR{} for compatibility with Unix
1249 @command{tar}. We present a full discussion of this way of writing
1250 options and operations appears in @ref{Old Options}, and we discuss
1251 the other two styles of writing options in @ref{Mnemonic Options} and
1252 @ref{Short Options}.)
1254 In the examples and in the text of this tutorial, we usually use the
1255 long forms of operations and options; but the ``short'' forms produce
1256 the same result and can make typing long @command{tar} commands easier.
1257 For example, instead of typing
1260 @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
1266 @kbd{tar -c -v -f afiles.tar apple angst aspic}
1272 @kbd{tar -cvf afiles.tar apple angst aspic}
1276 For more information on option syntax, see @ref{Advanced tar}. In
1277 discussions in the text, when we name an option by its long form, we
1278 also give the corresponding short option in parentheses.
1280 The term, ``option'', can be confusing at times, since ``operations''
1281 are often lumped in with the actual, @emph{optional} ``options'' in certain
1282 general class statements. For example, we just talked about ``short and
1283 long forms of options and operations''. However, experienced @command{tar}
1284 users often refer to these by shorthand terms such as, ``short and long
1285 options''. This term assumes that the ``operations'' are included, also.
1286 Context will help you determine which definition of ``options'' to use.
1288 Similarly, the term ``command'' can be confusing, as it is often used in
1289 two different ways. People sometimes refer to @command{tar} ``commands''.
1290 A @command{tar} @dfn{command} is the entire command line of user input
1291 which tells @command{tar} what to do --- including the operation, options,
1292 and any arguments (file names, pipes, other commands, etc). However,
1293 you will also sometimes hear the term ``the @command{tar} command''. When
1294 the word ``command'' is used specifically like this, a person is usually
1295 referring to the @command{tar} @emph{operation}, not the whole line.
1296 Again, use context to figure out which of the meanings the speaker
1299 @node frequent operations
1300 @section The Three Most Frequently Used Operations
1302 Here are the three most frequently used operations (both short and long
1303 forms), as well as a brief description of their meanings. The rest of
1304 this chapter will cover how to use these operations in detail. We will
1305 present the rest of the operations in the next chapter.
1310 Create a new @command{tar} archive.
1313 List the contents of an archive.
1316 Extract one or more members from an archive.
1319 @node Two Frequent Options
1320 @section Two Frequently Used Options
1322 To understand how to run @command{tar} in the three operating modes listed
1323 previously, you also need to understand how to use two of the options to
1324 @command{tar}: @samp{--file} (which takes an archive file as an argument)
1325 and @samp{--verbose}. (You are usually not @emph{required} to specify
1326 either of these options when you run @command{tar}, but they can be very
1327 useful in making things more clear and helping you avoid errors.)
1331 * verbose tutorial::
1336 @unnumberedsubsec The @samp{--file} Option
1339 @item --file=@var{archive-name}
1340 @itemx -f @var{archive-name}
1341 Specify the name of an archive file.
1344 You can specify an argument for the @value{op-file} option whenever you
1345 use @command{tar}; this option determines the name of the archive file
1346 that @command{tar} will work on.
1348 If you don't specify this argument, then @command{tar} will use a
1349 default, usually some physical tape drive attached to your machine.
1350 If there is no tape drive attached, or the default is not meaningful,
1351 then @command{tar} will print an error message. The error message might
1352 look roughly like one of the following:
1355 tar: can't open /dev/rmt8 : No such device or address
1356 tar: can't open /dev/rsmt0 : I/O error
1360 To avoid confusion, we recommend that you always specify an archive file
1361 name by using @value{op-file} when writing your @command{tar} commands.
1362 For more information on using the @value{op-file} option, see
1365 @node verbose tutorial
1366 @unnumberedsubsec The @samp{--verbose} Option
1371 Show the files being worked on as @command{tar} is running.
1374 @value{op-verbose} shows details about the results of running
1375 @command{tar}. This can be especially useful when the results might not be
1376 obvious. For example, if you want to see the progress of @command{tar} as
1377 it writes files into the archive, you can use the @samp{--verbose}
1378 option. In the beginning, you may find it useful to use
1379 @samp{--verbose} at all times; when you are more accustomed to
1380 @command{tar}, you will likely want to use it at certain times but not at
1381 others. We will use @samp{--verbose} at times to help make something
1382 clear, and we will give many examples both using and not using
1383 @samp{--verbose} to show the differences.
1385 Sometimes, a single instance of @samp{--verbose} on the command line
1386 will show a full, @samp{ls} style listing of an archive or files,
1387 @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
1388 giving sizes, owners, and similar information. Other times,
1389 @samp{--verbose} will only show files or members that the particular
1390 operation is operating on at the time. In the latter case, you can
1391 use @samp{--verbose} twice in a command to get a listing such as that
1392 in the former case. For example, instead of saying
1395 @kbd{tar -cvf afiles.tar apple angst aspic}
1399 above, you might say
1402 @kbd{tar -cvvf afiles.tar apple angst aspic}
1406 This works equally well using short or long forms of options. Using
1407 long forms, you would simply write out the mnemonic form of the option
1411 $ @kbd{tar --create --verbose --verbose @dots{}}
1415 Note that you must double the hyphens properly each time.
1417 Later in the tutorial, we will give examples using @w{@samp{--verbose
1421 @unnumberedsubsec Getting Help: Using the @code{--help} Option
1426 The @samp{--help} option to @command{tar} prints out a very brief list of
1427 all operations and option available for the current version of
1428 @command{tar} available on your system.
1432 @section How to Create Archives
1435 One of the basic operations of @command{tar} is @value{op-create}, which
1436 you use to create a @command{tar} archive. We will explain
1437 @samp{--create} first because, in order to learn about the other
1438 operations, you will find it useful to have an archive available to
1441 To make this easier, in this section you will first create a directory
1442 containing three files. Then, we will show you how to create an
1443 @emph{archive} (inside the new directory). Both the directory, and
1444 the archive are specifically for you to practice on. The rest of this
1445 chapter and the next chapter will show many examples using this
1446 directory and the files you will create: some of those files may be
1447 other directories and other archives.
1449 The three files you will archive in this example are called
1450 @file{blues}, @file{folk}, and @file{jazz}. The archive is called
1451 @file{collection.tar}.
1453 This section will proceed slowly, detailing how to use @samp{--create}
1454 in @code{verbose} mode, and showing examples using both short and long
1455 forms. In the rest of the tutorial, and in the examples in the next
1456 chapter, we will proceed at a slightly quicker pace. This section
1457 moves more slowly to allow beginning users to understand how
1458 @command{tar} works.
1461 * prepare for examples::
1462 * Creating the archive::
1468 @node prepare for examples
1469 @subsection Preparing a Practice Directory for Examples
1471 To follow along with this and future examples, create a new directory
1472 called @file{practice} containing files called @file{blues}, @file{folk}
1473 and @file{jazz}. The files can contain any information you like:
1474 ideally, they should contain information which relates to their names,
1475 and be of different lengths. Our examples assume that @file{practice}
1476 is a subdirectory of your home directory.
1478 Now @command{cd} to the directory named @file{practice}; @file{practice}
1479 is now your @dfn{working directory}. (@emph{Please note}: Although
1480 the full path name of this directory is
1481 @file{/@var{homedir}/practice}, in our examples we will refer to
1482 this directory as @file{practice}; the @var{homedir} is presumed.
1484 In general, you should check that the files to be archived exist where
1485 you think they do (in the working directory) by running @command{ls}.
1486 Because you just created the directory and the files and have changed to
1487 that directory, you probably don't need to do that this time.
1489 It is very important to make sure there isn't already a file in the
1490 working directory with the archive name you intend to use (in this case,
1491 @samp{collection.tar}), or that you don't care about its contents.
1492 Whenever you use @samp{create}, @command{tar} will erase the current
1493 contents of the file named by @value{op-file} if it exists. @command{tar}
1494 will not tell you if you are about to overwrite an archive unless you
1495 specify an option which does this. @FIXME{xref to the node for
1496 --backup!}To add files to an existing archive, you need to use a
1497 different option, such as @value{op-append}; see @ref{append} for
1498 information on how to do this.
1500 @node Creating the archive
1501 @subsection Creating the Archive
1503 To place the files @file{blues}, @file{folk}, and @file{jazz} into an
1504 archive named @file{collection.tar}, use the following command:
1507 $ @kbd{tar --create --file=collection.tar blues folk jazz}
1510 The order of the arguments is not very important, @emph{when using long
1511 option forms}. You could also say:
1514 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1518 However, you can see that this order is harder to understand; this is
1519 why we will list the arguments in the order that makes the commands
1520 easiest to understand (and we encourage you to do the same when you use
1521 @command{tar}, to avoid errors).
1523 Note that the part of the command which says,
1524 @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
1525 If you substituted any other string of characters for
1526 @kbd{collection.tar}, then that string would become the name of the
1527 archive file you create.
1529 The order of the options becomes more important when you begin to use
1530 short forms. With short forms, if you type commands in the wrong order
1531 (even if you type them correctly in all other ways), you may end up with
1532 results you don't expect. For this reason, it is a good idea to get
1533 into the habit of typing options in the order that makes inherent sense.
1534 @xref{short create}, for more information on this.
1536 In this example, you type the command as shown above: @samp{--create}
1537 is the operation which creates the new archive
1538 (@file{collection.tar}), and @samp{--file} is the option which lets
1539 you give it the name you chose. The files, @file{blues}, @file{folk},
1540 and @file{jazz}, are now members of the archive, @file{collection.tar}
1541 (they are @dfn{file name arguments} to the @samp{--create} operation).
1542 @FIXME{xref here to the discussion of file name args?}Now that they are
1543 in the archive, they are called @emph{archive members}, not files.
1544 @FIXME{xref to definitions?}
1546 When you create an archive, you @emph{must} specify which files you
1547 want placed in the archive. If you do not specify any archive
1548 members, @GNUTAR{} will complain.
1550 If you now list the contents of the working directory (@kbd{ls}), you will
1551 find the archive file listed as well as the files you saw previously:
1554 blues folk jazz collection.tar
1558 Creating the archive @samp{collection.tar} did not destroy the copies of
1559 the files in the directory.
1561 Keep in mind that if you don't indicate an operation, @command{tar} will not
1562 run and will prompt you for one. If you don't name any files, @command{tar}
1563 will complain. You must have write access to the working directory,
1564 or else you will not be able to create an archive in that directory.
1566 @emph{Caution}: Do not attempt to use @value{op-create} to add files to
1567 an existing archive; it will delete the archive and write a new one.
1568 Use @value{op-append} instead. @xref{append}.
1570 @node create verbose
1571 @subsection Running @samp{--create} with @samp{--verbose}
1573 If you include the @value{op-verbose} option on the command line,
1574 @command{tar} will list the files it is acting on as it is working. In
1575 verbose mode, the @code{create} example above would appear as:
1578 $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
1584 This example is just like the example we showed which did not use
1585 @samp{--verbose}, except that @command{tar} generated the remaining lines
1587 (note the different font styles).
1593 In the rest of the examples in this chapter, we will frequently use
1594 @code{verbose} mode so we can show actions or @command{tar} responses that
1595 you would otherwise not see, and which are important for you to
1599 @subsection Short Forms with @samp{create}
1601 As we said before, the @value{op-create} operation is one of the most
1602 basic uses of @command{tar}, and you will use it countless times.
1603 Eventually, you will probably want to use abbreviated (or ``short'')
1604 forms of options. A full discussion of the three different forms that
1605 options can take appears in @ref{Styles}; for now, here is what the
1606 previous example (including the @value{op-verbose} option) looks like
1607 using short option forms:
1610 $ @kbd{tar -cvf collection.tar blues folk jazz}
1617 As you can see, the system responds the same no matter whether you use
1618 long or short option forms.
1620 @FIXME{i don't like how this is worded:} One difference between using
1621 short and long option forms is that, although the exact placement of
1622 arguments following options is no more specific when using short forms,
1623 it is easier to become confused and make a mistake when using short
1624 forms. For example, suppose you attempted the above example in the
1628 $ @kbd{tar -cfv collection.tar blues folk jazz}
1632 In this case, @command{tar} will make an archive file called @file{v},
1633 containing the files @file{blues}, @file{folk}, and @file{jazz}, because
1634 the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
1635 is thus taken to be the chosen archive file name. @command{tar} will try
1636 to add a file called @file{collection.tar} to the @file{v} archive file;
1637 if the file @file{collection.tar} did not already exist, @command{tar} will
1638 report an error indicating that this file does not exist. If the file
1639 @file{collection.tar} does already exist (e.g., from a previous command
1640 you may have run), then @command{tar} will add this file to the archive.
1641 Because the @samp{-v} option did not get registered, @command{tar} will not
1642 run under @samp{verbose} mode, and will not report its progress.
1644 The end result is that you may be quite confused about what happened,
1645 and possibly overwrite a file. To illustrate this further, we will show
1646 you how an example we showed previously would look using short forms.
1651 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1655 is confusing as it is. When shown using short forms, however, it
1656 becomes much more so:
1659 $ @kbd{tar blues -c folk -f collection.tar jazz}
1663 It would be very easy to put the wrong string of characters
1664 immediately following the @samp{-f}, but doing that could sacrifice
1667 For this reason, we recommend that you pay very careful attention to
1668 the order of options and placement of file and archive names,
1669 especially when using short option forms. Not having the option name
1670 written out mnemonically can affect how well you remember which option
1671 does what, and therefore where different names have to be placed.
1672 (Placing options in an unusual order can also cause @command{tar} to
1673 report an error if you have set the shell environment variable
1674 @env{POSIXLY_CORRECT}; @pxref{posix compliance} for more information
1678 @subsection Archiving Directories
1680 @cindex Archiving Directories
1681 @cindex Directories, Archiving
1682 You can archive a directory by specifying its directory name as a
1683 file name argument to @command{tar}. The files in the directory will be
1684 archived relative to the working directory, and the directory will be
1685 re-created along with its contents when the archive is extracted.
1687 To archive a directory, first move to its superior directory. If you
1688 have followed the previous instructions in this tutorial, you should
1697 This will put you into the directory which contains @file{practice},
1698 i.e. your home directory. Once in the superior directory, you can
1699 specify the subdirectory, @file{practice}, as a file name argument. To
1700 store @file{practice} in the new archive file @file{music.tar}, type:
1703 $ @kbd{tar --create --verbose --file=music.tar practice}
1707 @command{tar} should output:
1714 practice/collection.tar
1717 Note that the archive thus created is not in the subdirectory
1718 @file{practice}, but rather in the current working directory---the
1719 directory from which @command{tar} was invoked. Before trying to archive a
1720 directory from its superior directory, you should make sure you have
1721 write access to the superior directory itself, not only the directory
1722 you are trying archive with @command{tar}. For example, you will probably
1723 not be able to store your home directory in an archive by invoking
1724 @command{tar} from the root directory; @value{xref-absolute-names}. (Note
1725 also that @file{collection.tar}, the original archive file, has itself
1726 been archived. @command{tar} will accept any file as a file to be
1727 archived, regardless of its content. When @file{music.tar} is
1728 extracted, the archive file @file{collection.tar} will be re-written
1729 into the file system).
1731 If you give @command{tar} a command such as
1734 $ @kbd{tar --create --file=foo.tar .}
1738 @command{tar} will report @samp{tar: ./foo.tar is the archive; not
1739 dumped}. This happens because @command{tar} creates the archive
1740 @file{foo.tar} in the current directory before putting any files into
1741 it. Then, when @command{tar} attempts to add all the files in the
1742 directory @file{.} to the archive, it notices that the file
1743 @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
1744 it. (It makes no sense to put an archive into itself.) @GNUTAR{}
1745 will continue in this case, and create the archive
1746 normally, except for the exclusion of that one file. (@emph{Please
1747 note:} Other versions of @command{tar} are not so clever; they will
1748 enter an infinite loop when this happens, so you should not depend on
1749 this behavior unless you are certain you are running @GNUTAR{}.)
1750 @FIXME{bob doesn't like this sentence, since he does
1751 it all the time, and we've been doing it in the editing passes for
1752 this manual: In general, make sure that the archive is not inside a
1753 directory being dumped.}
1756 @section How to List Archives
1758 Frequently, you will find yourself wanting to determine exactly what a
1759 particular archive contains. You can use the @value{op-list} operation
1760 to get the member names as they currently appear in the archive, as well
1761 as various attributes of the files at the time they were archived. For
1762 example, you can examine the archive @file{collection.tar} that you
1763 created in the last section with the command,
1766 $ @kbd{tar --list --file=collection.tar}
1770 The output of @command{tar} would then be:
1778 @FIXME{we hope this will change. if it doesn't, need to show the
1779 creation of bfiles somewhere above!!! : }
1782 The archive @file{bfiles.tar} would list as follows:
1791 Be sure to use a @value{op-file} option just as with @value{op-create}
1792 to specify the name of the archive.
1794 If you use the @value{op-verbose} option with @samp{--list}, then
1795 @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
1796 showing owner, file size, and so forth.
1798 If you had used @value{op-verbose} mode, the example above would look
1802 $ @kbd{tar --list --verbose --file=collection.tar folk}
1803 -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
1806 @cindex File name arguments, using @code{--list} with
1807 @cindex @code{--list} with file name arguments
1808 You can specify one or more individual member names as arguments when
1809 using @samp{list}. In this case, @command{tar} will only list the
1810 names of members you identify. For example, @w{@kbd{tar --list
1811 --file=afiles.tar apple}} would only print @file{apple}.
1813 @FIXME{we hope the relevant aspects of this will change:}Because
1814 @command{tar} preserves paths, file names must be specified as they appear
1815 in the archive (ie., relative to the directory from which the archive
1816 was created). Therefore, it is essential when specifying member names
1817 to @command{tar} that you give the exact member names. For example,
1818 @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
1819 something like @samp{tar: birds: Not found in archive}, because there is
1820 no member named @file{birds}, only one named @file{./birds}. While the
1821 names @file{birds} and @file{./birds} name the same file, @emph{member}
1822 names are compared using a simplistic name comparison, in which an exact
1823 match is necessary. @xref{absolute}.
1825 However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
1826 with @file{folk}, because @file{folk} is in the archive file
1827 @file{collection.tar}. If you are not sure of the exact file name, try
1828 listing all the files in the archive and searching for the one you
1829 expect to find; remember that if you use @samp{--list} with no file
1830 names as arguments, @command{tar} will print the names of all the members
1831 stored in the specified archive.
1838 @unnumberedsubsec Listing the Contents of a Stored Directory
1841 @FIXME{i changed the order of these nodes around and haven't had a
1842 chance to play around with this node's example, yet. i have to play
1843 with it and see what it actually does for my own satisfaction, even if
1844 what it says *is* correct..}
1846 To get information about the contents of an archived directory,
1847 use the directory name as a file name argument in conjunction with
1848 @value{op-list}. To find out file attributes, include the
1849 @value{op-verbose} option.
1851 For example, to find out about files in the directory @file{practice}, in
1852 the archive file @file{music.tar}, type:
1855 $ @kbd{tar --list --verbose --file=music.tar practice}
1858 @command{tar} responds:
1861 drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
1862 -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
1863 -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
1864 -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
1865 -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
1868 When you use a directory name as a file name argument, @command{tar} acts on
1869 all the files (including sub-directories) in that directory.
1872 @section How to Extract Members from an Archive
1875 @cindex Retrieving files from an archive
1876 @cindex Resurrecting files from an archive
1878 Creating an archive is only half the job---there is no point in storing
1879 files in an archive if you can't retrieve them. The act of retrieving
1880 members from an archive so they can be used and manipulated as
1881 unarchived files again is called @dfn{extraction}. To extract files
1882 from an archive, use the @value{op-extract} operation. As with
1883 @value{op-create}, specify the name of the archive with @value{op-file}.
1884 Extracting an archive does not modify the archive in any way; you can
1885 extract it multiple times if you want or need to.
1887 Using @samp{--extract}, you can extract an entire archive, or specific
1888 files. The files can be directories containing other files, or not. As
1889 with @value{op-create} and @value{op-list}, you may use the short or the
1890 long form of the operation without affecting the performance.
1893 * extracting archives::
1894 * extracting files::
1896 * extracting untrusted archives::
1897 * failing commands::
1900 @node extracting archives
1901 @subsection Extracting an Entire Archive
1903 To extract an entire archive, specify the archive file name only, with
1904 no individual file names as arguments. For example,
1907 $ @kbd{tar -xvf collection.tar}
1914 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
1915 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
1916 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
1919 @node extracting files
1920 @subsection Extracting Specific Files
1922 To extract specific archive members, give their exact member names as
1923 arguments, as printed by @value{op-list}. If you had mistakenly deleted
1924 one of the files you had placed in the archive @file{collection.tar}
1925 earlier (say, @file{blues}), you can extract it from the archive without
1926 changing the archive's structure. It will be identical to the original
1927 file @file{blues} that you deleted. @FIXME{check this; will the times,
1928 permissions, owner, etc be the same, also?}
1930 First, make sure you are in the @file{practice} directory, and list the
1931 files in the directory. Now, delete the file, @samp{blues}, and list
1932 the files in the directory again.
1934 You can now extract the member @file{blues} from the archive file
1935 @file{collection.tar} like this:
1938 $ @kbd{tar --extract --file=collection.tar blues}
1942 If you list the files in the directory again, you will see that the file
1943 @file{blues} has been restored, with its original permissions, creation
1944 times, and owner.@FIXME{This is only accidentally true, but not in
1945 general. In most cases, one has to be root for restoring the owner, and
1946 use a special option for restoring permissions. Here, it just happens
1947 that the restoring user is also the owner of the archived members, and
1948 that the current @code{umask} is compatible with original permissions.}
1949 (These parameters will be identical to those which
1950 the file had when you originally placed it in the archive; any changes
1951 you may have made before deleting the file from the file system,
1952 however, will @emph{not} have been made to the archive member.) The
1953 archive file, @samp{collection.tar}, is the same as it was before you
1954 extracted @samp{blues}. You can confirm this by running @command{tar} with
1957 @FIXME{we hope this will change:}Remember that as with other operations,
1958 specifying the exact member name is important. @w{@kbd{tar --extract
1959 --file=bfiles.tar birds}} will fail, because there is no member named
1960 @file{birds}. To extract the member named @file{./birds}, you must
1961 specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
1962 exact member names of the members of an archive, use @value{op-list}
1965 You can extract a file to standard output by combining the above options
1966 with the @option{--to-stdout} option (@pxref{Writing to Standard
1969 If you give the @value{op-verbose} option, then @value{op-extract} will
1970 print the names of the archive members as it extracts them.
1973 @subsection Extracting Files that are Directories
1975 Extracting directories which are members of an archive is similar to
1976 extracting other files. The main difference to be aware of is that if
1977 the extracted directory has the same name as any directory already in
1978 the working directory, then files in the extracted directory will be
1979 placed into the directory of the same name. Likewise, if there are
1980 files in the pre-existing directory with the same names as the members
1981 which you extract, the files from the extracted archive will replace
1982 the files already in the working directory (and possible
1983 subdirectories). This will happen regardless of whether or not the
1984 files in the working directory were more recent than those extracted.
1986 However, if a file was stored with a directory name as part of its file
1987 name, and that directory does not exist under the working directory when
1988 the file is extracted, @command{tar} will create the directory.
1990 We can demonstrate how to use @samp{--extract} to extract a directory
1991 file with an example. Change to the @file{practice} directory if you
1992 weren't there, and remove the files @file{folk} and @file{jazz}. Then,
1993 go back to the parent directory and extract the archive
1994 @file{music.tar}. You may either extract the entire archive, or you may
1995 extract only the files you just deleted. To extract the entire archive,
1996 don't give any file names as arguments after the archive name
1997 @file{music.tar}. To extract only the files you deleted, use the
2001 $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
2004 @FIXME{need to show tar's response; used verbose above. also, here's a
2005 good place to demonstrate the -v -v thing. have to write that up
2006 (should be trivial, but i'm too tired!).}
2009 Because you created the directory with @file{practice} as part of the
2010 file names of each of the files by archiving the @file{practice}
2011 directory as @file{practice}, you must give @file{practice} as part
2012 of the file names when you extract those files from the archive.
2014 @FIXME{IMPORTANT! show the final structure, here. figure out what it
2017 @node extracting untrusted archives
2018 @subsection Extracting Archives from Untrusted Sources
2020 Extracting files from archives can overwrite files that already exist.
2021 If you receive an archive from an untrusted source, you should make a
2022 new directory and extract into that directory, so that you don't have
2023 to worry about the extraction overwriting one of your existing files.
2024 For example, if @file{untrusted.tar} came from somewhere else on the
2025 Internet, and you don't necessarily trust its contents, you can
2026 extract it as follows:
2029 $ @kbd{mkdir newdir}
2031 $ @kbd{tar -xvf ../untrusted.tar}
2034 @node failing commands
2035 @subsection Commands That Will Fail
2037 Here are some sample commands you might try which will not work, and why
2040 If you try to use this command,
2043 $ @kbd{tar -xvf music.tar folk jazz}
2047 you will get the following response:
2050 tar: folk: Not found in archive
2051 tar: jazz: Not found in archive
2056 This is because these files were not originally @emph{in} the parent
2057 directory @file{..}, where the archive is located; they were in the
2058 @file{practice} directory, and their file names reflect this:
2061 $ @kbd{tar -tvf music.tar}
2067 @FIXME{make sure the above works when going through the examples in
2071 Likewise, if you try to use this command,
2074 $ @kbd{tar -tvf music.tar folk jazz}
2078 you would get a similar response. Members with those names are not in the
2079 archive. You must use the correct member names in order to extract the
2080 files from the archive.
2082 If you have forgotten the correct names of the files in the archive,
2083 use @w{@kbd{tar --list --verbose}} to list them correctly.
2085 @FIXME{more examples, here? hag thinks it's a good idea.}
2088 @section Going Further Ahead in this Manual
2090 @FIXME{need to write up a node here about the things that are going to
2091 be in the rest of the manual.}
2093 @node tar invocation
2094 @chapter Invoking @GNUTAR{}
2097 This chapter is about how one invokes the @GNUTAR{}
2098 command, from the command synopsis (@pxref{Synopsis}). There are
2099 numerous options, and many styles for writing them. One mandatory
2100 option specifies the operation @command{tar} should perform
2101 (@pxref{Operation Summary}), other options are meant to detail how
2102 this operation should be performed (@pxref{Option Summary}).
2103 Non-option arguments are not always interpreted the same way,
2104 depending on what the operation is.
2106 You will find in this chapter everything about option styles and rules for
2107 writing them (@pxref{Styles}). On the other hand, operations and options
2108 are fully described elsewhere, in other chapters. Here, you will find
2109 only synthetic descriptions for operations and options, together with
2110 pointers to other parts of the @command{tar} manual.
2112 Some options are so special they are fully described right in this
2113 chapter. They have the effect of inhibiting the normal operation of
2114 @command{tar} or else, they globally alter the amount of feedback the user
2115 receives about what is going on. These are the @value{op-help} and
2116 @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
2117 and @value{op-interactive} options (@pxref{interactive}).
2121 * using tar options::
2130 @section General Synopsis of @command{tar}
2132 The @GNUTAR{} program is invoked as either one of:
2135 @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
2136 @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
2139 The second form is for when old options are being used.
2141 You can use @command{tar} to store files in an archive, to extract them from
2142 an archive, and to do other types of archive manipulation. The primary
2143 argument to @command{tar}, which is called the @dfn{operation}, specifies
2144 which action to take. The other arguments to @command{tar} are either
2145 @dfn{options}, which change the way @command{tar} performs an operation,
2146 or file names or archive members, which specify the files or members
2147 @command{tar} is to act on.
2149 You can actually type in arguments in any order, even if in this manual
2150 the options always precede the other arguments, to make examples easier
2151 to understand. Further, the option stating the main operation mode
2152 (the @command{tar} main command) is usually given first.
2154 Each @var{name} in the synopsis above is interpreted as an archive member
2155 name when the main command is one of @value{op-compare}, @value{op-delete},
2156 @value{op-extract}, @value{op-list} or @value{op-update}. When naming
2157 archive members, you must give the exact name of the member in the
2158 archive, as it is printed by @value{op-list}. For @value{op-append}
2159 and @value{op-create}, these @var{name} arguments specify the names
2160 of either files or directory hierarchies to place in the archive.
2161 These files or hierarchies should already exist in the file system,
2162 prior to the execution of the @command{tar} command.
2164 @command{tar} interprets relative file names as being relative to the
2165 working directory. @command{tar} will make all file names relative
2166 (by removing leading slashes when archiving or restoring files),
2167 unless you specify otherwise (using the @value{op-absolute-names}
2168 option). @value{xref-absolute-names}, for more information about
2169 @value{op-absolute-names}.
2171 If you give the name of a directory as either a file name or a member
2172 name, then @command{tar} acts recursively on all the files and directories
2173 beneath that directory. For example, the name @file{/} identifies all
2174 the files in the filesystem to @command{tar}.
2176 The distinction between file names and archive member names is especially
2177 important when shell globbing is used, and sometimes a source of confusion
2178 for newcomers. @xref{Wildcards}, for more information about globbing.
2179 The problem is that shells may only glob using existing files in the
2180 file system. Only @command{tar} itself may glob on archive members, so when
2181 needed, you must ensure that wildcard characters reach @command{tar} without
2182 being interpreted by the shell first. Using a backslash before @samp{*}
2183 or @samp{?}, or putting the whole argument between quotes, is usually
2184 sufficient for this.
2186 Even if @var{name}s are often specified on the command line, they
2187 can also be read from a text file in the file system, using the
2188 @value{op-files-from} option.
2190 If you don't use any file name arguments, @value{op-append},
2191 @value{op-delete} and @value{op-concatenate} will do nothing, while
2192 @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
2193 execution. The other operations of @command{tar} (@value{op-list},
2194 @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
2195 on the entire contents of the archive.
2198 @cindex return status
2199 Besides successful exits, @GNUTAR{} may fail for
2200 many reasons. Some reasons correspond to bad usage, that is, when the
2201 @command{tar} command is improperly written. Errors may be
2202 encountered later, while encountering an error processing the archive
2203 or the files. Some errors are recoverable, in which case the failure
2204 is delayed until @command{tar} has completed all its work. Some
2205 errors are such that it would not meaningful, or at least risky, to
2206 continue processing: @command{tar} then aborts processing immediately.
2207 All abnormal exits, whether immediate or delayed, should always be
2208 clearly diagnosed on @code{stderr}, after a line stating the nature of
2211 @GNUTAR{} returns only a few exit statuses. I'm really
2212 aiming simplicity in that area, for now. If you are not using the
2213 @value{op-compare} option, zero means that everything went well, besides
2214 maybe innocuous warnings. Nonzero means that something went wrong.
2215 Right now, as of today, ``nonzero'' is almost always 2, except for
2216 remote operations, where it may be 128.
2218 @node using tar options
2219 @section Using @command{tar} Options
2221 @GNUTAR{} has a total of eight operating modes which
2222 allow you to perform a variety of tasks. You are required to choose
2223 one operating mode each time you employ the @command{tar} program by
2224 specifying one, and only one operation as an argument to the
2225 @command{tar} command (two lists of four operations each may be found
2226 at @ref{frequent operations} and @ref{Operations}). Depending on
2227 circumstances, you may also wish to customize how the chosen operating
2228 mode behaves. For example, you may wish to change the way the output
2229 looks, or the format of the files that you wish to archive may require
2230 you to do something special in order to make the archive look right.
2232 You can customize and control @command{tar}'s performance by running
2233 @command{tar} with one or more options (such as @value{op-verbose}, which
2234 we used in the tutorial). As we said in the tutorial, @dfn{options} are
2235 arguments to @command{tar} which are (as their name suggests) optional.
2236 Depending on the operating mode, you may specify one or more options.
2237 Different options will have different effects, but in general they all
2238 change details of the operation, such as archive format, archive name,
2239 or level of user interaction. Some options make sense with all
2240 operating modes, while others are meaningful only with particular modes.
2241 You will likely use some options frequently, while you will only use
2242 others infrequently, or not at all. (A full list of options is
2243 available in @pxref{All Options}.)
2245 The @env{TAR_OPTIONS} environment variable specifies default options to
2246 be placed in front of any explicit options. For example, if
2247 @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
2248 if the two options @option{-v} and @option{--unlink-first} had been
2249 specified before any explicit options. Option specifications are
2250 separated by whitespace. A backslash escapes the next character, so it
2251 can be used to specify an option containing whitespace or a backslash.
2253 Note that @command{tar} options are case sensitive. For example, the
2254 options @samp{-T} and @samp{-t} are different; the first requires an
2255 argument for stating the name of a file providing a list of @var{name}s,
2256 while the second does not require an argument and is another way to
2257 write @value{op-list}.
2259 In addition to the eight operations, there are many options to
2260 @command{tar}, and three different styles for writing both: long (mnemonic)
2261 form, short form, and old style. These styles are discussed below.
2262 Both the options and the operations can be written in any of these three
2265 @FIXME{menu at end of this node. need to think of an actual outline
2266 for this chapter; probably do that after stuff from chap. 4 is
2270 @section The Three Option Styles
2272 There are three styles for writing operations and options to the command
2273 line invoking @command{tar}. The different styles were developed at
2274 different times during the history of @command{tar}. These styles will be
2275 presented below, from the most recent to the oldest.
2277 Some options must take an argument. (For example, @value{op-file} takes
2278 the name of an archive file as an argument. If you do not supply an
2279 archive file name, @command{tar} will use a default, but this can be
2280 confusing; thus, we recommend that you always supply a specific archive
2281 file name.) Where you @emph{place} the arguments generally depends on
2282 which style of options you choose. We will detail specific information
2283 relevant to each option style in the sections on the different option
2284 styles, below. The differences are subtle, yet can often be very
2285 important; incorrect option placement can cause you to overwrite a
2286 number of important files. We urge you to note these differences, and
2287 only use the option style(s) which makes the most sense to you until you
2288 feel comfortable with the others.
2290 @FIXME{hag to write a brief paragraph on the option(s) which can
2291 optionally take an argument}
2294 * Mnemonic Options:: Mnemonic Option Style
2295 * Short Options:: Short Option Style
2296 * Old Options:: Old Option Style
2297 * Mixing:: Mixing Option Styles
2300 @node Mnemonic Options
2301 @subsection Mnemonic Option Style
2303 @FIXME{have to decide whether or not to replace other occurrences of
2304 "mnemonic" with "long", or *ugh* vice versa.}
2306 Each option has at least one long (or mnemonic) name starting with two
2307 dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
2308 their corresponding short or old names. It sometimes happens that a
2309 single mnemonic option has many different different names which are
2310 synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
2311 long option names can be given unique abbreviations. For example,
2312 @samp{--cre} can be used in place of @samp{--create} because there is no
2313 other mnemonic option which begins with @samp{cre}. (One way to find
2314 this out is by trying it and seeing what happens; if a particular
2315 abbreviation could represent more than one option, @command{tar} will tell
2316 you that that abbreviation is ambiguous and you'll know that that
2317 abbreviation won't work. You may also choose to run @samp{tar --help}
2318 to see a list of options. Be aware that if you run @command{tar} with a
2319 unique abbreviation for the long name of an option you didn't want to
2320 use, you are stuck; @command{tar} will perform the command as ordered.)
2322 Mnemonic options are meant to be obvious and easy to remember, and their
2323 meanings are generally easier to discern than those of their
2324 corresponding short options (see below). For example:
2327 $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
2331 gives a fairly good set of hints about what the command does, even
2332 for those not fully acquainted with @command{tar}.
2334 Mnemonic options which require arguments take those arguments
2335 immediately following the option name; they are introduced by an equal
2336 sign. For example, the @samp{--file} option (which tells the name
2337 of the @command{tar} archive) is given a file such as @file{archive.tar}
2338 as argument by using the notation @samp{--file=archive.tar} for the
2342 @subsection Short Option Style
2344 Most options also have a short option name. Short options start with
2345 a single dash, and are followed by a single character, e.g.@: @samp{-t}
2346 (which is equivalent to @samp{--list}). The forms are absolutely
2347 identical in function; they are interchangeable.
2349 The short option names are faster to type than long option names.
2351 Short options which require arguments take their arguments immediately
2352 following the option, usually separated by white space. It is also
2353 possible to stick the argument right after the short option name, using
2354 no intervening space. For example, you might write @w{@samp{-f
2355 archive.tar}} or @samp{-farchive.tar} instead of using
2356 @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
2357 @w{@samp{-f @var{archive-name}}} denote the option which indicates a
2358 specific archive, here named @file{archive.tar}.
2360 Short options' letters may be clumped together, but you are not
2361 required to do this (as compared to old options; see below). When
2362 short options are clumped as a set, use one (single) dash for them
2363 all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
2364 such a set is allowed to have an argument@footnote{Clustering many
2365 options, the last of which has an argument, is a rather opaque way to
2366 write options. Some wonder if @acronym{GNU} @code{getopt} should not
2367 even be made helpful enough for considering such usages as invalid.}.
2369 When the options are separated, the argument for each option which requires
2370 an argument directly follows that option, as is usual for Unix programs.
2374 $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
2377 If you reorder short options' locations, be sure to move any arguments
2378 that belong to them. If you do not move the arguments properly, you may
2379 end up overwriting files.
2382 @subsection Old Option Style
2385 Like short options, old options are single letters. However, old options
2386 must be written together as a single clumped set, without spaces separating
2387 them or dashes preceding them@footnote{Beware that if you precede options
2388 with a dash, you are announcing the short option style instead of the
2389 old option style; short options are decoded differently.}. This set
2390 of letters must be the first to appear on the command line, after the
2391 @command{tar} program name and some white space; old options cannot appear
2392 anywhere else. The letter of an old option is exactly the same letter as
2393 the corresponding short option. For example, the old option @samp{t} is
2394 the same as the short option @samp{-t}, and consequently, the same as the
2395 mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
2396 cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
2398 @FIXME{bob suggests having an uglier example. :-) }
2400 When options that need arguments are given together with the command,
2401 all the associated arguments follow, in the same order as the options.
2402 Thus, the example given previously could also be written in the old
2406 $ @kbd{tar cvbf 20 /dev/rmt0}
2410 Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
2411 the argument of @samp{-f}.
2413 On the other hand, this old style syntax makes it difficult to match
2414 option letters with their corresponding arguments, and is often
2415 confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
2416 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
2417 argument for @samp{-f}, and @samp{-v} does not have a corresponding
2418 argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
2419 /dev/rmt0}} is clearer, putting all arguments next to the option they
2422 If you want to reorder the letters in the old option argument, be
2423 sure to reorder any corresponding argument appropriately.
2425 This old way of writing @command{tar} options can surprise even experienced
2426 users. For example, the two commands:
2429 @kbd{tar cfz archive.tar.gz file}
2430 @kbd{tar -cfz archive.tar.gz file}
2434 are quite different. The first example uses @file{archive.tar.gz} as
2435 the value for option @samp{f} and recognizes the option @samp{z}. The
2436 second example, however, uses @file{z} as the value for option
2437 @samp{f}---probably not what was intended.
2439 Old options are kept for compatibility with old versions of @command{tar}.
2441 This second example could be corrected in many ways, among which the
2442 following are equivalent:
2445 @kbd{tar -czf archive.tar.gz file}
2446 @kbd{tar -cf archive.tar.gz -z file}
2447 @kbd{tar cf archive.tar.gz -z file}
2450 @FIXME{still could explain this better; it's redundant:}
2452 @cindex option syntax, traditional
2453 As far as we know, all @command{tar} programs, @acronym{GNU} and
2454 non-@acronym{GNU}, support old options. @GNUTAR{}
2455 supports them not only for historical reasons, but also because many
2456 people are used to them. For compatibility with Unix @command{tar},
2457 the first argument is always treated as containing command and option
2458 letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
2459 equivalent to @w{@samp{tar -c}:} both of them specify the
2460 @value{op-create} command to create an archive.
2463 @subsection Mixing Option Styles
2465 All three styles may be intermixed in a single @command{tar} command,
2466 so long as the rules for each style are fully
2467 respected@footnote{Before @GNUTAR{} version 1.11.6,
2468 a bug prevented intermixing old style options with mnemonic options in
2469 some cases.}. Old style options and either of the modern styles of
2470 options may be mixed within a single @command{tar} command. However,
2471 old style options must be introduced as the first arguments only,
2472 following the rule for old options (old options must appear directly
2473 after the @command{tar} command and some white space). Modern options
2474 may be given only after all arguments to the old options have been
2475 collected. If this rule is not respected, a modern option might be
2476 falsely interpreted as the value of the argument to one of the old
2479 For example, all the following commands are wholly equivalent, and
2480 illustrate the many combinations and orderings of option styles.
2483 @kbd{tar --create --file=archive.tar}
2484 @kbd{tar --create -f archive.tar}
2485 @kbd{tar --create -farchive.tar}
2486 @kbd{tar --file=archive.tar --create}
2487 @kbd{tar --file=archive.tar -c}
2488 @kbd{tar -c --file=archive.tar}
2489 @kbd{tar -c -f archive.tar}
2490 @kbd{tar -c -farchive.tar}
2491 @kbd{tar -cf archive.tar}
2492 @kbd{tar -cfarchive.tar}
2493 @kbd{tar -f archive.tar --create}
2494 @kbd{tar -f archive.tar -c}
2495 @kbd{tar -farchive.tar --create}
2496 @kbd{tar -farchive.tar -c}
2497 @kbd{tar c --file=archive.tar}
2498 @kbd{tar c -f archive.tar}
2499 @kbd{tar c -farchive.tar}
2500 @kbd{tar cf archive.tar}
2501 @kbd{tar f archive.tar --create}
2502 @kbd{tar f archive.tar -c}
2503 @kbd{tar fc archive.tar}
2506 On the other hand, the following commands are @emph{not} equivalent to
2510 @kbd{tar -f -c archive.tar}
2511 @kbd{tar -fc archive.tar}
2512 @kbd{tar -fcarchive.tar}
2513 @kbd{tar -farchive.tarc}
2514 @kbd{tar cfarchive.tar}
2518 These last examples mean something completely different from what the
2519 user intended (judging based on the example in the previous set which
2520 uses long options, whose intent is therefore very clear). The first
2521 four specify that the @command{tar} archive would be a file named
2522 @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
2523 respectively. The first two examples also specify a single non-option,
2524 @var{name} argument having the value @samp{archive.tar}. The last
2525 example contains only old style option letters (repeating option
2526 @samp{c} twice), not all of which are meaningful (eg., @samp{.},
2527 @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
2528 the first sentence of this paragraph..}
2531 @section All @command{tar} Options
2533 The coming manual sections contain an alphabetical listing of all
2534 @command{tar} operations and options, with brief descriptions and cross
2535 references to more in-depth explanations in the body of the manual.
2536 They also contain an alphabetically arranged table of the short option
2537 forms with their corresponding long option. You can use this table as
2538 a reference for deciphering @command{tar} commands in scripts.
2541 * Operation Summary::
2543 * Short Option Summary::
2546 @node Operation Summary
2547 @subsection Operations
2554 Appends files to the end of the archive. @xref{append}.
2559 Same as @samp{--concatenate}. @xref{concatenate}.
2564 Compares archive members with their counterparts in the file
2565 system, and reports differences in file size, mode, owner,
2566 modification date and contents. @xref{compare}.
2571 Appends other @command{tar} archives to the end of the archive.
2577 Creates a new @command{tar} archive. @xref{create}.
2581 Deletes members from the archive. Don't try this on a archive on a
2582 tape! @xref{delete}.
2587 Same @samp{--compare}. @xref{compare}.
2592 Extracts members from the archive into the file system. @xref{extract}.
2597 Same as @samp{--extract}. @xref{extract}.
2602 Lists the members in an archive. @xref{list}.
2607 @FIXME{It was: A combination of the @samp{--compare} and
2608 @samp{--append} operations. This is not true and rather misleading,
2609 as @value{op-compare} does a lot more than @value{op-update} for
2610 ensuring files are identical.} Adds files to the end of the archive,
2611 but only if they are newer than their counterparts already in the
2612 archive, or if they do not already exist in the archive.
2617 @node Option Summary
2618 @subsection @command{tar} Options
2622 @item --absolute-names
2625 Normally when creating an archive, @command{tar} strips an initial
2626 @samp{/} from member names. This option disables that behavior.
2631 (See @samp{--newer}.) @FIXME-pxref{}
2634 An exclude pattern must match an initial subsequence of the name's components.
2637 @item --atime-preserve
2639 Tells @command{tar} to preserve the access time field in a file's inode when
2640 reading it. Due to limitations in the @code{utimes} system call, the
2641 modification time field is also preserved, which may cause problems if
2642 the file is simultaneously being modified by another program.
2643 This option is incompatible with incremental backups, because
2644 preserving the access time involves updating the last-changed time.
2645 Also, this option does not work on files that you do not own,
2649 @item --backup=@var{backup-type}
2651 Rather than deleting files from the file system, @command{tar} will
2652 back them up using simple or numbered backups, depending upon
2653 @var{backup-type}. @FIXME-xref{}
2655 @item --block-number
2658 With this option present, @command{tar} prints error messages for read errors
2659 with the block number in the archive file. @FIXME-xref{}
2661 @item --blocking-factor=@var{blocking}
2662 @itemx -b @var{blocking}
2664 Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
2665 record. @FIXME-xref{}
2670 This option tells @command{tar} to read or write archives through
2671 @code{bzip2}. @FIXME-xref{}
2675 This option directs @command{tar} to print periodic checkpoint messages as it
2676 reads through the archive. Its intended for when you want a visual
2677 indication that @command{tar} is still running, but don't want to see
2678 @samp{--verbose} output. @FIXME-xref{}
2682 If this option was given, @command{tar} will check the number of links
2683 dumped for each processed file. If this number does not match the
2684 total number of hard links for the file, a warning message will be
2687 Future versions will take @option{-l} as a short version of
2688 @option{--check-links}. However, current release still retains the old
2689 semantics for @option{-l}.
2691 @xref{Current status}, for more information.
2697 @command{tar} will use the @command{compress} program when reading or
2698 writing the archive. This allows you to directly act on archives
2699 while saving space. @FIXME-xref{}
2701 @item --confirmation
2703 (See @samp{--interactive}.) @FIXME-pxref{}
2708 When creating a @command{tar} archive, @command{tar} will archive the
2709 file that a symbolic link points to, rather than archiving the
2710 symlink. @FIXME-xref{}
2712 @item --directory=@var{dir}
2715 When this option is specified, @command{tar} will change its current directory
2716 to @var{dir} before performing any operations. When this option is used
2717 during archive creation, it is order sensitive. @FIXME-xref{}
2719 @item --exclude=@var{pattern}
2721 When performing operations, @command{tar} will skip files that match
2722 @var{pattern}. @FIXME-xref{}
2724 @item --exclude-from=@var{file}
2725 @itemx -X @var{file}
2727 Similar to @samp{--exclude}, except @command{tar} will use the list of
2728 patterns in the file @var{file}. @FIXME-xref{}
2730 @item --file=@var{archive}
2731 @itemx -f @var{archive}
2733 @command{tar} will use the file @var{archive} as the @command{tar} archive it
2734 performs operations on, rather than @command{tar}'s compilation dependent
2735 default. @FIXME-xref{}
2737 @item --files-from=@var{file}
2738 @itemx -T @var{file}
2740 @command{tar} will use the contents of @var{file} as a list of archive members
2741 or files to operate on, in addition to those specified on the
2742 command-line. @FIXME-xref{}
2746 Forces @command{tar} to interpret the filename given to @samp{--file}
2747 as a local file, even if it looks like a remote tape drive name.
2750 @item --format=@var{format}
2752 Selects output archive format. @var{Format} may be one of the
2757 Creates an archive that is compatible with Unix V7 @command{tar}.
2760 Creates an archive that is compatible with GNU @command{tar} version
2764 Creates a POSIX.1-1988 compatible archive.
2767 Creates a POSIX.1-2001 archive.
2770 Creates archive in GNU format.
2773 @item --group=@var{group}
2775 Files added to the @command{tar} archive will have a group id of @var{group},
2776 rather than the group from the source file. @var{group} is first decoded
2777 as a group symbolic name, but if this interpretation fails, it has to be
2778 a decimal numeric group ID. @FIXME-xref{}
2780 Also see the comments for the @value{op-owner} option.
2787 This option tells @command{tar} to read or write archives through
2788 @command{gzip}, allowing @command{tar} to directly operate on several
2789 kinds of compressed archives transparently. @FIXME-xref{}
2793 @command{tar} will print out a short message summarizing the operations and
2794 options to @command{tar} and exit. @FIXME-xref{}
2797 Ignore case when excluding files.
2800 @item --ignore-failed-read
2802 Do not exit unsuccessfully merely because an unreadable file was encountered.
2805 @item --ignore-zeros
2808 With this option, @command{tar} will ignore zeroed blocks in the
2809 archive, which normally signals EOF. @xref{Reading}.
2814 Used to inform @command{tar} that it is working with an old
2815 @acronym{GNU}-format incremental backup archive. It is intended
2816 primarily for backwards compatibility only. @FIXME-xref{}
2818 @item --index-file=@var{file}
2820 Send verbose output to @var{file} instead of to standard output.
2822 @item --info-script=@var{script-file}
2823 @itemx --new-volume-script=@var{script-file}
2824 @itemx -F @var{script-file}
2826 When @command{tar} is performing multi-tape backups, @var{script-file} is run
2827 at the end of each tape. If @var{script-file} exits with nonzero status,
2828 @command{tar} fails immediately. @FIXME-xref{}
2831 @itemx --confirmation
2834 Specifies that @command{tar} should ask the user for confirmation before
2835 performing potentially destructive options, such as overwriting files.
2838 @item --keep-old-files
2841 Do not overwrite existing files when extracting files from an archive.
2844 @item --label=@var{name}
2845 @itemx -V @var{name}
2847 When creating an archive, instructs @command{tar} to write @var{name}
2848 as a name record in the archive. When extracting or listing archives,
2849 @command{tar} will only operate on archives that have a label matching
2850 the pattern specified in @var{name}. @FIXME-xref{}
2852 @item --listed-incremental=@var{snapshot-file}
2853 @itemx -g @var{snapshot-file}
2855 During a @samp{--create} operation, specifies that the archive that
2856 @command{tar} creates is a new @acronym{GNU}-format incremental
2857 backup, using @var{snapshot-file} to determine which files to backup.
2858 With other operations, informs @command{tar} that the archive is in
2859 incremental format. @FIXME-xref{}
2861 @item --mode=@var{permissions}
2863 When adding files to an archive, @command{tar} will use
2864 @var{permissions} for the archive members, rather than the permissions
2865 from the files. The program @command{chmod} and this @command{tar}
2866 option share the same syntax for what @var{permissions} might be.
2867 @xref{File permissions, Permissions, File permissions, fileutils,
2868 @acronym{GNU} file utilities}. This reference also has useful
2869 information for those not being overly familiar with the Unix
2872 Of course, @var{permissions} might be plainly specified as an octal number.
2873 However, by using generic symbolic modifications to mode bits, this allows
2874 more flexibility. For example, the value @samp{a+rw} adds read and write
2875 permissions for everybody, while retaining executable bits on directories
2876 or on any other file already marked as executable.
2878 @item --multi-volume
2881 Informs @command{tar} that it should create or otherwise operate on a
2882 multi-volume @command{tar} archive. @FIXME-xref{}
2884 @item --new-volume-script
2888 @item --newer=@var{date}
2889 @itemx --after-date=@var{date}
2892 When creating an archive, @command{tar} will only add files that have changed
2893 since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
2894 is taken to be the name of a file whose last-modified time specifies
2895 the date. @FIXME-xref{}
2897 @item --newer-mtime=@var{date}
2899 Like @samp{--newer}, but add only files whose
2900 contents have changed (as opposed to just @samp{--newer}, which will
2901 also back up files for which any status information has changed).
2904 An exclude pattern can match any subsequence of the name's components.
2907 @item --no-ignore-case
2908 Use case-sensitive matching when excluding files.
2911 @item --no-recursion
2913 With this option, @command{tar} will not recurse into directories.
2916 @item --no-same-owner
2919 When extracting an archive, do not attempt to preserve the owner
2920 specified in the @command{tar} archive. This the default behavior
2921 for ordinary users; this option has an effect only for the superuser.
2923 @item --no-same-permissions
2925 When extracting an archive, subtract the user's umask from files from
2926 the permissions specified in the archive. This is the default behavior
2927 for ordinary users; this option has an effect only for the superuser.
2929 @item --no-wildcards
2930 Do not use wildcards when excluding files.
2933 @item --no-wildcards-match-slash
2934 Wildcards do not match @samp{/} when excluding files.
2939 When @command{tar} is using the @samp{--files-from} option, this option
2940 instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
2941 @command{tar} can correctly work with file names that contain newlines.
2944 @item --numeric-owner
2946 This option will notify @command{tar} that it should use numeric user
2947 and group IDs when creating a @command{tar} file, rather than names.
2951 When extracting files, this option is a synonym for
2952 @option{--no-same-owner}, i.e. it prevents @command{tar} from
2953 restoring ownership of files being extracted.
2955 When creating an archive, @option{-o} is a synonym for
2956 @option{--old-archive}. This behavior is for compatibility
2957 with previous versions of @GNUTAR{}, and will be
2958 removed in the future releases.
2960 @xref{Current status}, for more information.
2962 @item --occurrence[=@var{number}]
2964 This option can be used in conjunction with one of the subcommands
2965 @option{--delete}, @option{--diff}, @option{--extract} or
2966 @option{--list} when a list of files is given either on the command
2967 line or via @option{-T} option.
2969 This option instructs @command{tar} to process only the @var{number}th
2970 occurrence of each named file. @var{Number} defaults to 1, so
2973 tar -x -f archive.tar --occurrence filename
2977 will extract the first occurrence of @file{filename} from @file{archive.tar}
2978 and will terminate without scanning to the end of the archive.
2981 Synonym for @option{--format=v7}.
2983 @item --one-file-system
2985 Used when creating an archive. Prevents @command{tar} from recursing into
2986 directories that are on different file systems from the current
2989 Earlier versions of @GNUTAR{} understood @option{-l} as a
2990 synonym for @option{--one-file-system}. Although such usage is still
2991 allowed in the present version, it is @emph{strongly discouraged}.
2992 The future versions of @GNUTAR{} will use @option{-l} as
2993 a synonym for @option{--check-links}.
2995 @xref{Current status}, for more information.
2999 Overwrite existing files and directory metadata when extracting files
3000 from an archive. @xref{Overwrite Old Files}.
3002 @item --overwrite-dir
3004 Overwrite the metadata of existing directories when extracting files
3005 from an archive. @xref{Overwrite Old Files}.
3007 @item --owner=@var{user}
3009 Specifies that @command{tar} should use @var{user} as the owner of members
3010 when creating archives, instead of the user associated with the source
3011 file. @var{user} is first decoded as a user symbolic name, but if
3012 this interpretation fails, it has to be a decimal numeric user ID.
3015 There is no value indicating a missing number, and @samp{0} usually means
3016 @code{root}. Some people like to force @samp{0} as the value to offer in
3017 their distributions for the owner of files, because the @code{root} user is
3018 anonymous anyway, so that might as well be the owner of anonymous archives.
3020 This option does not affect extraction from archives.
3023 @itemx --old-archive
3024 Synonym for @option{--format=v7}.
3027 Same as @option{--format=posix}.
3031 Synonymous with specifying both @samp{--preserve-permissions} and
3032 @samp{--same-order}. @FIXME-xref{}
3034 @item --preserve-order
3036 (See @samp{--same-order}; @pxref{Reading}.)
3038 @item --preserve-permissions
3039 @itemx --same-permissions
3042 When @command{tar} is extracting an archive, it normally subtracts the
3043 users' umask from the permissions specified in the archive and uses
3044 that number as the permissions to create the destination file.
3045 Specifying this option instructs @command{tar} that it should use the
3046 permissions directly from the archive. @xref{Writing}.
3048 @item --read-full-records
3051 Specifies that @command{tar} should reblock its input, for reading
3052 from pipes on systems with buggy implementations. @xref{Reading}.
3054 @item --record-size=@var{size}
3056 Instructs @command{tar} to use @var{size} bytes per record when accessing the
3057 archive. @FIXME-xref{}
3061 With this option, @command{tar} recurses into directories.
3064 @item --recursive-unlink
3067 directory hierarchies before extracting directories of the same name
3068 from the archive. @xref{Writing}.
3070 @item --remove-files
3072 Directs @command{tar} to remove the source file from the file system after
3073 appending it to an archive. @FIXME-xref{}
3075 @item --rsh-command=@var{cmd}
3077 Notifies @command{tar} that is should use @var{cmd} to communicate with remote
3078 devices. @FIXME-xref{}
3081 @itemx --preserve-order
3084 This option is an optimization for @command{tar} when running on machines with
3085 small amounts of memory. It informs @command{tar} that the list of file
3086 arguments has already been sorted to match the order of files in the
3087 archive. @xref{Reading}.
3091 When extracting an archive, @command{tar} will attempt to preserve the owner
3092 specified in the @command{tar} archive with this option present.
3093 This is the default behavior for the superuser; this option has an
3094 effect only for ordinary users. @FIXME-xref{}
3096 @item --same-permissions
3098 (See @samp{--preserve-permissions}; @pxref{Writing}.)
3100 @item --show-omitted-dirs
3102 Instructs @command{tar} to mention directories its skipping over when
3103 operating on a @command{tar} archive. @FIXME-xref{}
3108 Invokes a @acronym{GNU} extension when adding files to an archive that handles
3109 sparse files efficiently. @FIXME-xref{}
3111 @item --starting-file=@var{name}
3112 @itemx -K @var{name}
3114 This option affects extraction only; @command{tar} will skip extracting
3115 files in the archive until it finds one that matches @var{name}.
3118 @item --strip-path=@var{number}
3119 Strip given @var{number} of leading components from file names before
3120 extraction. For example, if archive @file{archive.tar} contained
3121 @file{/some/file/name}, then running
3124 tar --extract --file archive.tar --strip-path=2
3128 would extracted this file to file @file{name}.
3130 @item --suffix=@var{suffix}
3132 Alters the suffix @command{tar} uses when backing up files from the default
3133 @samp{~}. @FIXME-xref{}
3135 @item --tape-length=@var{num}
3138 Specifies the length of tapes that @command{tar} is writing as being
3139 @w{@var{num} x 1024} bytes long. @FIXME-xref{}
3144 During extraction, @command{tar} will extract files to stdout rather
3145 than to the file system. @xref{Writing}.
3149 Displays the total number of bytes written after creating an archive.
3155 Sets the modification time of extracted files to the extraction time,
3156 rather than the modification time stored in the archive.
3161 (See @samp{--compress}.) @FIXME-pxref{}
3165 (See @samp{--gzip}.) @FIXME-pxref{}
3167 @item --unlink-first
3170 Directs @command{tar} to remove the corresponding file from the file
3171 system before extracting it from the archive. @xref{Writing}.
3173 @item --use-compress-program=@var{prog}
3175 Instructs @command{tar} to access the archive through @var{prog}, which is
3176 presumed to be a compression program of some sort. @FIXME-xref{}
3181 Specifies that @command{tar} should be more verbose about the operations its
3182 performing. This option can be specified multiple times for some
3183 operations to increase the amount of information displayed. @FIXME-xref{}
3188 Verifies that the archive was correctly written when creating an
3189 archive. @FIXME-xref{}
3193 @command{tar} will print an informational message about what version
3194 it is and a copyright message, some credits, and then exit.
3197 @item --volno-file=@var{file}
3199 Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
3200 of which volume of a multi-volume archive its working in @var{file}.
3204 Use wildcards when excluding files.
3207 @item --wildcards-match-slash
3208 Wildcards match @samp{/} when excluding files.
3212 @node Short Option Summary
3213 @subsection Short Options Cross Reference
3215 Here is an alphabetized list of all of the short option forms, matching
3216 them with the equivalent long option.
3222 @samp{--concatenate}
3226 @samp{--read-full-records}
3234 @samp{--info-script}
3238 @samp{--incremental}
3242 @samp{--starting-file}
3246 @samp{--tape-length}
3250 @samp{--multi-volume}
3262 @samp{--absolute-names}
3266 @samp{--block-number}
3278 @samp{--unlink-first}
3290 @samp{--exclude-from}
3298 @samp{--blocking-factor}
3314 @samp{--listed-incremental}
3318 @samp{--dereference}
3322 @samp{--ignore-zeros}
3330 @samp{--keep-old-files}
3334 @samp{--one-file-system}. Use of this short option is deprecated. It
3335 is retained for compatibility with the earlier versions of GNU
3336 @command{tar}, and will be changed in future releases.
3338 @xref{Current status}, for more information.
3346 When creating --- @samp{--no-same-owner}, when extracting ---
3347 @samp{--portability}.
3349 The later usage is deprecated. It is retained for compatibility with
3350 the earlier versions of @GNUTAR{}. In the future releases
3351 @option{-o} will be equivalent to @samp{--no-same-owner} only.
3355 @samp{--preserve-permissions}
3379 @samp{--interactive}
3392 @section @GNUTAR{} documentation
3394 Being careful, the first thing is really checking that you are using
3395 @GNUTAR{}, indeed. The @value{op-version} option
3396 will generate a message giving confirmation that you are using
3397 @GNUTAR{}, with the precise version of @GNUTAR{}
3398 you are using. @command{tar} identifies itself and
3399 prints the version number to the standard output, then immediately
3400 exits successfully, without doing anything else, ignoring all other
3401 options. For example, @w{@samp{tar --version}} might return:
3404 tar (@acronym{GNU} tar) @value{VERSION}
3408 The first occurrence of @samp{tar} in the result above is the program
3409 name in the package (for example, @command{rmt} is another program),
3410 while the second occurrence of @samp{tar} is the name of the package
3411 itself, containing possibly many programs. The package is currently
3412 named @samp{tar}, after the name of the main program it
3413 contains@footnote{There are plans to merge the @command{cpio} and
3414 @command{tar} packages into a single one which would be called
3415 @code{paxutils}. So, who knows if, one of this days, the
3416 @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
3419 Another thing you might want to do is checking the spelling or meaning
3420 of some particular @command{tar} option, without resorting to this
3421 manual, for once you have carefully read it. @GNUTAR{}
3422 has a short help feature, triggerable through the
3423 @value{op-help} option. By using this option, @command{tar} will
3424 print a usage message listing all available options on standard
3425 output, then exit successfully, without doing anything else and
3426 ignoring all other options. Even if this is only a brief summary, it
3427 may be several screens long. So, if you are not using some kind of
3428 scrollable window, you might prefer to use something like:
3431 $ @kbd{tar --help | less}
3435 presuming, here, that you like using @command{less} for a pager. Other
3436 popular pagers are @command{more} and @command{pg}. If you know about some
3437 @var{keyword} which interests you and do not want to read all the
3438 @value{op-help} output, another common idiom is doing:
3441 tar --help | grep @var{keyword}
3445 for getting only the pertinent lines.
3447 The perceptive reader would have noticed some contradiction in the
3448 previous paragraphs. It is written that both @value{op-version} and
3449 @value{op-help} print something, and have all other options ignored. In
3450 fact, they cannot ignore each other, and one of them has to win. We do
3451 not specify which is stronger, here; experiment if you really wonder!
3453 The short help output is quite succinct, and you might have to get
3454 back to the full documentation for precise points. If you are reading
3455 this paragraph, you already have the @command{tar} manual in some
3456 form. This manual is available in printed form, as a kind of small
3457 book. It may printed out of the @GNUTAR{}
3458 distribution, provided you have @TeX{} already installed somewhere,
3459 and a laser printer around. Just configure the distribution, execute
3460 the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
3461 usual way (contact your local guru to know how). If @GNUTAR{}
3462 has been conveniently installed at your place, this
3463 manual is also available in interactive, hypertextual form as an Info
3464 file. Just call @w{@samp{info tar}} or, if you do not have the
3465 @command{info} program handy, use the Info reader provided within
3466 @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
3468 There is currently no @code{man} page for @GNUTAR{}.
3469 If you observe such a @code{man} page on the system you are running,
3470 either it does not long to @GNUTAR{}, or it has not
3471 been produced by @acronym{GNU}. Currently, @GNUTAR{}
3472 documentation is provided in Texinfo format only, if we
3473 except, of course, the short result of @kbd{tar --help}.
3476 @section Checking @command{tar} progress
3478 @cindex Progress information
3479 @cindex Status information
3480 @cindex Information on progress and status of operations
3481 @cindex Verbose operation
3482 @cindex Block number where error occurred
3483 @cindex Error message, block number of
3484 @cindex Version of the @command{tar} program
3486 @cindex Getting more information during the operation
3487 @cindex Information during operation
3488 @cindex Feedback from @command{tar}
3490 Typically, @command{tar} performs most operations without reporting any
3491 information to the user except error messages. When using @command{tar}
3492 with many options, particularly ones with complicated or
3493 difficult-to-predict behavior, it is possible to make serious mistakes.
3494 @command{tar} provides several options that make observing @command{tar}
3495 easier. These options cause @command{tar} to print information as it
3496 progresses in its job, and you might want to use them just for being
3497 more careful about what is going on, or merely for entertaining
3498 yourself. If you have encountered a problem when operating on an
3499 archive, however, you may need more information than just an error
3500 message in order to solve the problem. The following options can be
3501 helpful diagnostic tools.
3503 Normally, the @value{op-list} command to list an archive prints just
3504 the file names (one per line) and the other commands are silent.
3505 When used with most operations, the @value{op-verbose} option causes
3506 @command{tar} to print the name of each file or archive member as it
3507 is processed. This and the other options which make @command{tar} print
3508 status information can be useful in monitoring @command{tar}.
3510 With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
3511 just prints the names of the files or members as they are processed.
3512 Using it twice causes @command{tar} to print a longer listing (reminiscent
3513 of @samp{ls -l}) for each member. Since @value{op-list} already prints
3514 the names of the members, @value{op-verbose} used once with @value{op-list}
3515 causes @command{tar} to print an @samp{ls -l} type listing of the files
3516 in the archive. The following examples both extract members with
3520 $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
3521 $ @kbd{tar xvv archive.tar}
3524 Verbose output appears on the standard output except when an archive is
3525 being written to the standard output, as with @samp{tar --create
3526 --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
3527 installer let standard output be the default archive). In that case
3528 @command{tar} writes verbose output to the standard error stream.
3530 If @option{--index-file=@var{file}} is specified, @command{tar} sends
3531 verbose output to @var{file} rather than to standard output or standard
3534 The @value{op-totals} option---which is only meaningful when used with
3535 @value{op-create}---causes @command{tar} to print the total
3536 amount written to the archive, after it has been fully created.
3538 The @value{op-checkpoint} option prints an occasional message
3539 as @command{tar} reads or writes the archive. In fact, it print
3540 directory names while reading the archive. It is designed for
3541 those who don't need the more detailed (and voluminous) output of
3542 @value{op-block-number}, but do want visual confirmation that @command{tar}
3543 is actually making forward progress.
3545 @FIXME{There is some confusion here. It seems that -R once wrote a
3546 message at @samp{every} record read or written.}
3548 The @value{op-show-omitted-dirs} option, when reading an archive---with
3549 @value{op-list} or @value{op-extract}, for example---causes a message
3550 to be printed for each directory in the archive which is skipped.
3551 This happens regardless of the reason for skipping: the directory might
3552 not have been named on the command line (implicitly or explicitly),
3553 it might be excluded by the use of the @value{op-exclude} option, or
3556 If @value{op-block-number} is used, @command{tar} prints, along with
3557 every message it would normally produce, the block number within the
3558 archive where the message was triggered. Also, supplementary messages
3559 are triggered when reading blocks full of NULs, or when hitting end of
3560 file on the archive. As of now, if the archive if properly terminated
3561 with a NUL block, the reading of the file may stop before end of file
3562 is met, so the position of end of file will not usually show when
3563 @value{op-block-number} is used. Note that @GNUTAR{}
3564 drains the archive before exiting when reading the
3565 archive from a pipe.
3567 This option is especially useful when reading damaged archives, since
3568 it helps pinpoint the damaged sections. It can also be used with
3569 @value{op-list} when listing a file-system backup tape, allowing you to
3570 choose among several backup tapes when retrieving a file later, in
3571 favor of the tape where the file appears earliest (closest to the
3572 front of the tape). @FIXME-xref{when the node name is set and the
3573 backup section written.}
3576 @section Asking for Confirmation During Operations
3577 @cindex Interactive operation
3579 Typically, @command{tar} carries out a command without stopping for
3580 further instructions. In some situations however, you may want to
3581 exclude some files and archive members from the operation (for instance
3582 if disk or storage space is tight). You can do this by excluding
3583 certain files automatically (@pxref{Choosing}), or by performing
3584 an operation interactively, using the @value{op-interactive} option.
3585 @command{tar} also accepts @samp{--confirmation} for this option.
3587 When the @value{op-interactive} option is specified, before
3588 reading, writing, or deleting files, @command{tar} first prints a message
3589 for each such file, telling what operation it intends to take, then asks
3590 for confirmation on the terminal. The actions which require
3591 confirmation include adding a file to the archive, extracting a file
3592 from the archive, deleting a file from the archive, and deleting a file
3593 from disk. To confirm the action, you must type a line of input
3594 beginning with @samp{y}. If your input line begins with anything other
3595 than @samp{y}, @command{tar} skips that file.
3597 If @command{tar} is reading the archive from the standard input,
3598 @command{tar} opens the file @file{/dev/tty} to support the interactive
3601 Verbose output is normally sent to standard output, separate from
3602 other error messages. However, if the archive is produced directly
3603 on standard output, then verbose output is mixed with errors on
3604 @code{stderr}. Producing the archive on standard output may be used
3605 as a way to avoid using disk space, when the archive is soon to be
3606 consumed by another process reading it, say. Some people felt the need
3607 of producing an archive on stdout, still willing to segregate between
3608 verbose output and error output. A possible approach would be using a
3609 named pipe to receive the archive, and having the consumer process to
3610 read from that named pipe. This has the advantage of letting standard
3611 output free to receive verbose output, all separate from errors.
3614 @chapter @GNUTAR{} Operations
3627 @section Basic @GNUTAR{} Operations
3629 The basic @command{tar} operations, @value{op-create}, @value{op-list} and
3630 @value{op-extract}, are currently presented and described in the tutorial
3631 chapter of this manual. This section provides some complementary notes
3632 for these operations.
3635 @item @value{op-create}
3637 Creating an empty archive would have some kind of elegance. One can
3638 initialize an empty archive and later use @value{op-append} for adding
3639 all members. Some applications would not welcome making an exception
3640 in the way of adding the first archive member. On the other hand,
3641 many people reported that it is dangerously too easy for @command{tar}
3642 to destroy a magnetic tape with an empty archive@footnote{This is well
3643 described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
3644 Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
3649 Mistakingly using @code{create} instead of @code{extract}, when the
3650 intent was to extract the full contents of an archive. This error
3651 is likely: keys @kbd{c} and @kbd{x} are right next to each other on
3652 the QWERTY keyboard. Instead of being unpacked, the archive then
3653 gets wholly destroyed. When users speak about @dfn{exploding} an
3654 archive, they usually mean something else :-).
3657 Forgetting the argument to @code{file}, when the intent was to create
3658 an archive with a single file in it. This error is likely because a
3659 tired user can easily add the @kbd{f} key to the cluster of option
3660 letters, by the mere force of habit, without realizing the full
3661 consequence of doing so. The usual consequence is that the single
3662 file, which was meant to be saved, is rather destroyed.
3665 So, recognizing the likelihood and the catastrophical nature of these
3666 errors, @GNUTAR{} now takes some distance from elegance, and
3667 cowardly refuses to create an archive when @value{op-create} option is
3668 given, there are no arguments besides options, and @value{op-files-from}
3669 option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
3670 and nevertheless create an archive with nothing in it,
3671 one may still use, as the value for the @value{op-files-from} option,
3672 a file with no names in it, as shown in the following commands:
3675 @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
3676 @kbd{tar cfT empty-archive.tar /dev/null}
3679 @item @value{op-extract}
3681 A socket is stored, within a @GNUTAR{} archive, as a pipe.
3683 @item @value{op-list}
3685 @GNUTAR{} now shows dates as @samp{1996-08-30},
3686 while it used to show them as @samp{Aug 30 1996}. (One can revert to
3687 the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
3688 before reinstalling.) But preferably, people should get used to ISO
3689 8601 dates. Local American dates should be made available again with
3690 full date localization support, once ready. In the meantime, programs
3691 not being localizable for dates should prefer international dates,
3692 that's really the way to go.
3694 Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
3695 are curious, it contains a detailed explanation of the ISO 8601 standard.
3700 @section Advanced @GNUTAR{} Operations
3702 Now that you have learned the basics of using @GNUTAR{}, you may want
3703 to learn about further ways in which @command{tar} can help you.
3705 This chapter presents five, more advanced operations which you probably
3706 won't use on a daily basis, but which serve more specialized functions.
3707 We also explain the different styles of options and why you might want
3708 to use one or another, or a combination of them in your @command{tar}
3709 commands. Additionally, this chapter includes options which allow you to
3710 define the output from @command{tar} more carefully, and provide help and
3711 error correction in special circumstances.
3713 @FIXME{check this after the chapter is actually revised to make sure
3714 it still introduces the info in the chapter correctly : ).}
3726 @subsection The Five Advanced @command{tar} Operations
3729 In the last chapter, you learned about the first three operations to
3730 @command{tar}. This chapter presents the remaining five operations to
3731 @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
3732 @samp{--delete}, and @samp{--compare}.
3734 You are not likely to use these operations as frequently as those
3735 covered in the last chapter; however, since they perform specialized
3736 functions, they are quite useful when you do need to use them. We
3737 will give examples using the same directory and files that you created
3738 in the last chapter. As you may recall, the directory is called
3739 @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
3740 @samp{rock}, and the two archive files you created are
3741 @samp{collection.tar} and @samp{music.tar}.
3743 We will also use the archive files @samp{afiles.tar} and
3744 @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
3745 @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
3746 @samp{./birds}, @samp{baboon}, and @samp{./box}.
3748 Unless we state otherwise, all practicing you do and examples you follow
3749 in this chapter will take place in the @file{practice} directory that
3750 you created in the previous chapter; see @ref{prepare for examples}.
3751 (Below in this section, we will remind you of the state of the examples
3752 where the last chapter left them.)
3754 The five operations that we will cover in this chapter are:
3759 Add new entries to an archive that already exists.
3762 Add more recent copies of archive members to the end of an archive, if
3767 Add one or more pre-existing archives to the end of another archive.
3769 Delete items from an archive (does not work on tapes).
3773 Compare archive members to their counterparts in the file system.
3777 @subsection How to Add Files to Existing Archives: @code{--append}
3780 If you want to add files to an existing archive, you don't need to
3781 create a new archive; you can use @value{op-append}. The archive must
3782 already exist in order to use @samp{--append}. (A related operation
3783 is the @samp{--update} operation; you can use this to add newer
3784 versions of archive members to an existing archive. To learn how to
3785 do this with @samp{--update}, @pxref{update}.)
3787 @FIXME{Explain in second paragraph whether you can get to the previous
3788 version -- explain whole situation somewhat more clearly.}
3790 If you use @value{op-append} to add a file that has the same name as an
3791 archive member to an archive containing that archive member, then the
3792 old member is not deleted. What does happen, however, is somewhat
3793 complex. @command{tar} @emph{allows} you to have infinite numbers of files
3794 with the same name. Some operations treat these same-named members no
3795 differently than any other set of archive members: for example, if you
3796 view an archive with @value{op-list}, you will see all of those members
3797 listed, with their modification times, owners, etc.
3799 Other operations don't deal with these members as perfectly as you might
3800 prefer; if you were to use @value{op-extract} to extract the archive,
3801 only the most recently added copy of a member with the same name as four
3802 other members would end up in the working directory. This is because
3803 @samp{--extract} extracts an archive in the order the members appeared
3804 in the archive; the most recently archived members will be extracted
3805 last. Additionally, an extracted member will @emph{replace} a file of
3806 the same name which existed in the directory already, and @command{tar}
3807 will not prompt you about this. Thus, only the most recently archived
3808 member will end up being extracted, as it will replace the one
3809 extracted before it, and so on.
3811 @FIXME{ hag -- you might want to incorporate some of the above into the
3812 MMwtSN node; not sure. i didn't know how to make it simpler...}
3814 There are a few ways to get around this. @FIXME-xref{Multiple Members
3815 with the Same Name.}
3817 @cindex Members, replacing with other members
3818 @cindex Replacing members with other members
3819 If you want to replace an archive member, use @value{op-delete} to
3820 delete the member you want to remove from the archive, , and then use
3821 @samp{--append} to add the member you want to be in the archive. Note
3822 that you can not change the order of the archive; the most recently
3823 added member will still appear last. In this sense, you cannot truly
3824 ``replace'' one member with another. (Replacing one member with another
3825 will not work on certain types of media, such as tapes; see @ref{delete}
3826 and @ref{Media}, for more information.)
3829 * appending files:: Appending Files to an Archive
3833 @node appending files
3834 @subsubsection Appending Files to an Archive
3836 @cindex Adding files to an Archive
3837 @cindex Appending files to an Archive
3838 @cindex Archives, Appending files to
3840 The simplest way to add a file to an already existing archive is the
3841 @value{op-append} operation, which writes specified files into the
3842 archive whether or not they are already among the archived files.
3843 When you use @samp{--append}, you @emph{must} specify file name
3844 arguments, as there is no default. If you specify a file that already
3845 exists in the archive, another copy of the file will be added to the
3846 end of the archive. As with other operations, the member names of the
3847 newly added files will be exactly the same as their names given on the
3848 command line. The @value{op-verbose} option will print out the names
3849 of the files as they are written into the archive.
3851 @samp{--append} cannot be performed on some tape drives, unfortunately,
3852 due to deficiencies in the formats those tape drives use. The archive
3853 must be a valid @command{tar} archive, or else the results of using this
3854 operation will be unpredictable. @xref{Media}.
3856 To demonstrate using @samp{--append} to add a file to an archive,
3857 create a file called @file{rock} in the @file{practice} directory.
3858 Make sure you are in the @file{practice} directory. Then, run the
3859 following @command{tar} command to add @file{rock} to
3860 @file{collection.tar}:
3863 $ @kbd{tar --append --file=collection.tar rock}
3867 If you now use the @value{op-list} operation, you will see that
3868 @file{rock} has been added to the archive:
3871 $ @kbd{tar --list --file=collection.tar}
3872 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
3873 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
3874 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
3875 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
3878 @FIXME{in theory, dan will (soon) try to turn this node into what it's
3879 title claims it will become...}
3882 @subsubsection Multiple Files with the Same Name
3884 You can use @value{op-append} to add copies of files which have been
3885 updated since the archive was created. (However, we do not recommend
3886 doing this since there is another @command{tar} option called
3887 @samp{--update}; @pxref{update} for more information. We describe this
3888 use of @samp{--append} here for the sake of completeness.) @FIXME{is
3889 this really a good idea, to give this whole description for something
3890 which i believe is basically a Stupid way of doing something? certain
3891 aspects of it show ways in which tar is more broken than i'd personally
3892 like to admit to, specifically the last sentence. On the other hand, i
3893 don't think it's a good idea to be saying that re explicitly don't
3894 recommend using something, but i can't see any better way to deal with
3895 the situation.}When you extract the archive, the older version will be
3896 effectively lost. This works because files are extracted from an
3897 archive in the order in which they were archived. Thus, when the
3898 archive is extracted, a file archived later in time will replace a
3899 file of the same name which was archived earlier, even though the older
3900 version of the file will remain in the archive unless you delete all
3901 versions of the file.
3903 Supposing you change the file @file{blues} and then append the changed
3904 version to @file{collection.tar}. As you saw above, the original
3905 @file{blues} is in the archive @file{collection.tar}. If you change the
3906 file and append the new version of the file to the archive, there will
3907 be two copies in the archive. When you extract the archive, the older
3908 version of the file will be extracted first, and then replaced by the
3909 newer version when it is extracted.
3911 You can append the new, changed copy of the file @file{blues} to the
3912 archive in this way:
3915 $ @kbd{tar --append --verbose --file=collection.tar blues}
3920 Because you specified the @samp{--verbose} option, @command{tar} has
3921 printed the name of the file being appended as it was acted on. Now
3922 list the contents of the archive:
3925 $ @kbd{tar --list --verbose --file=collection.tar}
3926 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
3927 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
3928 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
3929 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
3930 -rw-rw-rw- me user 58 1996-10-24 18:30 blues
3934 The newest version of @file{blues} is now at the end of the archive
3935 (note the different creation dates and file sizes). If you extract
3936 the archive, the older version of the file @file{blues} will be
3937 replaced by the newer version. You can confirm this by extracting
3938 the archive and running @samp{ls} on the directory. @xref{Writing},
3939 for more information. (@emph{Please note:} This is the case unless
3940 you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
3941 with the Same Name}.)
3944 @subsection Updating an Archive
3946 @cindex Updating an archive
3948 In the previous section, you learned how to use @value{op-append} to add
3949 a file to an existing archive. A related operation is
3950 @value{op-update}. The @samp{--update} operation updates a @command{tar}
3951 archive by comparing the date of the specified archive members against
3952 the date of the file with the same name. If the file has been modified
3953 more recently than the archive member, then the newer version of the
3954 file is added to the archive (as with @value{op-append}).
3956 Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
3957 The operation will fail.
3959 @FIXME{other examples of media on which --update will fail? need to ask
3960 charles and/or mib/thomas/dave shevett..}
3962 Both @samp{--update} and @samp{--append} work by adding to the end
3963 of the archive. When you extract a file from the archive, only the
3964 version stored last will wind up in the file system, unless you use
3965 the @value{op-backup} option. @FIXME-ref{Multiple Members with the
3973 @subsubsection How to Update an Archive Using @code{--update}
3975 You must use file name arguments with the @value{op-update} operation.
3976 If you don't specify any files, @command{tar} won't act on any files and
3977 won't tell you that it didn't do anything (which may end up confusing
3980 @FIXME{note: the above parenthetical added because in fact, this
3981 behavior just confused the author. :-) }
3983 To see the @samp{--update} option at work, create a new file,
3984 @file{classical}, in your practice directory, and some extra text to the
3985 file @file{blues}, using any text editor. Then invoke @command{tar} with
3986 the @samp{update} operation and the @value{op-verbose} option specified,
3987 using the names of all the files in the practice directory as file name
3991 $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
3998 Because we have specified verbose mode, @command{tar} prints out the names
3999 of the files it is working on, which in this case are the names of the
4000 files that needed to be updated. If you run @samp{tar --list} and look
4001 at the archive, you will see @file{blues} and @file{classical} at its
4002 end. There will be a total of two versions of the member @samp{blues};
4003 the one at the end will be newer and larger, since you added text before
4006 (The reason @command{tar} does not overwrite the older file when updating
4007 it is because writing to the middle of a section of tape is a difficult
4008 process. Tapes are not designed to go backward. @xref{Media}, for more
4009 information about tapes.
4011 @value{op-update} is not suitable for performing backups for two
4012 reasons: it does not change directory content entries, and it
4013 lengthens the archive every time it is used. The @GNUTAR{}
4014 options intended specifically for backups are more
4015 efficient. If you need to run backups, please consult @ref{Backups}.
4018 @subsection Combining Archives with @code{--concatenate}
4020 @cindex Adding archives to an archive
4021 @cindex Concatenating Archives
4022 Sometimes it may be convenient to add a second archive onto the end of
4023 an archive rather than adding individual files to the archive. To add
4024 one or more archives to the end of another archive, you should use the
4025 @value{op-concatenate} operation.
4027 To use @samp{--concatenate}, name the archives to be concatenated on the
4028 command line. (Nothing happens if you don't list any.) The members,
4029 and their member names, will be copied verbatim from those archives. If
4030 this causes multiple members to have the same name, it does not delete
4031 any members; all the members with the same name coexist. @FIXME-ref{For
4032 information on how this affects reading the archive, Multiple
4033 Members with the Same Name.}
4035 To demonstrate how @samp{--concatenate} works, create two small archives
4036 called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
4037 files from @file{practice}:
4040 $ @kbd{tar -cvf bluesrock.tar blues rock}
4043 $ @kbd{tar -cvf folkjazz.tar folk jazz}
4049 If you like, You can run @samp{tar --list} to make sure the archives
4050 contain what they are supposed to:
4053 $ @kbd{tar -tvf bluesrock.tar}
4054 -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
4055 -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
4056 $ @kbd{tar -tvf folkjazz.tar}
4057 -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
4058 -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
4061 We can concatenate these two archives with @command{tar}:
4065 $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
4068 If you now list the contents of the @file{bluesclass.tar}, you will see
4069 that now it also contains the archive members of @file{jazzfolk.tar}:
4072 $ @kbd{tar --list --file=bluesrock.tar}
4079 When you use @samp{--concatenate}, the source and target archives must
4080 already exist and must have been created using compatible format
4081 parameters. @FIXME-pxref{Matching Format Parameters}The new,
4082 concatenated archive will be called by the same name as the first
4083 archive listed on the command line. @FIXME{is there a way to specify a
4086 Like @value{op-append}, this operation cannot be performed on some
4087 tape drives, due to deficiencies in the formats those tape drives use.
4089 @cindex @code{concatenate} vs @command{cat}
4090 @cindex @command{cat} vs @code{concatenate}
4091 It may seem more intuitive to you to want or try to use @command{cat} to
4092 concatenate two archives instead of using the @samp{--concatenate}
4093 operation; after all, @command{cat} is the utility for combining files.
4095 However, @command{tar} archives incorporate an end-of-file marker which
4096 must be removed if the concatenated archives are to be read properly as
4097 one archive. @samp{--concatenate} removes the end-of-archive marker
4098 from the target archive before each new archive is appended. If you use
4099 @command{cat} to combine the archives, the result will not be a valid
4100 @command{tar} format archive. If you need to retrieve files from an
4101 archive that was added to using the @command{cat} utility, use the
4102 @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
4103 information on dealing with archives improperly combined using the
4104 @command{cat} shell utility.
4106 @FIXME{this shouldn't go here. where should it go?} You must specify
4107 the source archives using @value{op-file} (@value{pxref-file}). If you
4108 do not specify the target archive, @command{tar} uses the value of the
4109 environment variable @env{TAPE}, or, if this has not been set, the
4110 default archive name.
4113 @subsection Removing Archive Members Using @samp{--delete}
4115 @cindex Deleting files from an archive
4116 @cindex Removing files from an archive
4118 You can remove members from an archive by using the @value{op-delete}
4119 option. Specify the name of the archive with @value{op-file} and then
4120 specify the names of the members to be deleted; if you list no member
4121 names, nothing will be deleted. The @value{op-verbose} option will
4122 cause @command{tar} to print the names of the members as they are deleted.
4123 As with @value{op-extract}, you must give the exact member names when
4124 using @samp{tar --delete}. @samp{--delete} will remove all versions of
4125 the named file from the archive. The @samp{--delete} operation can run
4128 Unlike other operations, @samp{--delete} has no short form.
4130 @cindex Tapes, using @code{--delete} and
4131 @cindex Deleting from tape archives
4132 This operation will rewrite the archive. You can only use
4133 @samp{--delete} on an archive if the archive device allows you to
4134 write to any point on the media, such as a disk; because of this, it
4135 does not work on magnetic tapes. Do not try to delete an archive member
4136 from a magnetic tape; the action will not succeed, and you will be
4137 likely to scramble the archive and damage your tape. There is no safe
4138 way (except by completely re-writing the archive) to delete files from
4139 most kinds of magnetic tape. @xref{Media}.
4141 To delete all versions of the file @file{blues} from the archive
4142 @file{collection.tar} in the @file{practice} directory, make sure you
4143 are in that directory, and then,
4146 $ @kbd{tar --list --file=collection.tar}
4156 $ @kbd{tar --delete --file=collection.tar blues}
4157 $ @kbd{tar --list --file=collection.tar}
4164 @FIXME{I changed the order of these nodes around and haven't had a chance
4165 to fix the above example's results, yet. I have to play with this and
4166 follow it and see what it actually does!}
4168 The @value{op-delete} option has been reported to work properly when
4169 @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
4172 @subsection Comparing Archive Members with the File System
4173 @cindex Verifying the currency of an archive
4176 The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
4177 specified archive members against files with the same names, and then
4178 reports differences in file size, mode, owner, modification date and
4179 contents. You should @emph{only} specify archive member names, not file
4180 names. If you do not name any members, then @command{tar} will compare the
4181 entire archive. If a file is represented in the archive but does not
4182 exist in the file system, @command{tar} reports a difference.
4184 You have to specify the record size of the archive when modifying an
4185 archive with a non-default record size.
4187 @command{tar} ignores files in the file system that do not have
4188 corresponding members in the archive.
4190 The following example compares the archive members @file{rock},
4191 @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
4192 files of the same name in the file system. (Note that there is no file,
4193 @file{funk}; @command{tar} will report an error message.)
4196 $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
4199 tar: funk not found in archive
4203 @FIXME{what does this actually depend on? i'm making a guess,
4204 here.}Depending on the system where you are running @command{tar} and the
4205 version you are running, @command{tar} may have a different error message,
4209 funk: does not exist
4212 @FIXME-xref{somewhere, for more information about format parameters.
4213 Melissa says: such as "format variations"? But why? Clearly I don't
4214 get it yet; I'll deal when I get to that section.}
4216 The spirit behind the @value{op-compare} option is to check whether the
4217 archive represents the current state of files on disk, more than validating
4218 the integrity of the archive media. For this later goal, @xref{verify}.
4220 @node create options
4221 @section Options Used by @code{--create}
4223 The previous chapter described the basics of how to use
4224 @value{op-create} to create an archive from a set of files.
4225 @xref{create}. This section described advanced options to be used with
4229 * Ignore Failed Read::
4232 @node Ignore Failed Read
4233 @subsection Ignore Fail Read
4236 @item --ignore-failed-read
4237 Do not exit with nonzero on unreadable files or directories.
4240 @node extract options
4241 @section Options Used by @code{--extract}
4244 @FIXME{i need to get dan to go over these options with me and see if
4245 there's a better way of organizing them.}
4247 The previous chapter showed how to use @value{op-extract} to extract
4248 an archive into the filesystem. Various options cause @command{tar} to
4249 extract more information than just file contents, such as the owner,
4250 the permissions, the modification date, and so forth. This section
4251 presents options to be used with @samp{--extract} when certain special
4252 considerations arise. You may review the information presented in
4253 @ref{extract} for more basic information about the
4254 @samp{--extract} operation.
4257 * Reading:: Options to Help Read Archives
4258 * Writing:: Changing How @command{tar} Writes Files
4259 * Scarce:: Coping with Scarce Resources
4263 @subsection Options to Help Read Archives
4264 @cindex Options when reading archives
4265 @cindex Reading incomplete records
4266 @cindex Records, incomplete
4267 @cindex End-of-archive entries, ignoring
4268 @cindex Ignoring end-of-archive entries
4269 @cindex Large lists of file names on small machines
4270 @cindex Small memory
4271 @cindex Running out of space
4274 Normally, @command{tar} will request data in full record increments from
4275 an archive storage device. If the device cannot return a full record,
4276 @command{tar} will report an error. However, some devices do not always
4277 return full records, or do not require the last record of an archive to
4278 be padded out to the next record boundary. To keep reading until you
4279 obtain a full record, or to accept an incomplete record if it contains
4280 an end-of-archive marker, specify the @value{op-read-full-records} option
4281 in conjunction with the @value{op-extract} or @value{op-list} operations.
4282 @value{xref-read-full-records}.
4284 The @value{op-read-full-records} option is turned on by default when
4285 @command{tar} reads an archive from standard input, or from a remote
4286 machine. This is because on BSD Unix systems, attempting to read a
4287 pipe returns however much happens to be in the pipe, even if it is
4288 less than was requested. If this option were not enabled, @command{tar}
4289 would fail as soon as it read an incomplete record from the pipe.
4291 If you're not sure of the blocking factor of an archive, you can
4292 read the archive by specifying @value{op-read-full-records} and
4293 @value{op-blocking-factor}, using a blocking factor larger than what the
4294 archive uses. This lets you avoid having to determine the blocking factor
4295 of an archive. @value{xref-blocking-factor}.
4298 * read full records::
4302 @node read full records
4303 @unnumberedsubsubsec Reading Full Records
4305 @FIXME{need sentence or so of intro here}
4308 @item --read-full-records
4310 Use in conjunction with @value{op-extract} to read an archive which
4311 contains incomplete records, or one which has a blocking factor less
4312 than the one specified.
4316 @unnumberedsubsubsec Ignoring Blocks of Zeros
4318 Normally, @command{tar} stops reading when it encounters a block of zeros
4319 between file entries (which usually indicates the end of the archive).
4320 @value{op-ignore-zeros} allows @command{tar} to completely read an archive
4321 which contains a block of zeros before the end (i.e.@: a damaged
4322 archive, or one which was created by concatenating several archives
4325 The @value{op-ignore-zeros} option is turned off by default because many
4326 versions of @command{tar} write garbage after the end-of-archive entry,
4327 since that part of the media is never supposed to be read. @GNUTAR{}
4328 does not write after the end of an archive, but seeks to
4329 maintain compatiblity among archiving utilities.
4332 @item --ignore-zeros
4334 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
4335 encountered while reading an archive. Use in conjunction with
4336 @value{op-extract} or @value{op-list}.
4340 @subsection Changing How @command{tar} Writes Files
4341 @cindex Overwriting old files, prevention
4342 @cindex Protecting old files
4343 @cindex Modification times of extracted files
4344 @cindex Permissions of extracted files
4345 @cindex Modes of extracted files
4346 @cindex Writing extracted files to standard output
4347 @cindex Standard output, writing extracted files to
4350 @FIXME{need to mention the brand new option, --backup}
4353 * Dealing with Old Files::
4354 * Overwrite Old Files::
4357 * Recursive Unlink::
4358 * Modification Times::
4359 * Setting Access Permissions::
4360 * Writing to Standard Output::
4364 @node Dealing with Old Files
4365 @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
4367 When extracting files, if @command{tar} discovers that the extracted
4368 file already exists, it normally replaces the file by removing it before
4369 extracting it, to prevent confusion in the presence of hard or symbolic
4370 links. (If the existing file is a symbolic link, it is removed, not
4371 followed.) However, if a directory cannot be removed because it is
4372 nonempty, @command{tar} normally overwrites its metadata (ownership,
4373 permission, etc.). The @option{--overwrite-dir} option enables this
4374 default behavior. To be more cautious and preserve the metadata of
4375 such a directory, use the @option{--no-overwrite-dir} option.
4377 To be even more cautious and prevent existing files from being replaced, use
4378 the @value{op-keep-old-files} option. It causes @command{tar} to refuse
4379 to replace or update a file that already exists, i.e., a file with the
4380 same name as an archive member prevents extraction of that archive
4381 member. Instead, it reports an error.
4383 To be more aggressive about altering existing files, use the
4384 @value{op-overwrite} option. It causes @command{tar} to overwrite
4385 existing files and to follow existing symbolic links when extracting.
4387 Some people argue that @GNUTAR{} should not hesitate
4388 to overwrite files with other files when extracting. When extracting
4389 a @command{tar} archive, they expect to see a faithful copy of the
4390 state of the filesystem when the archive was created. It is debatable
4391 that this would always be a proper behavior. For example, suppose one
4392 has an archive in which @file{usr/local} is a link to
4393 @file{usr/local2}. Since then, maybe the site removed the link and
4394 renamed the whole hierarchy from @file{/usr/local2} to
4395 @file{/usr/local}. Such things happen all the time. I guess it would
4396 not be welcome at all that @GNUTAR{} removes the
4397 whole hierarchy just to make room for the link to be reinstated
4398 (unless it @emph{also} simultaneously restores the full
4399 @file{/usr/local2}, of course! @GNUTAR{} is indeed
4400 able to remove a whole hierarchy to reestablish a symbolic link, for
4401 example, but @emph{only if} @value{op-recursive-unlink} is specified
4402 to allow this behavior. In any case, single files are silently
4405 Finally, the @value{op-unlink-first} option can improve performance in
4406 some cases by causing @command{tar} to remove files unconditionally
4407 before extracting them.
4409 @node Overwrite Old Files
4410 @unnumberedsubsubsec Overwrite Old Files
4414 Overwrite existing files and directory metadata when extracting files
4418 causes @command{tar} to write extracted files into the file system without
4419 regard to the files already on the system; i.e., files with the same
4420 names as archive members are overwritten when the archive is extracted.
4421 It also causes @command{tar} to extract the ownership, permissions,
4422 and time stamps onto any preexisting files or directories.
4423 If the name of a corresponding file name is a symbolic link, the file
4424 pointed to by the symbolic link will be overwritten instead of the
4425 symbolic link itself (if this is possible). Moreover, special devices,
4426 empty directories and even symbolic links are automatically removed if
4427 they are in the way of extraction.
4429 Be careful when using the @value{op-overwrite} option, particularly when
4430 combined with the @value{op-absolute-names} option, as this combination
4431 can change the contents, ownership or permissions of any file on your
4432 system. Also, many systems do not take kindly to overwriting files that
4433 are currently being executed.
4435 @item --overwrite-dir
4436 Overwrite the metadata of directories when extracting files from an
4437 archive, but remove other files before extracting.
4440 @node Keep Old Files
4441 @unnumberedsubsubsec Keep Old Files
4444 @item --keep-old-files
4446 Do not replace existing files from archive. The
4447 @value{op-keep-old-files} option prevents @command{tar} from replacing
4448 existing files with files with the same name from the archive.
4449 The @value{op-keep-old-files} option is meaningless with @value{op-list}.
4450 Prevents @command{tar} from replacing files in the file system during
4455 @unnumberedsubsubsec Unlink First
4458 @item --unlink-first
4460 Remove files before extracting over them.
4461 This can make @command{tar} run a bit faster if you know in advance
4462 that the extracted files all need to be removed. Normally this option
4463 slows @command{tar} down slightly, so it is disabled by default.
4466 @node Recursive Unlink
4467 @unnumberedsubsubsec Recursive Unlink
4470 @item --recursive-unlink
4471 When this option is specified, try removing files and directory hierarchies
4472 before extracting over them. @emph{This is a dangerous option!}
4475 If you specify the @value{op-recursive-unlink} option,
4476 @command{tar} removes @emph{anything} that keeps you from extracting a file
4477 as far as current permissions will allow it. This could include removal
4478 of the contents of a full directory hierarchy.
4480 @node Modification Times
4481 @unnumberedsubsubsec Setting Modification Times
4483 Normally, @command{tar} sets the modification times of extracted files to
4484 the modification times recorded for the files in the archive, but
4485 limits the permissions of extracted files by the current @code{umask}
4488 To set the modification times of extracted files to the time when
4489 the files were extracted, use the @value{op-touch} option in
4490 conjunction with @value{op-extract}.
4495 Sets the modification time of extracted archive members to the time
4496 they were extracted, not the time recorded for them in the archive.
4497 Use in conjunction with @value{op-extract}.
4500 @node Setting Access Permissions
4501 @unnumberedsubsubsec Setting Access Permissions
4503 To set the modes (access permissions) of extracted files to those
4504 recorded for those files in the archive, use @samp{--same-permissions}
4505 in conjunction with the @value{op-extract} operation. @FIXME{Should be
4506 aliased to ignore-umask.}
4509 @item --preserve-permission
4510 @itemx --same-permission
4511 @itemx --ignore-umask
4513 Set modes of extracted archive members to those recorded in the
4514 archive, instead of current umask settings. Use in conjunction with
4518 @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
4519 files together, why is this useful. is it really useful with
4520 more than one file?}
4522 @node Writing to Standard Output
4523 @unnumberedsubsubsec Writing to Standard Output
4525 To write the extracted files to the standard output, instead of
4526 creating the files on the file system, use @value{op-to-stdout} in
4527 conjunction with @value{op-extract}. This option is useful if you are
4528 extracting files to send them through a pipe, and do not need to
4529 preserve them in the file system. If you extract multiple members,
4530 they appear on standard output concatenated, in the order they are
4531 found in the archive.
4536 Writes files to the standard output. Used in conjunction with
4537 @value{op-extract}. Extract files to standard output. When this option
4538 is used, instead of creating the files specified, @command{tar} writes
4539 the contents of the files extracted to its standard output. This may
4540 be useful if you are only extracting the files in order to send them
4541 through a pipe. This option is meaningless with @value{op-list}.
4544 This can be useful, for example, if you have a tar archive containing
4545 a big file and don't want to store the file on disk before processing
4546 it. You can use a command like this:
4549 tar -xOzf foo.tgz bigfile | process
4552 or even like this if you want to process the concatenation of the files:
4555 tar -xOzf foo.tgz bigfile1 bigfile2 | process
4559 @unnumberedsubsubsec Removing Files
4561 @FIXME{the various macros in the front of the manual think that this
4562 option goes in this section. i have no idea; i only know it's nowhere
4563 else in the book...}
4566 @item --remove-files
4567 Remove files after adding them to the archive.
4571 @subsection Coping with Scarce Resources
4572 @cindex Middle of the archive, starting in the
4573 @cindex Running out of space during extraction
4574 @cindex Disk space, running out of
4575 @cindex Space on the disk, recovering from lack of
4584 @unnumberedsubsubsec Starting File
4587 @item --starting-file=@var{name}
4588 @itemx -K @var{name}
4589 Starts an operation in the middle of an archive. Use in conjunction
4590 with @value{op-extract} or @value{op-list}.
4593 If a previous attempt to extract files failed due to lack of disk
4594 space, you can use @value{op-starting-file} to start extracting only
4595 after member @var{name} of the archive. This assumes, of course, that
4596 there is now free space, or that you are now extracting into a
4597 different file system. (You could also choose to suspend @command{tar},
4598 remove unnecessary files from the file system, and then restart the
4599 same @command{tar} operation. In this case, @value{op-starting-file} is
4600 not necessary. @value{xref-incremental}, @value{xref-interactive},
4601 and @value{ref-exclude}.)
4604 @unnumberedsubsubsec Same Order
4608 @itemx --preserve-order
4610 To process large lists of file names on machines with small amounts of
4611 memory. Use in conjunction with @value{op-compare},
4613 or @value{op-extract}.
4616 @FIXME{we don't need/want --preserve to exist any more (from melissa:
4617 ie, don't want that *version* of the option to exist, or don't want
4618 the option to exist in either version?}
4620 @FIXME{i think this explanation is lacking.}
4622 The @value{op-same-order} option tells @command{tar} that the list of file
4623 names to be listed or extracted is sorted in the same order as the
4624 files in the archive. This allows a large list of names to be used,
4625 even on a small machine that would not otherwise be able to hold all
4626 the names in memory at the same time. Such a sorted list can easily be
4627 created by running @samp{tar -t} on the archive and editing its output.
4629 This option is probably never needed on modern computer systems.
4632 @section Backup options
4634 @cindex backup options
4636 @GNUTAR{} offers options for making backups of files
4637 before writing new versions. These options control the details of
4638 these backups. They may apply to the archive itself before it is
4639 created or rewritten, as well as individual extracted members. Other
4640 @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
4641 and @command{mv}, for example) offer similar options.
4643 Backup options may prove unexpectedly useful when extracting archives
4644 containing many members having identical name, or when extracting archives
4645 on systems having file name limitations, making different members appear
4646 has having similar names through the side-effect of name truncation.
4647 (This is true only if we have a good scheme for truncated backup names,
4648 which I'm not sure at all: I suspect work is needed in this area.)
4649 When any existing file is backed up before being overwritten by extraction,
4650 then clashing files are automatically be renamed to be unique, and the
4651 true name is kept for only the last file of a series of clashing files.
4652 By using verbose mode, users may track exactly what happens.
4654 At the detail level, some decisions are still experimental, and may
4655 change in the future, we are waiting comments from our users. So, please
4656 do not learn to depend blindly on the details of the backup features.
4657 For example, currently, directories themselves are never renamed through
4658 using these options, so, extracting a file over a directory still has
4659 good chances to fail. Also, backup options apply to created archives,
4660 not only to extracted members. For created archives, backups will not
4661 be attempted when the archive is a block or character device, or when it
4662 refers to a remote file.
4664 For the sake of simplicity and efficiency, backups are made by renaming old
4665 files prior to creation or extraction, and not by copying. The original
4666 name is restored if the file creation fails. If a failure occurs after a
4667 partial extraction of a file, both the backup and the partially extracted
4672 @item --backup[=@var{method}]
4674 @vindex VERSION_CONTROL
4676 Back up files that are about to be overwritten or removed.
4677 Without this option, the original versions are destroyed.
4679 Use @var{method} to determine the type of backups made.
4680 If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
4681 environment variable. And if @env{VERSION_CONTROL} is not set,
4682 use the @samp{existing} method.
4684 @vindex version-control @r{Emacs variable}
4685 This option corresponds to the Emacs variable @samp{version-control};
4686 the same values for @var{method} are accepted as in Emacs. This option
4687 also allows more descriptive names. The valid @var{method}s are:
4692 @opindex numbered @r{backup method}
4693 Always make numbered backups.
4697 @opindex existing @r{backup method}
4698 Make numbered backups of files that already have them, simple backups
4703 @opindex simple @r{backup method}
4704 Always make simple backups.
4708 @item --suffix=@var{suffix}
4710 @cindex backup suffix
4711 @vindex SIMPLE_BACKUP_SUFFIX
4712 Append @var{suffix} to each backup file made with @samp{--backup}. If this
4713 option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
4714 environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
4715 set, the default is @samp{~}, just as in Emacs.
4719 Some people express the desire to @emph{always} use the @value{op-backup}
4720 option, by defining some kind of alias or script. This is not as easy
4721 as one may think, due to the fact that old style options should appear first
4722 and consume arguments a bit unpredictably for an alias or script. But,
4723 if you are ready to give up using old style options, you may resort to
4724 using something like (a Bourne shell function here):
4727 tar () @{ /usr/local/bin/tar --backup $*; @}
4731 @section Notable @command{tar} Usages
4734 @FIXME{Using Unix file linking capability to recreate directory
4735 structures---linking files into one subdirectory and then
4736 @command{tar}ring that directory.}
4738 @FIXME{Nice hairy example using absolute-names, newer, etc.}
4741 You can easily use archive files to transport a group of files from
4742 one system to another: put all relevant files into an archive on one
4743 computer system, transfer the archive to another system, and extract
4744 the contents there. The basic transfer medium might be magnetic tape,
4745 Internet FTP, or even electronic mail (though you must encode the
4746 archive with @command{uuencode} in order to transport it properly by
4747 mail). Both machines do not have to use the same operating system, as
4748 long as they both support the @command{tar} program.
4750 For example, here is how you might copy a directory's contents from
4751 one disk to another, while preserving the dates, modes, owners and
4752 link-structure of all the files therein. In this case, the transfer
4753 medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
4756 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
4760 The command also works using short option forms:
4762 @FIXME{The following using standard input/output correct??}
4764 $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
4768 This is one of the easiest methods to transfer a @command{tar} archive.
4771 @section Looking Ahead: The Rest of this Manual
4773 You have now seen how to use all eight of the operations available to
4774 @command{tar}, and a number of the possible options. The next chapter
4775 explains how to choose and change file and archive names, how to use
4776 files to store names of other files which you can then call as
4777 arguments to @command{tar} (this can help you save time if you expect to
4778 archive the same list of files a number of times), and so forth.
4779 @FIXME{in case it's not obvious, i'm making this up in some sense
4780 based on my limited memory of what the next chapter *really* does. i
4781 just wanted to flesh out this final section a little bit so i'd
4782 remember to stick it in here. :-)}
4784 If there are too many files to conveniently list on the command line,
4785 you can list the names in a file, and @command{tar} will read that file.
4786 @value{xref-files-from}.
4788 There are various ways of causing @command{tar} to skip over some files,
4789 and not archive them. @xref{Choosing}.
4792 @chapter Performing Backups and Restoring Files
4795 @GNUTAR{} is distributed along with the scripts
4796 which the Free Software Foundation uses for performing backups. There
4797 is no corresponding scripts available yet for doing restoration of
4798 files. Even if there is a good chance those scripts may be satisfying
4799 to you, they are not the only scripts or methods available for doing
4800 backups and restore. You may well create your own, or use more
4801 sophisticated packages dedicated to that purpose.
4803 Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
4804 Automatic Network Disk Archiver), a backup system developed by James
4805 da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
4806 This is free software, and it is available at these places:
4809 http://www.cs.umd.edu/projects/amanda/amanda.html
4810 ftp://ftp.cs.umd.edu/pub/amanda
4815 Here is a possible plan for a future documentation about the backuping
4816 scripts which are provided within the @GNUTAR{}
4823 . + different levels of dumps
4824 . - full dump = dump everything
4825 . - level 1, level 2 dumps etc, -
4826 A level n dump dumps everything changed since the last level
4829 . + how to use scripts for dumps (ie, the concept)
4830 . - scripts to run after editing backup specs (details)
4832 . + Backup Specs, what is it.
4833 . - how to customize
4834 . - actual text of script [/sp/dump/backup-specs]
4837 . - rsh doesn't work
4838 . - rtape isn't installed
4841 . + the --incremental option of tar
4844 . - write protection
4846 . : different sizes and types, useful for different things
4847 . - files and tape marks
4848 one tape mark between files, two at end.
4849 . - positioning the tape
4850 MT writes two at end of write,
4851 backspaces over one when writing again.
4856 This chapter documents both the provided FSF scripts and @command{tar}
4857 options which are more specific to usage as a backup tool.
4859 To @dfn{back up} a file system means to create archives that contain
4860 all the files in that file system. Those archives can then be used to
4861 restore any or all of those files (for instance if a disk crashes or a
4862 file is accidentally deleted). File system @dfn{backups} are also
4866 * Full Dumps:: Using @command{tar} to Perform Full Dumps
4867 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
4868 * incremental and listed-incremental:: The Incremental Options
4869 * Backup Levels:: Levels of Backups
4870 * Backup Parameters:: Setting Parameters for Backups and Restoration
4871 * Scripted Backups:: Using the Backup Scripts
4872 * Scripted Restoration:: Using the Restore Script
4876 @section Using @command{tar} to Perform Full Dumps
4882 @cindex corrupted archives
4883 Full dumps should only be made when no other people or programs
4884 are modifying files in the filesystem. If files are modified while
4885 @command{tar} is making the backup, they may not be stored properly in
4886 the archive, in which case you won't be able to restore them if you
4887 have to. (Files not being modified are written with no trouble, and do
4888 not corrupt the entire archive.)
4890 You will want to use the @value{op-label} option to give the archive a
4891 volume label, so you can tell what this archive is even if the label
4892 falls off the tape, or anything like that.
4894 Unless the filesystem you are dumping is guaranteed to fit on
4895 one volume, you will need to use the @value{op-multi-volume} option.
4896 Make sure you have enough tapes on hand to complete the backup.
4898 If you want to dump each filesystem separately you will need to use
4899 the @value{op-one-file-system} option to prevent @command{tar} from crossing
4900 filesystem boundaries when storing (sub)directories.
4902 The @value{op-incremental} option is not needed, since this is a complete
4903 copy of everything in the filesystem, and a full restore from this
4904 backup would only be done onto a completely empty disk.
4906 Unless you are in a hurry, and trust the @command{tar} program (and your
4907 tapes), it is a good idea to use the @value{op-verify} option, to make
4908 sure your files really made it onto the dump properly. This will
4909 also detect cases where the file was modified while (or just after)
4910 it was being archived. Not all media (notably cartridge tapes) are
4911 capable of being verified, unfortunately.
4913 @value{op-listed-incremental} take a file name argument always. If the
4914 file doesn't exist, run a level zero dump, creating the file. If the
4915 file exists, uses that file to see what has changed.
4917 @value{op-incremental} @FIXME{look it up}
4919 @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
4921 This option should only be used when creating an incremental backup of
4922 a filesystem. When the @value{op-incremental} option is used, @command{tar}
4923 writes, at the beginning of the archive, an entry for each of the
4924 directories that will be operated on. The entry for a directory
4925 includes a list of all the files in the directory at the time the
4926 dump was done, and a flag for each file indicating whether the file
4927 is going to be put in the archive. This information is used when
4928 doing a complete incremental restore.
4930 Note that this option causes @command{tar} to create a non-standard
4931 archive that may not be readable by non-@acronym{GNU} versions of the
4932 @command{tar} program.
4934 The @value{op-incremental} option means the archive is an incremental
4935 backup. Its meaning depends on the command that it modifies.
4937 If the @value{op-incremental} option is used with @value{op-list},
4938 @command{tar} will list, for each directory in the archive, the list
4939 of files in that directory at the time the archive was created. This
4940 information is put out in a format that is not easy for humans to
4941 read, but which is unambiguous for a program: each file name is
4942 preceded by either a @samp{Y} if the file is present in the archive,
4943 an @samp{N} if the file is not included in the archive, or a @samp{D}
4944 if the file is a directory (and is included in the archive). Each
4945 file name is terminated by a null character. The last file is
4946 followed by an additional null and a newline to indicate the end of
4949 If the @value{op-incremental} option is used with @value{op-extract}, then
4950 when the entry for a directory is found, all files that currently
4951 exist in that directory but are not listed in the archive @emph{are
4952 deleted from the directory}.
4954 This behavior is convenient when you are restoring a damaged file
4955 system from a succession of incremental backups: it restores the
4956 entire state of the file system to that which obtained when the backup
4957 was made. If you don't use @value{op-incremental}, the file system will
4958 probably fill up with files that shouldn't exist any more.
4960 @value{op-listed-incremental} handle new @acronym{GNU}-format
4961 incremental backup. This option handles new @acronym{GNU}-format
4962 incremental backup. It has much the same effect as
4963 @value{op-incremental}, but also the time when the dump is done and
4964 the list of directories dumped is written to the given
4965 @var{file}. When restoring, only files newer than the saved time are
4966 restored, and the directory list is used to speed up operations.
4968 @value{op-listed-incremental} acts like @value{op-incremental}, but when
4969 used in conjunction with @value{op-create} will also cause @command{tar} to
4970 use the file @var{file}, which contains information about the state
4971 of the filesystem at the time of the last backup, to decide which
4972 files to include in the archive being created. That file will then
4973 be updated by @command{tar}. If the file @var{file} does not exist when
4974 this option is specified, @command{tar} will create it, and include all
4975 appropriate files in the archive.
4977 The file, which is archive independent, contains the date it was last
4978 modified and a list of devices, inode numbers and directory names.
4979 @command{tar} will archive files with newer mod dates or inode change
4980 times, and directories with an unchanged inode number and device but
4981 a changed directory name. The file is updated after the files to
4982 be archived are determined, but before the new archive is actually
4986 @section Using @command{tar} to Perform Incremental Dumps
4989 @cindex incremental dumps
4990 @cindex dumps, incremental
4992 Performing incremental dumps is similar to performing full dumps,
4993 although a few more options will usually be needed.
4995 A standard scheme is to do a @emph{monthly} (full) dump once a month,
4996 a @emph{weekly} dump once a week of everything since the last monthly
4997 and a @emph{daily} every day of everything since the last (weekly or
5000 Here is a sample script to dump the directory hierarchies @samp{/usr}
5006 --blocking-factor=126 \
5008 --label="`hostname` /usr /var `date +%Y-%m-%d`" \
5009 --listed-incremental=/var/log/usr-var.snar \
5014 This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
5015 store information about the previous tar dump.
5017 The blocking factor 126 is an attempt to make the tape drive stream.
5018 Some tape devices cannot handle 64 kB blocks or larger, and require the
5019 block size to be a multiple of 1 kB; for these devices, 126 is the
5020 largest blocking factor that can be used.
5022 @node incremental and listed-incremental
5023 @section The Incremental Options
5026 @value{op-incremental} is used in conjunction with @value{op-create},
5027 @value{op-extract} or @value{op-list} when backing up and restoring file
5028 systems. An archive cannot be extracted or listed with the
5029 @value{op-incremental} option specified unless it was created with the
5030 option specified. This option should only be used by a script, not by
5031 the user, and is usually disregarded in favor of
5032 @value{op-listed-incremental}, which is described below.
5034 @value{op-incremental} in conjunction with @value{op-create} causes
5035 @command{tar} to write, at the beginning of the archive, an entry for
5036 each of the directories that will be archived. The entry for a
5037 directory includes a list of all the files in the directory at the
5038 time the archive was created and a flag for each file indicating
5039 whether or not the file is going to be put in the archive.
5041 Note that this option causes @command{tar} to create a non-standard
5042 archive that may not be readable by non-@acronym{GNU} versions of the
5043 @command{tar} program.
5045 @value{op-incremental} in conjunction with @value{op-extract} causes
5046 @command{tar} to read the lists of directory contents previously stored
5047 in the archive, @emph{delete} files in the file system that did not
5048 exist in their directories when the archive was created, and then
5049 extract the files in the archive.
5051 This behavior is convenient when restoring a damaged file system from
5052 a succession of incremental backups: it restores the entire state of
5053 the file system to that which obtained when the backup was made. If
5054 @value{op-incremental} isn't specified, the file system will probably
5055 fill up with files that shouldn't exist any more.
5057 @value{op-incremental} in conjunction with @value{op-list} causes
5058 @command{tar} to print, for each directory in the archive, the list of
5059 files in that directory at the time the archive was created. This
5060 information is put out in a format that is not easy for humans to
5061 read, but which is unambiguous for a program: each file name is
5062 preceded by either a @samp{Y} if the file is present in the archive,
5063 an @samp{N} if the file is not included in the archive, or a @samp{D}
5064 if the file is a directory (and is included in the archive). Each
5065 file name is terminated by a null character. The last file is followed
5066 by an additional null and a newline to indicate the end of the data.
5068 @value{op-listed-incremental} acts like @value{op-incremental}, but when
5069 used in conjunction with @value{op-create} will also cause @command{tar}
5070 to use the file @var{snapshot-file}, which contains information about
5071 the state of the file system at the time of the last backup, to decide
5072 which files to include in the archive being created. That file will
5073 then be updated by @command{tar}. If the file @var{file} does not exist
5074 when this option is specified, @command{tar} will create it, and include
5075 all appropriate files in the archive.
5077 The file @var{file}, which is archive independent, contains the date
5078 it was last modified and a list of devices, inode numbers and
5079 directory names. @command{tar} will archive files with newer mod dates
5080 or inode change times, and directories with an unchanged inode number
5081 and device but a changed directory name. The file is updated after
5082 the files to be archived are determined, but before the new archive is
5085 Incremental dumps depend crucially on time stamps, so the results are
5086 unreliable if you modify a file's time stamps during dumping (e.g.@:
5087 with the @samp{--atime-preserve} option), or if you set the clock
5090 Despite it should be obvious that a device has a non-volatile value, NFS
5091 devices have non-dependable values when an automounter gets in the picture.
5092 This led to a great deal of spurious redumping in incremental dumps,
5093 so it is somewhat useless to compare two NFS devices numbers over time.
5094 So @command{tar} now considers all NFS devices as being equal when it comes
5095 to comparing directories; this is fairly gross, but there does not seem
5096 to be a better way to go.
5098 @command{tar} doesn't access @var{snapshot-file} when
5099 @value{op-create} or @value{op-list} are specified, but the
5100 @value{op-listed-incremental} option must still be given. A
5101 placeholder @var{snapshot-file} can be specified, e.g.,
5104 @FIXME{this section needs to be written}
5107 @section Levels of Backups
5110 An archive containing all the files in the file system is called a
5111 @dfn{full backup} or @dfn{full dump}. You could insure your data by
5112 creating a full dump every day. This strategy, however, would waste a
5113 substantial amount of archive media and user time, as unchanged files
5114 are daily re-archived.
5116 It is more efficient to do a full dump only occasionally. To back up
5117 files between full dumps, you can a incremental dump. A @dfn{level
5118 one} dump archives all the files that have changed since the last full
5121 A typical dump strategy would be to perform a full dump once a week,
5122 and a level one dump once a day. This means some versions of files
5123 will in fact be archived more than once, but this dump strategy makes
5124 it possible to restore a file system to within one day of accuracy by
5125 only extracting two archives---the last weekly (full) dump and the
5126 last daily (level one) dump. The only information lost would be in
5127 files changed or created since the last daily backup. (Doing dumps
5128 more than once a day is usually not worth the trouble).
5130 @GNUTAR{} comes with scripts you can use to do full
5131 and level-one dumps. Using scripts (shell programs) to perform
5132 backups and restoration is a convenient and reliable alternative to
5133 typing out file name lists and @command{tar} commands by hand.
5135 Before you use these scripts, you need to edit the file
5136 @file{backup-specs}, which specifies parameters used by the backup
5137 scripts and by the restore script. @FIXME{There is no such restore
5138 script!}@FIXME-xref{Script Syntax}Once the backup parameters
5139 are set, you can perform backups or restoration by running the
5142 The name of the restore script is @code{restore}. @FIXME{There is
5143 no such restore script!}The names of the level one and full backup
5144 scripts are, respectively, @code{level-1} and @code{level-0}.
5145 The @code{level-0} script also exists under the name @code{weekly}, and
5146 the @code{level-1} under the name @code{daily}---these additional names
5147 can be changed according to your backup schedule. @FIXME-xref{Scripted
5148 Restoration, for more information on running the restoration script.}
5149 @FIXME-xref{Scripted Backups, for more information on running the
5152 @emph{Please Note:} The backup scripts and the restoration scripts are
5153 designed to be used together. While it is possible to restore files by
5154 hand from an archive which was created using a backup script, and to create
5155 an archive by hand which could then be extracted using the restore script,
5156 it is easier to use the scripts.@FIXME{There is no such restore script!}
5157 @value{xref-incremental}, and @value{xref-listed-incremental},
5158 before making such an attempt.
5160 @FIXME{shorten node names}
5162 @node Backup Parameters
5163 @section Setting Parameters for Backups and Restoration
5166 The file @file{backup-specs} specifies backup parameters for the
5167 backup and restoration scripts provided with @command{tar}. You must
5168 edit @file{backup-specs} to fit your system configuration and schedule
5169 before using these scripts.
5171 @FIXME{This about backup scripts needs to be written: BS is a shell
5172 script .... thus ... @file{backup-specs} is in shell script syntax.}
5174 @FIXME-xref{Script Syntax, for an explanation of this syntax.}
5176 @FIXME{Whats a parameter .... looked at by the backup scripts
5177 ... which will be expecting to find ... now syntax ... value is linked
5178 to lame ... @file{backup-specs} specifies the following parameters:}
5182 The user name of the backup administrator.
5185 The hour at which the backups are done. This can be a number from 0
5186 to 23, or the string @samp{now}.
5189 The device @command{tar} writes the archive to. This device should be
5190 attached to the host on which the dump scripts are run.
5192 @FIXME{examples for all ...}
5195 The command to use to obtain the status of the archive device,
5196 including error count. On some tape drives there may not be such a
5197 command; in that case, simply use @samp{TAPE_STATUS=false}.
5200 The blocking factor @command{tar} will use when writing the dump archive.
5201 @value{xref-blocking-factor}.
5204 A list of file systems to be dumped. You can include any directory
5205 name in the list---subdirectories on that file system will be
5206 included, regardless of how they may look to other networked machines.
5207 Subdirectories on other file systems will be ignored.
5209 The host name specifies which host to run @command{tar} on, and should
5210 normally be the host that actually contains the file system. However,
5211 the host machine must have @GNUTAR{} installed, and
5212 must be able to access the directory containing the backup scripts and
5213 their support files using the same file name that is used on the
5214 machine where the scripts are run (ie. what @command{pwd} will print
5215 when in that directory on that machine). If the host that contains
5216 the file system does not have this capability, you can specify another
5217 host as long as it can access the file system through NFS.
5220 A list of individual files to be dumped. These should be accessible
5221 from the machine on which the backup script is run.
5223 @FIXME{Same file name, be specific. Through NFS ...}
5228 * backup-specs example:: An Example Text of @file{Backup-specs}
5229 * Script Syntax:: Syntax for @file{Backup-specs}
5232 @node backup-specs example
5233 @subsection An Example Text of @file{Backup-specs}
5236 The following is the text of @file{backup-specs} as it appears at FSF:
5239 # site-specific parameters for file system backup.
5241 ADMINISTRATOR=friedman
5243 TAPE_FILE=/dev/nrsmt0
5244 TAPE_STATUS="mts -t $TAPE_FILE"
5259 apple-gunkies:/com/mailer/gnu
5260 apple-gunkies:/com/archive/gnu"
5262 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
5267 @subsection Syntax for @file{Backup-specs}
5270 @file{backup-specs} is in shell script syntax. The following
5271 conventions should be considered when editing the script:
5272 @FIXME{"conventions?"}
5274 A quoted string is considered to be contiguous, even if it is on more
5275 than one line. Therefore, you cannot include commented-out lines
5276 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
5277 the two most likely parameters to be multi-line.
5279 A quoted string typically cannot contain wildcards. In
5280 @file{backup-specs}, however, the parameters BACKUP_DIRS and
5281 BACKUP_FILES can contain wildcards.
5283 @node Scripted Backups
5284 @section Using the Backup Scripts
5287 The syntax for running a backup script is:
5290 @file{script-name} [@var{time-to-be-run}]
5293 where @var{time-to-be-run} can be a specific system time, or can be
5294 @kbd{now}. If you do not specify a time, the script runs at the time
5295 specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
5297 You should start a script with a tape or disk mounted. Once you
5298 start a script, it prompts you for new tapes or disks as it
5299 needs them. Media volumes don't have to correspond to archive
5300 files---a multi-volume archive can be started in the middle of a
5301 tape that already contains the end of another multi-volume archive.
5302 The @code{restore} script prompts for media by its archive volume,
5303 so to avoid an error message you should keep track of which tape
5304 (or disk) contains which volume of the archive. @FIXME{There is
5305 no such restore script!} @FIXME-xref{Scripted Restoration}
5306 @FIXME{Have file names changed?}
5308 The backup scripts write two files on the file system. The first is a
5309 record file in @file{/etc/tar-backup/}, which is used by the scripts
5310 to store and retrieve information about which files were dumped. This
5311 file is not meant to be read by humans, and should not be deleted by
5312 them. @FIXME-xref{incremental and listed-incremental, for a more
5313 detailed explanation of this file.}
5315 The second file is a log file containing the names of the file systems
5316 and files dumped, what time the backup was made, and any error
5317 messages that were generated, as well as how much space was left in
5318 the media volume after the last volume of the archive was written.
5319 You should check this log file after every backup. The file name is
5320 @file{log-@var{mmm-ddd-yyyy}-level-1} or
5321 @file{log-@var{mmm-ddd-yyyy}-full}.
5323 The script also prints the name of each system being dumped to the
5326 @node Scripted Restoration
5327 @section Using the Restore Script
5332 The @command{tar} distribution does not provide restoring scripts.
5339 @strong{Warning:} The @GNUTAR{} distribution does @emph{not}
5340 provide any such @code{restore} script yet. This section is only
5341 listed here for documentation maintenance purposes. In any case,
5342 all contents is subject to change as things develop.
5345 @FIXME{A section on non-scripted restore may be a good idea.}
5347 To restore files that were archived using a scripted backup, use the
5348 @code{restore} script. The syntax for the script is:
5350 where ***** are the file systems to restore from, and
5351 ***** is a regular expression which specifies which files to
5352 restore. If you specify --all, the script restores all the files
5355 You should start the restore script with the media containing the
5356 first volume of the archive mounted. The script will prompt for other
5357 volumes as they are needed. If the archive is on tape, you don't need
5358 to rewind the tape to to its beginning---if the tape head is
5359 positioned past the beginning of the archive, the script will rewind
5360 the tape as needed. @FIXME-xref{Media, for a discussion of tape
5363 If you specify @samp{--all} as the @var{files} argument, the
5364 @code{restore} script extracts all the files in the archived file
5365 system into the active file system.
5368 @strong{Warning:} The script will delete files from the active file
5369 system if they were not in the file system when the archive was made.
5372 @value{xref-incremental}, and @value{ref-listed-incremental},
5373 for an explanation of how the script makes that determination.
5375 @FIXME{this may be an option, not a given}
5380 @chapter Choosing Files and Names for @command{tar}
5383 @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
5385 Certain options to @command{tar} enable you to specify a name for your
5386 archive. Other options let you decide which files to include or exclude
5387 from the archive, based on when or whether files were modified, whether
5388 the file names do or don't match specified patterns, or whether files
5389 are in specified directories.
5392 * file:: Choosing the Archive's Name
5393 * Selecting Archive Members::
5394 * files:: Reading Names from a File
5395 * exclude:: Excluding Some Files
5397 * after:: Operating Only on New Files
5398 * recurse:: Descending into Directories
5399 * one:: Crossing Filesystem Boundaries
5403 @section Choosing and Naming Archive Files
5404 @cindex Naming an archive
5405 @cindex Archive Name
5406 @cindex Directing output
5407 @cindex Choosing an archive file
5408 @cindex Where is the archive?
5411 @FIXME{should the title of this section actually be, "naming an
5414 By default, @command{tar} uses an archive file name that was compiled when
5415 it was built on the system; usually this name refers to some physical
5416 tape drive on the machine. However, the person who installed @command{tar}
5417 on the system may not set the default to a meaningful value as far as
5418 most users are concerned. As a result, you will usually want to tell
5419 @command{tar} where to find (or create) the archive. The @value{op-file}
5420 option allows you to either specify or name a file to use as the archive
5421 instead of the default archive file location.
5424 @item --file=@var{archive-name}
5425 @itemx -f @var{archive-name}
5426 Name the archive to create or operate on. Use in conjunction with
5430 For example, in this @command{tar} command,
5433 $ @kbd{tar -cvf collection.tar blues folk jazz}
5437 @file{collection.tar} is the name of the archive. It must directly
5438 follow the @samp{-f} option, since whatever directly follows @samp{-f}
5439 @emph{will} end up naming the archive. If you neglect to specify an
5440 archive name, you may end up overwriting a file in the working directory
5441 with the archive you create since @command{tar} will use this file's name
5442 for the archive name.
5444 An archive can be saved as a file in the file system, sent through a
5445 pipe or over a network, or written to an I/O device such as a tape,
5446 floppy disk, or CD write drive.
5448 @cindex Writing new archives
5449 @cindex Archive creation
5450 If you do not name the archive, @command{tar} uses the value of the
5451 environment variable @env{TAPE} as the file name for the archive. If
5452 that is not available, @command{tar} uses a default, compiled-in archive
5453 name, usually that for tape unit zero (ie. @file{/dev/tu00}).
5454 @command{tar} always needs an archive name.
5456 If you use @file{-} as an @var{archive-name}, @command{tar} reads the
5457 archive from standard input (when listing or extracting files), or
5458 writes it to standard output (when creating an archive). If you use
5459 @file{-} as an @var{archive-name} when modifying an archive,
5460 @command{tar} reads the original archive from its standard input and
5461 writes the entire new archive to its standard output.
5463 @FIXME{might want a different example here; this is already used in
5464 "notable tar usages".}
5467 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
5472 @cindex Standard input and output
5473 @cindex tar to standard input and output
5474 To specify an archive file on a device attached to a remote machine,
5478 @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
5482 @command{tar} will complete the remote connection, if possible, and
5483 prompt you for a username and password. If you use
5484 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
5485 will complete the remote connection, if possible, using your username
5486 as the username on the remote machine.
5488 If the archive file name includes a colon (@samp{:}), then it is assumed
5489 to be a file on another machine. If the archive file is
5490 @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
5491 host @var{host}. The remote host is accessed using the @command{rsh}
5492 program, with a username of @var{user}. If the username is omitted
5493 (along with the @samp{@@} sign), then your user name will be used.
5494 (This is the normal @command{rsh} behavior.) It is necessary for the
5495 remote machine, in addition to permitting your @command{rsh} access, to
5496 have the @file{/usr/ucb/rmt} program installed. If you need to use a
5497 file whose name includes a colon, then the remote tape drive behavior
5498 can be inhibited by using the @value{op-force-local} option.
5500 @FIXME{i know we went over this yesterday, but bob (and now i do again,
5501 too) thinks it's out of the middle of nowhere. it doesn't seem to tie
5502 into what came before it well enough <<i moved it now, is it better
5503 here?>>. bob also comments that if Amanda isn't free software, we
5504 shouldn't mention it..}
5506 When the archive is being created to @file{/dev/null}, @GNUTAR{}
5507 tries to minimize input and output operations. The
5508 Amanda backup system, when used with @GNUTAR{}, has
5509 an initial sizing pass which uses this feature.
5511 @node Selecting Archive Members
5512 @section Selecting Archive Members
5513 @cindex Specifying files to act on
5514 @cindex Specifying archive members
5516 @dfn{File Name arguments} specify which files in the file system
5517 @command{tar} operates on, when creating or adding to an archive, or which
5518 archive members @command{tar} operates on, when reading or deleting from
5519 an archive. @xref{Operations}.
5521 To specify file names, you can include them as the last arguments on
5522 the command line, as follows:
5524 @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
5527 If you specify a directory name as a file name argument, all the files
5528 in that directory are operated on by @command{tar}.
5530 If you do not specify files when @command{tar} is invoked with
5531 @value{op-create}, @command{tar} operates on all the non-directory files in
5532 the working directory. If you specify either @value{op-list} or
5533 @value{op-extract}, @command{tar} operates on all the archive members in the
5534 archive. If you specify any operation other than one of these three,
5535 @command{tar} does nothing.
5537 By default, @command{tar} takes file names from the command line. However,
5538 there are other ways to specify file or member names, or to modify the
5539 manner in which @command{tar} selects the files or members upon which to
5540 operate. @FIXME{add xref here}In general, these methods work both for
5541 specifying the names of files and archive members.
5544 @section Reading Names from a File
5547 @cindex Reading file names from a file
5548 @cindex Lists of file names
5549 @cindex File Name arguments, alternatives
5550 Instead of giving the names of files or archive members on the command
5551 line, you can put the names into a file, and then use the
5552 @value{op-files-from} option to @command{tar}. Give the name of the file
5553 which contains the list of files to include as the argument to
5554 @samp{--files-from}. In the list, the file names should be separated by
5555 newlines. You will frequently use this option when you have generated
5556 the list of files to archive with the @command{find} utility.
5559 @item --files-from=@var{file name}
5560 @itemx -T @var{file name}
5561 Get names to extract or create from file @var{file name}.
5564 If you give a single dash as a file name for @samp{--files-from}, (i.e.,
5565 you specify either @samp{--files-from=-} or @samp{-T -}), then the file
5566 names are read from standard input.
5568 Unless you are running @command{tar} with @samp{--create}, you can not use
5569 both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
5572 @FIXME{add bob's example, from his message on 2-10-97}
5574 The following example shows how to use @command{find} to generate a list of
5575 files smaller than 400K in length and put that list into a file
5576 called @file{small-files}. You can then use the @samp{-T} option to
5577 @command{tar} to specify the files from that file, @file{small-files}, to
5578 create the archive @file{little.tgz}. (The @samp{-z} option to
5579 @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
5583 $ @kbd{find . -size -400 -print > small-files}
5584 $ @kbd{tar -c -v -z -T small-files -f little.tgz}
5588 @FIXME{say more here to conclude the example/section?}
5595 @subsection @kbd{NUL} Terminated File Names
5597 @cindex File names, terminated by @kbd{NUL}
5598 @cindex @kbd{NUL} terminated file names
5599 The @value{op-null} option causes @value{op-files-from} to read file
5600 names terminated by a @code{NUL} instead of a newline, so files whose
5601 names contain newlines can be archived using @samp{--files-from}.
5605 Only consider @kbd{NUL} terminated file names, instead of files that
5606 terminate in a newline.
5609 The @samp{--null} option is just like the one in @acronym{GNU}
5610 @command{xargs} and @command{cpio}, and is useful with the
5611 @samp{-print0} predicate of @acronym{GNU} @command{find}. In
5612 @command{tar}, @samp{--null} also causes @value{op-directory} options
5613 to be treated as file names to archive, in case there are any files
5614 out there called @file{-C}.
5616 This example shows how to use @command{find} to generate a list of files
5617 larger than 800K in length and put that list into a file called
5618 @file{long-files}. The @samp{-print0} option to @command{find} just just
5619 like @samp{-print}, except that it separates files with a @kbd{NUL}
5620 rather than with a newline. You can then run @command{tar} with both the
5621 @samp{--null} and @samp{-T} options to specify that @command{tar} get the
5622 files from that file, @file{long-files}, to create the archive
5623 @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
5624 @command{tar} to recognize the @kbd{NUL} separator between files.
5627 $ @kbd{find . -size +800 -print0 > long-files}
5628 $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
5631 @FIXME{say anything else here to conclude the section?}
5634 @section Excluding Some Files
5635 @cindex File names, excluding files by
5636 @cindex Excluding files by name and pattern
5637 @cindex Excluding files by file system
5640 To avoid operating on files whose names match a particular pattern,
5641 use the @value{op-exclude} or @value{op-exclude-from} options.
5644 @item --exclude=@var{pattern}
5645 Causes @command{tar} to ignore files that match the @var{pattern}.
5649 The @value{op-exclude} option prevents any file or member whose name
5650 matches the shell wildcard (@var{pattern}) from being operated on.
5651 For example, to create an archive with all the contents of the directory
5652 @file{src} except for files whose names end in @file{.o}, use the
5653 command @samp{tar -cf src.tar --exclude='*.o' src}.
5655 You may give multiple @samp{--exclude} options.
5658 @item --exclude-from=@var{file}
5659 @itemx -X @var{file}
5660 Causes @command{tar} to ignore files that match the patterns listed in
5664 @findex exclude-from
5665 Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
5666 list of patterns, one per line, from @var{file}; @command{tar} will
5667 ignore files matching those patterns. Thus if @command{tar} is
5668 called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
5669 single line @file{*.o}, no files whose names end in @file{.o} will be
5670 added to the archive.
5672 @FIXME{do the exclude options files need to have stuff separated by
5673 newlines the same as the files-from option does?}
5676 * controlling pattern-patching with exclude::
5677 * problems with exclude::
5680 @node controlling pattern-patching with exclude
5681 @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
5683 Normally, a pattern matches a name if an initial subsequence of the
5684 name's components matches the pattern, where @samp{*}, @samp{?}, and
5685 @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
5686 and wildcards can match @samp{/}.
5688 Other than optionally stripping leading @samp{/} from names
5689 (@pxref{absolute}), patterns and names are used as-is. For
5690 example, trailing @samp{/} is not trimmed from a user-specified name
5691 before deciding whether to exclude it.
5693 However, this matching procedure can be altered by the options listed
5694 below. These options accumulate. For example:
5697 --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
5700 ignores case when excluding @samp{makefile}, but not when excluding
5705 @itemx --no-anchored
5706 If anchored (the default), a pattern must match an initial subsequence
5707 of the name's components. Otherwise, the pattern can match any subsequence.
5710 @itemx --no-ignore-case
5711 When ignoring case, upper-case patterns match lower-case names and vice versa.
5712 When not ignoring case (the default), matching is case-sensitive.
5715 @itemx --no-wildcards
5716 When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
5717 are the usual shell wildcards, and @samp{\} escapes wildcards.
5718 Otherwise, none of these characters are special, and patterns must match
5721 @item --wildcards-match-slash
5722 @itemx --no-wildcards-match-slash
5723 When wildcards match slash (the default), a wildcard like @samp{*} in
5724 the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
5725 matched only by @samp{/}.
5729 The @option{--recursion} and @option{--no-recursion} options
5730 (@pxref{recurse}) also affect how exclude patterns are interpreted. If
5731 recursion is in effect, a pattern excludes a name if it matches any of
5732 the name's parent directories.
5734 @node problems with exclude
5735 @unnumberedsubsec Problems with Using the @code{exclude} Options
5737 Some users find @samp{exclude} options confusing. Here are some common
5742 The main operating mode of @command{tar} does not act on a path name
5743 explicitly listed on the command line if one of its file name
5744 components is excluded. In the example above, if
5745 you create an archive and exclude files that end with @samp{*.o}, but
5746 explicitly name the file @samp{dir.o/foo} after all the options have been
5747 listed, @samp{dir.o/foo} will be excluded from the archive.
5750 You can sometimes confuse the meanings of @value{op-exclude} and
5751 @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
5752 to be excluded are given as a pattern on the command line. Use
5753 @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
5754 file which contains a list of patterns, one per line; each of these
5755 patterns can exclude zero, one, or many files.
5758 When you use @value{op-exclude}, be sure to quote the @var{pattern}
5759 parameter, so @GNUTAR{} sees wildcard characters
5760 like @samp{*}. If you do not do this, the shell might expand the
5761 @samp{*} itself using files at hand, so @command{tar} might receive a
5762 list of files instead of one pattern, or none at all, making the
5763 command somewhat illegal. This might not correspond to what you want.
5768 $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
5775 $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
5779 You must use use shell syntax, or globbing, rather than @code{regexp}
5780 syntax, when using exclude options in @command{tar}. If you try to use
5781 @code{regexp} syntax to describe files to be excluded, your command
5785 In earlier versions of @command{tar}, what is now the
5786 @samp{--exclude-from=@var{file-of-patterns}} option was called
5787 @samp{--exclude=@var{pattern}} instead. Now,
5788 @samp{--exclude=@var{pattern}} applies to patterns listed on the command
5789 line and @samp{--exclude-from=@var{file-of-patterns}} applies to
5790 patterns listed in a file.
5795 @section Wildcards Patterns and Matching
5797 @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
5798 @samp{*} or @samp{?} for example, are replaced and expanded into all
5799 existing files matching the given pattern. However, @command{tar} often
5800 uses wildcard patterns for matching (or globbing) archive members instead
5801 of actual files in the filesystem. Wildcard patterns are also used for
5802 verifying volume labels of @command{tar} archives. This section has the
5803 purpose of explaining wildcard syntax for @command{tar}.
5805 @FIXME{the next few paragraphs need work.}
5807 A @var{pattern} should be written according to shell syntax, using wildcard
5808 characters to effect globbing. Most characters in the pattern stand
5809 for themselves in the matched string, and case is significant: @samp{a}
5810 will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
5811 pattern matches any single character in the matched string. The character
5812 @samp{*} in the pattern matches zero, one, or more single characters in
5813 the matched string. The character @samp{\} says to take the following
5814 character of the pattern @emph{literally}; it is useful when one needs to
5815 match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
5817 The character @samp{[}, up to the matching @samp{]}, introduces a character
5818 class. A @dfn{character class} is a list of acceptable characters
5819 for the next single character of the matched string. For example,
5820 @samp{[abcde]} would match any of the first five letters of the alphabet.
5821 Note that within a character class, all of the ``special characters''
5822 listed above other than @samp{\} lose their special meaning; for example,
5823 @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
5824 @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
5825 the characters @samp{-} and @samp{]} must either come @emph{first} or
5826 @emph{last} in a character class.)
5828 @cindex Excluding characters from a character class
5829 @cindex Character class, excluding characters from
5830 If the first character of the class after the opening @samp{[}
5831 is @samp{!} or @samp{^}, then the meaning of the class is reversed.
5832 Rather than listing character to match, it lists those characters which
5833 are @emph{forbidden} as the next single character of the matched string.
5835 Other characters of the class stand for themselves. The special
5836 construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
5837 letters, is meant to represent all characters between @var{a} and
5840 @FIXME{need to add a sentence or so here to make this clear for those
5841 who don't have dan around.}
5843 Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
5844 special for wildcard matches. However, if a pattern completely matches
5845 a directory prefix of a matched string, then it matches the full matched
5846 string: excluding a directory also excludes all the files beneath it.
5849 @section Operating Only on New Files
5850 @cindex Excluding file by age
5851 @cindex Modification time, excluding files by
5852 @cindex Age, excluding files by
5855 The @value{op-after-date} option causes @command{tar} to only work on files
5856 whose modification or inode-changed times are newer than the @var{date}
5857 given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
5858 be a file name; the last-modified time of that file is used as the date.
5859 If you use this option when creating or appending to an archive,
5860 the archive will only include new files. If you use @samp{--after-date}
5861 when extracting an archive, @command{tar} will only extract files newer
5862 than the @var{date} you specify.
5864 If you only want @command{tar} to make the date comparison based on
5865 modification of the actual contents of the file (rather than inode
5866 changes), then use the @value{op-newer-mtime} option.
5868 You may use these options with any operation. Note that these options
5869 differ from the @value{op-update} operation in that they allow you to
5870 specify a particular date against which @command{tar} can compare when
5871 deciding whether or not to archive the files.
5874 @item --after-date=@var{date}
5875 @itemx --newer=@var{date}
5876 @itemx -N @var{date}
5877 Only store files newer than @var{date}.
5879 Acts on files only if their modification or inode-changed times are
5880 later than @var{date}. Use in conjunction with any operation.
5882 If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
5883 name; the last-modified time of that file is used as the date.
5885 @item --newer-mtime=@var{date}
5886 Acts like @value{op-after-date}, but only looks at modification times.
5889 These options limit @command{tar} to only operating on files which have
5890 been modified after the date specified. A file is considered to have
5891 changed if the contents have been modified, or if the owner,
5892 permissions, and so forth, have been changed. (For more information on
5893 how to specify a date, see @ref{Date input formats}; remember that the
5894 entire date argument must be quoted if it contains any spaces.)
5896 Gurus would say that @value{op-after-date} tests both the @code{mtime}
5897 (time the contents of the file were last modified) and @code{ctime}
5898 (time the file's status was last changed: owner, permissions, etc)
5899 fields, while @value{op-newer-mtime} tests only @code{mtime} field.
5901 To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
5902 @code{ctime} and processes the file if either one is more recent than
5903 @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
5904 disregards @code{ctime}. Neither uses @code{atime} (the last time the
5905 contents of the file were looked at).
5907 Date specifiers can have embedded spaces. Because of this, you may need
5908 to quote date arguments to keep the shell from parsing them as separate
5911 @FIXME{Need example of --newer-mtime with quoted argument.}
5914 @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
5915 should not be used for incremental backups. Some files (such as those
5916 in renamed directories) are not selected properly by these options.
5917 @xref{incremental and listed-incremental}.
5921 @FIXME{which tells -- need to fill this in!}
5924 @section Descending into Directories
5925 @cindex Avoiding recursion in directories
5926 @cindex Descending directories, avoiding
5927 @cindex Directories, avoiding recursion
5928 @cindex Recursion in directories, avoiding
5931 @FIXME{arrggh! this is still somewhat confusing to me. :-< }
5933 @FIXME{show dan bob's comments, from 2-10-97}
5935 Usually, @command{tar} will recursively explore all directories (either
5936 those given on the command line or through the @value{op-files-from}
5937 option) for the various files they contain. However, you may not always
5938 want @command{tar} to act this way.
5940 The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
5941 into specified directories. If you specify @samp{--no-recursion}, you can
5942 use the @command{find} utility for hunting through levels of directories to
5943 construct a list of file names which you could then pass to @command{tar}.
5944 @command{find} allows you to be more selective when choosing which files to
5945 archive; see @ref{files} for more information on using @command{find} with
5946 @command{tar}, or look.
5949 @item --no-recursion
5950 Prevents @command{tar} from recursively descending directories.
5953 Requires @command{tar} to recursively descend directories.
5954 This is the default.
5957 When you use @samp{--no-recursion}, @GNUTAR{} grabs
5958 directory entries themselves, but does not descend on them
5959 recursively. Many people use @command{find} for locating files they
5960 want to back up, and since @command{tar} @emph{usually} recursively
5961 descends on directories, they have to use the @samp{@w{! -d}} option
5962 to @command{find} @FIXME{needs more explanation or a cite to another
5963 info file}as they usually do not want all the files in a directory.
5964 They then use the @value{op-files-from} option to archive the files
5965 located via @command{find}.
5967 The problem when restoring files archived in this manner is that the
5968 directories themselves are not in the archive; so the
5969 @value{op-same-permissions} option does not affect them---while users
5970 might really like it to. Specifying @value{op-no-recursion} is a way to
5971 tell @command{tar} to grab only the directory entries given to it, adding
5972 no new files on its own.
5974 The @value{op-no-recursion} option also applies when extracting: it
5975 causes @command{tar} to extract only the matched directory entries, not
5976 the files under those directories.
5978 The @value{op-no-recursion} option also affects how exclude patterns
5979 are interpreted (@pxref{controlling pattern-patching with exclude}).
5981 The @option{--no-recursion} and @option{--recursion} options apply to
5982 later options and operands, and can be overridden by later occurrences
5983 of @option{--no-recursion} and @option{--recursion}. For example:
5986 $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
5990 creates an archive with one entry for @file{grape}, and the recursive
5991 contents of @file{grape/concord}, but no entries under @file{grape}
5992 other than @file{grape/concord}.
5995 @section Crossing Filesystem Boundaries
5996 @cindex File system boundaries, not crossing
5999 @command{tar} will normally automatically cross file system boundaries in
6000 order to archive files which are part of a directory tree. You can
6001 change this behavior by running @command{tar} and specifying
6002 @value{op-one-file-system}. This option only affects files that are
6003 archived because they are in a directory that is being archived;
6004 @command{tar} will still archive files explicitly named on the command line
6005 or through @value{op-files-from}, regardless of where they reside.
6008 @item --one-file-system
6010 Prevents @command{tar} from crossing file system boundaries when
6011 archiving. Use in conjunction with any write operation.
6014 The @samp{--one-file-system} option causes @command{tar} to modify its
6015 normal behavior in archiving the contents of directories. If a file in
6016 a directory is not on the same filesystem as the directory itself, then
6017 @command{tar} will not archive that file. If the file is a directory
6018 itself, @command{tar} will not archive anything beneath it; in other words,
6019 @command{tar} will not cross mount points.
6021 It is reported that using this option, the mount point is is archived,
6022 but nothing under it.
6024 This option is useful for making full or incremental archival backups of
6025 a file system. If this option is used in conjunction with
6026 @value{op-verbose}, files that are excluded are mentioned by name on the
6030 * directory:: Changing Directory
6031 * absolute:: Absolute File Names
6035 @subsection Changing the Working Directory
6037 @FIXME{need to read over this node now for continuity; i've switched
6038 things around some.}
6040 @cindex Changing directory mid-stream
6041 @cindex Directory, changing mid-stream
6042 @cindex Working directory, specifying
6045 To change the working directory in the middle of a list of file names,
6046 either on the command line or in a file specified using
6047 @value{op-files-from}, use @value{op-directory}. This will change the
6048 working directory to the directory @var{directory} after that point in
6052 @item --directory=@var{directory}
6053 @itemx -C @var{directory}
6054 Changes the working directory in the middle of a command line.
6060 $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
6064 will place the files @file{grape} and @file{prune} from the current
6065 directory into the archive @file{jams.tar}, followed by the file
6066 @file{cherry} from the directory @file{food}. This option is especially
6067 useful when you have several widely separated files that you want to
6068 store in the same archive.
6070 Note that the file @file{cherry} is recorded in the archive under the
6071 precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
6072 archive will contain three files that all appear to have come from the
6073 same directory; if the archive is extracted with plain @samp{tar
6074 --extract}, all three files will be written in the current directory.
6076 Contrast this with the command,
6079 $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
6083 which records the third file in the archive under the name
6084 @file{red/cherry} so that, if the archive is extracted using
6085 @samp{tar --extract}, the third file will be written in a subdirectory
6086 named @file{orange-colored}.
6088 You can use the @samp{--directory} option to make the archive
6089 independent of the original name of the directory holding the files.
6090 The following command places the files @file{/etc/passwd},
6091 @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
6095 $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
6099 However, the names of the archive members will be exactly what they were
6100 on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
6101 They will not appear to be related by file name to the original
6102 directories where those files were located.
6104 Note that @samp{--directory} options are interpreted consecutively. If
6105 @samp{--directory} specifies a relative file name, it is interpreted
6106 relative to the then current directory, which might not be the same as
6107 the original current working directory of @command{tar}, due to a previous
6108 @samp{--directory} option.
6110 @FIXME{dan: does this mean that you *can* use the short option form, but
6111 you can *not* use the long option form with --files-from? or is this
6114 When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
6115 options in the file list. Unfortunately, you cannot put
6116 @samp{--directory} options in the file list. (This interpretation can
6117 be disabled by using the @value{op-null} option.)
6120 @subsection Absolute File Names
6125 @itemx --absolute-names
6126 Do not strip leading slashes from file names, and permit file names
6127 containing a @file{..} file name component.
6130 By default, @GNUTAR{} drops a leading @samp{/} on
6131 input or output, and complains about file names containing a @file{..}
6132 component. This option turns off this behavior.
6134 When @command{tar} extracts archive members from an archive, it strips any
6135 leading slashes (@samp{/}) from the member name. This causes absolute
6136 member names in the archive to be treated as relative file names. This
6137 allows you to have such members extracted wherever you want, instead of
6138 being restricted to extracting the member in the exact directory named
6139 in the archive. For example, if the archive member has the name
6140 @file{/etc/passwd}, @command{tar} will extract it as if the name were
6141 really @file{etc/passwd}.
6143 File names containing @file{..} can cause problems when extracting, so
6144 @command{tar} normally warns you about such files when creating an
6145 archive, and rejects attempts to extracts such files.
6147 Other @command{tar} programs do not do this. As a result, if you
6148 create an archive whose member names start with a slash, they will be
6149 difficult for other people with a non-@GNUTAR{}
6150 program to use. Therefore, @GNUTAR{} also strips
6151 leading slashes from member names when putting members into the
6152 archive. For example, if you ask @command{tar} to add the file
6153 @file{/bin/ls} to an archive, it will do so, but the member name will
6156 If you use the @value{op-absolute-names} option, @command{tar} will do
6157 none of these transformations.
6159 To archive or extract files relative to the root directory, specify
6160 the @value{op-absolute-names} option.
6162 Normally, @command{tar} acts on files relative to the working
6163 directory---ignoring superior directory names when archiving, and
6164 ignoring leading slashes when extracting.
6166 When you specify @value{op-absolute-names}, @command{tar} stores file names
6167 including all superior directory names, and preserves leading slashes.
6168 If you only invoked @command{tar} from the root directory you would never
6169 need the @value{op-absolute-names} option, but using this option may be
6170 more convenient than switching to root.
6172 @FIXME{Should be an example in the tutorial/wizardry section using this
6173 to transfer files between systems.}
6175 @FIXME{Is write access an issue?}
6178 @item --absolute-names
6179 Preserves full file names (including superior directory names) when
6180 archiving files. Preserves leading slash when extracting files.
6184 @FIXME{this is still horrible; need to talk with dan on monday.}
6186 @command{tar} prints out a message about removing the @samp{/} from
6187 file names. This message appears once per @GNUTAR{}
6188 invocation. It represents something which ought to be told; ignoring
6189 what it means can cause very serious surprises, later.
6191 Some people, nevertheless, do not want to see this message. Wanting to
6192 play really dangerously, one may of course redirect @command{tar} standard
6193 error to the sink. For example, under @command{sh}:
6196 $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
6200 Another solution, both nicer and simpler, would be to change to
6201 the @file{/} directory first, and then avoid absolute notation.
6205 $ @kbd{(cd / && tar -c -f archive.tar home)}
6206 $ @kbd{tar -c -f archive.tar -C / home}
6209 @include getdate.texi
6212 @chapter Controlling the Archive Format
6214 Due to historical reasons, there are several formats of tar archives.
6215 All of them are based on the same principles, but have some subtle
6216 differences that often make them incompatible with each other.
6218 GNU tar is able to create and handle archives in a variety of formats.
6219 The most frequently used formats are (in alphabetical order):
6223 Format used by @GNUTAR{}.
6226 Archive format, compatible with the V7 implementation of tar.
6229 Format used by @GNUTAR{} of versions prior to 1.12.
6232 Archive format defined by POSIX.1-2001 specification.
6235 Format used by J@"org Schilling @command{star} implementation.
6238 @GNUTAR{} is able to create archives in any of these formats,
6239 except @samp{star}. It is able to read archives in any of these
6242 The default format for @GNUTAR{} is defined at compilation
6243 time. You may check it by running @command{tar --help}, and examining
6244 the last lines of its output. Usually, @GNUTAR{} is configured
6245 to create archives in @samp{gnu} format, however, future version will
6246 switch to @samp{posix}.
6249 * Portability:: Making @command{tar} Archives More Portable
6250 * Compression:: Using Less Space through Compression
6251 * Attributes:: Handling File Attributes
6252 * Standard:: The Standard Format
6253 * Extensions:: @acronym{GNU} Extensions to the Archive Format
6254 * cpio:: Comparison of @command{tar} and @command{cpio}
6258 @section Making @command{tar} Archives More Portable
6260 Creating a @command{tar} archive on a particular system that is meant to be
6261 useful later on many other machines and with other versions of @command{tar}
6262 is more challenging than you might think. @command{tar} archive formats
6263 have been evolving since the first versions of Unix. Many such formats
6264 are around, and are not always compatible with each other. This section
6265 discusses a few problems, and gives some advice about making @command{tar}
6266 archives more portable.
6268 One golden rule is simplicity. For example, limit your @command{tar}
6269 archives to contain only regular files and directories, avoiding
6270 other kind of special files. Do not attempt to save sparse files or
6271 contiguous files as such. Let's discuss a few more problems, in turn.
6274 * Portable Names:: Portable Names
6275 * dereference:: Symbolic Links
6276 * old:: Old V7 Archives
6277 * gnu:: GNU and old GNU format archives.
6278 * posix:: @sc{posix} archives
6279 * Checksumming:: Checksumming Problems
6280 * Large or Negative Values:: Large files, negative time stamps, etc.
6283 @node Portable Names
6284 @subsection Portable Names
6286 Use portable file and member names. A name is portable if it contains
6287 only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
6288 @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
6289 contain @samp{/-}. Avoid deep directory nesting. For portability to
6290 old Unix hosts, limit your file name components to 14 characters or
6293 If you intend to have your @command{tar} archives to be read under
6294 MSDOS, you should not rely on case distinction for file names, and you
6295 might use the @acronym{GNU} @command{doschk} program for helping you
6296 further diagnosing illegal MSDOS names, which are even more limited
6300 @subsection Symbolic Links
6301 @cindex File names, using symbolic links
6302 @cindex Symbolic link as file name
6304 Normally, when @command{tar} archives a symbolic link, it writes a
6305 block to the archive naming the target of the link. In that way, the
6306 @command{tar} archive is a faithful record of the filesystem contents.
6307 @value{op-dereference} is used with @value{op-create}, and causes
6308 @command{tar} to archive the files symbolic links point to, instead of
6309 the links themselves. When this option is used, when @command{tar}
6310 encounters a symbolic link, it will archive the linked-to file,
6311 instead of simply recording the presence of a symbolic link.
6313 The name under which the file is stored in the file system is not
6314 recorded in the archive. To record both the symbolic link name and
6315 the file name in the system, archive the file under both names. If
6316 all links were recorded automatically by @command{tar}, an extracted file
6317 might be linked to a file name that no longer exists in the file
6320 If a linked-to file is encountered again by @command{tar} while creating
6321 the same archive, an entire second copy of it will be stored. (This
6322 @emph{might} be considered a bug.)
6324 So, for portable archives, do not archive symbolic links as such,
6325 and use @value{op-dereference}: many systems do not support
6326 symbolic links, and moreover, your distribution might be unusable if
6327 it contains unresolved symbolic links.
6330 @subsection Old V7 Archives
6331 @cindex Format, old style
6332 @cindex Old style format
6333 @cindex Old style archives
6335 Certain old versions of @command{tar} cannot handle additional
6336 information recorded by newer @command{tar} programs. To create an
6337 archive in V7 format (not ANSI), which can be read by these old
6338 versions, specify the @value{op-format-v7} option in
6339 conjunction with the @value{op-create} (@command{tar} also
6340 accepts @samp{--portability} or @samp{op-old-archive} for this
6341 option). When you specify it,
6342 @command{tar} leaves out information about directories, pipes, fifos,
6343 contiguous files, and device files, and specifies file ownership by
6344 group and user IDs instead of group and user names.
6346 When updating an archive, do not use @value{op-format-v7}
6347 unless the archive was created with using this option.
6349 In most cases, a @emph{new} format archive can be read by an @emph{old}
6350 @command{tar} program without serious trouble, so this option should
6351 seldom be needed. On the other hand, most modern @command{tar}s are
6352 able to read old format archives, so it might be safer for you to
6353 always use @value{op-format-v7} for your distributions.
6356 @subsection @acronym{GNU} and old @GNUTAR{} format
6358 @GNUTAR{} was based on an early draft of the
6359 @sc{posix} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
6360 @command{tar}, such as the support for file names longer than 100
6361 characters, use portions of the @command{tar} header record which were
6362 specified in that @sc{posix} draft as unused. Subsequent changes in
6363 @sc{posix} have allocated the same parts of the header record for
6364 other purposes. As a result, @GNUTAR{} format is
6365 incompatible with the current @sc{posix} specification, and with
6366 @command{tar} programs that follow it.
6368 In the majority of cases, @command{tar} will be configured to create
6369 this format by default. This may change in the future, since we plan
6370 to make @samp{posix} format the default.
6372 To force creation a @GNUTAR{} archive, use option
6373 @value{op-format-gnu}.
6375 Some @command{tar} options are currently basing on @GNUTAR{}
6376 format, and can therefore be used only with @samp{gnu}
6377 or @samp{oldgnu} archive formats. The list of such options follows:
6380 @item @value{op-label}, when used with @value{op-create}.
6381 @item @value{op-incremental}
6382 @item @value{op-multi-volume}
6383 @item @value{op-sparse}
6386 These options will be re-implemented for the @samp{posix} archive
6387 format in the future.
6390 @subsection @GNUTAR{} and @sc{posix} @command{tar}
6392 The version @value{VERSION} of @GNUTAR{} is able
6393 to read and create archives conforming to @sc{posix.1-2001} standard.
6395 A @sc{posix} conformant archive will be created if @command{tar}
6396 was given @value{op-format-posix} option, or if it was given
6397 @value{op-format-gnu} option and the environment variable
6398 @env{POSIXLY_CORRECT} is set. The later usage is retained for
6399 compatibility with previous versions of @GNUTAR{}
6402 Notice, that currently @acronym{GNU} extensions are not
6403 allowed with this format. Following is the list of options that
6404 cannot be used with @value{op-format-posix}:
6407 @item @value{op-label}, when used with @value{op-create}.
6408 @item @value{op-incremental}
6409 @item @value{op-multi-volume}
6410 @item @value{op-sparse}
6413 This restriction will disappear in the future versions.
6416 @subsection Checksumming Problems
6418 SunOS and HP-UX @command{tar} fail to accept archives created using
6419 @GNUTAR{} and containing non-ASCII file names, that
6420 is, file names having characters with the eight bit set, because they
6421 use signed checksums, while @GNUTAR{} uses unsigned
6422 checksums while creating archives, as per @sc{posix} standards. On
6423 reading, @GNUTAR{} computes both checksums and
6424 accept any. It is somewhat worrying that a lot of people may go
6425 around doing backup of their files using faulty (or at least
6426 non-standard) software, not learning about it until it's time to
6427 restore their missing files with an incompatible file extractor, or
6430 @GNUTAR{} compute checksums both ways, and accept
6431 any on read, so @acronym{GNU} tar can read Sun tapes even with their
6432 wrong checksums. @GNUTAR{} produces the standard
6433 checksum, however, raising incompatibilities with Sun. That is to
6434 say, @GNUTAR{} has not been modified to
6435 @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
6436 I've been told that more recent Sun @command{tar} now read standard
6437 archives, so maybe Sun did a similar patch, after all?
6439 The story seems to be that when Sun first imported @command{tar}
6440 sources on their system, they recompiled it without realizing that
6441 the checksums were computed differently, because of a change in
6442 the default signing of @code{char}'s in their compiler. So they
6443 started computing checksums wrongly. When they later realized their
6444 mistake, they merely decided to stay compatible with it, and with
6445 themselves afterwards. Presumably, but I do not really know, HP-UX
6446 has chosen that their @command{tar} archives to be compatible with Sun's.
6447 The current standards do not favor Sun @command{tar} format. In any
6448 case, it now falls on the shoulders of SunOS and HP-UX users to get
6449 a @command{tar} able to read the good archives they receive.
6451 @node Large or Negative Values
6452 @subsection Large or Negative Values
6453 @cindex large values
6454 @cindex future time stamps
6455 @cindex negative time stamps
6457 @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
6458 to represent numeric values. User and group IDs and device major and
6459 minor numbers have unsigned 21-bit representations, and file sizes and
6460 times have unsigned 33-bit representations. @GNUTAR{}
6461 generates @sc{posix} representations when possible, but for values
6462 outside the @sc{posix} range it generates two's-complement base-256
6463 strings: uids, gids, and device numbers have signed 57-bit
6464 representations, and file sizes and times have signed 89-bit
6465 representations. These representations are an extension to @sc{posix}
6466 @command{tar} format, so they are not universally portable.
6468 The most common portability problems with out-of-range numeric values
6469 are large files and future or negative time stamps.
6471 Portable archives should avoid members of 8 GB or larger, as @sc{posix}
6472 @command{tar} format cannot represent them.
6474 Portable archives should avoid time stamps from the future. @sc{posix}
6475 @command{tar} format can represent time stamps in the range 1970-01-01
6476 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
6477 hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
6478 and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
6479 portable archives must avoid these time stamps for many years to come.
6481 Portable archives should also avoid time stamps before 1970. These time
6482 stamps are a common @sc{posix} extension but their @code{time_t}
6483 representations are negative. Many traditional @command{tar}
6484 implementations generate a two's complement representation for negative
6485 time stamps that assumes a signed 32-bit @code{time_t}; hence they
6486 generate archives that are not portable to hosts with differing
6487 @code{time_t} representations. @GNUTAR{} recognizes this
6488 situation when it is run on host with a signed 32-bit @code{time_t}, but
6489 it issues a warning, as these time stamps are nonstandard and unportable.
6492 @section Using Less Space through Compression
6495 * gzip:: Creating and Reading Compressed Archives
6496 * sparse:: Archiving Sparse Files
6500 @subsection Creating and Reading Compressed Archives
6501 @cindex Compressed archives
6502 @cindex Storing archives in compressed format
6509 Filter the archive through @command{gzip}.
6512 @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
6513 format parameters must be taken into consideration when modifying an
6514 archive.@FIXME{???} Compressed archives cannot be modified.
6516 You can use @samp{--gzip} and @samp{--gunzip} on physical devices
6517 (tape drives, etc.) and remote files as well as on normal files; data
6518 to or from such devices or remote files is reblocked by another copy
6519 of the @command{tar} program to enforce the specified (or default) record
6520 size. The default compression parameters are used; if you need to
6521 override them, avoid the @value{op-gzip} option and run @command{gzip}
6522 explicitly. (Or set the @env{GZIP} environment variable.)
6524 The @value{op-gzip} option does not work with the @value{op-multi-volume}
6525 option, or with the @value{op-update}, @value{op-append},
6526 @value{op-concatenate}, or @value{op-delete} operations.
6528 It is not exact to say that @GNUTAR{} is to work in concert
6529 with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
6530 possible that @command{tar} and @command{gzip} be done with a single call,
6534 $ @kbd{tar cfz archive.tar.gz subdir}
6538 to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
6542 $ @kbd{tar xfz archive.tar.gz}
6546 to explode and unpack.
6548 The difference is that the whole archive is compressed. With
6549 @command{zip}, archive members are archived individually. @command{tar}'s
6550 method yields better compression. On the other hand, one can view the
6551 contents of a @command{zip} archive without having to decompress it. As
6552 for the @command{tar} and @command{gzip} tandem, you need to decompress the
6553 archive to see its contents. However, this may be done without needing
6554 disk space, by using pipes internally:
6557 $ @kbd{tar tfz archive.tar.gz}
6560 @cindex corrupted archives
6561 About corrupted compressed archives: @command{gzip}'ed files have no
6562 redundancy, for maximum compression. The adaptive nature of the
6563 compression scheme means that the compression tables are implicitly
6564 spread all over the archive. If you lose a few blocks, the dynamic
6565 construction of the compression tables becomes unsynchronized, and there
6566 is little chance that you could recover later in the archive.
6568 There are pending suggestions for having a per-volume or per-file
6569 compression in @GNUTAR{}. This would allow for viewing the
6570 contents without decompression, and for resynchronizing decompression at
6571 every volume or file, in case of corrupted archives. Doing so, we might
6572 lose some compressibility. But this would have make recovering easier.
6573 So, there are pros and cons. We'll see!
6578 Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
6583 Filter the archive through @command{compress}. Otherwise like
6586 @item --use-compress-program=@var{prog}
6587 Filter through @var{prog} (must accept @samp{-d}).
6590 @value{op-compress} stores an archive in compressed format. This
6591 option is useful in saving time over networks and space in pipes, and
6592 when storage space is at a premium. @value{op-compress} causes
6593 @command{tar} to compress when writing the archive, or to uncompress when
6594 reading the archive.
6596 To perform compression and uncompression on the archive, @command{tar}
6597 runs the @command{compress} utility. @command{tar} uses the default
6598 compression parameters; if you need to override them, avoid the
6599 @value{op-compress} option and run the @command{compress} utility
6600 explicitly. It is useful to be able to call the @command{compress}
6601 utility from within @command{tar} because the @command{compress} utility by
6602 itself cannot access remote tape drives.
6604 The @value{op-compress} option will not work in conjunction with the
6605 @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
6606 and @value{op-delete} operations. @xref{Operations}, for
6607 more information on these operations.
6609 If there is no compress utility available, @command{tar} will report an error.
6610 @strong{Please note} that the @command{compress} program may be covered by
6611 a patent, and therefore we recommend you stop using it.
6613 @value{op-bzip2} acts like @value{op-compress}, except that it uses
6614 the @code{bzip2} utility.
6621 When this option is specified, @command{tar} will compress (when
6622 writing an archive), or uncompress (when reading an archive). Used in
6623 conjunction with the @value{op-create}, @value{op-extract},
6624 @value{op-list} and @value{op-compare} operations.
6627 You can have archives be compressed by using the @value{op-gzip} option.
6628 This will arrange for @command{tar} to use the @command{gzip} program to be
6629 used to compress or uncompress the archive wren writing or reading it.
6631 To use the older, obsolete, @command{compress} program, use the
6632 @value{op-compress} option. The @acronym{GNU} Project recommends you not use
6633 @command{compress}, because there is a patent covering the algorithm it
6634 uses. You could be sued for patent infringement merely by running
6637 I have one question, or maybe it's a suggestion if there isn't a way
6638 to do it now. I would like to use @value{op-gzip}, but I'd also like
6639 the output to be fed through a program like @acronym{GNU}
6640 @command{ecc} (actually, right now that's @samp{exactly} what I'd like
6641 to use :-)), basically adding ECC protection on top of compression.
6642 It seems as if this should be quite easy to do, but I can't work out
6643 exactly how to go about it. Of course, I can pipe the standard output
6644 of @command{tar} through @command{ecc}, but then I lose (though I
6645 haven't started using it yet, I confess) the ability to have
6646 @command{tar} use @command{rmt} for it's I/O (I think).
6648 I think the most straightforward thing would be to let me specify a
6649 general set of filters outboard of compression (preferably ordered,
6650 so the order can be automatically reversed on input operations, and
6651 with the options they require specifiable), but beggars shouldn't be
6652 choosers and anything you decide on would be fine with me.
6654 By the way, I like @command{ecc} but if (as the comments say) it can't
6655 deal with loss of block sync, I'm tempted to throw some time at adding
6656 that capability. Supposing I were to actually do such a thing and
6657 get it (apparently) working, do you accept contributed changes to
6658 utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
6660 Isn't that exactly the role of the @value{op-use-compress-prog} option?
6661 I never tried it myself, but I suspect you may want to write a
6662 @var{prog} script or program able to filter stdin to stdout to
6663 way you want. It should recognize the @samp{-d} option, for when
6664 extraction is needed rather than creation.
6666 It has been reported that if one writes compressed data (through the
6667 @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
6668 the DLT compression mode, the data will actually get bigger and one will
6669 end up with less space on the tape.
6672 @subsection Archiving Sparse Files
6673 @cindex Sparse Files
6679 Handle sparse files efficiently.
6682 This option causes all files to be put in the archive to be tested for
6683 sparseness, and handled specially if they are. The @value{op-sparse}
6684 option is useful when many @code{dbm} files, for example, are being
6685 backed up. Using this option dramatically decreases the amount of
6686 space needed to store such a file.
6688 In later versions, this option may be removed, and the testing and
6689 treatment of sparse files may be done automatically with any special
6690 @acronym{GNU} options. For now, it is an option needing to be specified on
6691 the command line with the creation or updating of an archive.
6693 Files in the filesystem occasionally have ``holes.'' A hole in a file
6694 is a section of the file's contents which was never written. The
6695 contents of a hole read as all zeros. On many operating systems,
6696 actual disk storage is not allocated for holes, but they are counted
6697 in the length of the file. If you archive such a file, @command{tar}
6698 could create an archive longer than the original. To have @command{tar}
6699 attempt to recognize the holes in a file, use @value{op-sparse}. When
6700 you use the @value{op-sparse} option, then, for any file using less
6701 disk space than would be expected from its length, @command{tar} searches
6702 the file for consecutive stretches of zeros. It then records in the
6703 archive for the file where the consecutive stretches of zeros are, and
6704 only archives the ``real contents'' of the file. On extraction (using
6705 @value{op-sparse} is not needed on extraction) any such files have
6706 holes created wherever the continuous stretches of zeros were found.
6707 Thus, if you use @value{op-sparse}, @command{tar} archives won't take
6708 more space than the original.
6710 A file is sparse if it contains blocks of zeros whose existence is
6711 recorded, but that have no space allocated on disk. When you specify
6712 the @value{op-sparse} option in conjunction with the @value{op-create}
6713 operation, @command{tar} tests all files for sparseness while archiving.
6714 If @command{tar} finds a file to be sparse, it uses a sparse representation of
6715 the file in the archive. @value{xref-create}, for more information
6716 about creating archives.
6718 @value{op-sparse} is useful when archiving files, such as dbm files,
6719 likely to contain many nulls. This option dramatically
6720 decreases the amount of space needed to store such an archive.
6723 @strong{Please Note:} Always use @value{op-sparse} when performing file
6724 system backups, to avoid archiving the expanded forms of files stored
6725 sparsely in the system.
6727 Even if your system has no sparse files currently, some may be
6728 created in the future. If you use @value{op-sparse} while making file
6729 system backups as a matter of course, you can be assured the archive
6730 will never take more space on the media than the files take on disk
6731 (otherwise, archiving a disk filled with sparse files might take
6732 hundreds of tapes). @FIXME-xref{incremental when node name is set.}
6735 @command{tar} ignores the @value{op-sparse} option when reading an archive.
6740 Files stored sparsely in the file system are represented sparsely in
6741 the archive. Use in conjunction with write operations.
6744 However, users should be well aware that at archive creation time,
6745 @GNUTAR{} still has to read whole disk file to
6746 locate the @dfn{holes}, and so, even if sparse files use little space
6747 on disk and in the archive, they may sometimes require inordinate
6748 amount of time for reading and examining all-zero blocks of a file.
6749 Although it works, it's painfully slow for a large (sparse) file, even
6750 though the resulting tar archive may be small. (One user reports that
6751 dumping a @file{core} file of over 400 megabytes, but with only about
6752 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
6753 ELC, with full CPU utilization.)
6755 This reading is required in all cases and is not related to the fact
6756 the @value{op-sparse} option is used or not, so by merely @emph{not}
6757 using the option, you are not saving time@footnote{Well! We should say
6758 the whole truth, here. When @value{op-sparse} is selected while creating
6759 an archive, the current @command{tar} algorithm requires sparse files to be
6760 read twice, not once. We hope to develop a new archive format for saving
6761 sparse files in which one pass will be sufficient.}.
6763 Programs like @command{dump} do not have to read the entire file; by
6764 examining the file system directly, they can determine in advance
6765 exactly where the holes are and thus avoid reading through them. The
6766 only data it need read are the actual allocated data blocks.
6767 @GNUTAR{} uses a more portable and straightforward
6768 archiving approach, it would be fairly difficult that it does
6769 otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
6773 What I did say is that you cannot tell the difference between a hole and an
6774 equivalent number of nulls without reading raw blocks. @code{st_blocks} at
6775 best tells you how many holes there are; it doesn't tell you @emph{where}.
6776 Just as programs may, conceivably, care what @code{st_blocks} is (care
6777 to name one that does?), they may also care where the holes are (I have
6778 no examples of this one either, but it's equally imaginable).
6780 I conclude from this that good archivers are not portable. One can
6781 arguably conclude that if you want a portable program, you can in good
6782 conscience restore files with as many holes as possible, since you can't
6787 @section Handling File Attributes
6790 When @command{tar} reads files, this causes them to have the access
6791 times updated. To have @command{tar} attempt to set the access times
6792 back to what they were before they were read, use the
6793 @value{op-atime-preserve} option.
6795 Handling of file attributes
6798 @item --atime-preserve
6799 Preserve access times on files that are read.
6800 This doesn't work for files that
6801 you don't own, unless you're root, and it doesn't interact with
6802 incremental dumps nicely (@pxref{Backups}), and it can set access or
6803 modification times incorrectly if other programs access the file while
6804 @command{tar} is running; but it is good enough for some purposes.
6808 Do not extract file modified time.
6810 When this option is used, @command{tar} leaves the modification times
6811 of the files it extracts as the time when the files were extracted,
6812 instead of setting it to the time recorded in the archive.
6814 This option is meaningless with @value{op-list}.
6817 Create extracted files with the same ownership they have in the
6820 This is the default behavior for the superuser,
6821 so this option is meaningful only for non-root users, when @command{tar}
6822 is executed on those systems able to give files away. This is
6823 considered as a security flaw by many people, at least because it
6824 makes quite difficult to correctly account users for the disk space
6825 they occupy. Also, the @code{suid} or @code{sgid} attributes of
6826 files are easily and silently lost when files are given away.
6828 When writing an archive, @command{tar} writes the user id and user name
6829 separately. If it can't find a user name (because the user id is not
6830 in @file{/etc/passwd}), then it does not write one. When restoring,
6831 and doing a @code{chmod} like when you use @value{op-same-permissions},
6832 @FIXME{same-owner?}it tries to look the name (if one was written)
6833 up in @file{/etc/passwd}. If it fails, then it uses the user id
6834 stored in the archive instead.
6836 @item --no-same-owner
6838 Do not attempt to restore ownership when extracting. This is the
6839 default behavior for ordinary users, so this option has an effect
6840 only for the superuser.
6842 @item --numeric-owner
6843 The @value{op-numeric-owner} option allows (ANSI) archives to be written
6844 without user/group name information or such information to be ignored
6845 when extracting. It effectively disables the generation and/or use
6846 of user/group name information. This option forces extraction using
6847 the numeric ids from the archive, ignoring the names.
6849 This is useful in certain circumstances, when restoring a backup from
6850 an emergency floppy with different passwd/group files for example.
6851 It is otherwise impossible to extract files with the right ownerships
6852 if the password file in use during the extraction does not match the
6853 one belonging to the filesystem(s) being extracted. This occurs,
6854 for example, if you are restoring your files after a major crash and
6855 had booted from an emergency floppy with no password file or put your
6856 disk into another machine to do the restore.
6858 The numeric ids are @emph{always} saved into @command{tar} archives.
6859 The identifying names are added at create time when provided by the
6860 system, unless @value{op-old-archive} is used. Numeric ids could be
6861 used when moving archives between a collection of machines using
6862 a centralized management for attribution of numeric ids to users
6863 and groups. This is often made through using the NIS capabilities.
6865 When making a @command{tar} file for distribution to other sites, it
6866 is sometimes cleaner to use a single owner for all files in the
6867 distribution, and nicer to specify the write permission bits of the
6868 files as stored in the archive independently of their actual value on
6869 the file system. The way to prepare a clean distribution is usually
6870 to have some Makefile rule creating a directory, copying all needed
6871 files in that directory, then setting ownership and permissions as
6872 wanted (there are a lot of possible schemes), and only then making a
6873 @command{tar} archive out of this directory, before cleaning
6874 everything out. Of course, we could add a lot of options to
6875 @GNUTAR{} for fine tuning permissions and ownership.
6876 This is not the good way, I think. @GNUTAR{} is
6877 already crowded with options and moreover, the approach just explained
6878 gives you a great deal of control already.
6881 @itemx --same-permissions
6882 @itemx --preserve-permissions
6883 Extract all protection information.
6885 This option causes @command{tar} to set the modes (access permissions) of
6886 extracted files exactly as recorded in the archive. If this option
6887 is not used, the current @code{umask} setting limits the permissions
6890 This option is meaningless with @value{op-list}.
6893 Same as both @value{op-same-permissions} and @value{op-same-order}.
6895 The @value{op-preserve} option has no equivalent short option name.
6896 It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
6898 @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
6903 @section The Standard Format
6906 While an archive may contain many files, the archive itself is a
6907 single ordinary file. Like any other file, an archive file can be
6908 written to a storage device such as a tape or disk, sent through a
6909 pipe or over a network, saved on the active file system, or even
6910 stored in another archive. An archive file is not easy to read or
6911 manipulate without using the @command{tar} utility or Tar mode in
6912 @acronym{GNU} Emacs.
6914 Physically, an archive consists of a series of file entries terminated
6915 by an end-of-archive entry, which consists of 512 zero bytes. A file
6916 entry usually describes one of the files in the archive (an
6917 @dfn{archive member}), and consists of a file header and the contents
6918 of the file. File headers contain file names and statistics, checksum
6919 information which @command{tar} uses to detect file corruption, and
6920 information about file types.
6922 Archives are permitted to have more than one member with the same
6923 member name. One way this situation can occur is if more than one
6924 version of a file has been stored in the archive. For information
6925 about adding new versions of a file to an archive, see @ref{update}.
6926 @FIXME-xref{To learn more about having more than one archive member with the
6927 same name, see -backup node, when it's written.}
6929 In addition to entries describing archive members, an archive may
6930 contain entries which @command{tar} itself uses to store information.
6931 @value{xref-label}, for an example of such an archive entry.
6933 A @command{tar} archive file contains a series of blocks. Each block
6934 contains @code{BLOCKSIZE} bytes. Although this format may be thought
6935 of as being on magnetic tape, other media are often used.
6937 Each file archived is represented by a header block which describes
6938 the file, followed by zero or more blocks which give the contents
6939 of the file. At the end of the archive file there may be a block
6940 filled with binary zeros as an end-of-file marker. A reasonable system
6941 should write a block of zeros at the end, but must not assume that
6942 such a block exists when reading an archive.
6944 The blocks may be @dfn{blocked} for physical I/O operations.
6945 Each record of @var{n} blocks (where @var{n} is set by the
6946 @value{op-blocking-factor} option to @command{tar}) is written with a single
6947 @w{@samp{write ()}} operation. On magnetic tapes, the result of
6948 such a write is a single record. When writing an archive,
6949 the last record of blocks should be written at the full size, with
6950 blocks after the zero block containing all zeros. When reading
6951 an archive, a reasonable system should properly handle an archive
6952 whose last record is shorter than the rest, or which contains garbage
6953 records after a zero block.
6955 The header block is defined in C as follows. In the @GNUTAR{}
6956 distribution, this is part of file @file{src/tar.h}:
6959 @include header.texi
6962 All characters in header blocks are represented by using 8-bit
6963 characters in the local variant of ASCII. Each field within the
6964 structure is contiguous; that is, there is no padding used within
6965 the structure. Each character on the archive medium is stored
6968 Bytes representing the contents of files (after the header block
6969 of each file) are not translated in any way and are not constrained
6970 to represent characters in any character set. The @command{tar} format
6971 does not distinguish text files from binary files, and no translation
6972 of file contents is performed.
6974 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
6975 @code{gname} are null-terminated character strings. All other fields
6976 are zero-filled octal numbers in ASCII. Each numeric field of width
6977 @var{w} contains @var{w} minus 2 digits, a space, and a null, except
6978 @code{size}, and @code{mtime}, which do not contain the trailing null.
6980 The @code{name} field is the file name of the file, with directory names
6981 (if any) preceding the file name, separated by slashes.
6983 @FIXME{how big a name before field overflows?}
6985 The @code{mode} field provides nine bits specifying file permissions
6986 and three bits to specify the Set UID, Set GID, and Save Text
6987 (@dfn{sticky}) modes. Values for these bits are defined above.
6988 When special permissions are required to create a file with a given
6989 mode, and the user restoring files from the archive does not hold such
6990 permissions, the mode bit(s) specifying those special permissions
6991 are ignored. Modes which are not supported by the operating system
6992 restoring files from the archive will be ignored. Unsupported modes
6993 should be faked up when creating or updating an archive; e.g.@: the
6994 group permission could be copied from the @emph{other} permission.
6996 The @code{uid} and @code{gid} fields are the numeric user and group
6997 ID of the file owners, respectively. If the operating system does
6998 not support numeric user or group IDs, these fields should be ignored.
7000 The @code{size} field is the size of the file in bytes; linked files
7001 are archived with this field specified as zero. @FIXME-xref{Modifiers, in
7002 particular the @value{op-incremental} option.}
7004 The @code{mtime} field is the modification time of the file at the time
7005 it was archived. It is the ASCII representation of the octal value of
7006 the last time the file was modified, represented as an integer number of
7007 seconds since January 1, 1970, 00:00 Coordinated Universal Time.
7009 The @code{chksum} field is the ASCII representation of the octal value
7010 of the simple sum of all bytes in the header block. Each 8-bit
7011 byte in the header is added to an unsigned integer, initialized to
7012 zero, the precision of which shall be no less than seventeen bits.
7013 When calculating the checksum, the @code{chksum} field is treated as
7014 if it were all blanks.
7016 The @code{typeflag} field specifies the type of file archived. If a
7017 particular implementation does not recognize or permit the specified
7018 type, the file will be extracted as if it were a regular file. As this
7019 action occurs, @command{tar} issues a warning to the standard error.
7021 The @code{atime} and @code{ctime} fields are used in making incremental
7022 backups; they store, respectively, the particular file's access time
7023 and last inode-change time.
7025 The @code{offset} is used by the @value{op-multi-volume} option, when
7026 making a multi-volume archive. The offset is number of bytes into
7027 the file that we need to restart at to continue the file on the next
7028 tape, i.e., where we store the location that a continued file is
7031 The following fields were added to deal with sparse files. A file
7032 is @dfn{sparse} if it takes in unallocated blocks which end up being
7033 represented as zeros, i.e., no useful data. A test to see if a file
7034 is sparse is to look at the number blocks allocated for it versus the
7035 number of characters in the file; if there are fewer blocks allocated
7036 for the file than would normally be allocated for a file of that
7037 size, then the file is sparse. This is the method @command{tar} uses to
7038 detect a sparse file, and once such a file is detected, it is treated
7039 differently from non-sparse files.
7041 Sparse files are often @code{dbm} files, or other database-type files
7042 which have data at some points and emptiness in the greater part of
7043 the file. Such files can appear to be very large when an @samp{ls
7044 -l} is done on them, when in truth, there may be a very small amount
7045 of important data contained in the file. It is thus undesirable
7046 to have @command{tar} think that it must back up this entire file, as
7047 great quantities of room are wasted on empty blocks, which can lead
7048 to running out of room on a tape far earlier than is necessary.
7049 Thus, sparse files are dealt with so that these empty blocks are
7050 not written to the tape. Instead, what is written to the tape is a
7051 description, of sorts, of the sparse file: where the holes are, how
7052 big the holes are, and how much data is found at the end of the hole.
7053 This way, the file takes up potentially far less room on the tape,
7054 and when the file is extracted later on, it will look exactly the way
7055 it looked beforehand. The following is a description of the fields
7056 used to handle a sparse file:
7058 The @code{sp} is an array of @code{struct sparse}. Each @code{struct
7059 sparse} contains two 12-character strings which represent an offset
7060 into the file and a number of bytes to be written at that offset.
7061 The offset is absolute, and not relative to the offset in preceding
7064 The header can hold four of these @code{struct sparse} at the moment;
7065 if more are needed, they are not stored in the header.
7067 The @code{isextended} flag is set when an @code{extended_header}
7068 is needed to deal with a file. Note that this means that this flag
7069 can only be set when dealing with a sparse file, and it is only set
7070 in the event that the description of the file will not fit in the
7071 allotted room for sparse structures in the header. In other words,
7072 an extended_header is needed.
7074 The @code{extended_header} structure is used for sparse files which
7075 need more sparse structures than can fit in the header. The header can
7076 fit 4 such structures; if more are needed, the flag @code{isextended}
7077 gets set and the next block is an @code{extended_header}.
7079 Each @code{extended_header} structure contains an array of 21
7080 sparse structures, along with a similar @code{isextended} flag
7081 that the header had. There can be an indeterminate number of such
7082 @code{extended_header}s to describe a sparse file.
7086 @item @code{REGTYPE}
7087 @itemx @code{AREGTYPE}
7088 These flags represent a regular file. In order to be compatible
7089 with older versions of @command{tar}, a @code{typeflag} value of
7090 @code{AREGTYPE} should be silently recognized as a regular file.
7091 New archives should be created using @code{REGTYPE}. Also, for
7092 backward compatibility, @command{tar} treats a regular file whose name
7093 ends with a slash as a directory.
7095 @item @code{LNKTYPE}
7096 This flag represents a file linked to another file, of any type,
7097 previously archived. Such files are identified in Unix by each
7098 file having the same device and inode number. The linked-to name is
7099 specified in the @code{linkname} field with a trailing null.
7101 @item @code{SYMTYPE}
7102 This represents a symbolic link to another file. The linked-to name
7103 is specified in the @code{linkname} field with a trailing null.
7105 @item @code{CHRTYPE}
7106 @itemx @code{BLKTYPE}
7107 These represent character special files and block special files
7108 respectively. In this case the @code{devmajor} and @code{devminor}
7109 fields will contain the major and minor device numbers respectively.
7110 Operating systems may map the device specifications to their own
7111 local specification, or may ignore the entry.
7113 @item @code{DIRTYPE}
7114 This flag specifies a directory or sub-directory. The directory
7115 name in the @code{name} field should end with a slash. On systems where
7116 disk allocation is performed on a directory basis, the @code{size} field
7117 will contain the maximum number of bytes (which may be rounded to
7118 the nearest disk block allocation unit) which the directory may
7119 hold. A @code{size} field of zero indicates no such limiting. Systems
7120 which do not support limiting in this manner should ignore the
7123 @item @code{FIFOTYPE}
7124 This specifies a FIFO special file. Note that the archiving of a
7125 FIFO file archives the existence of this file and not its contents.
7127 @item @code{CONTTYPE}
7128 This specifies a contiguous file, which is the same as a normal
7129 file except that, in operating systems which support it, all its
7130 space is allocated contiguously on the disk. Operating systems
7131 which do not allow contiguous allocation should silently treat this
7132 type as a normal file.
7134 @item @code{A} @dots{} @code{Z}
7135 These are reserved for custom implementations. Some of these are
7136 used in the @acronym{GNU} modified format, as described below.
7140 Other values are reserved for specification in future revisions of
7141 the P1003 standard, and should not be used by any @command{tar} program.
7143 The @code{magic} field indicates that this archive was output in
7144 the P1003 archive format. If this field contains @code{TMAGIC},
7145 the @code{uname} and @code{gname} fields will contain the ASCII
7146 representation of the owner and group of the file respectively.
7147 If found, the user and group IDs are used rather than the values in
7148 the @code{uid} and @code{gid} fields.
7150 For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
7151 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
7152 IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
7153 (section E.4.48) for @cite{pax - Portable archive interchange}.
7156 @section @acronym{GNU} Extensions to the Archive Format
7159 The @acronym{GNU} format uses additional file types to describe new types of
7160 files in an archive. These are listed below.
7163 @item GNUTYPE_DUMPDIR
7165 This represents a directory and a list of files created by the
7166 @value{op-incremental} option. The @code{size} field gives the total
7167 size of the associated list of files. Each file name is preceded by
7168 either a @samp{Y} (the file should be in this archive) or an @samp{N}.
7169 (The file is a directory, or is not stored in the archive.) Each file
7170 name is terminated by a null. There is an additional null after the
7173 @item GNUTYPE_MULTIVOL
7175 This represents a file continued from another volume of a multi-volume
7176 archive created with the @value{op-multi-volume} option. The original
7177 type of the file is not given here. The @code{size} field gives the
7178 maximum size of this piece of the file (assuming the volume does
7179 not end before the file is written out). The @code{offset} field
7180 gives the offset from the beginning of the file where this part of
7181 the file begins. Thus @code{size} plus @code{offset} should equal
7182 the original size of the file.
7184 @item GNUTYPE_SPARSE
7186 This flag indicates that we are dealing with a sparse file. Note
7187 that archiving a sparse file requires special operations to find
7188 holes in the file, which mark the positions of these holes, along
7189 with the number of bytes of data to be found after the hole.
7191 @item GNUTYPE_VOLHDR
7193 This file type is used to mark the volume header that was given with
7194 the @value{op-label} option when the archive was created. The @code{name}
7195 field contains the @code{name} given after the @value{op-label} option.
7196 The @code{size} field is zero. Only the first file in each volume
7197 of an archive should have this type.
7201 You may have trouble reading a @acronym{GNU} format archive on a
7202 non-@acronym{GNU} system if the options @value{op-incremental},
7203 @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
7204 used when writing the archive. In general, if @command{tar} does not
7205 use the @acronym{GNU}-added fields of the header, other versions of
7206 @command{tar} should be able to read the archive. Otherwise, the
7207 @command{tar} program will give an error, the most likely one being a
7211 @section Comparison of @command{tar} and @command{cpio}
7214 @FIXME{Reorganize the following material}
7216 The @command{cpio} archive formats, like @command{tar}, do have maximum
7217 pathname lengths. The binary and old ASCII formats have a max path
7218 length of 256, and the new ASCII and CRC ASCII formats have a max
7219 path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
7220 with arbitrary pathname lengths, but other @command{cpio} implementations
7221 may crash unexplainedly trying to read them.
7223 @command{tar} handles symbolic links in the form in which it comes in BSD;
7224 @command{cpio} doesn't handle symbolic links in the form in which it comes
7225 in System V prior to SVR4, and some vendors may have added symlinks
7226 to their system without enhancing @command{cpio} to know about them.
7227 Others may have enhanced it in a way other than the way I did it
7228 at Sun, and which was adopted by AT&T (and which is, I think, also
7229 present in the @command{cpio} that Berkeley picked up from AT&T and put
7230 into a later BSD release---I think I gave them my changes).
7232 (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
7233 can handle @command{tar} format input, and write it on output, and it
7234 probably handles symbolic links. They may not have bothered doing
7235 anything to enhance @command{tar} as a result.)
7237 @command{cpio} handles special files; traditional @command{tar} doesn't.
7239 @command{tar} comes with V7, System III, System V, and BSD source;
7240 @command{cpio} comes only with System III, System V, and later BSD
7241 (4.3-tahoe and later).
7243 @command{tar}'s way of handling multiple hard links to a file can handle
7244 file systems that support 32-bit inumbers (e.g., the BSD file system);
7245 @command{cpio}s way requires you to play some games (in its "binary"
7246 format, i-numbers are only 16 bits, and in its "portable ASCII" format,
7247 they're 18 bits---it would have to play games with the "file system ID"
7248 field of the header to make sure that the file system ID/i-number pairs
7249 of different files were always different), and I don't know which
7250 @command{cpio}s, if any, play those games. Those that don't might get
7251 confused and think two files are the same file when they're not, and
7252 make hard links between them.
7254 @command{tar}s way of handling multiple hard links to a file places only
7255 one copy of the link on the tape, but the name attached to that copy
7256 is the @emph{only} one you can use to retrieve the file; @command{cpio}s
7257 way puts one copy for every link, but you can retrieve it using any
7261 What type of check sum (if any) is used, and how is this calculated.
7264 See the attached manual pages for @command{tar} and @command{cpio} format.
7265 @command{tar} uses a checksum which is the sum of all the bytes in the
7266 @command{tar} header for a file; @command{cpio} uses no checksum.
7269 If anyone knows why @command{cpio} was made when @command{tar} was present
7273 It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
7274 generally-available version of UNIX had @command{tar} at the time. I don't
7275 know whether any version that was generally available @emph{within AT&T}
7276 had @command{tar}, or, if so, whether the people within AT&T who did
7277 @command{cpio} knew about it.
7279 On restore, if there is a corruption on a tape @command{tar} will stop at
7280 that point, while @command{cpio} will skip over it and try to restore the
7283 The main difference is just in the command syntax and header format.
7285 @command{tar} is a little more tape-oriented in that everything is blocked
7286 to start on a record boundary.
7289 Is there any differences between the ability to recover crashed
7290 archives between the two of them. (Is there any chance of recovering
7291 crashed archives at all.)
7294 Theoretically it should be easier under @command{tar} since the blocking
7295 lets you find a header with some variation of @samp{dd skip=@var{nn}}.
7296 However, modern @command{cpio}'s and variations have an option to just
7297 search for the next file header after an error with a reasonable chance
7298 of resyncing. However, lots of tape driver software won't allow you to
7299 continue past a media error which should be the only reason for getting
7300 out of sync unless a file changed sizes while you were writing the
7304 If anyone knows why @command{cpio} was made when @command{tar} was present
7305 at the unix scene, please tell me about this too.
7308 Probably because it is more media efficient (by not blocking everything
7309 and using only the space needed for the headers where @command{tar}
7310 always uses 512 bytes per file header) and it knows how to archive
7313 You might want to look at the freely available alternatives. The
7314 major ones are @command{afio}, @GNUTAR{}, and
7315 @command{pax}, each of which have their own extensions with some
7316 backwards compatibility.
7318 Sparse files were @command{tar}red as sparse files (which you can
7319 easily test, because the resulting archive gets smaller, and
7320 @acronym{GNU} @command{cpio} can no longer read it).
7323 @chapter Tapes and Other Archive Media
7326 A few special cases about tape handling warrant more detailed
7327 description. These special cases are discussed below.
7329 Many complexities surround the use of @command{tar} on tape drives. Since
7330 the creation and manipulation of archives located on magnetic tape was
7331 the original purpose of @command{tar}, it contains many features making
7332 such manipulation easier.
7334 Archives are usually written on dismountable media---tape cartridges,
7335 mag tapes, or floppy disks.
7337 The amount of data a tape or disk holds depends not only on its size,
7338 but also on how it is formatted. A 2400 foot long reel of mag tape
7339 holds 40 megabytes of data when formatted at 1600 bits per inch. The
7340 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
7342 Magnetic media are re-usable---once the archive on a tape is no longer
7343 needed, the archive can be erased and the tape or disk used over.
7344 Media quality does deteriorate with use, however. Most tapes or disks
7345 should be discarded when they begin to produce data errors. EXABYTE
7346 tape cartridges should be discarded when they generate an @dfn{error
7347 count} (number of non-usable bits) of more than 10k.
7349 Magnetic media are written and erased using magnetic fields, and
7350 should be protected from such fields to avoid damage to stored data.
7351 Sticking a floppy disk to a filing cabinet using a magnet is probably
7355 * Device:: Device selection and switching
7356 * Remote Tape Server::
7357 * Common Problems and Solutions::
7358 * Blocking:: Blocking
7359 * Many:: Many archives on one tape
7360 * Using Multiple Tapes:: Using Multiple Tapes
7361 * label:: Including a Label in the Archive
7363 * Write Protection::
7367 @section Device Selection and Switching
7371 @item -f [@var{hostname}:]@var{file}
7372 @itemx --file=[@var{hostname}:]@var{file}
7373 Use archive file or device @var{file} on @var{hostname}.
7376 This option is used to specify the file name of the archive @command{tar}
7379 If the file name is @samp{-}, @command{tar} reads the archive from standard
7380 input (when listing or extracting), or writes it to standard output
7381 (when creating). If the @samp{-} file name is given when updating an
7382 archive, @command{tar} will read the original archive from its standard
7383 input, and will write the entire new archive to its standard output.
7385 If the file name contains a @samp{:}, it is interpreted as
7386 @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
7387 sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
7388 either case, @command{tar} will invoke the command @command{rsh} (or
7389 @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
7390 you give an alternate login name, it will be given to the @command{rsh}.
7391 Naturally, the remote machine must have an executable @file{/etc/rmt}.
7392 This program is free software from the University of California, and a
7393 copy of the source code can be found with the sources for @command{tar};
7394 it's compiled and installed by default.
7396 If this option is not given, but the environment variable @env{TAPE}
7397 is set, its value is used; otherwise, old versions of @command{tar}
7398 used a default archive name (which was picked when @command{tar} was
7399 compiled). The default is normally set up to be the @dfn{first} tape
7400 drive or other transportable I/O medium on the system.
7402 Starting with version 1.11.5, @GNUTAR{} uses
7403 standard input and standard output as the default device, and I will
7404 not try anymore supporting automatic device detection at installation
7405 time. This was failing really in too many cases, it was hopeless.
7406 This is now completely left to the installer to override standard
7407 input and standard output for default device, if this seems
7408 preferable. Further, I think @emph{most} actual usages of
7409 @command{tar} are done with pipes or disks, not really tapes,
7410 cartridges or diskettes.
7412 Some users think that using standard input and output is running
7413 after trouble. This could lead to a nasty surprise on your screen if
7414 you forget to specify an output file name---especially if you are going
7415 through a network or terminal server capable of buffering large amounts
7416 of output. We had so many bug reports in that area of configuring
7417 default tapes automatically, and so many contradicting requests, that
7418 we finally consider the problem to be portably intractable. We could
7419 of course use something like @samp{/dev/tape} as a default, but this
7420 is @emph{also} running after various kind of trouble, going from hung
7421 processes to accidental destruction of real tapes. After having seen
7422 all this mess, using standard input and output as a default really
7423 sounds like the only clean choice left, and a very useful one too.
7425 @GNUTAR{} reads and writes archive in records, I
7426 suspect this is the main reason why block devices are preferred over
7427 character devices. Most probably, block devices are more efficient
7428 too. The installer could also check for @samp{DEFTAPE} in
7429 @file{<sys/mtio.h>}.
7433 Archive file is local even if it contains a colon.
7435 @item --rsh-command=@var{command}
7436 Use remote @var{command} instead of @command{rsh}. This option exists
7437 so that people who use something other than the standard @command{rsh}
7438 (e.g., a Kerberized @command{rsh}) can access a remote device.
7440 When this command is not used, the shell command found when
7441 the @command{tar} program was installed is used instead. This is
7442 the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
7443 @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
7444 The installer may have overridden this by defining the environment
7445 variable @env{RSH} @emph{at installation time}.
7448 Specify drive and density.
7451 @itemx --multi-volume
7452 Create/list/extract multi-volume archive.
7454 This option causes @command{tar} to write a @dfn{multi-volume} archive---one
7455 that may be larger than will fit on the medium used to hold it.
7456 @xref{Multi-Volume Archives}.
7459 @itemx --tape-length=@var{num}
7460 Change tape after writing @var{num} x 1024 bytes.
7462 This option might be useful when your tape drivers do not properly
7463 detect end of physical tapes. By being slightly conservative on the
7464 maximum tape length, you might avoid the problem entirely.
7467 @itemx --info-script=@var{file}
7468 @itemx --new-volume-script=@var{file}
7469 Execute @file{file} at end of each tape. If @file{file} exits with
7470 nonzero status, exit. This implies @value{op-multi-volume}.
7473 @node Remote Tape Server
7474 @section The Remote Tape Server
7476 @cindex remote tape drive
7478 In order to access the tape drive on a remote machine, @command{tar}
7479 uses the remote tape server written at the University of California at
7480 Berkeley. The remote tape server must be installed as @file{/etc/rmt}
7481 on any machine whose tape drive you want to use. @command{tar} calls
7482 @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
7483 machine, optionally using a different login name if one is supplied.
7485 A copy of the source for the remote tape server is provided. It is
7486 Copyright @copyright{} 1983 by the Regents of the University of
7487 California, but can be freely distributed. Instructions for compiling
7488 and installing it are included in the @file{Makefile}.
7490 @cindex absolute file names
7491 Unless you use the @value{op-absolute-names} option, @GNUTAR{}
7492 will not allow you to create an archive that contains
7493 absolute file names (a file name beginning with @samp{/}.) If you try,
7494 @command{tar} will automatically remove the leading @samp{/} from the
7495 file names it stores in the archive. It will also type a warning
7496 message telling you what it is doing.
7498 When reading an archive that was created with a different
7499 @command{tar} program, @GNUTAR{} automatically
7500 extracts entries in the archive which have absolute file names as if
7501 the file names were not absolute. This is an important feature. A
7502 visitor here once gave a @command{tar} tape to an operator to restore;
7503 the operator used Sun @command{tar} instead of @GNUTAR{},
7504 and the result was that it replaced large portions of
7505 our @file{/bin} and friends with versions from the tape; needless to
7506 say, we were unhappy about having to recover the file system from
7509 For example, if the archive contained a file @file{/usr/bin/computoy},
7510 @GNUTAR{} would extract the file to @file{usr/bin/computoy},
7511 relative to the current directory. If you want to extract the files in
7512 an archive to the same absolute names that they had when the archive
7513 was created, you should do a @samp{cd /} before extracting the files
7514 from the archive, or you should either use the @value{op-absolute-names}
7515 option, or use the command @samp{tar -C / @dots{}}.
7517 @cindex Ultrix 3.1 and write failure
7518 Some versions of Unix (Ultrix 3.1 is known to have this problem),
7519 can claim that a short write near the end of a tape succeeded,
7520 when it actually failed. This will result in the -M option not
7521 working correctly. The best workaround at the moment is to use a
7522 significantly larger blocking factor than the default 20.
7524 In order to update an archive, @command{tar} must be able to backspace the
7525 archive in order to reread or rewrite a record that was just read (or
7526 written). This is currently possible only on two kinds of files: normal
7527 disk files (or any other file that can be backspaced with @samp{lseek}),
7528 and industry-standard 9-track magnetic tape (or any other kind of tape
7529 that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
7531 This means that the @value{op-append}, @value{op-update},
7532 @value{op-concatenate}, and @value{op-delete} commands will not work on any
7533 other kind of file. Some media simply cannot be backspaced, which
7534 means these commands and options will never be able to work on them.
7535 These non-backspacing media include pipes and cartridge tape drives.
7537 Some other media can be backspaced, and @command{tar} will work on them
7538 once @command{tar} is modified to do so.
7540 Archives created with the @value{op-multi-volume}, @value{op-label}, and
7541 @value{op-incremental} options may not be readable by other version
7542 of @command{tar}. In particular, restoring a file that was split over
7543 a volume boundary will require some careful work with @command{dd}, if
7544 it can be done at all. Other versions of @command{tar} may also create
7545 an empty file whose name is that of the volume header. Some versions
7546 of @command{tar} may create normal files instead of directories archived
7547 with the @value{op-incremental} option.
7549 @node Common Problems and Solutions
7550 @section Some Common Problems and their Solutions
7557 no such file or directory
7560 errors from @command{tar}:
7561 directory checksum error
7564 errors from media/system:
7575 @dfn{Block} and @dfn{record} terminology is rather confused, and it
7576 is also confusing to the expert reader. On the other hand, readers
7577 who are new to the field have a fresh mind, and they may safely skip
7578 the next two paragraphs, as the remainder of this manual uses those
7579 two terms in a quite consistent way.
7581 John Gilmore, the writer of the public domain @command{tar} from which
7582 @GNUTAR{} was originally derived, wrote (June 1995):
7585 The nomenclature of tape drives comes from IBM, where I believe
7586 they were invented for the IBM 650 or so. On IBM mainframes, what
7587 is recorded on tape are tape blocks. The logical organization of
7588 data is into records. There are various ways of putting records into
7589 blocks, including @code{F} (fixed sized records), @code{V} (variable
7590 sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
7591 to a block), @code{VB} (variable size records, @var{n} to a block),
7592 @code{VSB} (variable spanned blocked: variable sized records that can
7593 occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
7594 parameter specified this to the operating system.
7596 The Unix man page on @command{tar} was totally confused about this.
7597 When I wrote @code{PD TAR}, I used the historically correct terminology
7598 (@command{tar} writes data records, which are grouped into blocks).
7599 It appears that the bogus terminology made it into @sc{posix} (no surprise
7600 here), and now Fran@,{c}ois has migrated that terminology back
7601 into the source code too.
7604 The term @dfn{physical block} means the basic transfer chunk from or
7605 to a device, after which reading or writing may stop without anything
7606 being lost. In this manual, the term @dfn{block} usually refers to
7607 a disk physical block, @emph{assuming} that each disk block is 512
7608 bytes in length. It is true that some disk devices have different
7609 physical blocks, but @command{tar} ignore these differences in its own
7610 format, which is meant to be portable, so a @command{tar} block is always
7611 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
7612 The term @dfn{logical block} often represents the basic chunk of
7613 allocation of many disk blocks as a single entity, which the operating
7614 system treats somewhat atomically; this concept is only barely used
7617 The term @dfn{physical record} is another way to speak of a physical
7618 block, those two terms are somewhat interchangeable. In this manual,
7619 the term @dfn{record} usually refers to a tape physical block,
7620 @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
7621 It is true that archives may be put on disk or used with pipes,
7622 but nevertheless, @command{tar} tries to read and write the archive one
7623 @dfn{record} at a time, whatever the medium in use. One record is made
7624 up of an integral number of blocks, and this operation of putting many
7625 disk blocks into a single tape block is called @dfn{reblocking}, or
7626 more simply, @dfn{blocking}. The term @dfn{logical record} refers to
7627 the logical organization of many characters into something meaningful
7628 to the application. The term @dfn{unit record} describes a small set
7629 of characters which are transmitted whole to or by the application,
7630 and often refers to a line of text. Those two last terms are unrelated
7631 to what we call a @dfn{record} in @GNUTAR{}.
7633 When writing to tapes, @command{tar} writes the contents of the archive
7634 in chunks known as @dfn{records}. To change the default blocking
7635 factor, use the @value{op-blocking-factor} option. Each record will
7636 then be composed of @var{512-size} blocks. (Each @command{tar} block is
7637 512 bytes. @xref{Standard}.) Each file written to the archive uses
7638 at least one full record. As a result, using a larger record size
7639 can result in more wasted space for small files. On the other hand, a
7640 larger record size can often be read and written much more efficiently.
7642 Further complicating the problem is that some tape drives ignore the
7643 blocking entirely. For these, a larger record size can still improve
7644 performance (because the software layers above the tape drive still
7645 honor the blocking), but not as dramatically as on tape drives that
7648 When reading an archive, @command{tar} can usually figure out the
7649 record size on itself. When this is the case, and a non-standard
7650 record size was used when the archive was created, @command{tar} will
7651 print a message about a non-standard blocking factor, and then operate
7652 normally. On some tape devices, however, @command{tar} cannot figure
7653 out the record size itself. On most of those, you can specify a
7654 blocking factor (with @value{op-blocking-factor}) larger than the
7655 actual blocking factor, and then use the @value{op-read-full-records}
7656 option. (If you specify a blocking factor with
7657 @value{op-blocking-factor} and don't use the
7658 @value{op-read-full-records} option, then @command{tar} will not
7659 attempt to figure out the recording size itself.) On some devices,
7660 you must always specify the record size exactly with
7661 @value{op-blocking-factor} when reading, because @command{tar} cannot
7662 figure it out. In any case, use @value{op-list} before doing any
7663 extractions to see whether @command{tar} is reading the archive
7666 @command{tar} blocks are all fixed size (512 bytes), and its scheme for
7667 putting them into records is to put a whole number of them (one or
7668 more) into each record. @command{tar} records are all the same size;
7669 at the end of the file there's a block containing all zeros, which
7670 is how you tell that the remainder of the last record(s) are garbage.
7672 In a standard @command{tar} file (no options), the block size is 512
7673 and the record size is 10240, for a blocking factor of 20. What the
7674 @value{op-blocking-factor} option does is sets the blocking factor,
7675 changing the record size while leaving the block size at 512 bytes.
7676 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
7677 most tape drives these days prefer much bigger records in order to
7678 stream and not waste tape. When writing tapes for myself, some tend
7679 to use a factor of the order of 2048, say, giving a record size of
7680 around one megabyte.
7682 If you use a blocking factor larger than 20, older @command{tar}
7683 programs might not be able to read the archive, so we recommend this
7684 as a limit to use in practice. @GNUTAR{}, however,
7685 will support arbitrarily large record sizes, limited only by the
7686 amount of virtual memory or the physical characteristics of the tape
7690 * Format Variations:: Format Variations
7691 * Blocking Factor:: The Blocking Factor of an Archive
7694 @node Format Variations
7695 @subsection Format Variations
7696 @cindex Format Parameters
7697 @cindex Format Options
7698 @cindex Options, archive format specifying
7699 @cindex Options, format specifying
7702 Format parameters specify how an archive is written on the archive
7703 media. The best choice of format parameters will vary depending on
7704 the type and number of files being archived, and on the media used to
7707 To specify format parameters when accessing or creating an archive,
7708 you can use the options described in the following sections.
7709 If you do not specify any format parameters, @command{tar} uses
7710 default parameters. You cannot modify a compressed archive.
7711 If you create an archive with the @value{op-blocking-factor} option
7712 specified (@value{pxref-blocking-factor}), you must specify that
7713 blocking-factor when operating on the archive. @xref{Formats}, for other
7714 examples of format parameter considerations.
7716 @node Blocking Factor
7717 @subsection The Blocking Factor of an Archive
7718 @cindex Blocking Factor
7720 @cindex Number of blocks per record
7721 @cindex Number of bytes per record
7722 @cindex Bytes per record
7723 @cindex Blocks per record
7726 The data in an archive is grouped into blocks, which are 512 bytes.
7727 Blocks are read and written in whole number multiples called
7728 @dfn{records}. The number of blocks in a record (ie. the size of a
7729 record in units of 512 bytes) is called the @dfn{blocking factor}.
7730 The @value{op-blocking-factor} option specifies the blocking factor of
7731 an archive. The default blocking factor is typically 20 (ie.@:
7732 10240 bytes), but can be specified at installation. To find out
7733 the blocking factor of an existing archive, use @samp{tar --list
7734 --file=@var{archive-name}}. This may not work on some devices.
7736 Records are separated by gaps, which waste space on the archive media.
7737 If you are archiving on magnetic tape, using a larger blocking factor
7738 (and therefore larger records) provides faster throughput and allows you
7739 to fit more data on a tape (because there are fewer gaps). If you are
7740 archiving on cartridge, a very large blocking factor (say 126 or more)
7741 greatly increases performance. A smaller blocking factor, on the other
7742 hand, may be useful when archiving small files, to avoid archiving lots
7743 of nulls as @command{tar} fills out the archive to the end of the record.
7744 In general, the ideal record size depends on the size of the
7745 inter-record gaps on the tape you are using, and the average size of the
7746 files you are archiving. @xref{create}, for information on
7749 @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
7751 Archives with blocking factors larger than 20 cannot be read
7752 by very old versions of @command{tar}, or by some newer versions
7753 of @command{tar} running on old machines with small address spaces.
7754 With @GNUTAR{}, the blocking factor of an archive is limited
7755 only by the maximum record size of the device containing the archive,
7756 or by the amount of available virtual memory.
7758 Also, on some systems, not using adequate blocking factors, as sometimes
7759 imposed by the device drivers, may yield unexpected diagnostics. For
7760 example, this has been reported:
7763 Cannot write to /dev/dlt: Invalid argument
7767 In such cases, it sometimes happen that the @command{tar} bundled by
7768 the system is aware of block size idiosyncrasies, while @GNUTAR{}
7769 requires an explicit specification for the block size,
7770 which it cannot guess. This yields some people to consider
7771 @GNUTAR{} is misbehaving, because by comparison,
7772 @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
7773 for example, might resolve the problem.
7775 If you use a non-default blocking factor when you create an archive, you
7776 must specify the same blocking factor when you modify that archive. Some
7777 archive devices will also require you to specify the blocking factor when
7778 reading that archive, however this is not typically the case. Usually, you
7779 can use @value{op-list} without specifying a blocking factor---@command{tar}
7780 reports a non-default record size and then lists the archive members as
7781 it would normally. To extract files from an archive with a non-standard
7782 blocking factor (particularly if you're not sure what the blocking factor
7783 is), you can usually use the @value{op-read-full-records} option while
7784 specifying a blocking factor larger then the blocking factor of the archive
7785 (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
7786 @xref{list}, for more information on the @value{op-list}
7787 operation. @xref{Reading}, for a more detailed explanation of that option.
7790 @item --blocking-factor=@var{number}
7791 @itemx -b @var{number}
7792 Specifies the blocking factor of an archive. Can be used with any
7793 operation, but is usually not necessary with @value{op-list}.
7799 @item -b @var{blocks}
7800 @itemx --blocking-factor=@var{blocks}
7801 Set record size to @math{@var{blocks} * 512} bytes.
7803 This option is used to specify a @dfn{blocking factor} for the archive.
7804 When reading or writing the archive, @command{tar}, will do reads and writes
7805 of the archive in records of @math{@var{block}*512} bytes. This is true
7806 even when the archive is compressed. Some devices requires that all
7807 write operations be a multiple of a certain size, and so, @command{tar}
7808 pads the archive out to the next record boundary.
7810 The default blocking factor is set when @command{tar} is compiled, and is
7811 typically 20. Blocking factors larger than 20 cannot be read by very
7812 old versions of @command{tar}, or by some newer versions of @command{tar}
7813 running on old machines with small address spaces.
7815 With a magnetic tape, larger records give faster throughput and fit
7816 more data on a tape (because there are fewer inter-record gaps).
7817 If the archive is in a disk file or a pipe, you may want to specify
7818 a smaller blocking factor, since a large one will result in a large
7819 number of null bytes at the end of the archive.
7821 When writing cartridge or other streaming tapes, a much larger
7822 blocking factor (say 126 or more) will greatly increase performance.
7823 However, you must specify the same blocking factor when reading or
7824 updating the archive.
7826 Apparently, Exabyte drives have a physical block size of 8K bytes.
7827 If we choose our blocksize as a multiple of 8k bytes, then the problem
7828 seems to disappear. Id est, we are using block size of 112 right
7829 now, and we haven't had the problem since we switched@dots{}
7831 With @GNUTAR{} the blocking factor is limited only
7832 by the maximum record size of the device containing the archive, or by
7833 the amount of available virtual memory.
7835 However, deblocking or reblocking is virtually avoided in a special
7836 case which often occurs in practice, but which requires all the
7837 following conditions to be simultaneously true:
7840 the archive is subject to a compression option,
7842 the archive is not handled through standard input or output, nor
7843 redirected nor piped,
7845 the archive is directly handled to a local disk, instead of any special
7848 @value{op-blocking-factor} is not explicitly specified on the @command{tar}
7852 If the output goes directly to a local disk, and not through
7853 stdout, then the last write is not extended to a full record size.
7854 Otherwise, reblocking occurs. Here are a few other remarks on this
7860 @command{gzip} will complain about trailing garbage if asked to
7861 uncompress a compressed archive on tape, there is an option to turn
7862 the message off, but it breaks the regularity of simply having to use
7863 @samp{@var{prog} -d} for decompression. It would be nice if gzip was
7864 silently ignoring any number of trailing zeros. I'll ask Jean-loup
7865 Gailly, by sending a copy of this message to him.
7868 @command{compress} does not show this problem, but as Jean-loup pointed
7869 out to Michael, @samp{compress -d} silently adds garbage after
7870 the result of decompression, which tar ignores because it already
7871 recognized its end-of-file indicator. So this bug may be safely
7875 @samp{gzip -d -q} will be silent about the trailing zeros indeed,
7876 but will still return an exit status of 2 which tar reports in turn.
7877 @command{tar} might ignore the exit status returned, but I hate doing
7878 that, as it weakens the protection @command{tar} offers users against
7879 other possible problems at decompression time. If @command{gzip} was
7880 silently skipping trailing zeros @emph{and} also avoiding setting the
7881 exit status in this innocuous case, that would solve this situation.
7884 @command{tar} should become more solid at not stopping to read a pipe at
7885 the first null block encountered. This inelegantly breaks the pipe.
7886 @command{tar} should rather drain the pipe out before exiting itself.
7890 @itemx --ignore-zeros
7891 Ignore blocks of zeros in archive (means EOF).
7893 The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
7894 of zeros in the archive. Normally a block of zeros indicates the
7895 end of the archive, but when reading a damaged archive, or one which
7896 was created by concatenating several archives together, this option
7897 allows @command{tar} to read the entire archive. This option is not on
7898 by default because many versions of @command{tar} write garbage after
7901 Note that this option causes @command{tar} to read to the end of the
7902 archive file, which may sometimes avoid problems when multiple files
7903 are stored on a single physical tape.
7906 @itemx --read-full-records
7907 Reblock as we read (for reading 4.2BSD pipes).
7909 If @value{op-read-full-records} is used, @command{tar} will not panic if an
7910 attempt to read a record from the archive does not return a full record.
7911 Instead, @command{tar} will keep reading until it has obtained a full
7914 This option is turned on by default when @command{tar} is reading
7915 an archive from standard input, or from a remote machine. This is
7916 because on BSD Unix systems, a read of a pipe will return however
7917 much happens to be in the pipe, even if it is less than @command{tar}
7918 requested. If this option was not used, @command{tar} would fail as
7919 soon as it read an incomplete record from the pipe.
7921 This option is also useful with the commands for updating an archive.
7927 @FIXME{Appropriate options should be moved here from elsewhere.}
7929 @cindex blocking factor
7930 @cindex tape blocking
7932 When handling various tapes or cartridges, you have to take care of
7933 selecting a proper blocking, that is, the number of disk blocks you
7934 put together as a single tape block on the tape, without intervening
7935 tape gaps. A @dfn{tape gap} is a small landing area on the tape
7936 with no information on it, used for decelerating the tape to a
7937 full stop, and for later regaining the reading or writing speed.
7938 When the tape driver starts reading a record, the record has to
7939 be read whole without stopping, as a tape gap is needed to stop the
7940 tape motion without loosing information.
7942 @cindex Exabyte blocking
7943 @cindex DAT blocking
7944 Using higher blocking (putting more disk blocks per tape block) will use
7945 the tape more efficiently as there will be less tape gaps. But reading
7946 such tapes may be more difficult for the system, as more memory will be
7947 required to receive at once the whole record. Further, if there is a
7948 reading error on a huge record, this is less likely that the system will
7949 succeed in recovering the information. So, blocking should not be too
7950 low, nor it should be too high. @command{tar} uses by default a blocking of
7951 20 for historical reasons, and it does not really matter when reading or
7952 writing to disk. Current tape technology would easily accommodate higher
7953 blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
7954 We were told that for some DLT drives, the blocking should be a multiple
7955 of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
7956 Other manufacturers may use different recommendations for the same tapes.
7957 This might also depends of the buffering techniques used inside modern
7958 tape controllers. Some imposes a minimum blocking, or a maximum blocking.
7959 Others request blocking to be some exponent of two.
7961 So, there is no fixed rule for blocking. But blocking at read time
7962 should ideally be the same as blocking used at write time. At one place
7963 I know, with a wide variety of equipment, they found it best to use a
7964 blocking of 32 to guarantee that their tapes are fully interchangeable.
7966 I was also told that, for recycled tapes, prior erasure (by the same
7967 drive unit that will be used to create the archives) sometimes lowers
7968 the error rates observed at rewriting time.
7970 I might also use @samp{--number-blocks} instead of
7971 @samp{--block-number}, so @samp{--block} will then expand to
7972 @samp{--blocking-factor} unambiguously.
7975 @section Many Archives on One Tape
7977 @FIXME{Appropriate options should be moved here from elsewhere.}
7979 @findex ntape @r{device}
7980 Most tape devices have two entries in the @file{/dev} directory, or
7981 entries that come in pairs, which differ only in the minor number for
7982 this device. Let's take for example @file{/dev/tape}, which often
7983 points to the only or usual tape device of a given system. There might
7984 be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
7985 name is the @emph{rewinding} version of the device, while the name
7986 having @samp{nr} in it is the @emph{no rewinding} version of the same
7989 A rewinding tape device will bring back the tape to its beginning point
7990 automatically when this device is opened or closed. Since @command{tar}
7991 opens the archive file before using it and closes it afterwards, this
7992 means that a simple:
7995 $ @kbd{tar cf /dev/tape @var{directory}}
7999 will reposition the tape to its beginning both prior and after saving
8000 @var{directory} contents to it, thus erasing prior tape contents and
8001 making it so that any subsequent write operation will destroy what has
8004 @cindex tape positioning
8005 So, a rewinding device is normally meant to hold one and only one file.
8006 If you want to put more than one @command{tar} archive on a given tape, you
8007 will need to avoid using the rewinding version of the tape device. You
8008 will also have to pay special attention to tape positioning. Errors in
8009 positioning may overwrite the valuable data already on your tape. Many
8010 people, burnt by past experiences, will only use rewinding devices and
8011 limit themselves to one file per tape, precisely to avoid the risk of
8012 such errors. Be fully aware that writing at the wrong position on a
8013 tape loses all information past this point and most probably until the
8014 end of the tape, and this destroyed information @emph{cannot} be
8017 To save @var{directory-1} as a first archive at the beginning of a
8018 tape, and leave that tape ready for a second archive, you should use:
8021 $ @kbd{mt -f /dev/nrtape rewind}
8022 $ @kbd{tar cf /dev/nrtape @var{directory-1}}
8026 @dfn{Tape marks} are special magnetic patterns written on the tape
8027 media, which are later recognizable by the reading hardware. These
8028 marks are used after each file, when there are many on a single tape.
8029 An empty file (that is to say, two tape marks in a row) signal the
8030 logical end of the tape, after which no file exist. Usually,
8031 non-rewinding tape device drivers will react to the close request issued
8032 by @command{tar} by first writing two tape marks after your archive, and by
8033 backspacing over one of these. So, if you remove the tape at that time
8034 from the tape drive, it is properly terminated. But if you write
8035 another file at the current position, the second tape mark will be
8036 erased by the new information, leaving only one tape mark between files.
8038 So, you may now save @var{directory-2} as a second archive after the
8039 first on the same tape by issuing the command:
8042 $ @kbd{tar cf /dev/nrtape @var{directory-2}}
8046 and so on for all the archives you want to put on the same tape.
8048 Another usual case is that you do not write all the archives the same
8049 day, and you need to remove and store the tape between two archive
8050 sessions. In general, you must remember how many files are already
8051 saved on your tape. Suppose your tape already has 16 files on it, and
8052 that you are ready to write the 17th. You have to take care of skipping
8053 the first 16 tape marks before saving @var{directory-17}, say, by using
8057 $ @kbd{mt -f /dev/nrtape rewind}
8058 $ @kbd{mt -f /dev/nrtape fsf 16}
8059 $ @kbd{tar cf /dev/nrtape @var{directory-17}}
8062 In all the previous examples, we put aside blocking considerations, but
8063 you should do the proper things for that as well. @xref{Blocking}.
8066 * Tape Positioning:: Tape Positions and Tape Marks
8067 * mt:: The @command{mt} Utility
8070 @node Tape Positioning
8071 @subsection Tape Positions and Tape Marks
8074 Just as archives can store more than one file from the file system,
8075 tapes can store more than one archive file. To keep track of where
8076 archive files (or any other type of file stored on tape) begin and
8077 end, tape archive devices write magnetic @dfn{tape marks} on the
8078 archive media. Tape drives write one tape mark between files,
8079 two at the end of all the file entries.
8081 If you think of data as a series of records "rrrr"'s, and tape marks as
8082 "*"'s, a tape might look like the following:
8085 rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
8088 Tape devices read and write tapes using a read/write @dfn{tape
8089 head}---a physical part of the device which can only access one
8090 point on the tape at a time. When you use @command{tar} to read or
8091 write archive data from a tape device, the device will begin reading
8092 or writing from wherever on the tape the tape head happens to be,
8093 regardless of which archive or what part of the archive the tape
8094 head is on. Before writing an archive, you should make sure that no
8095 data on the tape will be overwritten (unless it is no longer needed).
8096 Before reading an archive, you should make sure the tape head is at
8097 the beginning of the archive you want to read. (The @code{restore}
8098 script will find the archive automatically. @FIXME{There is no such
8099 restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
8100 an explanation of the tape moving utility.
8102 If you want to add new archive file entries to a tape, you should
8103 advance the tape to the end of the existing file entries, backspace
8104 over the last tape mark, and write the new archive file. If you were
8105 to add two archives to the example above, the tape might look like the
8109 rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
8113 @subsection The @command{mt} Utility
8116 @FIXME{Is it true that this only works on non-block devices?
8117 should explain the difference, (fixed or variable).}
8118 @value{xref-blocking-factor}.
8120 You can use the @command{mt} utility to advance or rewind a tape past a
8121 specified number of archive files on the tape. This will allow you
8122 to move to the beginning of an archive before extracting or reading
8123 it, or to the end of all the archives before writing a new one.
8124 @FIXME{Why isn't there an "advance 'til you find two tape marks
8127 The syntax of the @command{mt} command is:
8130 @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
8133 where @var{tapename} is the name of the tape device, @var{number} is
8134 the number of times an operation is performed (with a default of one),
8135 and @var{operation} is one of the following:
8137 @FIXME{is there any use for record operations?}
8142 Writes @var{number} tape marks at the current position on the tape.
8145 Moves tape position forward @var{number} files.
8148 Moves tape position back @var{number} files.
8151 Rewinds the tape. (Ignores @var{number}).
8155 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
8158 Prints status information about the tape unit.
8162 @FIXME{Is there a better way to frob the spacing on the list?}
8164 If you don't specify a @var{tapename}, @command{mt} uses the environment
8165 variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
8168 @command{mt} returns a 0 exit status when the operation(s) were
8169 successful, 1 if the command was unrecognized, and 2 if an operation
8172 @FIXME{New node on how to find an archive?}
8174 If you use @value{op-extract} with the @value{op-label} option specified,
8175 @command{tar} will read an archive label (the tape head has to be positioned
8176 on it) and print an error if the archive label doesn't match the
8177 @var{archive-name} specified. @var{archive-name} can be any regular
8178 expression. If the labels match, @command{tar} extracts the archive.
8180 @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
8181 references}@samp{tar --list --label} will cause @command{tar} to print the
8184 @FIXME{Program to list all the labels on a tape?}
8186 @node Using Multiple Tapes
8187 @section Using Multiple Tapes
8190 Often you might want to write a large archive, one larger than will fit
8191 on the actual tape you are using. In such a case, you can run multiple
8192 @command{tar} commands, but this can be inconvenient, particularly if you
8193 are using options like @value{op-exclude} or dumping entire filesystems.
8194 Therefore, @command{tar} supports multiple tapes automatically.
8196 Use @value{op-multi-volume} on the command line, and then @command{tar} will,
8197 when it reaches the end of the tape, prompt for another tape, and
8198 continue the archive. Each tape will have an independent archive, and
8199 can be read without needing the other. (As an exception to this, the
8200 file that @command{tar} was archiving when it ran out of tape will usually
8201 be split between the two archives; in this case you need to extract from
8202 the first archive, using @value{op-multi-volume}, and then put in the
8203 second tape when prompted, so @command{tar} can restore both halves of the
8206 @GNUTAR{} multi-volume archives do not use a truly
8207 portable format. You need @GNUTAR{} at both end to
8208 process them properly.
8210 When prompting for a new tape, @command{tar} accepts any of the following
8215 Request @command{tar} to explain possible responses
8217 Request @command{tar} to exit immediately.
8218 @item n @var{file name}
8219 Request @command{tar} to write the next volume on the file @var{file name}.
8221 Request @command{tar} to run a subshell.
8223 Request @command{tar} to begin writing the next volume.
8226 (You should only type @samp{y} after you have changed the tape;
8227 otherwise @command{tar} will write over the volume it just finished.)
8229 If you want more elaborate behavior than this, give @command{tar} the
8230 @value{op-info-script} option. The file @var{script-name} is expected
8231 to be a program (or shell script) to be run instead of the normal
8232 prompting procedure. If the program fails, @command{tar} exits;
8233 otherwise, @command{tar} begins writing the next volume. The behavior
8235 @samp{n} response to the normal tape-change prompt is not available
8236 if you use @value{op-info-script}.
8238 The method @command{tar} uses to detect end of tape is not perfect, and
8239 fails on some operating systems or on some devices. You can use the
8240 @value{op-tape-length} option if @command{tar} can't detect the end of the
8241 tape itself. This option selects @value{op-multi-volume} automatically.
8242 The @var{size} argument should then be the usable size of the tape.
8243 But for many devices, and floppy disks in particular, this option is
8244 never required for real, as far as we know.
8246 The volume number used by @command{tar} in its tape-change prompt
8247 can be changed; if you give the @value{op-volno-file} option, then
8248 @var{file-of-number} should be an unexisting file to be created, or else,
8249 a file already containing a decimal number. That number will be used
8250 as the volume number of the first volume written. When @command{tar} is
8251 finished, it will rewrite the file with the now-current volume number.
8252 (This does not change the volume number written on a tape label, as
8253 per @value{ref-label}, it @emph{only} affects the number used in
8256 If you want @command{tar} to cycle through a series of tape drives, then
8257 you can use the @samp{n} response to the tape-change prompt. This is
8258 error prone, however, and doesn't work at all with @value{op-info-script}.
8259 Therefore, if you give @command{tar} multiple @value{op-file} options, then
8260 the specified files will be used, in sequence, as the successive volumes
8261 of the archive. Only when the first one in the sequence needs to be
8262 used again will @command{tar} prompt for a tape change (or run the info
8265 Multi-volume archives
8267 With @value{op-multi-volume}, @command{tar} will not abort when it cannot
8268 read or write any more data. Instead, it will ask you to prepare a new
8269 volume. If the archive is on a magnetic tape, you should change tapes
8270 now; if the archive is on a floppy disk, you should change disks, etc.
8272 Each volume of a multi-volume archive is an independent @command{tar}
8273 archive, complete in itself. For example, you can list or extract any
8274 volume alone; just don't specify @value{op-multi-volume}. However, if one
8275 file in the archive is split across volumes, the only way to extract
8276 it successfully is with a multi-volume extract command @samp{--extract
8277 --multi-volume} (@samp{-xM}) starting on or before the volume where
8280 For example, let's presume someone has two tape drives on a system
8281 named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
8282 to switch to the second drive when it needs to write the
8283 second tape, and then back to the first tape, etc., just do either of:
8286 $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
8287 $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
8291 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
8292 * Tape Files:: Tape Files
8295 @node Multi-Volume Archives
8296 @subsection Archives Longer than One Tape or Disk
8297 @cindex Multi-volume archives
8300 To create an archive that is larger than will fit on a single unit of
8301 the media, use the @value{op-multi-volume} option in conjunction with
8302 the @value{op-create} option (@pxref{create}). A
8303 @dfn{multi-volume} archive can be manipulated like any other archive
8304 (provided the @value{op-multi-volume} option is specified), but is
8305 stored on more than one tape or disk.
8307 When you specify @value{op-multi-volume}, @command{tar} does not report an
8308 error when it comes to the end of an archive volume (when reading), or
8309 the end of the media (when writing). Instead, it prompts you to load
8310 a new storage volume. If the archive is on a magnetic tape, you
8311 should change tapes when you see the prompt; if the archive is on a
8312 floppy disk, you should change disks; etc.
8314 You can read each individual volume of a multi-volume archive as if it
8315 were an archive by itself. For example, to list the contents of one
8316 volume, use @value{op-list}, without @value{op-multi-volume} specified.
8317 To extract an archive member from one volume (assuming it is described
8318 that volume), use @value{op-extract}, again without
8319 @value{op-multi-volume}.
8321 If an archive member is split across volumes (ie. its entry begins on
8322 one volume of the media and ends on another), you need to specify
8323 @value{op-multi-volume} to extract it successfully. In this case, you
8324 should load the volume where the archive member starts, and use
8325 @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
8326 volumes as it needs them. @xref{extracting archives}, for more
8327 information about extracting archives.
8329 @value{op-info-script} is like @value{op-multi-volume}, except that
8330 @command{tar} does not prompt you directly to change media volumes when
8331 a volume is full---instead, @command{tar} runs commands you have stored
8332 in @var{script-name}. For example, this option can be used to eject
8333 cassettes, or to broadcast messages such as @samp{Someone please come
8334 change my tape} when performing unattended backups. When @var{script-name}
8335 is done, @command{tar} will assume that the media has been changed.
8337 Multi-volume archives can be modified like any other archive. To add
8338 files to a multi-volume archive, you need to only mount the last
8339 volume of the archive media (and new volumes, if needed). For all
8340 other operations, you need to use the entire archive.
8342 If a multi-volume archive was labeled using @value{op-label}
8343 (@value{pxref-label}) when it was created, @command{tar} will not
8344 automatically label volumes which are added later. To label subsequent
8345 volumes, specify @value{op-label} again in conjunction with the
8346 @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
8348 @cindex Labeling multi-volume archives
8351 @FIXME{There should be a sample program here, including an exit
8352 before end. Is the exit status even checked in tar? :-(}
8355 @item --multi-volume
8357 Creates a multi-volume archive, when used in conjunction with
8358 @value{op-create}. To perform any other operation on a multi-volume
8359 archive, specify @value{op-multi-volume} in conjunction with that
8362 @item --info-script=@var{program-file}
8363 @itemx -F @var{program-file}
8364 Creates a multi-volume archive via a script. Used in conjunction with
8368 Beware that there is @emph{no} real standard about the proper way, for
8369 a @command{tar} archive, to span volume boundaries. If you have a
8370 multi-volume created by some vendor's @command{tar}, there is almost
8371 no chance you could read all the volumes with @GNUTAR{}.
8372 The converse is also true: you may not expect
8373 multi-volume archives created by @GNUTAR{} to be
8374 fully recovered by vendor's @command{tar}. Since there is little
8375 chance that, in mixed system configurations, some vendor's
8376 @command{tar} will work on another vendor's machine, and there is a
8377 great chance that @GNUTAR{} will work on most of
8378 them, your best bet is to install @GNUTAR{} on all
8379 machines between which you know exchange of files is possible.
8382 @subsection Tape Files
8385 To give the archive a name which will be recorded in it, use the
8386 @value{op-label} option. This will write a special block identifying
8387 @var{volume-label} as the name of the archive to the front of the archive
8388 which will be displayed when the archive is listed with @value{op-list}.
8389 If you are creating a multi-volume archive with
8390 @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
8391 volume label will have
8392 @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
8393 the number of the volume of the archive. (If you use the @value{op-label}
8394 option when reading an archive, it checks to make sure the label on the
8395 tape matches the one you give. @value{xref-label}.
8397 When @command{tar} writes an archive to tape, it creates a single
8398 tape file. If multiple archives are written to the same tape, one
8399 after the other, they each get written as separate tape files. When
8400 extracting, it is necessary to position the tape at the right place
8401 before running @command{tar}. To do this, use the @command{mt} command.
8402 For more information on the @command{mt} command and on the organization
8403 of tapes into a sequence of tape files, see @ref{mt}.
8405 People seem to often do:
8408 @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
8411 or such, for pushing a common date in all volumes or an archive set.
8414 @section Including a Label in the Archive
8415 @cindex Labeling an archive
8416 @cindex Labels on the archive media
8421 @itemx --label=@var{name}
8422 Create archive with volume name @var{name}.
8425 This option causes @command{tar} to write out a @dfn{volume header} at
8426 the beginning of the archive. If @value{op-multi-volume} is used, each
8427 volume of the archive will have a volume header of @samp{@var{name}
8428 Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
8431 @FIXME{Should the arg to --label be a quoted string?? No.}
8433 To avoid problems caused by misplaced paper labels on the archive
8434 media, you can include a @dfn{label} entry---an archive member which
8435 contains the name of the archive---in the archive itself. Use the
8436 @value{op-label} option in conjunction with the @value{op-create} operation
8437 to include a label entry in the archive as it is being created.
8439 If you create an archive using both @value{op-label} and
8440 @value{op-multi-volume}, each volume of the archive will have an
8441 archive label of the form @samp{@var{archive-label} Volume @var{n}},
8442 where @var{n} is 1 for the first volume, 2 for the next, and so on.
8443 @FIXME-xref{Multi-Volume Archives, for information on creating multiple
8446 If you list or extract an archive using @value{op-label}, @command{tar} will
8447 print an error if the archive label doesn't match the @var{archive-label}
8448 specified, and will then not list nor extract the archive. In those cases,
8449 @var{archive-label} argument is interpreted as a globbing-style pattern
8450 which must match the actual magnetic volume label. @xref{exclude}, for
8451 a precise description of how match is attempted@footnote{Previous versions
8452 of @command{tar} used full regular expression matching, or before that, only
8453 exact string matching, instead of wildcard matchers. We decided for the
8454 sake of simplicity to use a uniform matching device through @command{tar}.}.
8455 If the switch @value{op-multi-volume} is being used, the volume label
8456 matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
8457 if the initial match fails, before giving up. Since the volume numbering
8458 is automatically added in labels at creation time, it sounded logical to
8459 equally help the user taking care of it when the archive is being read.
8461 The @value{op-label} was once called @samp{--volume}, but is not available
8462 under that name anymore.
8464 To find out an archive's label entry (or to find out if an archive has
8465 a label at all), use @samp{tar --list --verbose}. @command{tar} will
8466 print the label first, and then print archive member information, as
8467 in the example below:
8470 $ @kbd{tar --verbose --list --file=iamanarchive}
8471 V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
8472 -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
8476 @item --label=@var{archive-label}
8477 @itemx -V @var{archive-label}
8478 Includes an @dfn{archive-label} at the beginning of the archive when
8479 the archive is being created, when used in conjunction with the
8480 @value{op-create} option. Checks to make sure the archive label
8481 matches the one specified (when used in conjunction with the
8482 @value{op-extract} option.
8485 To get a common information on all tapes of a series, use the
8486 @value{op-label} option. For having this information different in each
8487 series created through a single script used on a regular basis, just
8488 manage to get some date string as part of the label. For example:
8491 $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
8492 $ @kbd{tar --create --file=/dev/tape --multi-volume \
8493 --volume="Daily backup for `date +%Y-%m-%d`"}
8496 Also note that each label has its own date and time, which corresponds
8497 to when @GNUTAR{} initially attempted to write it,
8498 often soon after the operator launches @command{tar} or types the
8499 carriage return telling that the next tape is ready. Comparing date
8500 labels does give an idea of tape throughput only if the delays for
8501 rewinding tapes and the operator switching them were negligible, which
8502 is usually not the case.
8504 @FIXME{was --volume}
8507 @section Verifying Data as It is Stored
8508 @cindex Verifying a write operation
8509 @cindex Double-checking a write operation
8514 Attempt to verify the archive after writing.
8517 This option causes @command{tar} to verify the archive after writing it.
8518 Each volume is checked after it is written, and any discrepancies
8519 are recorded on the standard error output.
8521 Verification requires that the archive be on a back-space-able medium.
8522 This means pipes, some cartridge tape drives, and some other devices
8525 You can insure the accuracy of an archive by comparing files in the
8526 system with archive members. @command{tar} can compare an archive to the
8527 file system as the archive is being written, to verify a write
8528 operation, or can compare a previously written archive, to insure that
8531 To check for discrepancies in an archive immediately after it is
8532 written, use the @value{op-verify} option in conjunction with
8533 the @value{op-create} operation. When this option is
8534 specified, @command{tar} checks archive members against their counterparts
8535 in the file system, and reports discrepancies on the standard error.
8537 To verify an archive, you must be able to read it from before the end
8538 of the last written entry. This option is useful for detecting data
8539 errors on some tapes. Archives written to pipes, some cartridge tape
8540 drives, and some other devices cannot be verified.
8542 One can explicitly compare an already made archive with the file system
8543 by using the @value{op-compare} option, instead of using the more automatic
8544 @value{op-verify} option. @value{xref-compare}.
8546 Note that these two options have a slightly different intent. The
8547 @value{op-compare} option how identical are the logical contents of some
8548 archive with what is on your disks, while the @value{op-verify} option is
8549 really for checking if the physical contents agree and if the recording
8550 media itself is of dependable quality. So, for the @value{op-verify}
8551 operation, @command{tar} tries to defeat all in-memory cache pertaining to
8552 the archive, while it lets the speed optimization undisturbed for the
8553 @value{op-compare} option. If you nevertheless use @value{op-compare} for
8554 media verification, you may have to defeat the in-memory cache yourself,
8555 maybe by opening and reclosing the door latch of your recording unit,
8556 forcing some doubt in your operating system about the fact this is really
8557 the same volume as the one just written or read.
8559 The @value{op-verify} option would not be necessary if drivers were indeed
8560 able to detect dependably all write failures. This sometimes require many
8561 magnetic heads, some able to read after the writes occurred. One would
8562 not say that drivers unable to detect all cases are necessarily flawed,
8563 as long as programming is concerned.
8565 The @value{op-verify} option will not work in conjunction with the
8566 @value{op-multi-volume} option or the @value{op-append},
8567 @value{op-update} and @value{op-delete} operations. @xref{Operations},
8568 for more information on these operations.
8570 Also, since @command{tar} normally strips leading @samp{/} from file
8571 names (@pxref{absolute}), a command like @samp{tar --verify -cf
8572 /tmp/foo.tar /etc} will work as desired only if the working directory is
8573 @file{/}, as @command{tar} uses the archive's relative member names
8574 (e.g., @file{etc/motd}) when verifying the archive.
8576 @node Write Protection
8577 @section Write Protection
8579 Almost all tapes and diskettes, and in a few rare cases, even disks can
8580 be @dfn{write protected}, to protect data on them from being changed.
8581 Once an archive is written, you should write protect the media to prevent
8582 the archive from being accidentally overwritten or deleted. (This will
8583 protect the archive from being changed with a tape or floppy drive---it
8584 will not protect it from magnet fields or other physical hazards).
8586 The write protection device itself is usually an integral part of the
8587 physical media, and can be a two position (write enabled/write
8588 disabled) switch, a notch which can be popped out or covered, a ring
8589 which can be removed from the center of a tape reel, or some other
8592 @node Free Software Needs Free Documentation
8593 @appendix Free Software Needs Free Documentation
8594 @include freemanuals.texi
8596 @node Copying This Manual
8597 @appendix Copying This Manual
8600 * GNU Free Documentation License:: License for copying this manual
8615 @c texinfo-column-for-description: 32