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, is 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{Keep Old Files}
266 @set xref-keep-old-files @xref{Keep Old Files}
267 @set pxref-keep-old-files @pxref{Keep Old Files}
269 @set op-keep-newer-files @kbd{--keep-old-files}
270 @set ref-keep-newer-files @ref{Keep Newer Files}
271 @set xref-keep-newer-files @xref{Keep Newer Files}
272 @set pxref-keep-newer-files @pxref{Keep Newer Files}
274 @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
275 @set ref-label @ref{label}
276 @set xref-label @xref{label}
277 @set pxref-label @pxref{label}
279 @set op-list @kbd{--list} (@kbd{-t})
280 @set ref-list @ref{list}
281 @set xref-list @xref{list}
282 @set pxref-list @pxref{list}
284 @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
285 @set ref-listed-incremental @ref{Inc Dumps}
286 @set xref-listed-incremental @xref{Inc Dumps}
287 @set pxref-listed-incremental @pxref{Inc Dumps}
289 @set op-mode @kbd{--mode=@var{permissions}}
290 @set ref-mode @ref{Option Summary}
291 @set xref-mode @xref{Option Summary}
292 @set pxref-mode @pxref{Option Summary}
294 @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
295 @set ref-multi-volume @ref{Multi-Volume Archives}
296 @set xref-multi-volume @xref{Multi-Volume Archives}
297 @set pxref-multi-volume @pxref{Multi-Volume Archives}
299 @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
300 @set ref-newer-mtime @ref{after}
301 @set xref-newer-mtime @xref{after}
302 @set pxref-newer-mtime @pxref{after}
304 @set op-no-recursion @kbd{--no-recursion}
305 @set ref-no-recursion @ref{recurse}
306 @set xref-no-recursion @xref{recurse}
307 @set pxref-no-recursion @pxref{recurse}
309 @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
310 @set ref-no-same-owner @ref{Attributes}
311 @set xref-no-same-owner @xref{Attributes}
312 @set pxref-no-same-owner @pxref{Attributes}
314 @set op-no-same-permissions @kbd{--no-same-permissions}
315 @set ref-no-same-permissions @ref{Attributes}
316 @set xref-no-same-permissions @xref{Attributes}
317 @set pxref-no-same-permissions @pxref{Attributes}
319 @set op-null @kbd{--null}
320 @set ref-null @ref{files}
321 @set xref-null @xref{files}
322 @set pxref-null @pxref{files}
324 @set op-numeric-owner @kbd{--numeric-owner}
325 @set ref-numeric-owner @ref{Attributes}
326 @set xref-numeric-owner @xref{Attributes}
327 @set pxref-numeric-owner @pxref{Attributes}
329 @set op-occurrence @kbd{--occurrence}
330 @set ref-occurrence @ref{--occurrence}
331 @set xref-occurrence @xref{--occurrence}
332 @set pxref-occurrence @pxref{--occurrence}
334 @set op-old-archive @kbd{--old-archive} (@kbd{-o})
335 @set ref-old-archive @ref{old}
336 @set xref-old-archive @xref{old}
337 @set pxref-old-archive @pxref{old}
339 @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
340 @set ref-one-file-system @ref{one}
341 @set xref-one-file-system @xref{one}
342 @set pxref-one-file-system @pxref{one}
344 @set op-overwrite @kbd{--overwrite}
345 @set ref-overwrite @ref{Overwrite Old Files}
346 @set xref-overwrite @xref{Overwrite Old Files}
347 @set pxref-overwrite @pxref{Overwrite Old Files}
349 @set op-owner @kbd{--owner=@var{user}}
350 @set ref-owner @ref{Option Summary}
351 @set xref-owner @xref{Option Summary}
352 @set pxref-owner @pxref{Option Summary}
354 @set op-format @kbd{--format}
355 @set ref-format @ref{format}
356 @set xref-format @xref{format}
357 @set pxref-format @pxref{format}
359 @set op-format-v7 @kbd{--format=v7}
360 @set op-format-gnu @kbd{--format=gnu}
361 @set op-format-oldgnu @kbd{--format=oldgnu}
362 @set op-format-posix @kbd{--format=posix}
363 @set op-format-ustar @kbd{--format=ustar}
365 @set op-posix @kbd{--posix}
366 @set ref-posix @ref{posix}
367 @set xref-posix @xref{posix}
368 @set pxref-posix @pxref{posix}
370 @set op-preserve @kbd{--preserve}
371 @set ref-preserve @ref{Attributes}
372 @set xref-preserve @xref{Attributes}
373 @set pxref-preserve @pxref{Attributes}
375 @set op-record-size @kbd{--record-size=@var{size}}
376 @set ref-record-size @ref{Blocking}
377 @set xref-record-size @xref{Blocking}
378 @set pxref-record-size @pxref{Blocking}
380 @set op-recursive-unlink @kbd{--recursive-unlink}
381 @set ref-recursive-unlink @ref{Writing}
382 @set xref-recursive-unlink @xref{Writing}
383 @set pxref-recursive-unlink @pxref{Writing}
385 @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
386 @set ref-read-full-records @ref{Blocking}
387 @set xref-read-full-records @xref{Blocking}
388 @set pxref-read-full-records @pxref{Blocking}
389 @c FIXME: or should it be Reading, or Blocking Factor
391 @set op-remove-files @kbd{--remove-files}
392 @set ref-remove-files @ref{Writing}
393 @set xref-remove-files @xref{Writing}
394 @set pxref-remove-files @pxref{Writing}
396 @set op-rsh-command @kbd{rsh-command=@var{command}}
398 @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
399 @set ref-same-order @ref{Scarce}
400 @set xref-same-order @xref{Scarce}
401 @set pxref-same-order @pxref{Scarce}
402 @c FIXME: or should it be Reading, or Attributes?
404 @set op-same-owner @kbd{--same-owner}
405 @set ref-same-owner @ref{Attributes}
406 @set xref-same-owner @xref{Attributes}
407 @set pxref-same-owner @pxref{Attributes}
409 @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
410 @set ref-same-permissions @ref{Attributes}
411 @set xref-same-permissions @xref{Attributes}
412 @set pxref-same-permissions @pxref{Attributes}
413 @c FIXME: or should it be Writing?
415 @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
416 @set ref-show-omitted-dirs @ref{verbose}
417 @set xref-show-omitted-dirs @xref{verbose}
418 @set pxref-show-omitted-dirs @pxref{verbose}
420 @set op-sparse @kbd{--sparse} (@kbd{-S})
421 @set ref-sparse @ref{sparse}
422 @set xref-sparse @xref{sparse}
423 @set pxref-sparse @pxref{sparse}
425 @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
426 @set ref-starting-file @ref{Scarce}
427 @set xref-starting-file @xref{Scarce}
428 @set pxref-starting-file @pxref{Scarce}
430 @set op-strip-path @kbd{--strip-path}
431 @set ref-strip-path @ref{--strip-path}
432 @set xref-strip-path @xref{--strip-path}
433 @set pxref-strip-path @pxref{--strip-path}
435 @set op-suffix @kbd{--suffix=@var{suffix}}
436 @set ref-suffix @ref{Backup options}
437 @set xref-suffix @xref{Backup options}
438 @set pxref-suffix @pxref{Backup options}
440 @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
441 @set ref-tape-length @ref{Using Multiple Tapes}
442 @set xref-tape-length @xref{Using Multiple Tapes}
443 @set pxref-tape-length @pxref{Using Multiple Tapes}
445 @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
446 @set ref-to-stdout @ref{Writing}
447 @set xref-to-stdout @xref{Writing}
448 @set pxref-to-stdout @pxref{Writing}
450 @set op-totals @kbd{--totals}
451 @set ref-totals @ref{verbose}
452 @set xref-totals @xref{verbose}
453 @set pxref-totals @pxref{verbose}
455 @set op-touch @kbd{--touch} (@kbd{-m})
456 @set ref-touch @ref{Writing}
457 @set xref-touch @xref{Writing}
458 @set pxref-touch @pxref{Writing}
460 @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
461 @set ref-unlink-first @ref{Writing}
462 @set xref-unlink-first @xref{Writing}
463 @set pxref-unlink-first @pxref{Writing}
465 @set op-update @kbd{--update} (@kbd{-u})
466 @set ref-update @ref{update}
467 @set xref-update @xref{update}
468 @set pxref-update @pxref{update}
470 @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
471 @set ref-use-compress-prog @ref{gzip}
472 @set xref-use-compress-prog @xref{gzip}
473 @set pxref-use-compress-prog @pxref{gzip}
475 @set op-verbose @kbd{--verbose} (@kbd{-v})
476 @set ref-verbose @ref{verbose}
477 @set xref-verbose @xref{verbose}
478 @set pxref-verbose @pxref{verbose}
480 @set op-verify @kbd{--verify} (@kbd{-W})
481 @set ref-verify @ref{verify}
482 @set xref-verify @xref{verify}
483 @set pxref-verify @pxref{verify}
485 @set op-version @kbd{--version}
486 @set ref-version @ref{help}
487 @set xref-version @xref{help}
488 @set pxref-version @pxref{help}
490 @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
491 @set ref-volno-file @ref{Using Multiple Tapes}
492 @set xref-volno-file @xref{Using Multiple Tapes}
493 @set pxref-volno-file @pxref{Using Multiple Tapes}
495 @c Put everything in one index (arbitrarily chosen to be the concept index).
506 This manual is for @acronym{GNU} @command{tar} (version
507 @value{VERSION}, @value{UPDATED}), which creates and extracts files
510 Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
511 2003, 2004 Free Software Foundation, Inc.
514 Permission is granted to copy, distribute and/or modify this document
515 under the terms of the GNU Free Documentation License, Version 1.1 or
516 any later version published by the Free Software Foundation; with the
517 Invariant Sections being "GNU General Public License", with the
518 Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
519 as in (a) below. A copy of the license is included in the section
520 entitled "GNU Free Documentation License".
522 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
523 this GNU Manual. Buying copies from GNU Press supports the FSF in
524 developing GNU and promoting software freedom.''
528 @dircategory Archiving
530 * Tar: (tar). Making tape (or disk) archives.
533 @dircategory Individual utilities
535 * tar: (tar)tar invocation. Invoking @GNUTAR{}.
538 @shorttitlepage @acronym{GNU} @command{tar}
541 @title @acronym{GNU} tar: an archiver tool
542 @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
543 @author Melissa Weisshaus, Jay Fenlason,
544 @author Thomas Bushnell, n/BSG, Amy Gorin
545 @c he said to remove it: Fran@,{c}ois Pinard
546 @c i'm thinking about how the author page *should* look. -mew 2may96
549 @vskip 0pt plus 1filll
555 @top @acronym{GNU} tar: an archiver tool
559 @cindex file archival
560 @cindex archiving files
562 The first part of this master menu lists the major nodes in this Info
563 document. The rest of the menu lists all the lower level nodes.
566 @c The master menu, created with texinfo-master-menu, goes here.
567 @c (However, getdate.texi's menu is interpolated by hand.)
576 * Date input formats::
579 * Free Software Needs Free Documentation::
580 * Copying This Manual::
584 --- The Detailed Node Listing ---
588 * Book Contents:: What this Book Contains
589 * Definitions:: Some Definitions
590 * What tar Does:: What @command{tar} Does
591 * Naming tar Archives:: How @command{tar} Archives are Named
592 * Current status:: Current development status of @GNUTAR{}
593 * Authors:: @GNUTAR{} Authors
594 * Reports:: Reporting bugs or suggestions
596 Tutorial Introduction to @command{tar}
599 * stylistic conventions::
600 * basic tar options:: Basic @command{tar} Operations and Options
601 * frequent operations::
602 * Two Frequent Options::
603 * create:: How to Create Archives
604 * list:: How to List Archives
605 * extract:: How to Extract Members from an Archive
608 Two Frequently Used Options
614 How to Create Archives
616 * prepare for examples::
617 * Creating the archive::
626 How to Extract Members from an Archive
628 * extracting archives::
636 * using tar options::
643 The Three Option Styles
645 * Mnemonic Options:: Mnemonic Option Style
646 * Short Options:: Short Option Style
647 * Old Options:: Old Option Style
648 * Mixing:: Mixing Option Styles
650 All @command{tar} Options
652 * Operation Summary::
654 * Short Option Summary::
666 Advanced @GNUTAR{} Operations
675 How to Add Files to Existing Archives: @code{--append}
677 * appending files:: Appending Files to an Archive
684 Options Used by @code{--create}
686 * Ignore Failed Read::
688 Options Used by @code{--extract}
690 * Reading:: Options to Help Read Archives
691 * Writing:: Changing How @command{tar} Writes Files
692 * Scarce:: Coping with Scarce Resources
694 Options to Help Read Archives
696 * read full records::
699 Changing How @command{tar} Writes Files
701 * Dealing with Old Files::
702 * Overwrite Old Files::
707 * Modification Times::
708 * Setting Access Permissions::
709 * Writing to Standard Output::
712 Coping with Scarce Resources
717 Performing Backups and Restoring Files
719 * Full Dumps:: Using @command{tar} to Perform Full Dumps
720 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
721 * incremental and listed-incremental:: The Incremental Options
722 * Backup Levels:: Levels of Backups
723 * Backup Parameters:: Setting Parameters for Backups and Restoration
724 * Scripted Backups:: Using the Backup Scripts
725 * Scripted Restoration:: Using the Restore Script
727 Setting Parameters for Backups and Restoration
729 * backup-specs example:: An Example Text of @file{Backup-specs}
730 * Script Syntax:: Syntax for @file{Backup-specs}
732 Choosing Files and Names for @command{tar}
734 * file:: Choosing the Archive's Name
735 * Selecting Archive Members::
736 * files:: Reading Names from a File
737 * exclude:: Excluding Some Files
739 * after:: Operating Only on New Files
740 * recurse:: Descending into Directories
741 * one:: Crossing Filesystem Boundaries
743 Reading Names from a File
749 * controlling pattern-patching with exclude::
750 * problems with exclude::
752 Crossing Filesystem Boundaries
754 * directory:: Changing Directory
755 * absolute:: Absolute File Names
759 * General date syntax:: Common rules.
760 * Calendar date items:: 19 Dec 1994.
761 * Time of day items:: 9:20pm.
762 * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
763 * Day of week items:: Monday and others.
764 * Relative items in date strings:: next tuesday, 2 years ago.
765 * Pure numbers in date strings:: 19931219, 1440.
766 * Seconds since the Epoch:: @@1078100502.
767 * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
769 Controlling the Archive Format
771 * Portability:: Making @command{tar} Archives More Portable
772 * Compression:: Using Less Space through Compression
773 * Attributes:: Handling File Attributes
774 * Standard:: The Standard Format
775 * Extensions:: @acronym{GNU} Extensions to the Archive Format
776 * cpio:: Comparison of @command{tar} and @command{cpio}
778 Making @command{tar} Archives More Portable
780 * Portable Names:: Portable Names
781 * dereference:: Symbolic Links
782 * old:: Old V7 Archives
783 * posix:: @sc{posix} archives
784 * Checksumming:: Checksumming Problems
785 * Large or Negative Values:: Large files, negative time stamps, etc.
787 Using Less Space through Compression
789 * gzip:: Creating and Reading Compressed Archives
790 * sparse:: Archiving Sparse Files
792 Tapes and Other Archive Media
794 * Device:: Device selection and switching
795 * Remote Tape Server::
796 * Common Problems and Solutions::
797 * Blocking:: Blocking
798 * Many:: Many archives on one tape
799 * Using Multiple Tapes:: Using Multiple Tapes
800 * label:: Including a Label in the Archive
806 * Format Variations:: Format Variations
807 * Blocking Factor:: The Blocking Factor of an Archive
809 Many Archives on One Tape
811 * Tape Positioning:: Tape Positions and Tape Marks
812 * mt:: The @command{mt} Utility
816 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
817 * Tape Files:: Tape Files
821 * GNU Free Documentation License:: License for copying this manual
827 @chapter Introduction
830 and manipulates @dfn{archives} which are actually collections of
831 many other files; the program provides users with an organized and
832 systematic method for controlling a large amount of data.
833 The name ``tar'' originally came from the phrase ``Tape ARchive'', but
834 archives need not (and these days, typically do not) reside on tapes.
837 * Book Contents:: What this Book Contains
838 * Definitions:: Some Definitions
839 * What tar Does:: What @command{tar} Does
840 * Naming tar Archives:: How @command{tar} Archives are Named
841 * Current status:: Current development status of @GNUTAR{}
842 * Authors:: @GNUTAR{} Authors
843 * Reports:: Reporting bugs or suggestions
847 @section What this Book Contains
849 The first part of this chapter introduces you to various terms that will
850 recur throughout the book. It also tells you who has worked on @GNUTAR{}
851 and its documentation, and where you should send bug reports
854 The second chapter is a tutorial (@pxref{Tutorial}) which provides a
855 gentle introduction for people who are new to using @command{tar}. It is
856 meant to be self contained, not requiring any reading from subsequent
857 chapters to make sense. It moves from topic to topic in a logical,
858 progressive order, building on information already explained.
860 Although the tutorial is paced and structured to allow beginners to
861 learn how to use @command{tar}, it is not intended solely for beginners.
862 The tutorial explains how to use the three most frequently used
863 operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
864 two frequently used options (@samp{file} and @samp{verbose}). The other
865 chapters do not refer to the tutorial frequently; however, if a section
866 discusses something which is a complex variant of a basic concept, there
867 may be a cross reference to that basic concept. (The entire book,
868 including the tutorial, assumes that the reader understands some basic
869 concepts of using a Unix-type operating system; @pxref{Tutorial}.)
871 The third chapter presents the remaining five operations, and
872 information about using @command{tar} options and option syntax.
874 @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
875 than the reality. should think about whether this makes sense to say
876 here, or not.} The other chapters are meant to be used as a
877 reference. Each chapter presents everything that needs to be said
878 about a specific topic.
880 One of the chapters (@pxref{Date input formats}) exists in its
881 entirety in other @acronym{GNU} manuals, and is mostly self-contained.
882 In addition, one section of this manual (@pxref{Standard}) contains a
883 big quote which is taken directly from @command{tar} sources.
885 In general, we give both long and short (abbreviated) option names
886 at least once in each section where the relevant option is covered, so
887 that novice readers will become familiar with both styles. (A few
888 options have no short versions, and the relevant sections will
892 @section Some Definitions
896 The @command{tar} program is used to create and manipulate @command{tar}
897 archives. An @dfn{archive} is a single file which contains the contents
898 of many files, while still identifying the names of the files, their
899 owner(s), and so forth. (In addition, archives record access
900 permissions, user and group, size in bytes, and last modification time.
901 Some archives also record the file names in each archived directory, as
902 well as other file and directory information.) You can use @command{tar}
903 to @dfn{create} a new archive in a specified directory.
906 @cindex archive member
909 The files inside an archive are called @dfn{members}. Within this
910 manual, we use the term @dfn{file} to refer only to files accessible in
911 the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
912 @dfn{member} to refer only to the members of an archive. Similarly, a
913 @dfn{file name} is the name of a file, as it resides in the filesystem,
914 and a @dfn{member name} is the name of an archive member within the
919 The term @dfn{extraction} refers to the process of copying an archive
920 member (or multiple members) into a file in the filesystem. Extracting
921 all the members of an archive is often called @dfn{extracting the
922 archive}. The term @dfn{unpack} can also be used to refer to the
923 extraction of many or all the members of an archive. Extracting an
924 archive does not destroy the archive's structure, just as creating an
925 archive does not destroy the copies of the files that exist outside of
926 the archive. You may also @dfn{list} the members in a given archive
927 (this is often thought of as ``printing'' them to the standard output,
928 or the command line), or @dfn{append} members to a pre-existing archive.
929 All of these operations can be performed using @command{tar}.
932 @section What @command{tar} Does
935 The @command{tar} program provides the ability to create @command{tar}
936 archives, as well as various other kinds of manipulation. For example,
937 you can use @command{tar} on previously created archives to extract files,
938 to store additional files, or to update or list files which were already
941 Initially, @command{tar} archives were used to store files conveniently on
942 magnetic tape. The name @command{tar} comes from this use; it stands for
943 @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
944 direct its output to available devices, files, or other programs (using
945 pipes). @command{tar} may even access remote devices or files (as archives).
947 @FIXME{the following table entries need a bit of work..}
949 You can use @command{tar} archives in many ways. We want to stress a few
950 of them: storage, backup, and transportation.
954 Often, @command{tar} archives are used to store related files for
955 convenient file transfer over a network. For example, the
956 @acronym{GNU} Project distributes its software bundled into
957 @command{tar} archives, so that all the files relating to a particular
958 program (or set of related programs) can be transferred as a single
961 A magnetic tape can store several files in sequence. However, the tape
962 has no names for these files; it only knows their relative position on
963 the tape. One way to store several files on one tape and retain their
964 names is by creating a @command{tar} archive. Even when the basic transfer
965 mechanism can keep track of names, as FTP can, the nuisance of handling
966 multiple files, directories, and multiple links makes @command{tar}
969 Archive files are also used for long-term storage. You can think of
970 this as transportation from the present into the future. (It is a
971 science-fiction idiom that you can move through time as well as in
972 space; the idea here is that @command{tar} can be used to move archives in
973 all dimensions, even time!)
976 Because the archive created by @command{tar} is capable of preserving
977 file information and directory structure, @command{tar} is commonly
978 used for performing full and incremental backups of disks. A backup
979 puts a collection of files (possibly pertaining to many users and
980 projects) together on a disk or a tape. This guards against
981 accidental destruction of the information in those files.
982 @GNUTAR{} has special features that allow it to be
983 used to make incremental and full dumps of all the files in a
987 You can create an archive on one system, transfer it to another system,
988 and extract the contents there. This allows you to transport a group of
989 files from one system to another.
992 @node Naming tar Archives
993 @section How @command{tar} Archives are Named
995 Conventionally, @command{tar} archives are given names ending with
996 @samp{.tar}. This is not necessary for @command{tar} to operate properly,
997 but this manual follows that convention in order to accustom readers to
998 it and to make examples more clear.
1003 Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
1004 archive members as ``files'' or ``entries''. For people familiar with
1005 the operation of @command{tar}, this causes no difficulty. However, in
1006 this manual, we consistently refer to ``archives'' and ``archive
1007 members'' to make learning to use @command{tar} easier for novice users.
1009 @node Current status
1010 @section Current development status of @GNUTAR{}
1012 @GNUTAR{} is currently in the process of active development, whose
1016 @item Improve compatibility between @GNUTAR{} and other @command{tar}
1018 @item Switch to using @acronym{POSIX} archives.
1019 @item Revise sparse file handling and multiple volume processing.
1020 @item Merge with the @acronym{GNU} @code{paxutils} project.
1023 Some of these aims are already attained, while others are still
1024 being worked upon. From the point of view of an end user, the
1025 following issues need special mentioning:
1028 @item Use of short option @option{-o}.
1030 Earlier versions of @GNUTAR{} understood @option{-o} command line
1031 option as a synonym for @option{--old-archive}.
1033 @GNUTAR{} starting from version 1.13.90 understands this option as
1034 a synonym for @option{--no-same-owner}. This is compatible with
1035 UNIX98 @command{tar} implementations.
1037 However, to facilitate transition, @option{-o} option retains its
1038 old semantics when it is used with one of archive-creation commands.
1039 Users are encouraged to use @value{op-format-oldgnu} instead.
1041 It is especially important, since versions of @acronym{GNU} Automake
1042 up to and including 1.8.4 invoke tar with this option to produce
1043 distribution tarballs. @xref{Formats,v7}, for the detailed discussion
1044 of this issue and its implications.
1046 Future versions of @GNUTAR{} will understand @option{-o} only as a
1047 synonym for @option{--no-same-owner}.
1049 @item Use of short option @option{-l}
1051 Earlier versions of @GNUTAR{} understood @option{-l} option as a
1052 synonym for @samp{--one-file-system}. Such usage is deprecated.
1053 For compatibility with other implementations future versions of
1054 @GNUTAR{} will understand this option as a synonym for
1055 @option{--check-links}.
1057 @item Use of options @option{--portability} and @option{--old-archive}
1059 These options are deprecated. Please use @option{--format=v7} instead.
1061 @item Use of option @option{--posix}
1063 This option is deprecated. Please use @option{--format=posix} instead.
1067 @section @GNUTAR{} Authors
1069 @GNUTAR{} was originally written by John Gilmore,
1070 and modified by many people. The @acronym{GNU} enhancements were
1071 written by Jay Fenlason, then Joy Kendall, and the whole package has
1072 been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
1073 Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
1074 numerous and kind users.
1076 We wish to stress that @command{tar} is a collective work, and owes much to
1077 all those people who reported problems, offered solutions and other
1078 insights, or shared their thoughts and suggestions. An impressive, yet
1079 partial list of those contributors can be found in the @file{THANKS}
1080 file from the @GNUTAR{} distribution.
1082 @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
1083 sure i want to spell out the history in this detail, at least not for
1084 the printed book. i'm just not sure it needs to be said this way.
1085 i'll think about it.}
1087 @FIXME{History is more important, and surely more interesting, than
1088 actual names. Quoting names without history would be meaningless. FP}
1090 Jay Fenlason put together a draft of a @GNUTAR{}
1091 manual, borrowing notes from the original man page from John Gilmore.
1092 This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
1093 Gorin worked on a tutorial and manual for @GNUTAR{}.
1094 Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
1095 taking information from all these sources and merging them. Melissa
1096 Weisshaus finally edited and redesigned the book to create version
1097 1.12. @FIXME{update version number as necessary; i'm being
1098 optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
1099 maybe melissa? maybe julie sussman?] needs to properly index the
1102 For version 1.12, Daniel Hagerty contributed a great deal of technical
1103 consulting. In particular, he is the primary author of @ref{Backups}.
1105 In July, 2003 @GNUTAR{} was put on CVS at @url{savannah.gnu.org}, and
1106 an active development and maintenance work has started
1107 again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
1108 Poznyakoff and Jeff Bailey.
1110 Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
1113 @section Reporting bugs or suggestions
1116 @cindex reporting bugs
1117 If you find problems or have suggestions about this program or manual,
1118 please report them to @file{bug-tar@@gnu.org}.
1120 When reporting a bug, please be sure to include as much detail as
1121 possible, in order to reproduce it. @FIXME{Be more specific, I'd
1122 like to make this node as detailed as 'Bug reporting' node in Emacs
1126 @chapter Tutorial Introduction to @command{tar}
1128 This chapter guides you through some basic examples of three @command{tar}
1129 operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
1130 you already know how to use some other version of @command{tar}, then you
1131 may not need to read this chapter. This chapter omits most complicated
1132 details about how @command{tar} works.
1136 * stylistic conventions::
1137 * basic tar options:: Basic @command{tar} Operations and Options
1138 * frequent operations::
1139 * Two Frequent Options::
1140 * create:: How to Create Archives
1141 * list:: How to List Archives
1142 * extract:: How to Extract Members from an Archive
1147 @section Assumptions this Tutorial Makes
1149 This chapter is paced to allow beginners to learn about @command{tar}
1150 slowly. At the same time, we will try to cover all the basic aspects of
1151 these three operations. In order to accomplish both of these tasks, we
1152 have made certain assumptions about your knowledge before reading this
1153 manual, and the hardware you will be using:
1157 Before you start to work through this tutorial, you should understand
1158 what the terms ``archive'' and ``archive member'' mean
1159 (@pxref{Definitions}). In addition, you should understand something
1160 about how Unix-type operating systems work, and you should know how to
1161 use some basic utilities. For example, you should know how to create,
1162 list, copy, rename, edit, and delete files and directories; how to
1163 change between directories; and how to figure out where you are in the
1164 filesystem. You should have some basic understanding of directory
1165 structure and how files are named according to which directory they are
1166 in. You should understand concepts such as standard output and standard
1167 input, what various definitions of the term ``argument'' mean, and the
1168 differences between relative and absolute path names. @FIXME{and what
1172 This manual assumes that you are working from your own home directory
1173 (unless we state otherwise). In this tutorial, you will create a
1174 directory to practice @command{tar} commands in. When we show path names,
1175 we will assume that those paths are relative to your home directory.
1176 For example, my home directory path is @file{/home/fsf/melissa}. All of
1177 my examples are in a subdirectory of the directory named by that path
1178 name; the subdirectory is called @file{practice}.
1181 In general, we show examples of archives which exist on (or can be
1182 written to, or worked with from) a directory on a hard disk. In most
1183 cases, you could write those archives to, or work with them on any other
1184 device, such as a tape drive. However, some of the later examples in
1185 the tutorial and next chapter will not work on tape drives.
1186 Additionally, working with tapes is much more complicated than working
1187 with hard disks. For these reasons, the tutorial does not cover working
1188 with tape drives. @xref{Media}, for complete information on using
1189 @command{tar} archives with tape drives.
1191 @FIXME{this is a cop out. need to add some simple tape drive info.}
1194 @node stylistic conventions
1195 @section Stylistic Conventions
1197 In the examples, @samp{$} represents a typical shell prompt. It
1198 precedes lines you should type; to make this more clear, those lines are
1199 shown in @kbd{this font}, as opposed to lines which represent the
1200 computer's response; those lines are shown in @code{this font}, or
1201 sometimes @samp{like this}.
1203 @c When we have lines which are too long to be
1204 @c displayed in any other way, we will show them like this:
1206 @node basic tar options
1207 @section Basic @command{tar} Operations and Options
1209 @command{tar} can take a wide variety of arguments which specify and define
1210 the actions it will have on the particular set of files or the archive.
1211 The main types of arguments to @command{tar} fall into one of two classes:
1212 operations, and options.
1214 Some arguments fall into a class called @dfn{operations}; exactly one of
1215 these is both allowed and required for any instance of using @command{tar};
1216 you may @emph{not} specify more than one. People sometimes speak of
1217 @dfn{operating modes}. You are in a particular operating mode when you
1218 have specified the operation which specifies it; there are eight
1219 operations in total, and thus there are eight operating modes.
1221 The other arguments fall into the class known as @dfn{options}. You are
1222 not required to specify any options, and you are allowed to specify more
1223 than one at a time (depending on the way you are using @command{tar} at
1224 that time). Some options are used so frequently, and are so useful for
1225 helping you type commands more carefully that they are effectively
1226 ``required''. We will discuss them in this chapter.
1228 You can write most of the @command{tar} operations and options in any
1229 of three forms: long (mnemonic) form, short form, and old style. Some
1230 of the operations and options have no short or ``old'' forms; however,
1231 the operations and options which we will cover in this tutorial have
1232 corresponding abbreviations. @FIXME{make sure this is still the case,
1233 at the end}We will indicate those abbreviations appropriately to get
1234 you used to seeing them. (Note that the ``old style'' option forms
1235 exist in @GNUTAR{} for compatibility with Unix
1236 @command{tar}. We present a full discussion of this way of writing
1237 options and operations appears in @ref{Old Options}, and we discuss
1238 the other two styles of writing options in @ref{Mnemonic Options}, and
1239 @ref{Short Options}.)
1241 In the examples and in the text of this tutorial, we usually use the
1242 long forms of operations and options; but the ``short'' forms produce
1243 the same result and can make typing long @command{tar} commands easier.
1244 For example, instead of typing
1247 @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
1253 @kbd{tar -c -v -f afiles.tar apple angst aspic}
1259 @kbd{tar -cvf afiles.tar apple angst aspic}
1263 For more information on option syntax, see @ref{Advanced tar}. In
1264 discussions in the text, when we name an option by its long form, we
1265 also give the corresponding short option in parentheses.
1267 The term, ``option'', can be confusing at times, since ``operations''
1268 are often lumped in with the actual, @emph{optional} ``options'' in certain
1269 general class statements. For example, we just talked about ``short and
1270 long forms of options and operations''. However, experienced @command{tar}
1271 users often refer to these by shorthand terms such as, ``short and long
1272 options''. This term assumes that the ``operations'' are included, also.
1273 Context will help you determine which definition of ``options'' to use.
1275 Similarly, the term ``command'' can be confusing, as it is often used in
1276 two different ways. People sometimes refer to @command{tar} ``commands''.
1277 A @command{tar} @dfn{command} is the entire command line of user input
1278 which tells @command{tar} what to do --- including the operation, options,
1279 and any arguments (file names, pipes, other commands, etc). However,
1280 you will also sometimes hear the term ``the @command{tar} command''. When
1281 the word ``command'' is used specifically like this, a person is usually
1282 referring to the @command{tar} @emph{operation}, not the whole line.
1283 Again, use context to figure out which of the meanings the speaker
1286 @node frequent operations
1287 @section The Three Most Frequently Used Operations
1289 Here are the three most frequently used operations (both short and long
1290 forms), as well as a brief description of their meanings. The rest of
1291 this chapter will cover how to use these operations in detail. We will
1292 present the rest of the operations in the next chapter.
1297 Create a new @command{tar} archive.
1300 List the contents of an archive.
1303 Extract one or more members from an archive.
1306 @node Two Frequent Options
1307 @section Two Frequently Used Options
1309 To understand how to run @command{tar} in the three operating modes listed
1310 previously, you also need to understand how to use two of the options to
1311 @command{tar}: @samp{--file} (which takes an archive file as an argument)
1312 and @samp{--verbose}. (You are usually not @emph{required} to specify
1313 either of these options when you run @command{tar}, but they can be very
1314 useful in making things more clear and helping you avoid errors.)
1318 * verbose tutorial::
1323 @unnumberedsubsec The @samp{--file} Option
1326 @item --file=@var{archive-name}
1327 @itemx -f @var{archive-name}
1328 Specify the name of an archive file.
1331 You can specify an argument for the @value{op-file} option whenever you
1332 use @command{tar}; this option determines the name of the archive file
1333 that @command{tar} will work on.
1335 If you don't specify this argument, then @command{tar} will use a
1336 default, usually some physical tape drive attached to your machine.
1337 If there is no tape drive attached, or the default is not meaningful,
1338 then @command{tar} will print an error message. The error message might
1339 look roughly like one of the following:
1342 tar: can't open /dev/rmt8 : No such device or address
1343 tar: can't open /dev/rsmt0 : I/O error
1347 To avoid confusion, we recommend that you always specify an archive file
1348 name by using @value{op-file} when writing your @command{tar} commands.
1349 For more information on using the @value{op-file} option, see
1352 @node verbose tutorial
1353 @unnumberedsubsec The @samp{--verbose} Option
1358 Show the files being worked on as @command{tar} is running.
1361 @value{op-verbose} shows details about the results of running
1362 @command{tar}. This can be especially useful when the results might not be
1363 obvious. For example, if you want to see the progress of @command{tar} as
1364 it writes files into the archive, you can use the @samp{--verbose}
1365 option. In the beginning, you may find it useful to use
1366 @samp{--verbose} at all times; when you are more accustomed to
1367 @command{tar}, you will likely want to use it at certain times but not at
1368 others. We will use @samp{--verbose} at times to help make something
1369 clear, and we will give many examples both using and not using
1370 @samp{--verbose} to show the differences.
1372 Sometimes, a single instance of @samp{--verbose} on the command line
1373 will show a full, @samp{ls} style listing of an archive or files,
1374 @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
1375 giving sizes, owners, and similar information. Other times,
1376 @samp{--verbose} will only show files or members that the particular
1377 operation is operating on at the time. In the latter case, you can
1378 use @samp{--verbose} twice in a command to get a listing such as that
1379 in the former case. For example, instead of saying
1382 @kbd{tar -cvf afiles.tar apple angst aspic}
1386 above, you might say
1389 @kbd{tar -cvvf afiles.tar apple angst aspic}
1393 This works equally well using short or long forms of options. Using
1394 long forms, you would simply write out the mnemonic form of the option
1398 $ @kbd{tar --create --verbose --verbose @dots{}}
1402 Note that you must double the hyphens properly each time.
1404 Later in the tutorial, we will give examples using @w{@samp{--verbose
1408 @unnumberedsubsec Getting Help: Using the @code{--help} Option
1413 The @samp{--help} option to @command{tar} prints out a very brief list of
1414 all operations and option available for the current version of
1415 @command{tar} available on your system.
1419 @section How to Create Archives
1422 One of the basic operations of @command{tar} is @value{op-create}, which
1423 you use to create a @command{tar} archive. We will explain
1424 @samp{--create} first because, in order to learn about the other
1425 operations, you will find it useful to have an archive available to
1428 To make this easier, in this section you will first create a directory
1429 containing three files. Then, we will show you how to create an
1430 @emph{archive} (inside the new directory). Both the directory, and
1431 the archive are specifically for you to practice on. The rest of this
1432 chapter and the next chapter will show many examples using this
1433 directory and the files you will create: some of those files may be
1434 other directories and other archives.
1436 The three files you will archive in this example are called
1437 @file{blues}, @file{folk}, and @file{jazz}. The archive is called
1438 @file{collection.tar}.
1440 This section will proceed slowly, detailing how to use @samp{--create}
1441 in @code{verbose} mode, and showing examples using both short and long
1442 forms. In the rest of the tutorial, and in the examples in the next
1443 chapter, we will proceed at a slightly quicker pace. This section
1444 moves more slowly to allow beginning users to understand how
1445 @command{tar} works.
1448 * prepare for examples::
1449 * Creating the archive::
1455 @node prepare for examples
1456 @subsection Preparing a Practice Directory for Examples
1458 To follow along with this and future examples, create a new directory
1459 called @file{practice} containing files called @file{blues}, @file{folk}
1460 and @file{jazz}. The files can contain any information you like:
1461 ideally, they should contain information which relates to their names,
1462 and be of different lengths. Our examples assume that @file{practice}
1463 is a subdirectory of your home directory.
1465 Now @command{cd} to the directory named @file{practice}; @file{practice}
1466 is now your @dfn{working directory}. (@emph{Please note}: Although
1467 the full path name of this directory is
1468 @file{/@var{homedir}/practice}, in our examples we will refer to
1469 this directory as @file{practice}; the @var{homedir} is presumed.
1471 In general, you should check that the files to be archived exist where
1472 you think they do (in the working directory) by running @command{ls}.
1473 Because you just created the directory and the files and have changed to
1474 that directory, you probably don't need to do that this time.
1476 It is very important to make sure there isn't already a file in the
1477 working directory with the archive name you intend to use (in this case,
1478 @samp{collection.tar}), or that you don't care about its contents.
1479 Whenever you use @samp{create}, @command{tar} will erase the current
1480 contents of the file named by @value{op-file} if it exists. @command{tar}
1481 will not tell you if you are about to overwrite an archive unless you
1482 specify an option which does this. @FIXME{xref to the node for
1483 --backup!}To add files to an existing archive, you need to use a
1484 different option, such as @value{op-append}; see @ref{append} for
1485 information on how to do this.
1487 @node Creating the archive
1488 @subsection Creating the Archive
1490 To place the files @file{blues}, @file{folk}, and @file{jazz} into an
1491 archive named @file{collection.tar}, use the following command:
1494 $ @kbd{tar --create --file=collection.tar blues folk jazz}
1497 The order of the arguments is not very important, @emph{when using long
1498 option forms}. You could also say:
1501 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1505 However, you can see that this order is harder to understand; this is
1506 why we will list the arguments in the order that makes the commands
1507 easiest to understand (and we encourage you to do the same when you use
1508 @command{tar}, to avoid errors).
1510 Note that the part of the command which says,
1511 @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
1512 If you substituted any other string of characters for
1513 @kbd{collection.tar}, then that string would become the name of the
1514 archive file you create.
1516 The order of the options becomes more important when you begin to use
1517 short forms. With short forms, if you type commands in the wrong order
1518 (even if you type them correctly in all other ways), you may end up with
1519 results you don't expect. For this reason, it is a good idea to get
1520 into the habit of typing options in the order that makes inherent sense.
1521 @xref{short create}, for more information on this.
1523 In this example, you type the command as shown above: @samp{--create}
1524 is the operation which creates the new archive
1525 (@file{collection.tar}), and @samp{--file} is the option which lets
1526 you give it the name you chose. The files, @file{blues}, @file{folk},
1527 and @file{jazz}, are now members of the archive, @file{collection.tar}
1528 (they are @dfn{file name arguments} to the @samp{--create} operation).
1529 @FIXME{xref here to the discussion of file name args?}Now that they are
1530 in the archive, they are called @emph{archive members}, not files.
1531 (@pxref{Definitions,members}).
1533 When you create an archive, you @emph{must} specify which files you
1534 want placed in the archive. If you do not specify any archive
1535 members, @GNUTAR{} will complain.
1537 If you now list the contents of the working directory (@kbd{ls}), you will
1538 find the archive file listed as well as the files you saw previously:
1541 blues folk jazz collection.tar
1545 Creating the archive @samp{collection.tar} did not destroy the copies of
1546 the files in the directory.
1548 Keep in mind that if you don't indicate an operation, @command{tar} will not
1549 run and will prompt you for one. If you don't name any files, @command{tar}
1550 will complain. You must have write access to the working directory,
1551 or else you will not be able to create an archive in that directory.
1553 @emph{Caution}: Do not attempt to use @value{op-create} to add files to
1554 an existing archive; it will delete the archive and write a new one.
1555 Use @value{op-append} instead. @xref{append}.
1557 @node create verbose
1558 @subsection Running @samp{--create} with @samp{--verbose}
1560 If you include the @value{op-verbose} option on the command line,
1561 @command{tar} will list the files it is acting on as it is working. In
1562 verbose mode, the @code{create} example above would appear as:
1565 $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
1571 This example is just like the example we showed which did not use
1572 @samp{--verbose}, except that @command{tar} generated the remaining lines
1574 (note the different font styles).
1580 In the rest of the examples in this chapter, we will frequently use
1581 @code{verbose} mode so we can show actions or @command{tar} responses that
1582 you would otherwise not see, and which are important for you to
1586 @subsection Short Forms with @samp{create}
1588 As we said before, the @value{op-create} operation is one of the most
1589 basic uses of @command{tar}, and you will use it countless times.
1590 Eventually, you will probably want to use abbreviated (or ``short'')
1591 forms of options. A full discussion of the three different forms that
1592 options can take appears in @ref{Styles}; for now, here is what the
1593 previous example (including the @value{op-verbose} option) looks like
1594 using short option forms:
1597 $ @kbd{tar -cvf collection.tar blues folk jazz}
1604 As you can see, the system responds the same no matter whether you use
1605 long or short option forms.
1607 @FIXME{i don't like how this is worded:} One difference between using
1608 short and long option forms is that, although the exact placement of
1609 arguments following options is no more specific when using short forms,
1610 it is easier to become confused and make a mistake when using short
1611 forms. For example, suppose you attempted the above example in the
1615 $ @kbd{tar -cfv collection.tar blues folk jazz}
1619 In this case, @command{tar} will make an archive file called @file{v},
1620 containing the files @file{blues}, @file{folk}, and @file{jazz}, because
1621 the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
1622 is thus taken to be the chosen archive file name. @command{tar} will try
1623 to add a file called @file{collection.tar} to the @file{v} archive file;
1624 if the file @file{collection.tar} did not already exist, @command{tar} will
1625 report an error indicating that this file does not exist. If the file
1626 @file{collection.tar} does already exist (e.g., from a previous command
1627 you may have run), then @command{tar} will add this file to the archive.
1628 Because the @samp{-v} option did not get registered, @command{tar} will not
1629 run under @samp{verbose} mode, and will not report its progress.
1631 The end result is that you may be quite confused about what happened,
1632 and possibly overwrite a file. To illustrate this further, we will show
1633 you how an example we showed previously would look using short forms.
1638 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1642 is confusing as it is. When shown using short forms, however, it
1643 becomes much more so:
1646 $ @kbd{tar blues -c folk -f collection.tar jazz}
1650 It would be very easy to put the wrong string of characters
1651 immediately following the @samp{-f}, but doing that could sacrifice
1654 For this reason, we recommend that you pay very careful attention to
1655 the order of options and placement of file and archive names,
1656 especially when using short option forms. Not having the option name
1657 written out mnemonically can affect how well you remember which option
1658 does what, and therefore where different names have to be placed.
1659 (Placing options in an unusual order can also cause @command{tar} to
1660 report an error if you have set the shell environment variable
1661 @env{POSIXLY_CORRECT}.)
1664 @subsection Archiving Directories
1666 @cindex Archiving Directories
1667 @cindex Directories, Archiving
1668 You can archive a directory by specifying its directory name as a
1669 file name argument to @command{tar}. The files in the directory will be
1670 archived relative to the working directory, and the directory will be
1671 re-created along with its contents when the archive is extracted.
1673 To archive a directory, first move to its superior directory. If you
1674 have followed the previous instructions in this tutorial, you should
1683 This will put you into the directory which contains @file{practice},
1684 i.e. your home directory. Once in the superior directory, you can
1685 specify the subdirectory, @file{practice}, as a file name argument. To
1686 store @file{practice} in the new archive file @file{music.tar}, type:
1689 $ @kbd{tar --create --verbose --file=music.tar practice}
1693 @command{tar} should output:
1700 practice/collection.tar
1703 Note that the archive thus created is not in the subdirectory
1704 @file{practice}, but rather in the current working directory---the
1705 directory from which @command{tar} was invoked. Before trying to archive a
1706 directory from its superior directory, you should make sure you have
1707 write access to the superior directory itself, not only the directory
1708 you are trying archive with @command{tar}. For example, you will probably
1709 not be able to store your home directory in an archive by invoking
1710 @command{tar} from the root directory; @value{xref-absolute-names}. (Note
1711 also that @file{collection.tar}, the original archive file, has itself
1712 been archived. @command{tar} will accept any file as a file to be
1713 archived, regardless of its content. When @file{music.tar} is
1714 extracted, the archive file @file{collection.tar} will be re-written
1715 into the file system).
1717 If you give @command{tar} a command such as
1720 $ @kbd{tar --create --file=foo.tar .}
1724 @command{tar} will report @samp{tar: ./foo.tar is the archive; not
1725 dumped}. This happens because @command{tar} creates the archive
1726 @file{foo.tar} in the current directory before putting any files into
1727 it. Then, when @command{tar} attempts to add all the files in the
1728 directory @file{.} to the archive, it notices that the file
1729 @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
1730 it. (It makes no sense to put an archive into itself.) @GNUTAR{}
1731 will continue in this case, and create the archive
1732 normally, except for the exclusion of that one file. (@emph{Please
1733 note:} Other versions of @command{tar} are not so clever; they will
1734 enter an infinite loop when this happens, so you should not depend on
1735 this behavior unless you are certain you are running @GNUTAR{}.)
1736 @FIXME{bob doesn't like this sentence, since he does
1737 it all the time, and we've been doing it in the editing passes for
1738 this manual: In general, make sure that the archive is not inside a
1739 directory being dumped.}
1742 @section How to List Archives
1744 Frequently, you will find yourself wanting to determine exactly what a
1745 particular archive contains. You can use the @value{op-list} operation
1746 to get the member names as they currently appear in the archive, as well
1747 as various attributes of the files at the time they were archived. For
1748 example, you can examine the archive @file{collection.tar} that you
1749 created in the last section with the command,
1752 $ @kbd{tar --list --file=collection.tar}
1756 The output of @command{tar} would then be:
1764 @FIXME{we hope this will change. if it doesn't, need to show the
1765 creation of bfiles somewhere above!!! : }
1768 The archive @file{bfiles.tar} would list as follows:
1777 Be sure to use a @value{op-file} option just as with @value{op-create}
1778 to specify the name of the archive.
1780 If you use the @value{op-verbose} option with @samp{--list}, then
1781 @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
1782 showing owner, file size, and so forth.
1784 If you had used @value{op-verbose} mode, the example above would look
1788 $ @kbd{tar --list --verbose --file=collection.tar folk}
1789 -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
1792 @cindex File name arguments, using @code{--list} with
1793 @cindex @code{--list} with file name arguments
1794 You can specify one or more individual member names as arguments when
1795 using @samp{list}. In this case, @command{tar} will only list the
1796 names of members you identify. For example, @w{@kbd{tar --list
1797 --file=afiles.tar apple}} would only print @file{apple}.
1799 @FIXME{we hope the relevant aspects of this will change:}Because
1800 @command{tar} preserves paths, file names must be specified as they appear
1801 in the archive (ie., relative to the directory from which the archive
1802 was created). Therefore, it is essential when specifying member names
1803 to @command{tar} that you give the exact member names. For example,
1804 @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
1805 something like @samp{tar: birds: Not found in archive}, because there is
1806 no member named @file{birds}, only one named @file{./birds}. While the
1807 names @file{birds} and @file{./birds} name the same file, @emph{member}
1808 names are compared using a simplistic name comparison, in which an exact
1809 match is necessary. @xref{absolute}.
1811 However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
1812 with @file{folk}, because @file{folk} is in the archive file
1813 @file{collection.tar}. If you are not sure of the exact file name, try
1814 listing all the files in the archive and searching for the one you
1815 expect to find; remember that if you use @samp{--list} with no file
1816 names as arguments, @command{tar} will print the names of all the members
1817 stored in the specified archive.
1824 @unnumberedsubsec Listing the Contents of a Stored Directory
1826 To get information about the contents of an archived directory,
1827 use the directory name as a file name argument in conjunction with
1828 @value{op-list}. To find out file attributes, include the
1829 @value{op-verbose} option.
1831 For example, to find out about files in the directory @file{practice}, in
1832 the archive file @file{music.tar}, type:
1835 $ @kbd{tar --list --verbose --file=music.tar practice}
1838 @command{tar} responds:
1841 drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
1842 -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
1843 -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
1844 -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
1845 -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
1848 When you use a directory name as a file name argument, @command{tar} acts on
1849 all the files (including sub-directories) in that directory.
1852 @section How to Extract Members from an Archive
1855 @cindex Retrieving files from an archive
1856 @cindex Resurrecting files from an archive
1858 Creating an archive is only half the job---there is no point in storing
1859 files in an archive if you can't retrieve them. The act of retrieving
1860 members from an archive so they can be used and manipulated as
1861 unarchived files again is called @dfn{extraction}. To extract files
1862 from an archive, use the @value{op-extract} operation. As with
1863 @value{op-create}, specify the name of the archive with @value{op-file}.
1864 Extracting an archive does not modify the archive in any way; you can
1865 extract it multiple times if you want or need to.
1867 Using @samp{--extract}, you can extract an entire archive, or specific
1868 files. The files can be directories containing other files, or not. As
1869 with @value{op-create} and @value{op-list}, you may use the short or the
1870 long form of the operation without affecting the performance.
1873 * extracting archives::
1874 * extracting files::
1876 * extracting untrusted archives::
1877 * failing commands::
1880 @node extracting archives
1881 @subsection Extracting an Entire Archive
1883 To extract an entire archive, specify the archive file name only, with
1884 no individual file names as arguments. For example,
1887 $ @kbd{tar -xvf collection.tar}
1894 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
1895 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
1896 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
1899 @node extracting files
1900 @subsection Extracting Specific Files
1902 To extract specific archive members, give their exact member names as
1903 arguments, as printed by @value{op-list}. If you had mistakenly deleted
1904 one of the files you had placed in the archive @file{collection.tar}
1905 earlier (say, @file{blues}), you can extract it from the archive without
1906 changing the archive's structure. It will be identical to the original
1907 file @file{blues} that you deleted. @FIXME{At the time of this
1908 writing, atime and ctime are not restored. Since this is a tutorial
1909 for a beginnig user, it should hardly be mentioned here. Maybe in
1910 a footnote? --gray}.
1912 First, make sure you are in the @file{practice} directory, and list the
1913 files in the directory. Now, delete the file, @samp{blues}, and list
1914 the files in the directory again.
1916 You can now extract the member @file{blues} from the archive file
1917 @file{collection.tar} like this:
1920 $ @kbd{tar --extract --file=collection.tar blues}
1924 If you list the files in the directory again, you will see that the file
1925 @file{blues} has been restored, with its original permissions, creation
1926 times, and owner.@FIXME{This is only accidentally true, but not in
1927 general. In most cases, one has to be root for restoring the owner, and
1928 use a special option for restoring permissions. Here, it just happens
1929 that the restoring user is also the owner of the archived members, and
1930 that the current @code{umask} is compatible with original permissions.}
1931 (These parameters will be identical to those which
1932 the file had when you originally placed it in the archive; any changes
1933 you may have made before deleting the file from the file system,
1934 however, will @emph{not} have been made to the archive member.) The
1935 archive file, @samp{collection.tar}, is the same as it was before you
1936 extracted @samp{blues}. You can confirm this by running @command{tar} with
1939 @FIXME{we hope this will change:}Remember that as with other operations,
1940 specifying the exact member name is important. @w{@kbd{tar --extract
1941 --file=bfiles.tar birds}} will fail, because there is no member named
1942 @file{birds}. To extract the member named @file{./birds}, you must
1943 specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
1944 exact member names of the members of an archive, use @value{op-list}
1947 You can extract a file to standard output by combining the above options
1948 with the @value{op-to-stdout} option (@pxref{Writing to Standard
1951 If you give the @value{op-verbose} option, then @value{op-extract} will
1952 print the names of the archive members as it extracts them.
1955 @subsection Extracting Files that are Directories
1957 Extracting directories which are members of an archive is similar to
1958 extracting other files. The main difference to be aware of is that if
1959 the extracted directory has the same name as any directory already in
1960 the working directory, then files in the extracted directory will be
1961 placed into the directory of the same name. Likewise, if there are
1962 files in the pre-existing directory with the same names as the members
1963 which you extract, the files from the extracted archive will replace
1964 the files already in the working directory (and possible
1965 subdirectories). This will happen regardless of whether or not the
1966 files in the working directory were more recent than those extracted
1967 (there exist, however, special options that alter this behavior
1970 However, if a file was stored with a directory name as part of its file
1971 name, and that directory does not exist under the working directory when
1972 the file is extracted, @command{tar} will create the directory.
1974 We can demonstrate how to use @samp{--extract} to extract a directory
1975 file with an example. Change to the @file{practice} directory if you
1976 weren't there, and remove the files @file{folk} and @file{jazz}. Then,
1977 go back to the parent directory and extract the archive
1978 @file{music.tar}. You may either extract the entire archive, or you may
1979 extract only the files you just deleted. To extract the entire archive,
1980 don't give any file names as arguments after the archive name
1981 @file{music.tar}. To extract only the files you deleted, use the
1985 $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
1991 If you were to specify two @value{op-verbose} options, @command{tar}
1992 would have displayed more detail about the extracted files, as shown
1993 in the example below:
1996 $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
1997 -rw-rw-rw- me user 28 1996-10-18 16:31 practice/jazz
1998 -rw-rw-rw- me user 20 1996-09-23 16:44 practice/folk
2002 Because you created the directory with @file{practice} as part of the
2003 file names of each of the files by archiving the @file{practice}
2004 directory as @file{practice}, you must give @file{practice} as part
2005 of the file names when you extract those files from the archive.
2007 @FIXME{IMPORTANT! show the final structure, here. figure out what it
2010 @node extracting untrusted archives
2011 @subsection Extracting Archives from Untrusted Sources
2013 Extracting files from archives can overwrite files that already exist.
2014 If you receive an archive from an untrusted source, you should make a
2015 new directory and extract into that directory, so that you don't have
2016 to worry about the extraction overwriting one of your existing files.
2017 For example, if @file{untrusted.tar} came from somewhere else on the
2018 Internet, and you don't necessarily trust its contents, you can
2019 extract it as follows:
2022 $ @kbd{mkdir newdir}
2024 $ @kbd{tar -xvf ../untrusted.tar}
2027 It is also a good practice to examine contents of the archive
2028 before extracting it, using @option{op-list} option, possibly combined
2029 with @option{op-verbose}.
2031 @node failing commands
2032 @subsection Commands That Will Fail
2034 Here are some sample commands you might try which will not work, and why
2037 If you try to use this command,
2040 $ @kbd{tar -xvf music.tar folk jazz}
2044 you will get the following response:
2047 tar: folk: Not found in archive
2048 tar: jazz: Not found in archive
2053 This is because these files were not originally @emph{in} the parent
2054 directory @file{..}, where the archive is located; they were in the
2055 @file{practice} directory, and their file names reflect this:
2058 $ @kbd{tar -tvf music.tar}
2064 @FIXME{make sure the above works when going through the examples in
2068 Likewise, if you try to use this command,
2071 $ @kbd{tar -tvf music.tar folk jazz}
2075 you would get a similar response. Members with those names are not in the
2076 archive. You must use the correct member names in order to extract the
2077 files from the archive.
2079 If you have forgotten the correct names of the files in the archive,
2080 use @w{@kbd{tar --list --verbose}} to list them correctly.
2082 @FIXME{more examples, here? hag thinks it's a good idea.}
2085 @section Going Further Ahead in this Manual
2087 @FIXME{need to write up a node here about the things that are going to
2088 be in the rest of the manual.}
2090 @node tar invocation
2091 @chapter Invoking @GNUTAR{}
2094 This chapter is about how one invokes the @GNUTAR{}
2095 command, from the command synopsis (@pxref{Synopsis}). There are
2096 numerous options, and many styles for writing them. One mandatory
2097 option specifies the operation @command{tar} should perform
2098 (@pxref{Operation Summary}), other options are meant to detail how
2099 this operation should be performed (@pxref{Option Summary}).
2100 Non-option arguments are not always interpreted the same way,
2101 depending on what the operation is.
2103 You will find in this chapter everything about option styles and rules for
2104 writing them (@pxref{Styles}). On the other hand, operations and options
2105 are fully described elsewhere, in other chapters. Here, you will find
2106 only synthetic descriptions for operations and options, together with
2107 pointers to other parts of the @command{tar} manual.
2109 Some options are so special they are fully described right in this
2110 chapter. They have the effect of inhibiting the normal operation of
2111 @command{tar} or else, they globally alter the amount of feedback the user
2112 receives about what is going on. These are the @value{op-help} and
2113 @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
2114 and @value{op-interactive} options (@pxref{interactive}).
2118 * using tar options::
2127 @section General Synopsis of @command{tar}
2129 The @GNUTAR{} program is invoked as either one of:
2132 @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
2133 @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
2136 The second form is for when old options are being used.
2138 You can use @command{tar} to store files in an archive, to extract them from
2139 an archive, and to do other types of archive manipulation. The primary
2140 argument to @command{tar}, which is called the @dfn{operation}, specifies
2141 which action to take. The other arguments to @command{tar} are either
2142 @dfn{options}, which change the way @command{tar} performs an operation,
2143 or file names or archive members, which specify the files or members
2144 @command{tar} is to act on.
2146 You can actually type in arguments in any order, even if in this manual
2147 the options always precede the other arguments, to make examples easier
2148 to understand. Further, the option stating the main operation mode
2149 (the @command{tar} main command) is usually given first.
2151 Each @var{name} in the synopsis above is interpreted as an archive member
2152 name when the main command is one of @value{op-compare}, @value{op-delete},
2153 @value{op-extract}, @value{op-list} or @value{op-update}. When naming
2154 archive members, you must give the exact name of the member in the
2155 archive, as it is printed by @value{op-list}. For @value{op-append}
2156 and @value{op-create}, these @var{name} arguments specify the names
2157 of either files or directory hierarchies to place in the archive.
2158 These files or hierarchies should already exist in the file system,
2159 prior to the execution of the @command{tar} command.
2161 @command{tar} interprets relative file names as being relative to the
2162 working directory. @command{tar} will make all file names relative
2163 (by removing leading slashes when archiving or restoring files),
2164 unless you specify otherwise (using the @value{op-absolute-names}
2165 option). @value{xref-absolute-names}, for more information about
2166 @value{op-absolute-names}.
2168 If you give the name of a directory as either a file name or a member
2169 name, then @command{tar} acts recursively on all the files and directories
2170 beneath that directory. For example, the name @file{/} identifies all
2171 the files in the filesystem to @command{tar}.
2173 The distinction between file names and archive member names is especially
2174 important when shell globbing is used, and sometimes a source of confusion
2175 for newcomers. @xref{Wildcards}, for more information about globbing.
2176 The problem is that shells may only glob using existing files in the
2177 file system. Only @command{tar} itself may glob on archive members, so when
2178 needed, you must ensure that wildcard characters reach @command{tar} without
2179 being interpreted by the shell first. Using a backslash before @samp{*}
2180 or @samp{?}, or putting the whole argument between quotes, is usually
2181 sufficient for this.
2183 Even if @var{name}s are often specified on the command line, they
2184 can also be read from a text file in the file system, using the
2185 @value{op-files-from} option.
2187 If you don't use any file name arguments, @value{op-append},
2188 @value{op-delete} and @value{op-concatenate} will do nothing, while
2189 @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
2190 execution. The other operations of @command{tar} (@value{op-list},
2191 @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
2192 on the entire contents of the archive.
2195 @cindex return status
2196 Besides successful exits, @GNUTAR{} may fail for
2197 many reasons. Some reasons correspond to bad usage, that is, when the
2198 @command{tar} command is improperly written. Errors may be
2199 encountered later, while encountering an error processing the archive
2200 or the files. Some errors are recoverable, in which case the failure
2201 is delayed until @command{tar} has completed all its work. Some
2202 errors are such that it would not meaningful, or at least risky, to
2203 continue processing: @command{tar} then aborts processing immediately.
2204 All abnormal exits, whether immediate or delayed, should always be
2205 clearly diagnosed on @code{stderr}, after a line stating the nature of
2208 @GNUTAR{} returns only a few exit statuses. I'm really
2209 aiming simplicity in that area, for now. If you are not using the
2210 @value{op-compare} option, zero means that everything went well, besides
2211 maybe innocuous warnings. Nonzero means that something went wrong.
2212 Right now, as of today, ``nonzero'' is almost always 2, except for
2213 remote operations, where it may be 128.
2215 @node using tar options
2216 @section Using @command{tar} Options
2218 @GNUTAR{} has a total of eight operating modes which
2219 allow you to perform a variety of tasks. You are required to choose
2220 one operating mode each time you employ the @command{tar} program by
2221 specifying one, and only one operation as an argument to the
2222 @command{tar} command (two lists of four operations each may be found
2223 at @ref{frequent operations} and @ref{Operations}). Depending on
2224 circumstances, you may also wish to customize how the chosen operating
2225 mode behaves. For example, you may wish to change the way the output
2226 looks, or the format of the files that you wish to archive may require
2227 you to do something special in order to make the archive look right.
2229 You can customize and control @command{tar}'s performance by running
2230 @command{tar} with one or more options (such as @value{op-verbose}, which
2231 we used in the tutorial). As we said in the tutorial, @dfn{options} are
2232 arguments to @command{tar} which are (as their name suggests) optional.
2233 Depending on the operating mode, you may specify one or more options.
2234 Different options will have different effects, but in general they all
2235 change details of the operation, such as archive format, archive name,
2236 or level of user interaction. Some options make sense with all
2237 operating modes, while others are meaningful only with particular modes.
2238 You will likely use some options frequently, while you will only use
2239 others infrequently, or not at all. (A full list of options is
2240 available in @pxref{All Options}.)
2242 The @env{TAR_OPTIONS} environment variable specifies default options to
2243 be placed in front of any explicit options. For example, if
2244 @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
2245 if the two options @option{-v} and @option{--unlink-first} had been
2246 specified before any explicit options. Option specifications are
2247 separated by whitespace. A backslash escapes the next character, so it
2248 can be used to specify an option containing whitespace or a backslash.
2250 Note that @command{tar} options are case sensitive. For example, the
2251 options @samp{-T} and @samp{-t} are different; the first requires an
2252 argument for stating the name of a file providing a list of @var{name}s,
2253 while the second does not require an argument and is another way to
2254 write @value{op-list}.
2256 In addition to the eight operations, there are many options to
2257 @command{tar}, and three different styles for writing both: long (mnemonic)
2258 form, short form, and old style. These styles are discussed below.
2259 Both the options and the operations can be written in any of these three
2262 @FIXME{menu at end of this node. need to think of an actual outline
2263 for this chapter; probably do that after stuff from chap. 4 is
2267 @section The Three Option Styles
2269 There are three styles for writing operations and options to the command
2270 line invoking @command{tar}. The different styles were developed at
2271 different times during the history of @command{tar}. These styles will be
2272 presented below, from the most recent to the oldest.
2274 Some options must take an argument. (For example, @value{op-file} takes
2275 the name of an archive file as an argument. If you do not supply an
2276 archive file name, @command{tar} will use a default, but this can be
2277 confusing; thus, we recommend that you always supply a specific archive
2278 file name.) Where you @emph{place} the arguments generally depends on
2279 which style of options you choose. We will detail specific information
2280 relevant to each option style in the sections on the different option
2281 styles, below. The differences are subtle, yet can often be very
2282 important; incorrect option placement can cause you to overwrite a
2283 number of important files. We urge you to note these differences, and
2284 only use the option style(s) which makes the most sense to you until you
2285 feel comfortable with the others.
2287 Some options @emph{may} take an argument (currently, there are
2288 two such options: @value{op-backup} and @value{op-occurrence}). Such
2289 options may have at most long and short forms, they do not have old style
2290 equivalent. The rules for specifying an argument for such options
2291 are stricter than those for specifying mandatory arguments. Please,
2292 pay special attention to them.
2295 * Mnemonic Options:: Mnemonic Option Style
2296 * Short Options:: Short Option Style
2297 * Old Options:: Old Option Style
2298 * Mixing:: Mixing Option Styles
2301 @node Mnemonic Options
2302 @subsection Mnemonic Option Style
2304 @FIXME{have to decide whether or not to replace other occurrences of
2305 "mnemonic" with "long", or *ugh* vice versa.}
2307 Each option has at least one long (or mnemonic) name starting with two
2308 dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
2309 their corresponding short or old names. It sometimes happens that a
2310 single mnemonic option has many different different names which are
2311 synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
2312 long option names can be given unique abbreviations. For example,
2313 @samp{--cre} can be used in place of @samp{--create} because there is no
2314 other mnemonic option which begins with @samp{cre}. (One way to find
2315 this out is by trying it and seeing what happens; if a particular
2316 abbreviation could represent more than one option, @command{tar} will tell
2317 you that that abbreviation is ambiguous and you'll know that that
2318 abbreviation won't work. You may also choose to run @samp{tar --help}
2319 to see a list of options. Be aware that if you run @command{tar} with a
2320 unique abbreviation for the long name of an option you didn't want to
2321 use, you are stuck; @command{tar} will perform the command as ordered.)
2323 Mnemonic options are meant to be obvious and easy to remember, and their
2324 meanings are generally easier to discern than those of their
2325 corresponding short options (see below). For example:
2328 $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
2332 gives a fairly good set of hints about what the command does, even
2333 for those not fully acquainted with @command{tar}.
2335 Mnemonic options which require arguments take those arguments
2336 immediately following the option name. There are two ways of
2337 specifying a mandatory argument. It can be separated from the
2338 option name either by an equal sign, or by any amount of
2339 white space characters. For example, the @samp{--file} option (which
2340 tells the name of the @command{tar} archive) is given a file such as
2341 @file{archive.tar} as argument by using any of the following notations:
2342 @samp{--file=archive.tar} or @samp{--file archive.tar}.
2344 In contrast, optional arguments must always be introduced using
2345 an equal sign. For example, the @samp{--backup} option takes
2346 an optional argument specifying backup type. It must be used
2347 as @samp{--backup=@var{backup-type}}.
2350 @subsection Short Option Style
2352 Most options also have a short option name. Short options start with
2353 a single dash, and are followed by a single character, e.g.@: @samp{-t}
2354 (which is equivalent to @samp{--list}). The forms are absolutely
2355 identical in function; they are interchangeable.
2357 The short option names are faster to type than long option names.
2359 Short options which require arguments take their arguments immediately
2360 following the option, usually separated by white space. It is also
2361 possible to stick the argument right after the short option name, using
2362 no intervening space. For example, you might write @w{@samp{-f
2363 archive.tar}} or @samp{-farchive.tar} instead of using
2364 @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
2365 @w{@samp{-f @var{archive-name}}} denote the option which indicates a
2366 specific archive, here named @file{archive.tar}.
2368 Short options which take optional arguments take their arguments
2369 immediately following the option letter, @emph{without any intervening
2370 white space characters}.
2372 Short options' letters may be clumped together, but you are not
2373 required to do this (as compared to old options; see below). When
2374 short options are clumped as a set, use one (single) dash for them
2375 all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
2376 such a set is allowed to have an argument@footnote{Clustering many
2377 options, the last of which has an argument, is a rather opaque way to
2378 write options. Some wonder if @acronym{GNU} @code{getopt} should not
2379 even be made helpful enough for considering such usages as invalid.}.
2381 When the options are separated, the argument for each option which requires
2382 an argument directly follows that option, as is usual for Unix programs.
2386 $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
2389 If you reorder short options' locations, be sure to move any arguments
2390 that belong to them. If you do not move the arguments properly, you may
2391 end up overwriting files.
2394 @subsection Old Option Style
2397 Like short options, old options are single letters. However, old options
2398 must be written together as a single clumped set, without spaces separating
2399 them or dashes preceding them@footnote{Beware that if you precede options
2400 with a dash, you are announcing the short option style instead of the
2401 old option style; short options are decoded differently.}. This set
2402 of letters must be the first to appear on the command line, after the
2403 @command{tar} program name and some white space; old options cannot appear
2404 anywhere else. The letter of an old option is exactly the same letter as
2405 the corresponding short option. For example, the old option @samp{t} is
2406 the same as the short option @samp{-t}, and consequently, the same as the
2407 mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
2408 cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
2410 @FIXME{bob suggests having an uglier example. :-) }
2412 When options that need arguments are given together with the command,
2413 all the associated arguments follow, in the same order as the options.
2414 Thus, the example given previously could also be written in the old
2418 $ @kbd{tar cvbf 20 /dev/rmt0}
2422 Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
2423 the argument of @samp{-f}.
2425 On the other hand, this old style syntax makes it difficult to match
2426 option letters with their corresponding arguments, and is often
2427 confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
2428 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
2429 argument for @samp{-f}, and @samp{-v} does not have a corresponding
2430 argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
2431 /dev/rmt0}} is clearer, putting all arguments next to the option they
2434 If you want to reorder the letters in the old option argument, be
2435 sure to reorder any corresponding argument appropriately.
2437 This old way of writing @command{tar} options can surprise even experienced
2438 users. For example, the two commands:
2441 @kbd{tar cfz archive.tar.gz file}
2442 @kbd{tar -cfz archive.tar.gz file}
2446 are quite different. The first example uses @file{archive.tar.gz} as
2447 the value for option @samp{f} and recognizes the option @samp{z}. The
2448 second example, however, uses @file{z} as the value for option
2449 @samp{f} --- probably not what was intended.
2451 Old options are kept for compatibility with old versions of @command{tar}.
2453 This second example could be corrected in many ways, among which the
2454 following are equivalent:
2457 @kbd{tar -czf archive.tar.gz file}
2458 @kbd{tar -cf archive.tar.gz -z file}
2459 @kbd{tar cf archive.tar.gz -z file}
2462 @FIXME{still could explain this better; it's redundant:}
2464 @cindex option syntax, traditional
2465 As far as we know, all @command{tar} programs, @acronym{GNU} and
2466 non-@acronym{GNU}, support old options. @GNUTAR{}
2467 supports them not only for historical reasons, but also because many
2468 people are used to them. For compatibility with Unix @command{tar},
2469 the first argument is always treated as containing command and option
2470 letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
2471 equivalent to @w{@samp{tar -c}:} both of them specify the
2472 @value{op-create} command to create an archive.
2475 @subsection Mixing Option Styles
2477 All three styles may be intermixed in a single @command{tar} command,
2478 so long as the rules for each style are fully
2479 respected@footnote{Before @GNUTAR{} version 1.11.6,
2480 a bug prevented intermixing old style options with mnemonic options in
2481 some cases.}. Old style options and either of the modern styles of
2482 options may be mixed within a single @command{tar} command. However,
2483 old style options must be introduced as the first arguments only,
2484 following the rule for old options (old options must appear directly
2485 after the @command{tar} command and some white space). Modern options
2486 may be given only after all arguments to the old options have been
2487 collected. If this rule is not respected, a modern option might be
2488 falsely interpreted as the value of the argument to one of the old
2491 For example, all the following commands are wholly equivalent, and
2492 illustrate the many combinations and orderings of option styles.
2495 @kbd{tar --create --file=archive.tar}
2496 @kbd{tar --create -f archive.tar}
2497 @kbd{tar --create -farchive.tar}
2498 @kbd{tar --file=archive.tar --create}
2499 @kbd{tar --file=archive.tar -c}
2500 @kbd{tar -c --file=archive.tar}
2501 @kbd{tar -c -f archive.tar}
2502 @kbd{tar -c -farchive.tar}
2503 @kbd{tar -cf archive.tar}
2504 @kbd{tar -cfarchive.tar}
2505 @kbd{tar -f archive.tar --create}
2506 @kbd{tar -f archive.tar -c}
2507 @kbd{tar -farchive.tar --create}
2508 @kbd{tar -farchive.tar -c}
2509 @kbd{tar c --file=archive.tar}
2510 @kbd{tar c -f archive.tar}
2511 @kbd{tar c -farchive.tar}
2512 @kbd{tar cf archive.tar}
2513 @kbd{tar f archive.tar --create}
2514 @kbd{tar f archive.tar -c}
2515 @kbd{tar fc archive.tar}
2518 On the other hand, the following commands are @emph{not} equivalent to
2522 @kbd{tar -f -c archive.tar}
2523 @kbd{tar -fc archive.tar}
2524 @kbd{tar -fcarchive.tar}
2525 @kbd{tar -farchive.tarc}
2526 @kbd{tar cfarchive.tar}
2530 These last examples mean something completely different from what the
2531 user intended (judging based on the example in the previous set which
2532 uses long options, whose intent is therefore very clear). The first
2533 four specify that the @command{tar} archive would be a file named
2534 @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
2535 respectively. The first two examples also specify a single non-option,
2536 @var{name} argument having the value @samp{archive.tar}. The last
2537 example contains only old style option letters (repeating option
2538 @samp{c} twice), not all of which are meaningful (eg., @samp{.},
2539 @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
2540 the first sentence of this paragraph..}
2543 @section All @command{tar} Options
2545 The coming manual sections contain an alphabetical listing of all
2546 @command{tar} operations and options, with brief descriptions and cross
2547 references to more in-depth explanations in the body of the manual.
2548 They also contain an alphabetically arranged table of the short option
2549 forms with their corresponding long option. You can use this table as
2550 a reference for deciphering @command{tar} commands in scripts.
2553 * Operation Summary::
2555 * Short Option Summary::
2558 @node Operation Summary
2559 @subsection Operations
2566 Appends files to the end of the archive. @xref{append}.
2571 Same as @samp{--concatenate}. @xref{concatenate}.
2576 Compares archive members with their counterparts in the file
2577 system, and reports differences in file size, mode, owner,
2578 modification date and contents. @xref{compare}.
2583 Appends other @command{tar} archives to the end of the archive.
2589 Creates a new @command{tar} archive. @xref{create}.
2593 Deletes members from the archive. Don't try this on a archive on a
2594 tape! @xref{delete}.
2599 Same @samp{--compare}. @xref{compare}.
2604 Extracts members from the archive into the file system. @xref{extract}.
2609 Same as @samp{--extract}. @xref{extract}.
2614 Lists the members in an archive. @xref{list}.
2619 @FIXME{It was: A combination of the @samp{--compare} and
2620 @samp{--append} operations. This is not true and rather misleading,
2621 as @value{op-compare} does a lot more than @value{op-update} for
2622 ensuring files are identical.} Adds files to the end of the archive,
2623 but only if they are newer than their counterparts already in the
2624 archive, or if they do not already exist in the archive.
2629 @node Option Summary
2630 @subsection @command{tar} Options
2634 @item --absolute-names
2637 Normally when creating an archive, @command{tar} strips an initial
2638 @samp{/} from member names. This option disables that behavior.
2643 (See @samp{--newer}.) @FIXME-pxref{}
2646 An exclude pattern must match an initial subsequence of the name's components.
2649 @item --atime-preserve
2651 Tells @command{tar} to preserve the access time field in a file's inode when
2652 reading it. Due to limitations in the @code{utimes} system call, the
2653 modification time field is also preserved, which may cause problems if
2654 the file is simultaneously being modified by another program.
2655 This option is incompatible with incremental backups, because
2656 preserving the access time involves updating the last-changed time.
2657 Also, this option does not work on files that you do not own,
2661 @item --backup=@var{backup-type}
2663 Rather than deleting files from the file system, @command{tar} will
2664 back them up using simple or numbered backups, depending upon
2665 @var{backup-type}. @FIXME-xref{}
2667 @item --block-number
2670 With this option present, @command{tar} prints error messages for read errors
2671 with the block number in the archive file. @FIXME-xref{}
2673 @item --blocking-factor=@var{blocking}
2674 @itemx -b @var{blocking}
2676 Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
2677 record. @FIXME-xref{}
2682 This option tells @command{tar} to read or write archives through
2683 @code{bzip2}. @FIXME-xref{}
2687 This option directs @command{tar} to print periodic checkpoint messages as it
2688 reads through the archive. Its intended for when you want a visual
2689 indication that @command{tar} is still running, but don't want to see
2690 @samp{--verbose} output. @FIXME-xref{}
2694 If this option was given, @command{tar} will check the number of links
2695 dumped for each processed file. If this number does not match the
2696 total number of hard links for the file, a warning message will be
2699 Future versions will take @option{-l} as a short version of
2700 @option{--check-links}. However, current release still retains the old
2701 semantics for @option{-l}.
2703 @xref{Current status}, for more information.
2709 @command{tar} will use the @command{compress} program when reading or
2710 writing the archive. This allows you to directly act on archives
2711 while saving space. @FIXME-xref{}
2713 @item --confirmation
2715 (See @samp{--interactive}.) @FIXME-pxref{}
2720 When creating a @command{tar} archive, @command{tar} will archive the
2721 file that a symbolic link points to, rather than archiving the
2722 symlink. @FIXME-xref{}
2724 @item --directory=@var{dir}
2727 When this option is specified, @command{tar} will change its current directory
2728 to @var{dir} before performing any operations. When this option is used
2729 during archive creation, it is order sensitive. @FIXME-xref{}
2731 @item --exclude=@var{pattern}
2733 When performing operations, @command{tar} will skip files that match
2734 @var{pattern}. @FIXME-xref{}
2736 @item --exclude-from=@var{file}
2737 @itemx -X @var{file}
2739 Similar to @samp{--exclude}, except @command{tar} will use the list of
2740 patterns in the file @var{file}. @FIXME-xref{}
2742 @item --file=@var{archive}
2743 @itemx -f @var{archive}
2745 @command{tar} will use the file @var{archive} as the @command{tar} archive it
2746 performs operations on, rather than @command{tar}'s compilation dependent
2747 default. @FIXME-xref{}
2749 @item --files-from=@var{file}
2750 @itemx -T @var{file}
2752 @command{tar} will use the contents of @var{file} as a list of archive members
2753 or files to operate on, in addition to those specified on the
2754 command-line. @FIXME-xref{}
2758 Forces @command{tar} to interpret the filename given to @samp{--file}
2759 as a local file, even if it looks like a remote tape drive name.
2762 @item --format=@var{format}
2764 Selects output archive format. @var{Format} may be one of the
2769 Creates an archive that is compatible with Unix V7 @command{tar}.
2772 Creates an archive that is compatible with GNU @command{tar} version
2776 Creates archive in GNU tar 1.13 format. Basically it is the same as
2777 @samp{oldgnu} with the only difference in the way it handles long
2781 Creates a POSIX.1-1988 compatible archive.
2784 Creates a POSIX.1-2001 archive.
2788 @xref{Formats}, for a detailed discussion of these formats.
2790 @item --group=@var{group}
2792 Files added to the @command{tar} archive will have a group id of @var{group},
2793 rather than the group from the source file. @var{group} is first decoded
2794 as a group symbolic name, but if this interpretation fails, it has to be
2795 a decimal numeric group ID. @FIXME-xref{}
2797 Also see the comments for the @value{op-owner} option.
2804 This option tells @command{tar} to read or write archives through
2805 @command{gzip}, allowing @command{tar} to directly operate on several
2806 kinds of compressed archives transparently. @FIXME-xref{}
2810 @command{tar} will print out a short message summarizing the operations and
2811 options to @command{tar} and exit. @FIXME-xref{}
2814 Ignore case when excluding files.
2817 @item --ignore-failed-read
2819 Do not exit unsuccessfully merely because an unreadable file was encountered.
2822 @item --ignore-zeros
2825 With this option, @command{tar} will ignore zeroed blocks in the
2826 archive, which normally signals EOF. @xref{Reading}.
2831 Used to inform @command{tar} that it is working with an old
2832 @acronym{GNU}-format incremental backup archive. It is intended
2833 primarily for backwards compatibility only. @FIXME-xref{}
2835 @item --index-file=@var{file}
2837 Send verbose output to @var{file} instead of to standard output.
2839 @item --info-script=@var{script-file}
2840 @itemx --new-volume-script=@var{script-file}
2841 @itemx -F @var{script-file}
2843 When @command{tar} is performing multi-tape backups, @var{script-file} is run
2844 at the end of each tape. If @var{script-file} exits with nonzero status,
2845 @command{tar} fails immediately. @FIXME-xref{}
2848 @itemx --confirmation
2851 Specifies that @command{tar} should ask the user for confirmation before
2852 performing potentially destructive options, such as overwriting files.
2855 @item --keep-newer-files
2857 Do not replace existing files that are newer than their archive copies
2858 when extracting files from an archive.
2860 @item --keep-old-files
2863 Do not overwrite existing files when extracting files from an archive.
2866 @item --label=@var{name}
2867 @itemx -V @var{name}
2869 When creating an archive, instructs @command{tar} to write @var{name}
2870 as a name record in the archive. When extracting or listing archives,
2871 @command{tar} will only operate on archives that have a label matching
2872 the pattern specified in @var{name}. @FIXME-xref{}
2874 @item --listed-incremental=@var{snapshot-file}
2875 @itemx -g @var{snapshot-file}
2877 During a @samp{--create} operation, specifies that the archive that
2878 @command{tar} creates is a new @acronym{GNU}-format incremental
2879 backup, using @var{snapshot-file} to determine which files to backup.
2880 With other operations, informs @command{tar} that the archive is in
2881 incremental format. @FIXME-xref{}
2883 @item --mode=@var{permissions}
2885 When adding files to an archive, @command{tar} will use
2886 @var{permissions} for the archive members, rather than the permissions
2887 from the files. The program @command{chmod} and this @command{tar}
2888 option share the same syntax for what @var{permissions} might be.
2889 @xref{File permissions, Permissions, File permissions, fileutils,
2890 @acronym{GNU} file utilities}. This reference also has useful
2891 information for those not being overly familiar with the Unix
2894 Of course, @var{permissions} might be plainly specified as an octal number.
2895 However, by using generic symbolic modifications to mode bits, this allows
2896 more flexibility. For example, the value @samp{a+rw} adds read and write
2897 permissions for everybody, while retaining executable bits on directories
2898 or on any other file already marked as executable.
2900 @item --multi-volume
2903 Informs @command{tar} that it should create or otherwise operate on a
2904 multi-volume @command{tar} archive. @FIXME-xref{}
2906 @item --new-volume-script
2910 @item --newer=@var{date}
2911 @itemx --after-date=@var{date}
2914 When creating an archive, @command{tar} will only add files that have changed
2915 since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
2916 is taken to be the name of a file whose last-modified time specifies
2917 the date. @FIXME-xref{}
2919 @item --newer-mtime=@var{date}
2921 Like @samp{--newer}, but add only files whose
2922 contents have changed (as opposed to just @samp{--newer}, which will
2923 also back up files for which any status information has changed).
2926 An exclude pattern can match any subsequence of the name's components.
2929 @item --no-ignore-case
2930 Use case-sensitive matching when excluding files.
2933 @item --no-recursion
2935 With this option, @command{tar} will not recurse into directories.
2938 @item --no-same-owner
2941 When extracting an archive, do not attempt to preserve the owner
2942 specified in the @command{tar} archive. This the default behavior
2943 for ordinary users; this option has an effect only for the superuser.
2945 @item --no-same-permissions
2947 When extracting an archive, subtract the user's umask from files from
2948 the permissions specified in the archive. This is the default behavior
2949 for ordinary users; this option has an effect only for the superuser.
2951 @item --no-wildcards
2952 Do not use wildcards when excluding files.
2955 @item --no-wildcards-match-slash
2956 Wildcards do not match @samp{/} when excluding files.
2961 When @command{tar} is using the @samp{--files-from} option, this option
2962 instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
2963 @command{tar} can correctly work with file names that contain newlines.
2966 @item --numeric-owner
2968 This option will notify @command{tar} that it should use numeric user
2969 and group IDs when creating a @command{tar} file, rather than names.
2973 When extracting files, this option is a synonym for
2974 @option{--no-same-owner}, i.e. it prevents @command{tar} from
2975 restoring ownership of files being extracted.
2977 When creating an archive, @option{-o} is a synonym for
2978 @option{--old-archive}. This behavior is for compatibility
2979 with previous versions of @GNUTAR{}, and will be
2980 removed in the future releases.
2982 @xref{Current status}, for more information.
2984 @item --occurrence[=@var{number}]
2986 This option can be used in conjunction with one of the subcommands
2987 @option{--delete}, @option{--diff}, @option{--extract} or
2988 @option{--list} when a list of files is given either on the command
2989 line or via @option{-T} option.
2991 This option instructs @command{tar} to process only the @var{number}th
2992 occurrence of each named file. @var{Number} defaults to 1, so
2995 tar -x -f archive.tar --occurrence filename
2999 will extract the first occurrence of @file{filename} from @file{archive.tar}
3000 and will terminate without scanning to the end of the archive.
3003 Synonym for @option{--format=v7}.
3005 @item --one-file-system
3007 Used when creating an archive. Prevents @command{tar} from recursing into
3008 directories that are on different file systems from the current
3011 Earlier versions of @GNUTAR{} understood @option{-l} as a
3012 synonym for @option{--one-file-system}. Although such usage is still
3013 allowed in the present version, it is @emph{strongly discouraged}.
3014 The future versions of @GNUTAR{} will use @option{-l} as
3015 a synonym for @option{--check-links}.
3017 @xref{Current status}, for more information.
3021 Overwrite existing files and directory metadata when extracting files
3022 from an archive. @xref{Overwrite Old Files}.
3024 @item --overwrite-dir
3026 Overwrite the metadata of existing directories when extracting files
3027 from an archive. @xref{Overwrite Old Files}.
3029 @item --owner=@var{user}
3031 Specifies that @command{tar} should use @var{user} as the owner of members
3032 when creating archives, instead of the user associated with the source
3033 file. @var{user} is first decoded as a user symbolic name, but if
3034 this interpretation fails, it has to be a decimal numeric user ID.
3037 There is no value indicating a missing number, and @samp{0} usually means
3038 @code{root}. Some people like to force @samp{0} as the value to offer in
3039 their distributions for the owner of files, because the @code{root} user is
3040 anonymous anyway, so that might as well be the owner of anonymous archives.
3042 This option does not affect extraction from archives.
3044 @item --pax-option=@var{keyword-list}
3046 This option is meaningful only with POSIX.1-2001 archives
3047 (@FIXME-xref{}). It modifies the way @command{tar} handles the
3048 extended header keywords. @var{Keyword-list} is a comma-separated
3049 list of keyword options, each keyword option taking one of
3050 the following forms:
3053 @item delete=@var{pattern}
3054 When used with one of archive-creation command (@FIXME-xref{}),
3055 this option instructs @command{tar} to omit from extended header records
3056 that it produces any keywords matching the string @var{pattern}.
3058 When used in extract or list mode, this option instructs tar
3059 to ignore any keywords matching the given @var{pattern} in the extended
3060 header records. In both cases, matching is performed using the pattern
3061 matching notation described in POSIX 1003.2, 3.13 (@FIXME-xref{}, see
3062 man 7 glob). For example:
3065 --pax-option delete=security.*
3068 would suppress security-related information.
3070 @item exthdr.name=@var{string}
3072 This keyword allows user control over the name that is written into the
3073 ustar header blocks for the extended headers. The name is obtained
3074 from @var{string} after substituting the following meta-characters:
3076 @multitable @columnfractions .30 .70
3077 @item Meta-character @tab Replaced By
3078 @item %d @tab The directory name of the file, equivalent to the
3079 result of the @command{dirname} utility on the translated pathname.
3080 @item %f @tab The filename of the file, equivalent to the result
3081 of the @command{basename} utility on the translated pathname.
3082 @item %p @tab The process ID of the @command{tar} process.
3083 @item %% @tab A @samp{%} character.
3086 Any other @samp{%} characters in @var{string} produce undefined
3089 If no option @samp{exthdr.name=string} is specified, @command{tar}
3090 will use the following default value:
3096 @item globexthdr.name=@var{string}
3097 This keyword allows user control over the name that is written into
3098 the ustar header blocks for global extended header records. The name
3099 shall will be obtained from the contents of @var{string}, after the
3100 following character substitutions have been made:
3102 @multitable @columnfractions .30 .70
3103 @item Meta-character @tab Replaced By
3104 @item %n @tab An integer that represents the
3105 sequence number of the global extended header record in the archive,
3107 @item %p @tab The process ID of the @command{tar} process.
3108 @item %% @tab A @samp{%} character.
3111 Any other @samp{%} characters in string produce undefined results.
3113 If no option @samp{globexthdr.name=string} is specified, @command{tar}
3114 will use the following default value:
3117 $TMPDIR/GlobalHead.%p.%n
3121 where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
3122 environment variable. If @var{TMPDIR} is not set, @command{tar}
3125 @item @var{keyword}=@var{value}
3126 When used with one of archive-creation commands, these keyword/value pairs
3127 will be included at the beginning of the archive in a global extended
3128 header record. When used with one of archive-reading commands,
3129 @command{tar} will behave as if it has encountered these keyword/value
3130 pairs at the beginning of the archive in a global extended header
3133 @item @var{keyword}:=@var{value}
3134 When used with one of archive-creation commands, these keyword/value pairs
3135 will be included as records at the beginning of an extended header for
3136 each file. This is effectively equivalent to @var{keyword}=@var{value}
3137 form except that it creates no global extended header records.
3139 When used with one of archive-reading commands, @command{tar} will
3140 behave as if these keyword/value pairs were included as records at the
3141 end of each extended header; thus, they will override any global or
3142 file-specific extended header record keywords of the same names.
3143 For example, in the command:
3146 tar --format=posix --create \
3147 --file archive --pax-option gname:=user .
3150 the group name will be forced to a new value for all files
3151 stored in the archive.
3155 @itemx --old-archive
3156 Synonym for @option{--format=v7}.
3159 Same as @option{--format=posix}.
3163 Synonymous with specifying both @samp{--preserve-permissions} and
3164 @samp{--same-order}. @FIXME-xref{}
3166 @item --preserve-order
3168 (See @samp{--same-order}; @pxref{Reading}.)
3170 @item --preserve-permissions
3171 @itemx --same-permissions
3174 When @command{tar} is extracting an archive, it normally subtracts the
3175 users' umask from the permissions specified in the archive and uses
3176 that number as the permissions to create the destination file.
3177 Specifying this option instructs @command{tar} that it should use the
3178 permissions directly from the archive. @xref{Writing}.
3180 @item --read-full-records
3183 Specifies that @command{tar} should reblock its input, for reading
3184 from pipes on systems with buggy implementations. @xref{Reading}.
3186 @item --record-size=@var{size}
3188 Instructs @command{tar} to use @var{size} bytes per record when accessing the
3189 archive. @FIXME-xref{}
3193 With this option, @command{tar} recurses into directories.
3196 @item --recursive-unlink
3199 directory hierarchies before extracting directories of the same name
3200 from the archive. @xref{Writing}.
3202 @item --remove-files
3204 Directs @command{tar} to remove the source file from the file system after
3205 appending it to an archive. @FIXME-xref{}
3207 @item --rsh-command=@var{cmd}
3209 Notifies @command{tar} that is should use @var{cmd} to communicate with remote
3210 devices. @FIXME-xref{}
3213 @itemx --preserve-order
3216 This option is an optimization for @command{tar} when running on machines with
3217 small amounts of memory. It informs @command{tar} that the list of file
3218 arguments has already been sorted to match the order of files in the
3219 archive. @xref{Reading}.
3223 When extracting an archive, @command{tar} will attempt to preserve the owner
3224 specified in the @command{tar} archive with this option present.
3225 This is the default behavior for the superuser; this option has an
3226 effect only for ordinary users. @FIXME-xref{}
3228 @item --same-permissions
3230 (See @samp{--preserve-permissions}; @pxref{Writing}.)
3232 @item --show-defaults
3234 Displays the default options used by @command{tar} and exits
3235 successfully. This option is intended for use in shell scripts.
3236 Here is an example of what you can see using this option:
3239 $ tar --show-defaults
3240 --format=gnu -f- -b20
3243 @item --show-omitted-dirs
3245 Instructs @command{tar} to mention directories its skipping over when
3246 operating on a @command{tar} archive. @FIXME-xref{}
3251 Invokes a @acronym{GNU} extension when adding files to an archive that handles
3252 sparse files efficiently. @FIXME-xref{}
3254 @item --starting-file=@var{name}
3255 @itemx -K @var{name}
3257 This option affects extraction only; @command{tar} will skip extracting
3258 files in the archive until it finds one that matches @var{name}.
3261 @item --strip-path=@var{number}
3262 Strip given @var{number} of leading components from file names before
3263 extraction. For example, if archive @file{archive.tar} contained
3264 @file{/some/file/name}, then running
3267 tar --extract --file archive.tar --strip-path=2
3271 would extracted this file to file @file{name}.
3273 @item --suffix=@var{suffix}
3275 Alters the suffix @command{tar} uses when backing up files from the default
3276 @samp{~}. @FIXME-xref{}
3278 @item --tape-length=@var{num}
3281 Specifies the length of tapes that @command{tar} is writing as being
3282 @w{@var{num} x 1024} bytes long. @FIXME-xref{}
3287 During extraction, @command{tar} will extract files to stdout rather
3288 than to the file system. @xref{Writing}.
3292 Displays the total number of bytes written after creating an archive.
3298 Sets the modification time of extracted files to the extraction time,
3299 rather than the modification time stored in the archive.
3304 (See @samp{--compress}.) @FIXME-pxref{}
3308 (See @samp{--gzip}.) @FIXME-pxref{}
3310 @item --unlink-first
3313 Directs @command{tar} to remove the corresponding file from the file
3314 system before extracting it from the archive. @xref{Writing}.
3316 @item --use-compress-program=@var{prog}
3318 Instructs @command{tar} to access the archive through @var{prog}, which is
3319 presumed to be a compression program of some sort. @FIXME-xref{}
3323 Display file modification dates in @acronym{UTC}. This option implies
3329 Specifies that @command{tar} should be more verbose about the operations its
3330 performing. This option can be specified multiple times for some
3331 operations to increase the amount of information displayed. @FIXME-xref{}
3336 Verifies that the archive was correctly written when creating an
3337 archive. @FIXME-xref{}
3341 @command{tar} will print an informational message about what version
3342 it is and a copyright message, some credits, and then exit.
3345 @item --volno-file=@var{file}
3347 Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
3348 of which volume of a multi-volume archive its working in @var{file}.
3352 Use wildcards when excluding files.
3355 @item --wildcards-match-slash
3356 Wildcards match @samp{/} when excluding files.
3360 @node Short Option Summary
3361 @subsection Short Options Cross Reference
3363 Here is an alphabetized list of all of the short option forms, matching
3364 them with the equivalent long option.
3370 @samp{--concatenate}
3374 @samp{--read-full-records}
3382 @samp{--info-script}
3386 @samp{--incremental}
3390 @samp{--starting-file}
3394 @samp{--tape-length}
3398 @samp{--multi-volume}
3410 @samp{--absolute-names}
3414 @samp{--block-number}
3426 @samp{--unlink-first}
3438 @samp{--exclude-from}
3446 @samp{--blocking-factor}
3462 @samp{--listed-incremental}
3466 @samp{--dereference}
3470 @samp{--ignore-zeros}
3478 @samp{--keep-old-files}
3482 @samp{--one-file-system}. Use of this short option is deprecated. It
3483 is retained for compatibility with the earlier versions of GNU
3484 @command{tar}, and will be changed in future releases.
3486 @xref{Current status}, for more information.
3494 When creating --- @samp{--no-same-owner}, when extracting ---
3495 @samp{--portability}.
3497 The later usage is deprecated. It is retained for compatibility with
3498 the earlier versions of @GNUTAR{}. In the future releases
3499 @option{-o} will be equivalent to @samp{--no-same-owner} only.
3503 @samp{--preserve-permissions}
3527 @samp{--interactive}
3540 @section @GNUTAR{} documentation
3542 Being careful, the first thing is really checking that you are using
3543 @GNUTAR{}, indeed. The @value{op-version} option
3544 will generate a message giving confirmation that you are using
3545 @GNUTAR{}, with the precise version of @GNUTAR{}
3546 you are using. @command{tar} identifies itself and
3547 prints the version number to the standard output, then immediately
3548 exits successfully, without doing anything else, ignoring all other
3549 options. For example, @w{@samp{tar --version}} might return:
3552 tar (@acronym{GNU} tar) @value{VERSION}
3556 The first occurrence of @samp{tar} in the result above is the program
3557 name in the package (for example, @command{rmt} is another program),
3558 while the second occurrence of @samp{tar} is the name of the package
3559 itself, containing possibly many programs. The package is currently
3560 named @samp{tar}, after the name of the main program it
3561 contains@footnote{There are plans to merge the @command{cpio} and
3562 @command{tar} packages into a single one which would be called
3563 @code{paxutils}. So, who knows if, one of this days, the
3564 @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
3567 Another thing you might want to do is checking the spelling or meaning
3568 of some particular @command{tar} option, without resorting to this
3569 manual, for once you have carefully read it. @GNUTAR{}
3570 has a short help feature, triggerable through the
3571 @value{op-help} option. By using this option, @command{tar} will
3572 print a usage message listing all available options on standard
3573 output, then exit successfully, without doing anything else and
3574 ignoring all other options. Even if this is only a brief summary, it
3575 may be several screens long. So, if you are not using some kind of
3576 scrollable window, you might prefer to use something like:
3579 $ @kbd{tar --help | less}
3583 presuming, here, that you like using @command{less} for a pager. Other
3584 popular pagers are @command{more} and @command{pg}. If you know about some
3585 @var{keyword} which interests you and do not want to read all the
3586 @value{op-help} output, another common idiom is doing:
3589 tar --help | grep @var{keyword}
3593 for getting only the pertinent lines.
3595 The perceptive reader would have noticed some contradiction in the
3596 previous paragraphs. It is written that both @value{op-version} and
3597 @value{op-help} print something, and have all other options ignored. In
3598 fact, they cannot ignore each other, and one of them has to win. We do
3599 not specify which is stronger, here; experiment if you really wonder!
3601 The short help output is quite succinct, and you might have to get
3602 back to the full documentation for precise points. If you are reading
3603 this paragraph, you already have the @command{tar} manual in some
3604 form. This manual is available in printed form, as a kind of small
3605 book. It may printed out of the @GNUTAR{}
3606 distribution, provided you have @TeX{} already installed somewhere,
3607 and a laser printer around. Just configure the distribution, execute
3608 the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
3609 usual way (contact your local guru to know how). If @GNUTAR{}
3610 has been conveniently installed at your place, this
3611 manual is also available in interactive, hypertextual form as an Info
3612 file. Just call @w{@samp{info tar}} or, if you do not have the
3613 @command{info} program handy, use the Info reader provided within
3614 @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
3616 There is currently no @code{man} page for @GNUTAR{}.
3617 If you observe such a @code{man} page on the system you are running,
3618 either it does not long to @GNUTAR{}, or it has not
3619 been produced by @acronym{GNU}. Currently, @GNUTAR{}
3620 documentation is provided in Texinfo format only, if we
3621 except, of course, the short result of @kbd{tar --help}.
3624 @section Checking @command{tar} progress
3626 @cindex Progress information
3627 @cindex Status information
3628 @cindex Information on progress and status of operations
3629 @cindex Verbose operation
3630 @cindex Block number where error occurred
3631 @cindex Error message, block number of
3632 @cindex Version of the @command{tar} program
3634 @cindex Getting more information during the operation
3635 @cindex Information during operation
3636 @cindex Feedback from @command{tar}
3638 Typically, @command{tar} performs most operations without reporting any
3639 information to the user except error messages. When using @command{tar}
3640 with many options, particularly ones with complicated or
3641 difficult-to-predict behavior, it is possible to make serious mistakes.
3642 @command{tar} provides several options that make observing @command{tar}
3643 easier. These options cause @command{tar} to print information as it
3644 progresses in its job, and you might want to use them just for being
3645 more careful about what is going on, or merely for entertaining
3646 yourself. If you have encountered a problem when operating on an
3647 archive, however, you may need more information than just an error
3648 message in order to solve the problem. The following options can be
3649 helpful diagnostic tools.
3651 Normally, the @value{op-list} command to list an archive prints just
3652 the file names (one per line) and the other commands are silent.
3653 When used with most operations, the @value{op-verbose} option causes
3654 @command{tar} to print the name of each file or archive member as it
3655 is processed. This and the other options which make @command{tar} print
3656 status information can be useful in monitoring @command{tar}.
3658 With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
3659 just prints the names of the files or members as they are processed.
3660 Using it twice causes @command{tar} to print a longer listing (reminiscent
3661 of @samp{ls -l}) for each member. Since @value{op-list} already prints
3662 the names of the members, @value{op-verbose} used once with @value{op-list}
3663 causes @command{tar} to print an @samp{ls -l} type listing of the files
3664 in the archive. The following examples both extract members with
3668 $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
3669 $ @kbd{tar xvvf archive.tar}
3672 Verbose output appears on the standard output except when an archive is
3673 being written to the standard output, as with @samp{tar --create
3674 --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
3675 installer let standard output be the default archive). In that case
3676 @command{tar} writes verbose output to the standard error stream.
3678 If @option{--index-file=@var{file}} is specified, @command{tar} sends
3679 verbose output to @var{file} rather than to standard output or standard
3682 The @value{op-totals} option---which is only meaningful when used with
3683 @value{op-create}---causes @command{tar} to print the total
3684 amount written to the archive, after it has been fully created.
3686 The @value{op-checkpoint} option prints an occasional message
3687 as @command{tar} reads or writes the archive. In fact, it print
3688 directory names while reading the archive. It is designed for
3689 those who don't need the more detailed (and voluminous) output of
3690 @value{op-block-number}, but do want visual confirmation that @command{tar}
3691 is actually making forward progress.
3693 @FIXME{There is some confusion here. It seems that -R once wrote a
3694 message at @samp{every} record read or written.}
3696 The @value{op-show-omitted-dirs} option, when reading an archive---with
3697 @value{op-list} or @value{op-extract}, for example---causes a message
3698 to be printed for each directory in the archive which is skipped.
3699 This happens regardless of the reason for skipping: the directory might
3700 not have been named on the command line (implicitly or explicitly),
3701 it might be excluded by the use of the @value{op-exclude} option, or
3704 If @value{op-block-number} is used, @command{tar} prints, along with
3705 every message it would normally produce, the block number within the
3706 archive where the message was triggered. Also, supplementary messages
3707 are triggered when reading blocks full of NULs, or when hitting end of
3708 file on the archive. As of now, if the archive if properly terminated
3709 with a NUL block, the reading of the file may stop before end of file
3710 is met, so the position of end of file will not usually show when
3711 @value{op-block-number} is used. Note that @GNUTAR{}
3712 drains the archive before exiting when reading the
3713 archive from a pipe.
3715 This option is especially useful when reading damaged archives, since
3716 it helps pinpoint the damaged sections. It can also be used with
3717 @value{op-list} when listing a file-system backup tape, allowing you to
3718 choose among several backup tapes when retrieving a file later, in
3719 favor of the tape where the file appears earliest (closest to the
3720 front of the tape). @FIXME-xref{when the node name is set and the
3721 backup section written.}
3724 @section Asking for Confirmation During Operations
3725 @cindex Interactive operation
3727 Typically, @command{tar} carries out a command without stopping for
3728 further instructions. In some situations however, you may want to
3729 exclude some files and archive members from the operation (for instance
3730 if disk or storage space is tight). You can do this by excluding
3731 certain files automatically (@pxref{Choosing}), or by performing
3732 an operation interactively, using the @value{op-interactive} option.
3733 @command{tar} also accepts @samp{--confirmation} for this option.
3735 When the @value{op-interactive} option is specified, before
3736 reading, writing, or deleting files, @command{tar} first prints a message
3737 for each such file, telling what operation it intends to take, then asks
3738 for confirmation on the terminal. The actions which require
3739 confirmation include adding a file to the archive, extracting a file
3740 from the archive, deleting a file from the archive, and deleting a file
3741 from disk. To confirm the action, you must type a line of input
3742 beginning with @samp{y}. If your input line begins with anything other
3743 than @samp{y}, @command{tar} skips that file.
3745 If @command{tar} is reading the archive from the standard input,
3746 @command{tar} opens the file @file{/dev/tty} to support the interactive
3749 Verbose output is normally sent to standard output, separate from
3750 other error messages. However, if the archive is produced directly
3751 on standard output, then verbose output is mixed with errors on
3752 @code{stderr}. Producing the archive on standard output may be used
3753 as a way to avoid using disk space, when the archive is soon to be
3754 consumed by another process reading it, say. Some people felt the need
3755 of producing an archive on stdout, still willing to segregate between
3756 verbose output and error output. A possible approach would be using a
3757 named pipe to receive the archive, and having the consumer process to
3758 read from that named pipe. This has the advantage of letting standard
3759 output free to receive verbose output, all separate from errors.
3762 @chapter @GNUTAR{} Operations
3775 @section Basic @GNUTAR{} Operations
3777 The basic @command{tar} operations, @value{op-create}, @value{op-list} and
3778 @value{op-extract}, are currently presented and described in the tutorial
3779 chapter of this manual. This section provides some complementary notes
3780 for these operations.
3783 @item @value{op-create}
3785 Creating an empty archive would have some kind of elegance. One can
3786 initialize an empty archive and later use @value{op-append} for adding
3787 all members. Some applications would not welcome making an exception
3788 in the way of adding the first archive member. On the other hand,
3789 many people reported that it is dangerously too easy for @command{tar}
3790 to destroy a magnetic tape with an empty archive@footnote{This is well
3791 described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
3792 Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
3797 Mistakingly using @code{create} instead of @code{extract}, when the
3798 intent was to extract the full contents of an archive. This error
3799 is likely: keys @kbd{c} and @kbd{x} are right next to each other on
3800 the QWERTY keyboard. Instead of being unpacked, the archive then
3801 gets wholly destroyed. When users speak about @dfn{exploding} an
3802 archive, they usually mean something else :-).
3805 Forgetting the argument to @code{file}, when the intent was to create
3806 an archive with a single file in it. This error is likely because a
3807 tired user can easily add the @kbd{f} key to the cluster of option
3808 letters, by the mere force of habit, without realizing the full
3809 consequence of doing so. The usual consequence is that the single
3810 file, which was meant to be saved, is rather destroyed.
3813 So, recognizing the likelihood and the catastrophical nature of these
3814 errors, @GNUTAR{} now takes some distance from elegance, and
3815 cowardly refuses to create an archive when @value{op-create} option is
3816 given, there are no arguments besides options, and @value{op-files-from}
3817 option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
3818 and nevertheless create an archive with nothing in it,
3819 one may still use, as the value for the @value{op-files-from} option,
3820 a file with no names in it, as shown in the following commands:
3823 @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
3824 @kbd{tar cfT empty-archive.tar /dev/null}
3827 @item @value{op-extract}
3829 A socket is stored, within a @GNUTAR{} archive, as a pipe.
3831 @item @value{op-list}
3833 @GNUTAR{} now shows dates as @samp{1996-08-30},
3834 while it used to show them as @samp{Aug 30 1996}. (One can revert to
3835 the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
3836 before reinstalling.) But preferably, people should get used to ISO
3837 8601 dates. Local American dates should be made available again with
3838 full date localization support, once ready. In the meantime, programs
3839 not being localizable for dates should prefer international dates,
3840 that's really the way to go.
3842 Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
3843 are curious, it contains a detailed explanation of the ISO 8601 standard.
3848 @section Advanced @GNUTAR{} Operations
3850 Now that you have learned the basics of using @GNUTAR{}, you may want
3851 to learn about further ways in which @command{tar} can help you.
3853 This chapter presents five, more advanced operations which you probably
3854 won't use on a daily basis, but which serve more specialized functions.
3855 We also explain the different styles of options and why you might want
3856 to use one or another, or a combination of them in your @command{tar}
3857 commands. Additionally, this chapter includes options which allow you to
3858 define the output from @command{tar} more carefully, and provide help and
3859 error correction in special circumstances.
3861 @FIXME{check this after the chapter is actually revised to make sure
3862 it still introduces the info in the chapter correctly : ).}
3874 @subsection The Five Advanced @command{tar} Operations
3877 In the last chapter, you learned about the first three operations to
3878 @command{tar}. This chapter presents the remaining five operations to
3879 @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
3880 @samp{--delete}, and @samp{--compare}.
3882 You are not likely to use these operations as frequently as those
3883 covered in the last chapter; however, since they perform specialized
3884 functions, they are quite useful when you do need to use them. We
3885 will give examples using the same directory and files that you created
3886 in the last chapter. As you may recall, the directory is called
3887 @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
3888 @samp{rock}, and the two archive files you created are
3889 @samp{collection.tar} and @samp{music.tar}.
3891 We will also use the archive files @samp{afiles.tar} and
3892 @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
3893 @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
3894 @samp{./birds}, @samp{baboon}, and @samp{./box}.
3896 Unless we state otherwise, all practicing you do and examples you follow
3897 in this chapter will take place in the @file{practice} directory that
3898 you created in the previous chapter; see @ref{prepare for examples}.
3899 (Below in this section, we will remind you of the state of the examples
3900 where the last chapter left them.)
3902 The five operations that we will cover in this chapter are:
3907 Add new entries to an archive that already exists.
3910 Add more recent copies of archive members to the end of an archive, if
3915 Add one or more pre-existing archives to the end of another archive.
3917 Delete items from an archive (does not work on tapes).
3921 Compare archive members to their counterparts in the file system.
3925 @subsection How to Add Files to Existing Archives: @code{--append}
3928 If you want to add files to an existing archive, you don't need to
3929 create a new archive; you can use @value{op-append}. The archive must
3930 already exist in order to use @samp{--append}. (A related operation
3931 is the @samp{--update} operation; you can use this to add newer
3932 versions of archive members to an existing archive. To learn how to
3933 do this with @samp{--update}, @pxref{update}.)
3935 @FIXME{Explain in second paragraph whether you can get to the previous
3936 version -- explain whole situation somewhat more clearly.}
3938 If you use @value{op-append} to add a file that has the same name as an
3939 archive member to an archive containing that archive member, then the
3940 old member is not deleted. What does happen, however, is somewhat
3941 complex. @command{tar} @emph{allows} you to have infinite numbers of files
3942 with the same name. Some operations treat these same-named members no
3943 differently than any other set of archive members: for example, if you
3944 view an archive with @value{op-list}, you will see all of those members
3945 listed, with their modification times, owners, etc.
3947 Other operations don't deal with these members as perfectly as you might
3948 prefer; if you were to use @value{op-extract} to extract the archive,
3949 only the most recently added copy of a member with the same name as four
3950 other members would end up in the working directory. This is because
3951 @samp{--extract} extracts an archive in the order the members appeared
3952 in the archive; the most recently archived members will be extracted
3953 last. Additionally, an extracted member will @emph{replace} a file of
3954 the same name which existed in the directory already, and @command{tar}
3955 will not prompt you about this. Thus, only the most recently archived
3956 member will end up being extracted, as it will replace the one
3957 extracted before it, and so on.
3959 @FIXME{ hag -- you might want to incorporate some of the above into the
3960 MMwtSN node; not sure. i didn't know how to make it simpler...}
3962 There are a few ways to get around this. @FIXME-xref{Multiple Members
3963 with the Same Name.}
3965 @cindex Members, replacing with other members
3966 @cindex Replacing members with other members
3967 If you want to replace an archive member, use @value{op-delete} to
3968 delete the member you want to remove from the archive, , and then use
3969 @samp{--append} to add the member you want to be in the archive. Note
3970 that you can not change the order of the archive; the most recently
3971 added member will still appear last. In this sense, you cannot truly
3972 ``replace'' one member with another. (Replacing one member with another
3973 will not work on certain types of media, such as tapes; see @ref{delete}
3974 and @ref{Media}, for more information.)
3977 * appending files:: Appending Files to an Archive
3981 @node appending files
3982 @subsubsection Appending Files to an Archive
3984 @cindex Adding files to an Archive
3985 @cindex Appending files to an Archive
3986 @cindex Archives, Appending files to
3988 The simplest way to add a file to an already existing archive is the
3989 @value{op-append} operation, which writes specified files into the
3990 archive whether or not they are already among the archived files.
3991 When you use @samp{--append}, you @emph{must} specify file name
3992 arguments, as there is no default. If you specify a file that already
3993 exists in the archive, another copy of the file will be added to the
3994 end of the archive. As with other operations, the member names of the
3995 newly added files will be exactly the same as their names given on the
3996 command line. The @value{op-verbose} option will print out the names
3997 of the files as they are written into the archive.
3999 @samp{--append} cannot be performed on some tape drives, unfortunately,
4000 due to deficiencies in the formats those tape drives use. The archive
4001 must be a valid @command{tar} archive, or else the results of using this
4002 operation will be unpredictable. @xref{Media}.
4004 To demonstrate using @samp{--append} to add a file to an archive,
4005 create a file called @file{rock} in the @file{practice} directory.
4006 Make sure you are in the @file{practice} directory. Then, run the
4007 following @command{tar} command to add @file{rock} to
4008 @file{collection.tar}:
4011 $ @kbd{tar --append --file=collection.tar rock}
4015 If you now use the @value{op-list} operation, you will see that
4016 @file{rock} has been added to the archive:
4019 $ @kbd{tar --list --file=collection.tar}
4020 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
4021 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
4022 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
4023 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
4026 @FIXME{in theory, dan will (soon) try to turn this node into what it's
4027 title claims it will become...}
4030 @subsubsection Multiple Files with the Same Name
4032 You can use @value{op-append} to add copies of files which have been
4033 updated since the archive was created. (However, we do not recommend
4034 doing this since there is another @command{tar} option called
4035 @samp{--update}; @pxref{update} for more information. We describe this
4036 use of @samp{--append} here for the sake of completeness.) @FIXME{is
4037 this really a good idea, to give this whole description for something
4038 which i believe is basically a Stupid way of doing something? certain
4039 aspects of it show ways in which tar is more broken than i'd personally
4040 like to admit to, specifically the last sentence. On the other hand, i
4041 don't think it's a good idea to be saying that we explicitly don't
4042 recommend using something, but i can't see any better way to deal with
4043 the situation.}When you extract the archive, the older version will be
4044 effectively lost. This works because files are extracted from an
4045 archive in the order in which they were archived. Thus, when the
4046 archive is extracted, a file archived later in time will replace a
4047 file of the same name which was archived earlier, even though the older
4048 version of the file will remain in the archive unless you delete all
4049 versions of the file.
4051 Supposing you change the file @file{blues} and then append the changed
4052 version to @file{collection.tar}. As you saw above, the original
4053 @file{blues} is in the archive @file{collection.tar}. If you change the
4054 file and append the new version of the file to the archive, there will
4055 be two copies in the archive. When you extract the archive, the older
4056 version of the file will be extracted first, and then replaced by the
4057 newer version when it is extracted.
4059 You can append the new, changed copy of the file @file{blues} to the
4060 archive in this way:
4063 $ @kbd{tar --append --verbose --file=collection.tar blues}
4068 Because you specified the @samp{--verbose} option, @command{tar} has
4069 printed the name of the file being appended as it was acted on. Now
4070 list the contents of the archive:
4073 $ @kbd{tar --list --verbose --file=collection.tar}
4074 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
4075 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
4076 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
4077 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
4078 -rw-rw-rw- me user 58 1996-10-24 18:30 blues
4082 The newest version of @file{blues} is now at the end of the archive
4083 (note the different creation dates and file sizes). If you extract
4084 the archive, the older version of the file @file{blues} will be
4085 replaced by the newer version. You can confirm this by extracting
4086 the archive and running @samp{ls} on the directory. @xref{Writing},
4087 for more information. (@emph{Please note:} This is the case unless
4088 you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
4089 with the Same Name}.)
4092 @subsection Updating an Archive
4094 @cindex Updating an archive
4096 In the previous section, you learned how to use @value{op-append} to add
4097 a file to an existing archive. A related operation is
4098 @value{op-update}. The @samp{--update} operation updates a @command{tar}
4099 archive by comparing the date of the specified archive members against
4100 the date of the file with the same name. If the file has been modified
4101 more recently than the archive member, then the newer version of the
4102 file is added to the archive (as with @value{op-append}).
4104 Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
4105 The operation will fail.
4107 @FIXME{other examples of media on which --update will fail? need to ask
4108 charles and/or mib/thomas/dave shevett..}
4110 Both @samp{--update} and @samp{--append} work by adding to the end
4111 of the archive. When you extract a file from the archive, only the
4112 version stored last will wind up in the file system, unless you use
4113 the @value{op-backup} option. @FIXME-ref{Multiple Members with the
4121 @subsubsection How to Update an Archive Using @code{--update}
4123 You must use file name arguments with the @value{op-update} operation.
4124 If you don't specify any files, @command{tar} won't act on any files and
4125 won't tell you that it didn't do anything (which may end up confusing
4128 @FIXME{note: the above parenthetical added because in fact, this
4129 behavior just confused the author. :-) }
4131 To see the @samp{--update} option at work, create a new file,
4132 @file{classical}, in your practice directory, and some extra text to the
4133 file @file{blues}, using any text editor. Then invoke @command{tar} with
4134 the @samp{update} operation and the @value{op-verbose} option specified,
4135 using the names of all the files in the practice directory as file name
4139 $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
4146 Because we have specified verbose mode, @command{tar} prints out the names
4147 of the files it is working on, which in this case are the names of the
4148 files that needed to be updated. If you run @samp{tar --list} and look
4149 at the archive, you will see @file{blues} and @file{classical} at its
4150 end. There will be a total of two versions of the member @samp{blues};
4151 the one at the end will be newer and larger, since you added text before
4154 (The reason @command{tar} does not overwrite the older file when updating
4155 it is because writing to the middle of a section of tape is a difficult
4156 process. Tapes are not designed to go backward. @xref{Media}, for more
4157 information about tapes.
4159 @value{op-update} is not suitable for performing backups for two
4160 reasons: it does not change directory content entries, and it
4161 lengthens the archive every time it is used. The @GNUTAR{}
4162 options intended specifically for backups are more
4163 efficient. If you need to run backups, please consult @ref{Backups}.
4166 @subsection Combining Archives with @code{--concatenate}
4168 @cindex Adding archives to an archive
4169 @cindex Concatenating Archives
4170 Sometimes it may be convenient to add a second archive onto the end of
4171 an archive rather than adding individual files to the archive. To add
4172 one or more archives to the end of another archive, you should use the
4173 @value{op-concatenate} operation.
4175 To use @samp{--concatenate}, name the archives to be concatenated on the
4176 command line. (Nothing happens if you don't list any.) The members,
4177 and their member names, will be copied verbatim from those archives. If
4178 this causes multiple members to have the same name, it does not delete
4179 any members; all the members with the same name coexist. @FIXME-ref{For
4180 information on how this affects reading the archive, Multiple
4181 Members with the Same Name.}
4183 To demonstrate how @samp{--concatenate} works, create two small archives
4184 called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
4185 files from @file{practice}:
4188 $ @kbd{tar -cvf bluesrock.tar blues rock}
4191 $ @kbd{tar -cvf folkjazz.tar folk jazz}
4197 If you like, You can run @samp{tar --list} to make sure the archives
4198 contain what they are supposed to:
4201 $ @kbd{tar -tvf bluesrock.tar}
4202 -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
4203 -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
4204 $ @kbd{tar -tvf folkjazz.tar}
4205 -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
4206 -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
4209 We can concatenate these two archives with @command{tar}:
4213 $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
4216 If you now list the contents of the @file{bluesclass.tar}, you will see
4217 that now it also contains the archive members of @file{jazzfolk.tar}:
4220 $ @kbd{tar --list --file=bluesrock.tar}
4227 When you use @samp{--concatenate}, the source and target archives must
4228 already exist and must have been created using compatible format
4229 parameters. @FIXME-pxref{Matching Format Parameters}The new,
4230 concatenated archive will be called by the same name as the first
4231 archive listed on the command line. @FIXME{is there a way to specify a
4234 Like @value{op-append}, this operation cannot be performed on some
4235 tape drives, due to deficiencies in the formats those tape drives use.
4237 @cindex @code{concatenate} vs @command{cat}
4238 @cindex @command{cat} vs @code{concatenate}
4239 It may seem more intuitive to you to want or try to use @command{cat} to
4240 concatenate two archives instead of using the @samp{--concatenate}
4241 operation; after all, @command{cat} is the utility for combining files.
4243 However, @command{tar} archives incorporate an end-of-file marker which
4244 must be removed if the concatenated archives are to be read properly as
4245 one archive. @samp{--concatenate} removes the end-of-archive marker
4246 from the target archive before each new archive is appended. If you use
4247 @command{cat} to combine the archives, the result will not be a valid
4248 @command{tar} format archive. If you need to retrieve files from an
4249 archive that was added to using the @command{cat} utility, use the
4250 @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
4251 information on dealing with archives improperly combined using the
4252 @command{cat} shell utility.
4254 @FIXME{this shouldn't go here. where should it go?} You must specify
4255 the source archives using @value{op-file} (@value{pxref-file}). If you
4256 do not specify the target archive, @command{tar} uses the value of the
4257 environment variable @env{TAPE}, or, if this has not been set, the
4258 default archive name.
4261 @subsection Removing Archive Members Using @samp{--delete}
4263 @cindex Deleting files from an archive
4264 @cindex Removing files from an archive
4266 You can remove members from an archive by using the @value{op-delete}
4267 option. Specify the name of the archive with @value{op-file} and then
4268 specify the names of the members to be deleted; if you list no member
4269 names, nothing will be deleted. The @value{op-verbose} option will
4270 cause @command{tar} to print the names of the members as they are deleted.
4271 As with @value{op-extract}, you must give the exact member names when
4272 using @samp{tar --delete}. @samp{--delete} will remove all versions of
4273 the named file from the archive. The @samp{--delete} operation can run
4276 Unlike other operations, @samp{--delete} has no short form.
4278 @cindex Tapes, using @code{--delete} and
4279 @cindex Deleting from tape archives
4280 This operation will rewrite the archive. You can only use
4281 @samp{--delete} on an archive if the archive device allows you to
4282 write to any point on the media, such as a disk; because of this, it
4283 does not work on magnetic tapes. Do not try to delete an archive member
4284 from a magnetic tape; the action will not succeed, and you will be
4285 likely to scramble the archive and damage your tape. There is no safe
4286 way (except by completely re-writing the archive) to delete files from
4287 most kinds of magnetic tape. @xref{Media}.
4289 To delete all versions of the file @file{blues} from the archive
4290 @file{collection.tar} in the @file{practice} directory, make sure you
4291 are in that directory, and then,
4294 $ @kbd{tar --list --file=collection.tar}
4304 $ @kbd{tar --delete --file=collection.tar blues}
4305 $ @kbd{tar --list --file=collection.tar}
4312 @FIXME{I changed the order of these nodes around and haven't had a chance
4313 to fix the above example's results, yet. I have to play with this and
4314 follow it and see what it actually does!}
4316 The @value{op-delete} option has been reported to work properly when
4317 @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
4320 @subsection Comparing Archive Members with the File System
4321 @cindex Verifying the currency of an archive
4324 The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
4325 specified archive members against files with the same names, and then
4326 reports differences in file size, mode, owner, modification date and
4327 contents. You should @emph{only} specify archive member names, not file
4328 names. If you do not name any members, then @command{tar} will compare the
4329 entire archive. If a file is represented in the archive but does not
4330 exist in the file system, @command{tar} reports a difference.
4332 You have to specify the record size of the archive when modifying an
4333 archive with a non-default record size.
4335 @command{tar} ignores files in the file system that do not have
4336 corresponding members in the archive.
4338 The following example compares the archive members @file{rock},
4339 @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
4340 files of the same name in the file system. (Note that there is no file,
4341 @file{funk}; @command{tar} will report an error message.)
4344 $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
4347 tar: funk not found in archive
4351 @FIXME{what does this actually depend on? i'm making a guess,
4352 here.}Depending on the system where you are running @command{tar} and the
4353 version you are running, @command{tar} may have a different error message,
4357 funk: does not exist
4360 @FIXME-xref{somewhere, for more information about format parameters.
4361 Melissa says: such as "format variations"? But why? Clearly I don't
4362 get it yet; I'll deal when I get to that section.}
4364 The spirit behind the @value{op-compare} option is to check whether the
4365 archive represents the current state of files on disk, more than validating
4366 the integrity of the archive media. For this later goal, @xref{verify}.
4368 @node create options
4369 @section Options Used by @code{--create}
4371 The previous chapter described the basics of how to use
4372 @value{op-create} to create an archive from a set of files.
4373 @xref{create}. This section described advanced options to be used with
4377 * Ignore Failed Read::
4380 @node Ignore Failed Read
4381 @subsection Ignore Fail Read
4384 @item --ignore-failed-read
4385 Do not exit with nonzero on unreadable files or directories.
4388 @node extract options
4389 @section Options Used by @code{--extract}
4392 @FIXME{i need to get dan to go over these options with me and see if
4393 there's a better way of organizing them.}
4395 The previous chapter showed how to use @value{op-extract} to extract
4396 an archive into the filesystem. Various options cause @command{tar} to
4397 extract more information than just file contents, such as the owner,
4398 the permissions, the modification date, and so forth. This section
4399 presents options to be used with @samp{--extract} when certain special
4400 considerations arise. You may review the information presented in
4401 @ref{extract} for more basic information about the
4402 @samp{--extract} operation.
4405 * Reading:: Options to Help Read Archives
4406 * Writing:: Changing How @command{tar} Writes Files
4407 * Scarce:: Coping with Scarce Resources
4411 @subsection Options to Help Read Archives
4412 @cindex Options when reading archives
4413 @cindex Reading incomplete records
4414 @cindex Records, incomplete
4415 @cindex End-of-archive entries, ignoring
4416 @cindex Ignoring end-of-archive entries
4417 @cindex Large lists of file names on small machines
4418 @cindex Small memory
4419 @cindex Running out of space
4422 Normally, @command{tar} will request data in full record increments from
4423 an archive storage device. If the device cannot return a full record,
4424 @command{tar} will report an error. However, some devices do not always
4425 return full records, or do not require the last record of an archive to
4426 be padded out to the next record boundary. To keep reading until you
4427 obtain a full record, or to accept an incomplete record if it contains
4428 an end-of-archive marker, specify the @value{op-read-full-records} option
4429 in conjunction with the @value{op-extract} or @value{op-list} operations.
4430 @value{xref-read-full-records}.
4432 The @value{op-read-full-records} option is turned on by default when
4433 @command{tar} reads an archive from standard input, or from a remote
4434 machine. This is because on BSD Unix systems, attempting to read a
4435 pipe returns however much happens to be in the pipe, even if it is
4436 less than was requested. If this option were not enabled, @command{tar}
4437 would fail as soon as it read an incomplete record from the pipe.
4439 If you're not sure of the blocking factor of an archive, you can
4440 read the archive by specifying @value{op-read-full-records} and
4441 @value{op-blocking-factor}, using a blocking factor larger than what the
4442 archive uses. This lets you avoid having to determine the blocking factor
4443 of an archive. @value{xref-blocking-factor}.
4446 * read full records::
4450 @node read full records
4451 @unnumberedsubsubsec Reading Full Records
4453 @FIXME{need sentence or so of intro here}
4456 @item --read-full-records
4458 Use in conjunction with @value{op-extract} to read an archive which
4459 contains incomplete records, or one which has a blocking factor less
4460 than the one specified.
4464 @unnumberedsubsubsec Ignoring Blocks of Zeros
4466 Normally, @command{tar} stops reading when it encounters a block of zeros
4467 between file entries (which usually indicates the end of the archive).
4468 @value{op-ignore-zeros} allows @command{tar} to completely read an archive
4469 which contains a block of zeros before the end (i.e.@: a damaged
4470 archive, or one which was created by concatenating several archives
4473 The @value{op-ignore-zeros} option is turned off by default because many
4474 versions of @command{tar} write garbage after the end-of-archive entry,
4475 since that part of the media is never supposed to be read. @GNUTAR{}
4476 does not write after the end of an archive, but seeks to
4477 maintain compatiblity among archiving utilities.
4480 @item --ignore-zeros
4482 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
4483 encountered while reading an archive. Use in conjunction with
4484 @value{op-extract} or @value{op-list}.
4488 @subsection Changing How @command{tar} Writes Files
4489 @cindex Overwriting old files, prevention
4490 @cindex Protecting old files
4491 @cindex Modification times of extracted files
4492 @cindex Permissions of extracted files
4493 @cindex Modes of extracted files
4494 @cindex Writing extracted files to standard output
4495 @cindex Standard output, writing extracted files to
4498 @FIXME{need to mention the brand new option, --backup}
4501 * Dealing with Old Files::
4502 * Overwrite Old Files::
4504 * Keep Newer Files::
4506 * Recursive Unlink::
4507 * Modification Times::
4508 * Setting Access Permissions::
4509 * Writing to Standard Output::
4513 @node Dealing with Old Files
4514 @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
4516 When extracting files, if @command{tar} discovers that the extracted
4517 file already exists, it normally replaces the file by removing it before
4518 extracting it, to prevent confusion in the presence of hard or symbolic
4519 links. (If the existing file is a symbolic link, it is removed, not
4520 followed.) However, if a directory cannot be removed because it is
4521 nonempty, @command{tar} normally overwrites its metadata (ownership,
4522 permission, etc.). The @option{--overwrite-dir} option enables this
4523 default behavior. To be more cautious and preserve the metadata of
4524 such a directory, use the @option{--no-overwrite-dir} option.
4526 To be even more cautious and prevent existing files from being replaced, use
4527 the @value{op-keep-old-files} option. It causes @command{tar} to refuse
4528 to replace or update a file that already exists, i.e., a file with the
4529 same name as an archive member prevents extraction of that archive
4530 member. Instead, it reports an error.
4532 To be more aggressive about altering existing files, use the
4533 @value{op-overwrite} option. It causes @command{tar} to overwrite
4534 existing files and to follow existing symbolic links when extracting.
4536 Some people argue that @GNUTAR{} should not hesitate
4537 to overwrite files with other files when extracting. When extracting
4538 a @command{tar} archive, they expect to see a faithful copy of the
4539 state of the filesystem when the archive was created. It is debatable
4540 that this would always be a proper behavior. For example, suppose one
4541 has an archive in which @file{usr/local} is a link to
4542 @file{usr/local2}. Since then, maybe the site removed the link and
4543 renamed the whole hierarchy from @file{/usr/local2} to
4544 @file{/usr/local}. Such things happen all the time. I guess it would
4545 not be welcome at all that @GNUTAR{} removes the
4546 whole hierarchy just to make room for the link to be reinstated
4547 (unless it @emph{also} simultaneously restores the full
4548 @file{/usr/local2}, of course! @GNUTAR{} is indeed
4549 able to remove a whole hierarchy to reestablish a symbolic link, for
4550 example, but @emph{only if} @value{op-recursive-unlink} is specified
4551 to allow this behavior. In any case, single files are silently
4554 Finally, the @value{op-unlink-first} option can improve performance in
4555 some cases by causing @command{tar} to remove files unconditionally
4556 before extracting them.
4558 @node Overwrite Old Files
4559 @unnumberedsubsubsec Overwrite Old Files
4563 Overwrite existing files and directory metadata when extracting files
4567 causes @command{tar} to write extracted files into the file system without
4568 regard to the files already on the system; i.e., files with the same
4569 names as archive members are overwritten when the archive is extracted.
4570 It also causes @command{tar} to extract the ownership, permissions,
4571 and time stamps onto any preexisting files or directories.
4572 If the name of a corresponding file name is a symbolic link, the file
4573 pointed to by the symbolic link will be overwritten instead of the
4574 symbolic link itself (if this is possible). Moreover, special devices,
4575 empty directories and even symbolic links are automatically removed if
4576 they are in the way of extraction.
4578 Be careful when using the @value{op-overwrite} option, particularly when
4579 combined with the @value{op-absolute-names} option, as this combination
4580 can change the contents, ownership or permissions of any file on your
4581 system. Also, many systems do not take kindly to overwriting files that
4582 are currently being executed.
4584 @item --overwrite-dir
4585 Overwrite the metadata of directories when extracting files from an
4586 archive, but remove other files before extracting.
4589 @node Keep Old Files
4590 @unnumberedsubsubsec Keep Old Files
4593 @item --keep-old-files
4595 Do not replace existing files from archive. The
4596 @value{op-keep-old-files} option prevents @command{tar} from replacing
4597 existing files with files with the same name from the archive.
4598 The @value{op-keep-old-files} option is meaningless with @value{op-list}.
4599 Prevents @command{tar} from replacing files in the file system during
4603 @node Keep Newer Files
4604 @unnumberedsubsubsec Keep Newer Files
4607 @item --keep-newer-files
4608 Do not replace existing files that are newer than their archive
4609 copies. This option is meaningless with @value{op-list}.
4613 @unnumberedsubsubsec Unlink First
4616 @item --unlink-first
4618 Remove files before extracting over them.
4619 This can make @command{tar} run a bit faster if you know in advance
4620 that the extracted files all need to be removed. Normally this option
4621 slows @command{tar} down slightly, so it is disabled by default.
4624 @node Recursive Unlink
4625 @unnumberedsubsubsec Recursive Unlink
4628 @item --recursive-unlink
4629 When this option is specified, try removing files and directory hierarchies
4630 before extracting over them. @emph{This is a dangerous option!}
4633 If you specify the @value{op-recursive-unlink} option,
4634 @command{tar} removes @emph{anything} that keeps you from extracting a file
4635 as far as current permissions will allow it. This could include removal
4636 of the contents of a full directory hierarchy.
4638 @node Modification Times
4639 @unnumberedsubsubsec Setting Modification Times
4641 Normally, @command{tar} sets the modification times of extracted files to
4642 the modification times recorded for the files in the archive, but
4643 limits the permissions of extracted files by the current @code{umask}
4646 To set the modification times of extracted files to the time when
4647 the files were extracted, use the @value{op-touch} option in
4648 conjunction with @value{op-extract}.
4653 Sets the modification time of extracted archive members to the time
4654 they were extracted, not the time recorded for them in the archive.
4655 Use in conjunction with @value{op-extract}.
4658 @node Setting Access Permissions
4659 @unnumberedsubsubsec Setting Access Permissions
4661 To set the modes (access permissions) of extracted files to those
4662 recorded for those files in the archive, use @samp{--same-permissions}
4663 in conjunction with the @value{op-extract} operation. @FIXME{Should be
4664 aliased to ignore-umask.}
4667 @item --preserve-permission
4668 @itemx --same-permission
4669 @itemx --ignore-umask
4671 Set modes of extracted archive members to those recorded in the
4672 archive, instead of current umask settings. Use in conjunction with
4676 @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
4677 files together, why is this useful. is it really useful with
4678 more than one file?}
4680 @node Writing to Standard Output
4681 @unnumberedsubsubsec Writing to Standard Output
4683 To write the extracted files to the standard output, instead of
4684 creating the files on the file system, use @value{op-to-stdout} in
4685 conjunction with @value{op-extract}. This option is useful if you are
4686 extracting files to send them through a pipe, and do not need to
4687 preserve them in the file system. If you extract multiple members,
4688 they appear on standard output concatenated, in the order they are
4689 found in the archive.
4694 Writes files to the standard output. Used in conjunction with
4695 @value{op-extract}. Extract files to standard output. When this option
4696 is used, instead of creating the files specified, @command{tar} writes
4697 the contents of the files extracted to its standard output. This may
4698 be useful if you are only extracting the files in order to send them
4699 through a pipe. This option is meaningless with @value{op-list}.
4702 This can be useful, for example, if you have a tar archive containing
4703 a big file and don't want to store the file on disk before processing
4704 it. You can use a command like this:
4707 tar -xOzf foo.tgz bigfile | process
4710 or even like this if you want to process the concatenation of the files:
4713 tar -xOzf foo.tgz bigfile1 bigfile2 | process
4717 @unnumberedsubsubsec Removing Files
4719 @FIXME{the various macros in the front of the manual think that this
4720 option goes in this section. i have no idea; i only know it's nowhere
4721 else in the book...}
4724 @item --remove-files
4725 Remove files after adding them to the archive.
4729 @subsection Coping with Scarce Resources
4730 @cindex Middle of the archive, starting in the
4731 @cindex Running out of space during extraction
4732 @cindex Disk space, running out of
4733 @cindex Space on the disk, recovering from lack of
4742 @unnumberedsubsubsec Starting File
4745 @item --starting-file=@var{name}
4746 @itemx -K @var{name}
4747 Starts an operation in the middle of an archive. Use in conjunction
4748 with @value{op-extract} or @value{op-list}.
4751 If a previous attempt to extract files failed due to lack of disk
4752 space, you can use @value{op-starting-file} to start extracting only
4753 after member @var{name} of the archive. This assumes, of course, that
4754 there is now free space, or that you are now extracting into a
4755 different file system. (You could also choose to suspend @command{tar},
4756 remove unnecessary files from the file system, and then restart the
4757 same @command{tar} operation. In this case, @value{op-starting-file} is
4758 not necessary. @value{xref-incremental}, @value{xref-interactive},
4759 and @value{ref-exclude}.)
4762 @unnumberedsubsubsec Same Order
4766 @itemx --preserve-order
4768 To process large lists of file names on machines with small amounts of
4769 memory. Use in conjunction with @value{op-compare},
4771 or @value{op-extract}.
4774 @FIXME{we don't need/want --preserve to exist any more (from melissa:
4775 ie, don't want that *version* of the option to exist, or don't want
4776 the option to exist in either version?}
4778 @FIXME{i think this explanation is lacking.}
4780 The @value{op-same-order} option tells @command{tar} that the list of file
4781 names to be listed or extracted is sorted in the same order as the
4782 files in the archive. This allows a large list of names to be used,
4783 even on a small machine that would not otherwise be able to hold all
4784 the names in memory at the same time. Such a sorted list can easily be
4785 created by running @samp{tar -t} on the archive and editing its output.
4787 This option is probably never needed on modern computer systems.
4790 @section Backup options
4792 @cindex backup options
4794 @GNUTAR{} offers options for making backups of files
4795 before writing new versions. These options control the details of
4796 these backups. They may apply to the archive itself before it is
4797 created or rewritten, as well as individual extracted members. Other
4798 @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
4799 and @command{mv}, for example) offer similar options.
4801 Backup options may prove unexpectedly useful when extracting archives
4802 containing many members having identical name, or when extracting archives
4803 on systems having file name limitations, making different members appear
4804 has having similar names through the side-effect of name truncation.
4805 (This is true only if we have a good scheme for truncated backup names,
4806 which I'm not sure at all: I suspect work is needed in this area.)
4807 When any existing file is backed up before being overwritten by extraction,
4808 then clashing files are automatically be renamed to be unique, and the
4809 true name is kept for only the last file of a series of clashing files.
4810 By using verbose mode, users may track exactly what happens.
4812 At the detail level, some decisions are still experimental, and may
4813 change in the future, we are waiting comments from our users. So, please
4814 do not learn to depend blindly on the details of the backup features.
4815 For example, currently, directories themselves are never renamed through
4816 using these options, so, extracting a file over a directory still has
4817 good chances to fail. Also, backup options apply to created archives,
4818 not only to extracted members. For created archives, backups will not
4819 be attempted when the archive is a block or character device, or when it
4820 refers to a remote file.
4822 For the sake of simplicity and efficiency, backups are made by renaming old
4823 files prior to creation or extraction, and not by copying. The original
4824 name is restored if the file creation fails. If a failure occurs after a
4825 partial extraction of a file, both the backup and the partially extracted
4830 @item --backup[=@var{method}]
4832 @vindex VERSION_CONTROL
4834 Back up files that are about to be overwritten or removed.
4835 Without this option, the original versions are destroyed.
4837 Use @var{method} to determine the type of backups made.
4838 If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
4839 environment variable. And if @env{VERSION_CONTROL} is not set,
4840 use the @samp{existing} method.
4842 @vindex version-control @r{Emacs variable}
4843 This option corresponds to the Emacs variable @samp{version-control};
4844 the same values for @var{method} are accepted as in Emacs. This option
4845 also allows more descriptive names. The valid @var{method}s are:
4850 @opindex numbered @r{backup method}
4851 Always make numbered backups.
4855 @opindex existing @r{backup method}
4856 Make numbered backups of files that already have them, simple backups
4861 @opindex simple @r{backup method}
4862 Always make simple backups.
4866 @item --suffix=@var{suffix}
4868 @cindex backup suffix
4869 @vindex SIMPLE_BACKUP_SUFFIX
4870 Append @var{suffix} to each backup file made with @samp{--backup}. If this
4871 option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
4872 environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
4873 set, the default is @samp{~}, just as in Emacs.
4877 Some people express the desire to @emph{always} use the @value{op-backup}
4878 option, by defining some kind of alias or script. This is not as easy
4879 as one may think, due to the fact that old style options should appear first
4880 and consume arguments a bit unpredictably for an alias or script. But,
4881 if you are ready to give up using old style options, you may resort to
4882 using something like (a Bourne shell function here):
4885 tar () @{ /usr/local/bin/tar --backup $*; @}
4889 @section Notable @command{tar} Usages
4892 @FIXME{Using Unix file linking capability to recreate directory
4893 structures---linking files into one subdirectory and then
4894 @command{tar}ring that directory.}
4896 @FIXME{Nice hairy example using absolute-names, newer, etc.}
4899 You can easily use archive files to transport a group of files from
4900 one system to another: put all relevant files into an archive on one
4901 computer system, transfer the archive to another system, and extract
4902 the contents there. The basic transfer medium might be magnetic tape,
4903 Internet FTP, or even electronic mail (though you must encode the
4904 archive with @command{uuencode} in order to transport it properly by
4905 mail). Both machines do not have to use the same operating system, as
4906 long as they both support the @command{tar} program.
4908 For example, here is how you might copy a directory's contents from
4909 one disk to another, while preserving the dates, modes, owners and
4910 link-structure of all the files therein. In this case, the transfer
4911 medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
4914 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
4918 The command also works using short option forms:
4921 $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
4925 This is one of the easiest methods to transfer a @command{tar} archive.
4928 @section Looking Ahead: The Rest of this Manual
4930 You have now seen how to use all eight of the operations available to
4931 @command{tar}, and a number of the possible options. The next chapter
4932 explains how to choose and change file and archive names, how to use
4933 files to store names of other files which you can then call as
4934 arguments to @command{tar} (this can help you save time if you expect to
4935 archive the same list of files a number of times), and so forth.
4936 @FIXME{in case it's not obvious, i'm making this up in some sense
4937 based on my limited memory of what the next chapter *really* does. i
4938 just wanted to flesh out this final section a little bit so i'd
4939 remember to stick it in here. :-)}
4941 If there are too many files to conveniently list on the command line,
4942 you can list the names in a file, and @command{tar} will read that file.
4943 @value{xref-files-from}.
4945 There are various ways of causing @command{tar} to skip over some files,
4946 and not archive them. @xref{Choosing}.
4949 @chapter Performing Backups and Restoring Files
4952 @GNUTAR{} is distributed along with the scripts
4953 which the Free Software Foundation uses for performing backups. There
4954 is no corresponding scripts available yet for doing restoration of
4955 files. Even if there is a good chance those scripts may be satisfying
4956 to you, they are not the only scripts or methods available for doing
4957 backups and restore. You may well create your own, or use more
4958 sophisticated packages dedicated to that purpose.
4960 Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
4961 Automatic Network Disk Archiver), a backup system developed by James
4962 da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
4963 This is free software, and it is available at these places:
4966 http://www.cs.umd.edu/projects/amanda/amanda.html
4967 ftp://ftp.cs.umd.edu/pub/amanda
4972 Here is a possible plan for a future documentation about the backuping
4973 scripts which are provided within the @GNUTAR{}
4980 . + different levels of dumps
4981 . - full dump = dump everything
4982 . - level 1, level 2 dumps etc, -
4983 A level n dump dumps everything changed since the last level
4986 . + how to use scripts for dumps (ie, the concept)
4987 . - scripts to run after editing backup specs (details)
4989 . + Backup Specs, what is it.
4990 . - how to customize
4991 . - actual text of script [/sp/dump/backup-specs]
4994 . - rsh doesn't work
4995 . - rtape isn't installed
4998 . + the --incremental option of tar
5001 . - write protection
5003 . : different sizes and types, useful for different things
5004 . - files and tape marks
5005 one tape mark between files, two at end.
5006 . - positioning the tape
5007 MT writes two at end of write,
5008 backspaces over one when writing again.
5013 This chapter documents both the provided FSF scripts and @command{tar}
5014 options which are more specific to usage as a backup tool.
5016 To @dfn{back up} a file system means to create archives that contain
5017 all the files in that file system. Those archives can then be used to
5018 restore any or all of those files (for instance if a disk crashes or a
5019 file is accidentally deleted). File system @dfn{backups} are also
5023 * Full Dumps:: Using @command{tar} to Perform Full Dumps
5024 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
5025 * incremental and listed-incremental:: The Incremental Options
5026 * Backup Levels:: Levels of Backups
5027 * Backup Parameters:: Setting Parameters for Backups and Restoration
5028 * Scripted Backups:: Using the Backup Scripts
5029 * Scripted Restoration:: Using the Restore Script
5033 @section Using @command{tar} to Perform Full Dumps
5039 @cindex corrupted archives
5040 Full dumps should only be made when no other people or programs
5041 are modifying files in the filesystem. If files are modified while
5042 @command{tar} is making the backup, they may not be stored properly in
5043 the archive, in which case you won't be able to restore them if you
5044 have to. (Files not being modified are written with no trouble, and do
5045 not corrupt the entire archive.)
5047 You will want to use the @value{op-label} option to give the archive a
5048 volume label, so you can tell what this archive is even if the label
5049 falls off the tape, or anything like that.
5051 Unless the filesystem you are dumping is guaranteed to fit on
5052 one volume, you will need to use the @value{op-multi-volume} option.
5053 Make sure you have enough tapes on hand to complete the backup.
5055 If you want to dump each filesystem separately you will need to use
5056 the @value{op-one-file-system} option to prevent @command{tar} from crossing
5057 filesystem boundaries when storing (sub)directories.
5059 The @value{op-incremental} option is not needed, since this is a complete
5060 copy of everything in the filesystem, and a full restore from this
5061 backup would only be done onto a completely empty disk.
5063 Unless you are in a hurry, and trust the @command{tar} program (and your
5064 tapes), it is a good idea to use the @value{op-verify} option, to make
5065 sure your files really made it onto the dump properly. This will
5066 also detect cases where the file was modified while (or just after)
5067 it was being archived. Not all media (notably cartridge tapes) are
5068 capable of being verified, unfortunately.
5070 @value{op-listed-incremental} take a file name argument always. If the
5071 file doesn't exist, run a level zero dump, creating the file. If the
5072 file exists, uses that file to see what has changed.
5074 @value{op-incremental} @FIXME{look it up}
5076 @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
5078 This option should only be used when creating an incremental backup of
5079 a filesystem. When the @value{op-incremental} option is used, @command{tar}
5080 writes, at the beginning of the archive, an entry for each of the
5081 directories that will be operated on. The entry for a directory
5082 includes a list of all the files in the directory at the time the
5083 dump was done, and a flag for each file indicating whether the file
5084 is going to be put in the archive. This information is used when
5085 doing a complete incremental restore.
5087 Note that this option causes @command{tar} to create a non-standard
5088 archive that may not be readable by non-@acronym{GNU} versions of the
5089 @command{tar} program.
5091 The @value{op-incremental} option means the archive is an incremental
5092 backup. Its meaning depends on the command that it modifies.
5094 If the @value{op-incremental} option is used with @value{op-list},
5095 @command{tar} will list, for each directory in the archive, the list
5096 of files in that directory at the time the archive was created. This
5097 information is put out in a format that is not easy for humans to
5098 read, but which is unambiguous for a program: each file name is
5099 preceded by either a @samp{Y} if the file is present in the archive,
5100 an @samp{N} if the file is not included in the archive, or a @samp{D}
5101 if the file is a directory (and is included in the archive). Each
5102 file name is terminated by a null character. The last file is
5103 followed by an additional null and a newline to indicate the end of
5106 If the @value{op-incremental} option is used with @value{op-extract}, then
5107 when the entry for a directory is found, all files that currently
5108 exist in that directory but are not listed in the archive @emph{are
5109 deleted from the directory}.
5111 This behavior is convenient when you are restoring a damaged file
5112 system from a succession of incremental backups: it restores the
5113 entire state of the file system to that which obtained when the backup
5114 was made. If you don't use @value{op-incremental}, the file system will
5115 probably fill up with files that shouldn't exist any more.
5117 @value{op-listed-incremental} handle new @acronym{GNU}-format
5118 incremental backup. This option handles new @acronym{GNU}-format
5119 incremental backup. It has much the same effect as
5120 @value{op-incremental}, but also the time when the dump is done and
5121 the list of directories dumped is written to the given
5122 @var{file}. When restoring, only files newer than the saved time are
5123 restored, and the directory list is used to speed up operations.
5125 @value{op-listed-incremental} acts like @value{op-incremental}, but when
5126 used in conjunction with @value{op-create} will also cause @command{tar} to
5127 use the file @var{file}, which contains information about the state
5128 of the filesystem at the time of the last backup, to decide which
5129 files to include in the archive being created. That file will then
5130 be updated by @command{tar}. If the file @var{file} does not exist when
5131 this option is specified, @command{tar} will create it, and include all
5132 appropriate files in the archive.
5134 The file, which is archive independent, contains the date it was last
5135 modified and a list of devices, inode numbers and directory names.
5136 @command{tar} will archive files with newer mod dates or inode change
5137 times, and directories with an unchanged inode number and device but
5138 a changed directory name. The file is updated after the files to
5139 be archived are determined, but before the new archive is actually
5143 @section Using @command{tar} to Perform Incremental Dumps
5146 @cindex incremental dumps
5147 @cindex dumps, incremental
5149 Performing incremental dumps is similar to performing full dumps,
5150 although a few more options will usually be needed.
5152 A standard scheme is to do a @emph{monthly} (full) dump once a month,
5153 a @emph{weekly} dump once a week of everything since the last monthly
5154 and a @emph{daily} every day of everything since the last (weekly or
5157 Here is a sample script to dump the directory hierarchies @samp{/usr}
5163 --blocking-factor=126 \
5165 --label="`hostname` /usr /var `date +%Y-%m-%d`" \
5166 --listed-incremental=/var/log/usr-var.snar \
5171 This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
5172 store information about the previous tar dump.
5174 The blocking factor 126 is an attempt to make the tape drive stream.
5175 Some tape devices cannot handle 64 kB blocks or larger, and require the
5176 block size to be a multiple of 1 kB; for these devices, 126 is the
5177 largest blocking factor that can be used.
5179 @node incremental and listed-incremental
5180 @section The Incremental Options
5183 @value{op-incremental} is used in conjunction with @value{op-create},
5184 @value{op-extract} or @value{op-list} when backing up and restoring file
5185 systems. An archive cannot be extracted or listed with the
5186 @value{op-incremental} option specified unless it was created with the
5187 option specified. This option should only be used by a script, not by
5188 the user, and is usually disregarded in favor of
5189 @value{op-listed-incremental}, which is described below.
5191 @value{op-incremental} in conjunction with @value{op-create} causes
5192 @command{tar} to write, at the beginning of the archive, an entry for
5193 each of the directories that will be archived. The entry for a
5194 directory includes a list of all the files in the directory at the
5195 time the archive was created and a flag for each file indicating
5196 whether or not the file is going to be put in the archive.
5198 Note that this option causes @command{tar} to create a non-standard
5199 archive that may not be readable by non-@acronym{GNU} versions of the
5200 @command{tar} program.
5202 @value{op-incremental} in conjunction with @value{op-extract} causes
5203 @command{tar} to read the lists of directory contents previously stored
5204 in the archive, @emph{delete} files in the file system that did not
5205 exist in their directories when the archive was created, and then
5206 extract the files in the archive.
5208 This behavior is convenient when restoring a damaged file system from
5209 a succession of incremental backups: it restores the entire state of
5210 the file system to that which obtained when the backup was made. If
5211 @value{op-incremental} isn't specified, the file system will probably
5212 fill up with files that shouldn't exist any more.
5214 @value{op-incremental} in conjunction with @value{op-list} causes
5215 @command{tar} to print, for each directory in the archive, the list of
5216 files in that directory at the time the archive was created. This
5217 information is put out in a format that is not easy for humans to
5218 read, but which is unambiguous for a program: each file name is
5219 preceded by either a @samp{Y} if the file is present in the archive,
5220 an @samp{N} if the file is not included in the archive, or a @samp{D}
5221 if the file is a directory (and is included in the archive). Each
5222 file name is terminated by a null character. The last file is followed
5223 by an additional null and a newline to indicate the end of the data.
5225 @value{op-listed-incremental} acts like @value{op-incremental}, but when
5226 used in conjunction with @value{op-create} will also cause @command{tar}
5227 to use the file @var{snapshot-file}, which contains information about
5228 the state of the file system at the time of the last backup, to decide
5229 which files to include in the archive being created. That file will
5230 then be updated by @command{tar}. If the file @var{file} does not exist
5231 when this option is specified, @command{tar} will create it, and include
5232 all appropriate files in the archive.
5234 The file @var{file}, which is archive independent, contains the date
5235 it was last modified and a list of devices, inode numbers and
5236 directory names. @command{tar} will archive files with newer mod dates
5237 or inode change times, and directories with an unchanged inode number
5238 and device but a changed directory name. The file is updated after
5239 the files to be archived are determined, but before the new archive is
5242 Incremental dumps depend crucially on time stamps, so the results are
5243 unreliable if you modify a file's time stamps during dumping (e.g.@:
5244 with the @samp{--atime-preserve} option), or if you set the clock
5247 Despite it should be obvious that a device has a non-volatile value, NFS
5248 devices have non-dependable values when an automounter gets in the picture.
5249 This led to a great deal of spurious redumping in incremental dumps,
5250 so it is somewhat useless to compare two NFS devices numbers over time.
5251 So @command{tar} now considers all NFS devices as being equal when it comes
5252 to comparing directories; this is fairly gross, but there does not seem
5253 to be a better way to go.
5255 @command{tar} doesn't access @var{snapshot-file} when
5256 @value{op-create} or @value{op-list} are specified, but the
5257 @value{op-listed-incremental} option must still be given. A
5258 placeholder @var{snapshot-file} can be specified, e.g.,
5261 @FIXME{this section needs to be written}
5264 @section Levels of Backups
5267 An archive containing all the files in the file system is called a
5268 @dfn{full backup} or @dfn{full dump}. You could insure your data by
5269 creating a full dump every day. This strategy, however, would waste a
5270 substantial amount of archive media and user time, as unchanged files
5271 are daily re-archived.
5273 It is more efficient to do a full dump only occasionally. To back up
5274 files between full dumps, you can a incremental dump. A @dfn{level
5275 one} dump archives all the files that have changed since the last full
5278 A typical dump strategy would be to perform a full dump once a week,
5279 and a level one dump once a day. This means some versions of files
5280 will in fact be archived more than once, but this dump strategy makes
5281 it possible to restore a file system to within one day of accuracy by
5282 only extracting two archives---the last weekly (full) dump and the
5283 last daily (level one) dump. The only information lost would be in
5284 files changed or created since the last daily backup. (Doing dumps
5285 more than once a day is usually not worth the trouble).
5287 @GNUTAR{} comes with scripts you can use to do full
5288 and level-one dumps. Using scripts (shell programs) to perform
5289 backups and restoration is a convenient and reliable alternative to
5290 typing out file name lists and @command{tar} commands by hand.
5292 Before you use these scripts, you need to edit the file
5293 @file{backup-specs}, which specifies parameters used by the backup
5294 scripts and by the restore script. @FIXME{There is no such restore
5295 script!}@FIXME-xref{Script Syntax}Once the backup parameters
5296 are set, you can perform backups or restoration by running the
5299 The name of the restore script is @code{restore}. @FIXME{There is
5300 no such restore script!}The names of the level one and full backup
5301 scripts are, respectively, @code{level-1} and @code{level-0}.
5302 The @code{level-0} script also exists under the name @code{weekly}, and
5303 the @code{level-1} under the name @code{daily}---these additional names
5304 can be changed according to your backup schedule. @FIXME-xref{Scripted
5305 Restoration, for more information on running the restoration script.}
5306 @FIXME-xref{Scripted Backups, for more information on running the
5309 @emph{Please Note:} The backup scripts and the restoration scripts are
5310 designed to be used together. While it is possible to restore files by
5311 hand from an archive which was created using a backup script, and to create
5312 an archive by hand which could then be extracted using the restore script,
5313 it is easier to use the scripts.@FIXME{There is no such restore script!}
5314 @value{xref-incremental}, and @value{xref-listed-incremental},
5315 before making such an attempt.
5317 @FIXME{shorten node names}
5319 @node Backup Parameters
5320 @section Setting Parameters for Backups and Restoration
5323 The file @file{backup-specs} specifies backup parameters for the
5324 backup and restoration scripts provided with @command{tar}. You must
5325 edit @file{backup-specs} to fit your system configuration and schedule
5326 before using these scripts.
5328 @FIXME{This about backup scripts needs to be written: BS is a shell
5329 script .... thus ... @file{backup-specs} is in shell script syntax.}
5331 @FIXME-xref{Script Syntax, for an explanation of this syntax.}
5333 @FIXME{Whats a parameter .... looked at by the backup scripts
5334 ... which will be expecting to find ... now syntax ... value is linked
5335 to lame ... @file{backup-specs} specifies the following parameters:}
5339 The user name of the backup administrator.
5342 The hour at which the backups are done. This can be a number from 0
5343 to 23, or the string @samp{now}.
5346 The device @command{tar} writes the archive to. This device should be
5347 attached to the host on which the dump scripts are run.
5349 @FIXME{examples for all ...}
5352 The command to use to obtain the status of the archive device,
5353 including error count. On some tape drives there may not be such a
5354 command; in that case, simply use @samp{TAPE_STATUS=false}.
5357 The blocking factor @command{tar} will use when writing the dump archive.
5358 @value{xref-blocking-factor}.
5361 A list of file systems to be dumped. You can include any directory
5362 name in the list---subdirectories on that file system will be
5363 included, regardless of how they may look to other networked machines.
5364 Subdirectories on other file systems will be ignored.
5366 The host name specifies which host to run @command{tar} on, and should
5367 normally be the host that actually contains the file system. However,
5368 the host machine must have @GNUTAR{} installed, and
5369 must be able to access the directory containing the backup scripts and
5370 their support files using the same file name that is used on the
5371 machine where the scripts are run (ie. what @command{pwd} will print
5372 when in that directory on that machine). If the host that contains
5373 the file system does not have this capability, you can specify another
5374 host as long as it can access the file system through NFS.
5377 A list of individual files to be dumped. These should be accessible
5378 from the machine on which the backup script is run.
5380 @FIXME{Same file name, be specific. Through NFS ...}
5385 * backup-specs example:: An Example Text of @file{Backup-specs}
5386 * Script Syntax:: Syntax for @file{Backup-specs}
5389 @node backup-specs example
5390 @subsection An Example Text of @file{Backup-specs}
5393 The following is the text of @file{backup-specs} as it appears at FSF:
5396 # site-specific parameters for file system backup.
5398 ADMINISTRATOR=friedman
5400 TAPE_FILE=/dev/nrsmt0
5401 TAPE_STATUS="mts -t $TAPE_FILE"
5416 apple-gunkies:/com/mailer/gnu
5417 apple-gunkies:/com/archive/gnu"
5419 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
5424 @subsection Syntax for @file{Backup-specs}
5427 @file{backup-specs} is in shell script syntax. The following
5428 conventions should be considered when editing the script:
5429 @FIXME{"conventions?"}
5431 A quoted string is considered to be contiguous, even if it is on more
5432 than one line. Therefore, you cannot include commented-out lines
5433 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
5434 the two most likely parameters to be multi-line.
5436 A quoted string typically cannot contain wildcards. In
5437 @file{backup-specs}, however, the parameters BACKUP_DIRS and
5438 BACKUP_FILES can contain wildcards.
5440 @node Scripted Backups
5441 @section Using the Backup Scripts
5444 The syntax for running a backup script is:
5447 @file{script-name} [@var{time-to-be-run}]
5450 where @var{time-to-be-run} can be a specific system time, or can be
5451 @kbd{now}. If you do not specify a time, the script runs at the time
5452 specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
5454 You should start a script with a tape or disk mounted. Once you
5455 start a script, it prompts you for new tapes or disks as it
5456 needs them. Media volumes don't have to correspond to archive
5457 files---a multi-volume archive can be started in the middle of a
5458 tape that already contains the end of another multi-volume archive.
5459 The @code{restore} script prompts for media by its archive volume,
5460 so to avoid an error message you should keep track of which tape
5461 (or disk) contains which volume of the archive. @FIXME{There is
5462 no such restore script!} @FIXME-xref{Scripted Restoration}
5463 @FIXME{Have file names changed?}
5465 The backup scripts write two files on the file system. The first is a
5466 record file in @file{/etc/tar-backup/}, which is used by the scripts
5467 to store and retrieve information about which files were dumped. This
5468 file is not meant to be read by humans, and should not be deleted by
5469 them. @FIXME-xref{incremental and listed-incremental, for a more
5470 detailed explanation of this file.}
5472 The second file is a log file containing the names of the file systems
5473 and files dumped, what time the backup was made, and any error
5474 messages that were generated, as well as how much space was left in
5475 the media volume after the last volume of the archive was written.
5476 You should check this log file after every backup. The file name is
5477 @file{log-@var{mmm-ddd-yyyy}-level-1} or
5478 @file{log-@var{mmm-ddd-yyyy}-full}.
5480 The script also prints the name of each system being dumped to the
5483 @node Scripted Restoration
5484 @section Using the Restore Script
5489 The @command{tar} distribution does not provide restoring scripts.
5496 @strong{Warning:} The @GNUTAR{} distribution does @emph{not}
5497 provide any such @code{restore} script yet. This section is only
5498 listed here for documentation maintenance purposes. In any case,
5499 all contents is subject to change as things develop.
5502 @FIXME{A section on non-scripted restore may be a good idea.}
5504 To restore files that were archived using a scripted backup, use the
5505 @code{restore} script. The syntax for the script is:
5507 where ***** are the file systems to restore from, and
5508 ***** is a regular expression which specifies which files to
5509 restore. If you specify --all, the script restores all the files
5512 You should start the restore script with the media containing the
5513 first volume of the archive mounted. The script will prompt for other
5514 volumes as they are needed. If the archive is on tape, you don't need
5515 to rewind the tape to to its beginning---if the tape head is
5516 positioned past the beginning of the archive, the script will rewind
5517 the tape as needed. @FIXME-xref{Media, for a discussion of tape
5520 If you specify @samp{--all} as the @var{files} argument, the
5521 @code{restore} script extracts all the files in the archived file
5522 system into the active file system.
5525 @strong{Warning:} The script will delete files from the active file
5526 system if they were not in the file system when the archive was made.
5529 @value{xref-incremental}, and @value{ref-listed-incremental},
5530 for an explanation of how the script makes that determination.
5532 @FIXME{this may be an option, not a given}
5537 @chapter Choosing Files and Names for @command{tar}
5540 @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
5542 Certain options to @command{tar} enable you to specify a name for your
5543 archive. Other options let you decide which files to include or exclude
5544 from the archive, based on when or whether files were modified, whether
5545 the file names do or don't match specified patterns, or whether files
5546 are in specified directories.
5549 * file:: Choosing the Archive's Name
5550 * Selecting Archive Members::
5551 * files:: Reading Names from a File
5552 * exclude:: Excluding Some Files
5554 * after:: Operating Only on New Files
5555 * recurse:: Descending into Directories
5556 * one:: Crossing Filesystem Boundaries
5560 @section Choosing and Naming Archive Files
5561 @cindex Naming an archive
5562 @cindex Archive Name
5563 @cindex Directing output
5564 @cindex Choosing an archive file
5565 @cindex Where is the archive?
5568 @FIXME{should the title of this section actually be, "naming an
5571 By default, @command{tar} uses an archive file name that was compiled when
5572 it was built on the system; usually this name refers to some physical
5573 tape drive on the machine. However, the person who installed @command{tar}
5574 on the system may not set the default to a meaningful value as far as
5575 most users are concerned. As a result, you will usually want to tell
5576 @command{tar} where to find (or create) the archive. The @value{op-file}
5577 option allows you to either specify or name a file to use as the archive
5578 instead of the default archive file location.
5581 @item --file=@var{archive-name}
5582 @itemx -f @var{archive-name}
5583 Name the archive to create or operate on. Use in conjunction with
5587 For example, in this @command{tar} command,
5590 $ @kbd{tar -cvf collection.tar blues folk jazz}
5594 @file{collection.tar} is the name of the archive. It must directly
5595 follow the @samp{-f} option, since whatever directly follows @samp{-f}
5596 @emph{will} end up naming the archive. If you neglect to specify an
5597 archive name, you may end up overwriting a file in the working directory
5598 with the archive you create since @command{tar} will use this file's name
5599 for the archive name.
5601 An archive can be saved as a file in the file system, sent through a
5602 pipe or over a network, or written to an I/O device such as a tape,
5603 floppy disk, or CD write drive.
5605 @cindex Writing new archives
5606 @cindex Archive creation
5607 If you do not name the archive, @command{tar} uses the value of the
5608 environment variable @env{TAPE} as the file name for the archive. If
5609 that is not available, @command{tar} uses a default, compiled-in archive
5610 name, usually that for tape unit zero (ie. @file{/dev/tu00}).
5611 @command{tar} always needs an archive name.
5613 If you use @file{-} as an @var{archive-name}, @command{tar} reads the
5614 archive from standard input (when listing or extracting files), or
5615 writes it to standard output (when creating an archive). If you use
5616 @file{-} as an @var{archive-name} when modifying an archive,
5617 @command{tar} reads the original archive from its standard input and
5618 writes the entire new archive to its standard output.
5620 @FIXME{might want a different example here; this is already used in
5621 "notable tar usages".}
5624 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
5629 @cindex Standard input and output
5630 @cindex tar to standard input and output
5631 To specify an archive file on a device attached to a remote machine,
5635 @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
5639 @command{tar} will complete the remote connection, if possible, and
5640 prompt you for a username and password. If you use
5641 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
5642 will complete the remote connection, if possible, using your username
5643 as the username on the remote machine.
5645 If the archive file name includes a colon (@samp{:}), then it is assumed
5646 to be a file on another machine. If the archive file is
5647 @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
5648 host @var{host}. The remote host is accessed using the @command{rsh}
5649 program, with a username of @var{user}. If the username is omitted
5650 (along with the @samp{@@} sign), then your user name will be used.
5651 (This is the normal @command{rsh} behavior.) It is necessary for the
5652 remote machine, in addition to permitting your @command{rsh} access, to
5653 have the @file{/usr/ucb/rmt} program installed. If you need to use a
5654 file whose name includes a colon, then the remote tape drive behavior
5655 can be inhibited by using the @value{op-force-local} option.
5657 @FIXME{i know we went over this yesterday, but bob (and now i do again,
5658 too) thinks it's out of the middle of nowhere. it doesn't seem to tie
5659 into what came before it well enough <<i moved it now, is it better
5660 here?>>. bob also comments that if Amanda isn't free software, we
5661 shouldn't mention it..}
5663 When the archive is being created to @file{/dev/null}, @GNUTAR{}
5664 tries to minimize input and output operations. The
5665 Amanda backup system, when used with @GNUTAR{}, has
5666 an initial sizing pass which uses this feature.
5668 @node Selecting Archive Members
5669 @section Selecting Archive Members
5670 @cindex Specifying files to act on
5671 @cindex Specifying archive members
5673 @dfn{File Name arguments} specify which files in the file system
5674 @command{tar} operates on, when creating or adding to an archive, or which
5675 archive members @command{tar} operates on, when reading or deleting from
5676 an archive. @xref{Operations}.
5678 To specify file names, you can include them as the last arguments on
5679 the command line, as follows:
5681 @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
5684 If you specify a directory name as a file name argument, all the files
5685 in that directory are operated on by @command{tar}.
5687 If you do not specify files when @command{tar} is invoked with
5688 @value{op-create}, @command{tar} operates on all the non-directory files in
5689 the working directory. If you specify either @value{op-list} or
5690 @value{op-extract}, @command{tar} operates on all the archive members in the
5691 archive. If you specify any operation other than one of these three,
5692 @command{tar} does nothing.
5694 By default, @command{tar} takes file names from the command line. However,
5695 there are other ways to specify file or member names, or to modify the
5696 manner in which @command{tar} selects the files or members upon which to
5697 operate. @FIXME{add xref here}In general, these methods work both for
5698 specifying the names of files and archive members.
5701 @section Reading Names from a File
5704 @cindex Reading file names from a file
5705 @cindex Lists of file names
5706 @cindex File Name arguments, alternatives
5707 Instead of giving the names of files or archive members on the command
5708 line, you can put the names into a file, and then use the
5709 @value{op-files-from} option to @command{tar}. Give the name of the file
5710 which contains the list of files to include as the argument to
5711 @samp{--files-from}. In the list, the file names should be separated by
5712 newlines. You will frequently use this option when you have generated
5713 the list of files to archive with the @command{find} utility.
5716 @item --files-from=@var{file name}
5717 @itemx -T @var{file name}
5718 Get names to extract or create from file @var{file name}.
5721 If you give a single dash as a file name for @samp{--files-from}, (i.e.,
5722 you specify either @samp{--files-from=-} or @samp{-T -}), then the file
5723 names are read from standard input.
5725 Unless you are running @command{tar} with @samp{--create}, you can not use
5726 both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
5729 @FIXME{add bob's example, from his message on 2-10-97}
5731 The following example shows how to use @command{find} to generate a list of
5732 files smaller than 400K in length and put that list into a file
5733 called @file{small-files}. You can then use the @samp{-T} option to
5734 @command{tar} to specify the files from that file, @file{small-files}, to
5735 create the archive @file{little.tgz}. (The @samp{-z} option to
5736 @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
5740 $ @kbd{find . -size -400 -print > small-files}
5741 $ @kbd{tar -c -v -z -T small-files -f little.tgz}
5745 @FIXME{say more here to conclude the example/section?}
5752 @subsection @kbd{NUL} Terminated File Names
5754 @cindex File names, terminated by @kbd{NUL}
5755 @cindex @kbd{NUL} terminated file names
5756 The @value{op-null} option causes @value{op-files-from} to read file
5757 names terminated by a @code{NUL} instead of a newline, so files whose
5758 names contain newlines can be archived using @samp{--files-from}.
5762 Only consider @kbd{NUL} terminated file names, instead of files that
5763 terminate in a newline.
5766 The @samp{--null} option is just like the one in @acronym{GNU}
5767 @command{xargs} and @command{cpio}, and is useful with the
5768 @samp{-print0} predicate of @acronym{GNU} @command{find}. In
5769 @command{tar}, @samp{--null} also causes @value{op-directory} options
5770 to be treated as file names to archive, in case there are any files
5771 out there called @file{-C}.
5773 This example shows how to use @command{find} to generate a list of files
5774 larger than 800K in length and put that list into a file called
5775 @file{long-files}. The @samp{-print0} option to @command{find} just just
5776 like @samp{-print}, except that it separates files with a @kbd{NUL}
5777 rather than with a newline. You can then run @command{tar} with both the
5778 @samp{--null} and @samp{-T} options to specify that @command{tar} get the
5779 files from that file, @file{long-files}, to create the archive
5780 @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
5781 @command{tar} to recognize the @kbd{NUL} separator between files.
5784 $ @kbd{find . -size +800 -print0 > long-files}
5785 $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
5788 @FIXME{say anything else here to conclude the section?}
5791 @section Excluding Some Files
5792 @cindex File names, excluding files by
5793 @cindex Excluding files by name and pattern
5794 @cindex Excluding files by file system
5797 To avoid operating on files whose names match a particular pattern,
5798 use the @value{op-exclude} or @value{op-exclude-from} options.
5801 @item --exclude=@var{pattern}
5802 Causes @command{tar} to ignore files that match the @var{pattern}.
5806 The @value{op-exclude} option prevents any file or member whose name
5807 matches the shell wildcard (@var{pattern}) from being operated on.
5808 For example, to create an archive with all the contents of the directory
5809 @file{src} except for files whose names end in @file{.o}, use the
5810 command @samp{tar -cf src.tar --exclude='*.o' src}.
5812 You may give multiple @samp{--exclude} options.
5815 @item --exclude-from=@var{file}
5816 @itemx -X @var{file}
5817 Causes @command{tar} to ignore files that match the patterns listed in
5821 @findex exclude-from
5822 Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
5823 list of patterns, one per line, from @var{file}; @command{tar} will
5824 ignore files matching those patterns. Thus if @command{tar} is
5825 called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
5826 single line @file{*.o}, no files whose names end in @file{.o} will be
5827 added to the archive.
5829 @FIXME{do the exclude options files need to have stuff separated by
5830 newlines the same as the files-from option does?}
5833 * controlling pattern-patching with exclude::
5834 * problems with exclude::
5837 @node controlling pattern-patching with exclude
5838 @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
5840 Normally, a pattern matches a name if an initial subsequence of the
5841 name's components matches the pattern, where @samp{*}, @samp{?}, and
5842 @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
5843 and wildcards can match @samp{/}.
5845 Other than optionally stripping leading @samp{/} from names
5846 (@pxref{absolute}), patterns and names are used as-is. For
5847 example, trailing @samp{/} is not trimmed from a user-specified name
5848 before deciding whether to exclude it.
5850 However, this matching procedure can be altered by the options listed
5851 below. These options accumulate. For example:
5854 --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
5857 ignores case when excluding @samp{makefile}, but not when excluding
5862 @itemx --no-anchored
5863 If anchored (the default), a pattern must match an initial subsequence
5864 of the name's components. Otherwise, the pattern can match any subsequence.
5867 @itemx --no-ignore-case
5868 When ignoring case, upper-case patterns match lower-case names and vice versa.
5869 When not ignoring case (the default), matching is case-sensitive.
5872 @itemx --no-wildcards
5873 When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
5874 are the usual shell wildcards, and @samp{\} escapes wildcards.
5875 Otherwise, none of these characters are special, and patterns must match
5878 @item --wildcards-match-slash
5879 @itemx --no-wildcards-match-slash
5880 When wildcards match slash (the default), a wildcard like @samp{*} in
5881 the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
5882 matched only by @samp{/}.
5886 The @option{--recursion} and @option{--no-recursion} options
5887 (@pxref{recurse}) also affect how exclude patterns are interpreted. If
5888 recursion is in effect, a pattern excludes a name if it matches any of
5889 the name's parent directories.
5891 @node problems with exclude
5892 @unnumberedsubsec Problems with Using the @code{exclude} Options
5894 Some users find @samp{exclude} options confusing. Here are some common
5899 The main operating mode of @command{tar} does not act on a path name
5900 explicitly listed on the command line if one of its file name
5901 components is excluded. In the example above, if
5902 you create an archive and exclude files that end with @samp{*.o}, but
5903 explicitly name the file @samp{dir.o/foo} after all the options have been
5904 listed, @samp{dir.o/foo} will be excluded from the archive.
5907 You can sometimes confuse the meanings of @value{op-exclude} and
5908 @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
5909 to be excluded are given as a pattern on the command line. Use
5910 @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
5911 file which contains a list of patterns, one per line; each of these
5912 patterns can exclude zero, one, or many files.
5915 When you use @value{op-exclude}, be sure to quote the @var{pattern}
5916 parameter, so @GNUTAR{} sees wildcard characters
5917 like @samp{*}. If you do not do this, the shell might expand the
5918 @samp{*} itself using files at hand, so @command{tar} might receive a
5919 list of files instead of one pattern, or none at all, making the
5920 command somewhat illegal. This might not correspond to what you want.
5925 $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
5932 $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
5936 You must use use shell syntax, or globbing, rather than @code{regexp}
5937 syntax, when using exclude options in @command{tar}. If you try to use
5938 @code{regexp} syntax to describe files to be excluded, your command
5942 In earlier versions of @command{tar}, what is now the
5943 @samp{--exclude-from=@var{file-of-patterns}} option was called
5944 @samp{--exclude=@var{pattern}} instead. Now,
5945 @samp{--exclude=@var{pattern}} applies to patterns listed on the command
5946 line and @samp{--exclude-from=@var{file-of-patterns}} applies to
5947 patterns listed in a file.
5952 @section Wildcards Patterns and Matching
5954 @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
5955 @samp{*} or @samp{?} for example, are replaced and expanded into all
5956 existing files matching the given pattern. However, @command{tar} often
5957 uses wildcard patterns for matching (or globbing) archive members instead
5958 of actual files in the filesystem. Wildcard patterns are also used for
5959 verifying volume labels of @command{tar} archives. This section has the
5960 purpose of explaining wildcard syntax for @command{tar}.
5962 @FIXME{the next few paragraphs need work.}
5964 A @var{pattern} should be written according to shell syntax, using wildcard
5965 characters to effect globbing. Most characters in the pattern stand
5966 for themselves in the matched string, and case is significant: @samp{a}
5967 will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
5968 pattern matches any single character in the matched string. The character
5969 @samp{*} in the pattern matches zero, one, or more single characters in
5970 the matched string. The character @samp{\} says to take the following
5971 character of the pattern @emph{literally}; it is useful when one needs to
5972 match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
5974 The character @samp{[}, up to the matching @samp{]}, introduces a character
5975 class. A @dfn{character class} is a list of acceptable characters
5976 for the next single character of the matched string. For example,
5977 @samp{[abcde]} would match any of the first five letters of the alphabet.
5978 Note that within a character class, all of the ``special characters''
5979 listed above other than @samp{\} lose their special meaning; for example,
5980 @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
5981 @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
5982 the characters @samp{-} and @samp{]} must either come @emph{first} or
5983 @emph{last} in a character class.)
5985 @cindex Excluding characters from a character class
5986 @cindex Character class, excluding characters from
5987 If the first character of the class after the opening @samp{[}
5988 is @samp{!} or @samp{^}, then the meaning of the class is reversed.
5989 Rather than listing character to match, it lists those characters which
5990 are @emph{forbidden} as the next single character of the matched string.
5992 Other characters of the class stand for themselves. The special
5993 construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
5994 letters, is meant to represent all characters between @var{a} and
5997 @FIXME{need to add a sentence or so here to make this clear for those
5998 who don't have dan around.}
6000 Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
6001 special for wildcard matches. However, if a pattern completely matches
6002 a directory prefix of a matched string, then it matches the full matched
6003 string: excluding a directory also excludes all the files beneath it.
6006 @section Operating Only on New Files
6007 @cindex Excluding file by age
6008 @cindex Modification time, excluding files by
6009 @cindex Age, excluding files by
6012 The @value{op-after-date} option causes @command{tar} to only work on files
6013 whose modification or inode-changed times are newer than the @var{date}
6014 given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
6015 be a file name; the last-modified time of that file is used as the date.
6016 If you use this option when creating or appending to an archive,
6017 the archive will only include new files. If you use @samp{--after-date}
6018 when extracting an archive, @command{tar} will only extract files newer
6019 than the @var{date} you specify.
6021 If you only want @command{tar} to make the date comparison based on
6022 modification of the actual contents of the file (rather than inode
6023 changes), then use the @value{op-newer-mtime} option.
6025 You may use these options with any operation. Note that these options
6026 differ from the @value{op-update} operation in that they allow you to
6027 specify a particular date against which @command{tar} can compare when
6028 deciding whether or not to archive the files.
6031 @item --after-date=@var{date}
6032 @itemx --newer=@var{date}
6033 @itemx -N @var{date}
6034 Only store files newer than @var{date}.
6036 Acts on files only if their modification or inode-changed times are
6037 later than @var{date}. Use in conjunction with any operation.
6039 If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
6040 name; the last-modified time of that file is used as the date.
6042 @item --newer-mtime=@var{date}
6043 Acts like @value{op-after-date}, but only looks at modification times.
6046 These options limit @command{tar} to only operating on files which have
6047 been modified after the date specified. A file is considered to have
6048 changed if the contents have been modified, or if the owner,
6049 permissions, and so forth, have been changed. (For more information on
6050 how to specify a date, see @ref{Date input formats}; remember that the
6051 entire date argument must be quoted if it contains any spaces.)
6053 Gurus would say that @value{op-after-date} tests both the @code{mtime}
6054 (time the contents of the file were last modified) and @code{ctime}
6055 (time the file's status was last changed: owner, permissions, etc)
6056 fields, while @value{op-newer-mtime} tests only @code{mtime} field.
6058 To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
6059 @code{ctime} and processes the file if either one is more recent than
6060 @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
6061 disregards @code{ctime}. Neither uses @code{atime} (the last time the
6062 contents of the file were looked at).
6064 Date specifiers can have embedded spaces. Because of this, you may need
6065 to quote date arguments to keep the shell from parsing them as separate
6068 @FIXME{Need example of --newer-mtime with quoted argument.}
6071 @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
6072 should not be used for incremental backups. Some files (such as those
6073 in renamed directories) are not selected properly by these options.
6074 @xref{incremental and listed-incremental}.
6078 @FIXME{which tells -- need to fill this in!}
6081 @section Descending into Directories
6082 @cindex Avoiding recursion in directories
6083 @cindex Descending directories, avoiding
6084 @cindex Directories, avoiding recursion
6085 @cindex Recursion in directories, avoiding
6088 @FIXME{arrggh! this is still somewhat confusing to me. :-< }
6090 @FIXME{show dan bob's comments, from 2-10-97}
6092 Usually, @command{tar} will recursively explore all directories (either
6093 those given on the command line or through the @value{op-files-from}
6094 option) for the various files they contain. However, you may not always
6095 want @command{tar} to act this way.
6097 The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
6098 into specified directories. If you specify @samp{--no-recursion}, you can
6099 use the @command{find} utility for hunting through levels of directories to
6100 construct a list of file names which you could then pass to @command{tar}.
6101 @command{find} allows you to be more selective when choosing which files to
6102 archive; see @ref{files} for more information on using @command{find} with
6103 @command{tar}, or look.
6106 @item --no-recursion
6107 Prevents @command{tar} from recursively descending directories.
6110 Requires @command{tar} to recursively descend directories.
6111 This is the default.
6114 When you use @samp{--no-recursion}, @GNUTAR{} grabs
6115 directory entries themselves, but does not descend on them
6116 recursively. Many people use @command{find} for locating files they
6117 want to back up, and since @command{tar} @emph{usually} recursively
6118 descends on directories, they have to use the @samp{@w{! -d}} option
6119 to @command{find} @FIXME{needs more explanation or a cite to another
6120 info file}as they usually do not want all the files in a directory.
6121 They then use the @value{op-files-from} option to archive the files
6122 located via @command{find}.
6124 The problem when restoring files archived in this manner is that the
6125 directories themselves are not in the archive; so the
6126 @value{op-same-permissions} option does not affect them---while users
6127 might really like it to. Specifying @value{op-no-recursion} is a way to
6128 tell @command{tar} to grab only the directory entries given to it, adding
6129 no new files on its own.
6131 The @value{op-no-recursion} option also applies when extracting: it
6132 causes @command{tar} to extract only the matched directory entries, not
6133 the files under those directories.
6135 The @value{op-no-recursion} option also affects how exclude patterns
6136 are interpreted (@pxref{controlling pattern-patching with exclude}).
6138 The @option{--no-recursion} and @option{--recursion} options apply to
6139 later options and operands, and can be overridden by later occurrences
6140 of @option{--no-recursion} and @option{--recursion}. For example:
6143 $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
6147 creates an archive with one entry for @file{grape}, and the recursive
6148 contents of @file{grape/concord}, but no entries under @file{grape}
6149 other than @file{grape/concord}.
6152 @section Crossing Filesystem Boundaries
6153 @cindex File system boundaries, not crossing
6156 @command{tar} will normally automatically cross file system boundaries in
6157 order to archive files which are part of a directory tree. You can
6158 change this behavior by running @command{tar} and specifying
6159 @value{op-one-file-system}. This option only affects files that are
6160 archived because they are in a directory that is being archived;
6161 @command{tar} will still archive files explicitly named on the command line
6162 or through @value{op-files-from}, regardless of where they reside.
6165 @item --one-file-system
6167 Prevents @command{tar} from crossing file system boundaries when
6168 archiving. Use in conjunction with any write operation.
6171 The @samp{--one-file-system} option causes @command{tar} to modify its
6172 normal behavior in archiving the contents of directories. If a file in
6173 a directory is not on the same filesystem as the directory itself, then
6174 @command{tar} will not archive that file. If the file is a directory
6175 itself, @command{tar} will not archive anything beneath it; in other words,
6176 @command{tar} will not cross mount points.
6178 It is reported that using this option, the mount point is is archived,
6179 but nothing under it.
6181 This option is useful for making full or incremental archival backups of
6182 a file system. If this option is used in conjunction with
6183 @value{op-verbose}, files that are excluded are mentioned by name on the
6187 * directory:: Changing Directory
6188 * absolute:: Absolute File Names
6192 @subsection Changing the Working Directory
6194 @FIXME{need to read over this node now for continuity; i've switched
6195 things around some.}
6197 @cindex Changing directory mid-stream
6198 @cindex Directory, changing mid-stream
6199 @cindex Working directory, specifying
6202 To change the working directory in the middle of a list of file names,
6203 either on the command line or in a file specified using
6204 @value{op-files-from}, use @value{op-directory}. This will change the
6205 working directory to the directory @var{directory} after that point in
6209 @item --directory=@var{directory}
6210 @itemx -C @var{directory}
6211 Changes the working directory in the middle of a command line.
6217 $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
6221 will place the files @file{grape} and @file{prune} from the current
6222 directory into the archive @file{jams.tar}, followed by the file
6223 @file{cherry} from the directory @file{food}. This option is especially
6224 useful when you have several widely separated files that you want to
6225 store in the same archive.
6227 Note that the file @file{cherry} is recorded in the archive under the
6228 precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
6229 archive will contain three files that all appear to have come from the
6230 same directory; if the archive is extracted with plain @samp{tar
6231 --extract}, all three files will be written in the current directory.
6233 Contrast this with the command,
6236 $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
6240 which records the third file in the archive under the name
6241 @file{red/cherry} so that, if the archive is extracted using
6242 @samp{tar --extract}, the third file will be written in a subdirectory
6243 named @file{orange-colored}.
6245 You can use the @samp{--directory} option to make the archive
6246 independent of the original name of the directory holding the files.
6247 The following command places the files @file{/etc/passwd},
6248 @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
6252 $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
6256 However, the names of the archive members will be exactly what they were
6257 on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
6258 They will not appear to be related by file name to the original
6259 directories where those files were located.
6261 Note that @samp{--directory} options are interpreted consecutively. If
6262 @samp{--directory} specifies a relative file name, it is interpreted
6263 relative to the then current directory, which might not be the same as
6264 the original current working directory of @command{tar}, due to a previous
6265 @samp{--directory} option.
6267 @FIXME{dan: does this mean that you *can* use the short option form, but
6268 you can *not* use the long option form with --files-from? or is this
6271 When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
6272 options in the file list. Unfortunately, you cannot put
6273 @samp{--directory} options in the file list. (This interpretation can
6274 be disabled by using the @value{op-null} option.)
6277 @subsection Absolute File Names
6282 @itemx --absolute-names
6283 Do not strip leading slashes from file names, and permit file names
6284 containing a @file{..} file name component.
6287 By default, @GNUTAR{} drops a leading @samp{/} on
6288 input or output, and complains about file names containing a @file{..}
6289 component. This option turns off this behavior.
6291 When @command{tar} extracts archive members from an archive, it strips any
6292 leading slashes (@samp{/}) from the member name. This causes absolute
6293 member names in the archive to be treated as relative file names. This
6294 allows you to have such members extracted wherever you want, instead of
6295 being restricted to extracting the member in the exact directory named
6296 in the archive. For example, if the archive member has the name
6297 @file{/etc/passwd}, @command{tar} will extract it as if the name were
6298 really @file{etc/passwd}.
6300 File names containing @file{..} can cause problems when extracting, so
6301 @command{tar} normally warns you about such files when creating an
6302 archive, and rejects attempts to extracts such files.
6304 Other @command{tar} programs do not do this. As a result, if you
6305 create an archive whose member names start with a slash, they will be
6306 difficult for other people with a non-@GNUTAR{}
6307 program to use. Therefore, @GNUTAR{} also strips
6308 leading slashes from member names when putting members into the
6309 archive. For example, if you ask @command{tar} to add the file
6310 @file{/bin/ls} to an archive, it will do so, but the member name will
6313 If you use the @value{op-absolute-names} option, @command{tar} will do
6314 none of these transformations.
6316 To archive or extract files relative to the root directory, specify
6317 the @value{op-absolute-names} option.
6319 Normally, @command{tar} acts on files relative to the working
6320 directory---ignoring superior directory names when archiving, and
6321 ignoring leading slashes when extracting.
6323 When you specify @value{op-absolute-names}, @command{tar} stores file names
6324 including all superior directory names, and preserves leading slashes.
6325 If you only invoked @command{tar} from the root directory you would never
6326 need the @value{op-absolute-names} option, but using this option may be
6327 more convenient than switching to root.
6329 @FIXME{Should be an example in the tutorial/wizardry section using this
6330 to transfer files between systems.}
6332 @FIXME{Is write access an issue?}
6335 @item --absolute-names
6336 Preserves full file names (including superior directory names) when
6337 archiving files. Preserves leading slash when extracting files.
6341 @FIXME{this is still horrible; need to talk with dan on monday.}
6343 @command{tar} prints out a message about removing the @samp{/} from
6344 file names. This message appears once per @GNUTAR{}
6345 invocation. It represents something which ought to be told; ignoring
6346 what it means can cause very serious surprises, later.
6348 Some people, nevertheless, do not want to see this message. Wanting to
6349 play really dangerously, one may of course redirect @command{tar} standard
6350 error to the sink. For example, under @command{sh}:
6353 $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
6357 Another solution, both nicer and simpler, would be to change to
6358 the @file{/} directory first, and then avoid absolute notation.
6362 $ @kbd{(cd / && tar -c -f archive.tar home)}
6363 $ @kbd{tar -c -f archive.tar -C / home}
6366 @include getdate.texi
6369 @chapter Controlling the Archive Format
6371 Due to historical reasons, there are several formats of tar archives.
6372 All of them are based on the same principles, but have some subtle
6373 differences that often make them incompatible with each other.
6375 GNU tar is able to create and handle archives in a variety of formats.
6376 The most frequently used formats are (in alphabetical order):
6380 Format used by @GNUTAR{} versions up to 1.13.25. This format derived
6381 from an early POSIX standard, adding some improvements such as
6382 sparse file handling and incremental archives. Unfortunately these
6383 features were implemented in a way incompatible with other archive
6386 Archives in @samp{gnu} format are able to hold pathnames of unlimited
6390 Format used by @GNUTAR{} of versions prior to 1.12.
6393 Archive format, compatible with the V7 implementation of tar. This
6394 format imposes a number of limitations. The most important of them
6398 @item The maximum length of a file name is limited to 99 characters.
6399 @item The maximum length of a symbolic link is limited to 99 characters.
6400 @item It is impossible to store special files (block and character
6401 devices, fifos etc.)
6402 @item Maximum value of user or group ID is limited to 2097151 (7777777
6404 @item V7 archives do not contain symbolic ownership information (user
6405 and group name of the file owner).
6408 This format has traditionally been used by Automake when producing
6409 Makefiles. This practice will change in the future, in the meantime,
6410 however this means that projects containing filenames more than 99
6411 characters long will not be able to use @GNUTAR{} @value{VERSION} and
6412 Automake prior to 1.9.
6415 Archive format defined by POSIX.1-1988 specification. It stores
6416 symbolic ownership information. It is also able to store
6417 special files. However, it imposes several restrictions as well:
6420 @item The maximum length of a file name is limited to 256 characters,
6421 provided that the filename can be split at directory separator in
6422 two parts, first of them being at most 155 bytes long. So, in most
6423 cases the maximum file name length will be shorter than 256
6425 @item The maximum length of a symbolic link name is limited to
6427 @item Maximum size of a file the archive is able to accomodate
6429 @item Maximum value of UID/GID is 2097151.
6430 @item Maximum number of bits in device major and minor numbers is 21.
6434 Format used by J@"org Schilling @command{star}
6435 implementation. @GNUTAR{} is able to read @samp{star} archives but
6436 currently does not produce them.
6439 Archive format defined by POSIX.1-2001 specification. This is the
6440 most flexible and feature-rich format. It does not impose any
6441 restrictions on file sizes or filename lengths. This format is quite
6442 recent, so not all tar implementations are able to handle it properly.
6443 However, this format is designed in such a way that any tar
6444 implementation able to read @samp{ustar} archives will be able to read
6445 most @samp{posix} archives as well, with the only exception that any
6446 additional information (such as long file names etc.) will in such
6447 case be extracted as plain text files along with the files it refers to.
6449 This archive format will be the default format for future versions
6454 The following table summarizes the limitations of each of these
6457 @multitable @columnfractions .10 .20 .20 .20 .20
6458 @item Format @tab UID @tab File Size @tab Path Name @tab Devn
6459 @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
6460 @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
6461 @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
6462 @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
6463 @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
6466 The default format for @GNUTAR{} is defined at compilation
6467 time. You may check it by running @command{tar --help}, and examining
6468 the last lines of its output. Usually, @GNUTAR{} is configured
6469 to create archives in @samp{gnu} format, however, future version will
6470 switch to @samp{posix}.
6473 * Portability:: Making @command{tar} Archives More Portable
6474 * Compression:: Using Less Space through Compression
6475 * Attributes:: Handling File Attributes
6476 * Standard:: The Standard Format
6477 * Extensions:: @acronym{GNU} Extensions to the Archive Format
6478 * cpio:: Comparison of @command{tar} and @command{cpio}
6482 @section Making @command{tar} Archives More Portable
6484 Creating a @command{tar} archive on a particular system that is meant to be
6485 useful later on many other machines and with other versions of @command{tar}
6486 is more challenging than you might think. @command{tar} archive formats
6487 have been evolving since the first versions of Unix. Many such formats
6488 are around, and are not always compatible with each other. This section
6489 discusses a few problems, and gives some advice about making @command{tar}
6490 archives more portable.
6492 One golden rule is simplicity. For example, limit your @command{tar}
6493 archives to contain only regular files and directories, avoiding
6494 other kind of special files. Do not attempt to save sparse files or
6495 contiguous files as such. Let's discuss a few more problems, in turn.
6498 * Portable Names:: Portable Names
6499 * dereference:: Symbolic Links
6500 * old:: Old V7 Archives
6501 * gnu:: GNU and old GNU format archives.
6502 * posix:: @sc{posix} archives
6503 * Checksumming:: Checksumming Problems
6504 * Large or Negative Values:: Large files, negative time stamps, etc.
6507 @node Portable Names
6508 @subsection Portable Names
6510 Use portable file and member names. A name is portable if it contains
6511 only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
6512 @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
6513 contain @samp{/-}. Avoid deep directory nesting. For portability to
6514 old Unix hosts, limit your file name components to 14 characters or
6517 If you intend to have your @command{tar} archives to be read under
6518 MSDOS, you should not rely on case distinction for file names, and you
6519 might use the @acronym{GNU} @command{doschk} program for helping you
6520 further diagnosing illegal MSDOS names, which are even more limited
6524 @subsection Symbolic Links
6525 @cindex File names, using symbolic links
6526 @cindex Symbolic link as file name
6528 Normally, when @command{tar} archives a symbolic link, it writes a
6529 block to the archive naming the target of the link. In that way, the
6530 @command{tar} archive is a faithful record of the filesystem contents.
6531 @value{op-dereference} is used with @value{op-create}, and causes
6532 @command{tar} to archive the files symbolic links point to, instead of
6533 the links themselves. When this option is used, when @command{tar}
6534 encounters a symbolic link, it will archive the linked-to file,
6535 instead of simply recording the presence of a symbolic link.
6537 The name under which the file is stored in the file system is not
6538 recorded in the archive. To record both the symbolic link name and
6539 the file name in the system, archive the file under both names. If
6540 all links were recorded automatically by @command{tar}, an extracted file
6541 might be linked to a file name that no longer exists in the file
6544 If a linked-to file is encountered again by @command{tar} while creating
6545 the same archive, an entire second copy of it will be stored. (This
6546 @emph{might} be considered a bug.)
6548 So, for portable archives, do not archive symbolic links as such,
6549 and use @value{op-dereference}: many systems do not support
6550 symbolic links, and moreover, your distribution might be unusable if
6551 it contains unresolved symbolic links.
6554 @subsection Old V7 Archives
6555 @cindex Format, old style
6556 @cindex Old style format
6557 @cindex Old style archives
6559 Certain old versions of @command{tar} cannot handle additional
6560 information recorded by newer @command{tar} programs. To create an
6561 archive in V7 format (not ANSI), which can be read by these old
6562 versions, specify the @value{op-format-v7} option in
6563 conjunction with the @value{op-create} (@command{tar} also
6564 accepts @samp{--portability} or @samp{op-old-archive} for this
6565 option). When you specify it,
6566 @command{tar} leaves out information about directories, pipes, fifos,
6567 contiguous files, and device files, and specifies file ownership by
6568 group and user IDs instead of group and user names.
6570 When updating an archive, do not use @value{op-format-v7}
6571 unless the archive was created with using this option.
6573 In most cases, a @emph{new} format archive can be read by an @emph{old}
6574 @command{tar} program without serious trouble, so this option should
6575 seldom be needed. On the other hand, most modern @command{tar}s are
6576 able to read old format archives, so it might be safer for you to
6577 always use @value{op-format-v7} for your distributions.
6580 @subsection @acronym{GNU} and old @GNUTAR{} format
6582 @GNUTAR{} was based on an early draft of the
6583 @sc{posix} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
6584 @command{tar}, such as the support for file names longer than 100
6585 characters, use portions of the @command{tar} header record which were
6586 specified in that @sc{posix} draft as unused. Subsequent changes in
6587 @sc{posix} have allocated the same parts of the header record for
6588 other purposes. As a result, @GNUTAR{} format is
6589 incompatible with the current @sc{posix} specification, and with
6590 @command{tar} programs that follow it.
6592 In the majority of cases, @command{tar} will be configured to create
6593 this format by default. This may change in the future, since we plan
6594 to make @samp{posix} format the default.
6596 To force creation a @GNUTAR{} archive, use option
6597 @value{op-format-gnu}.
6599 Some @command{tar} options are currently basing on @GNUTAR{}
6600 format, and can therefore be used only with @samp{gnu}
6601 or @samp{oldgnu} archive formats. The list of such options follows:
6604 @item @value{op-label}, when used with @value{op-create}.
6605 @item @value{op-incremental}
6606 @item @value{op-multi-volume}
6607 @item @value{op-sparse}
6610 These options will be re-implemented for the @samp{posix} archive
6611 format in the future.
6614 @subsection @GNUTAR{} and @sc{posix} @command{tar}
6616 The version @value{VERSION} of @GNUTAR{} is able
6617 to read and create archives conforming to @sc{posix.1-2001} standard.
6619 A @sc{posix} conformant archive will be created if @command{tar}
6620 was given @value{op-format-posix} option.
6621 Notice, that currently @acronym{GNU} extensions are not
6622 allowed with this format. Following is the list of options that
6623 cannot be used with @value{op-format-posix}:
6626 @item @value{op-label}, when used with @value{op-create}.
6627 @item @value{op-incremental}
6628 @item @value{op-multi-volume}
6629 @item @value{op-sparse}
6632 This restriction will disappear in the future versions.
6635 @subsection Checksumming Problems
6637 SunOS and HP-UX @command{tar} fail to accept archives created using
6638 @GNUTAR{} and containing non-ASCII file names, that
6639 is, file names having characters with the eight bit set, because they
6640 use signed checksums, while @GNUTAR{} uses unsigned
6641 checksums while creating archives, as per @sc{posix} standards. On
6642 reading, @GNUTAR{} computes both checksums and
6643 accept any. It is somewhat worrying that a lot of people may go
6644 around doing backup of their files using faulty (or at least
6645 non-standard) software, not learning about it until it's time to
6646 restore their missing files with an incompatible file extractor, or
6649 @GNUTAR{} compute checksums both ways, and accept
6650 any on read, so @acronym{GNU} tar can read Sun tapes even with their
6651 wrong checksums. @GNUTAR{} produces the standard
6652 checksum, however, raising incompatibilities with Sun. That is to
6653 say, @GNUTAR{} has not been modified to
6654 @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
6655 I've been told that more recent Sun @command{tar} now read standard
6656 archives, so maybe Sun did a similar patch, after all?
6658 The story seems to be that when Sun first imported @command{tar}
6659 sources on their system, they recompiled it without realizing that
6660 the checksums were computed differently, because of a change in
6661 the default signing of @code{char}'s in their compiler. So they
6662 started computing checksums wrongly. When they later realized their
6663 mistake, they merely decided to stay compatible with it, and with
6664 themselves afterwards. Presumably, but I do not really know, HP-UX
6665 has chosen that their @command{tar} archives to be compatible with Sun's.
6666 The current standards do not favor Sun @command{tar} format. In any
6667 case, it now falls on the shoulders of SunOS and HP-UX users to get
6668 a @command{tar} able to read the good archives they receive.
6670 @node Large or Negative Values
6671 @subsection Large or Negative Values
6672 @cindex large values
6673 @cindex future time stamps
6674 @cindex negative time stamps
6676 @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
6677 to represent numeric values. User and group IDs and device major and
6678 minor numbers have unsigned 21-bit representations, and file sizes and
6679 times have unsigned 33-bit representations. @GNUTAR{}
6680 generates @sc{posix} representations when possible, but for values
6681 outside the @sc{posix} range it generates two's-complement base-256
6682 strings: uids, gids, and device numbers have signed 57-bit
6683 representations, and file sizes and times have signed 89-bit
6684 representations. These representations are an extension to @sc{posix}
6685 @command{tar} format, so they are not universally portable.
6687 The most common portability problems with out-of-range numeric values
6688 are large files and future or negative time stamps.
6690 Portable archives should avoid members of 8 GB or larger, as @sc{posix}
6691 @command{tar} format cannot represent them.
6693 Portable archives should avoid time stamps from the future. @sc{posix}
6694 @command{tar} format can represent time stamps in the range 1970-01-01
6695 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
6696 hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
6697 and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
6698 portable archives must avoid these time stamps for many years to come.
6700 Portable archives should also avoid time stamps before 1970. These time
6701 stamps are a common @sc{posix} extension but their @code{time_t}
6702 representations are negative. Many traditional @command{tar}
6703 implementations generate a two's complement representation for negative
6704 time stamps that assumes a signed 32-bit @code{time_t}; hence they
6705 generate archives that are not portable to hosts with differing
6706 @code{time_t} representations. @GNUTAR{} recognizes this
6707 situation when it is run on host with a signed 32-bit @code{time_t}, but
6708 it issues a warning, as these time stamps are nonstandard and unportable.
6711 @section Using Less Space through Compression
6714 * gzip:: Creating and Reading Compressed Archives
6715 * sparse:: Archiving Sparse Files
6719 @subsection Creating and Reading Compressed Archives
6720 @cindex Compressed archives
6721 @cindex Storing archives in compressed format
6728 Filter the archive through @command{gzip}.
6731 @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
6732 format parameters must be taken into consideration when modifying an
6733 archive.@FIXME{???} Compressed archives cannot be modified.
6735 You can use @samp{--gzip} and @samp{--gunzip} on physical devices
6736 (tape drives, etc.) and remote files as well as on normal files; data
6737 to or from such devices or remote files is reblocked by another copy
6738 of the @command{tar} program to enforce the specified (or default) record
6739 size. The default compression parameters are used; if you need to
6740 override them, avoid the @value{op-gzip} option and run @command{gzip}
6741 explicitly. (Or set the @env{GZIP} environment variable.)
6743 The @value{op-gzip} option does not work with the @value{op-multi-volume}
6744 option, or with the @value{op-update}, @value{op-append},
6745 @value{op-concatenate}, or @value{op-delete} operations.
6747 It is not exact to say that @GNUTAR{} is to work in concert
6748 with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
6749 possible that @command{tar} and @command{gzip} be done with a single call,
6753 $ @kbd{tar cfz archive.tar.gz subdir}
6757 to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
6761 $ @kbd{tar xfz archive.tar.gz}
6765 to explode and unpack.
6767 The difference is that the whole archive is compressed. With
6768 @command{zip}, archive members are archived individually. @command{tar}'s
6769 method yields better compression. On the other hand, one can view the
6770 contents of a @command{zip} archive without having to decompress it. As
6771 for the @command{tar} and @command{gzip} tandem, you need to decompress the
6772 archive to see its contents. However, this may be done without needing
6773 disk space, by using pipes internally:
6776 $ @kbd{tar tfz archive.tar.gz}
6779 @cindex corrupted archives
6780 About corrupted compressed archives: @command{gzip}'ed files have no
6781 redundancy, for maximum compression. The adaptive nature of the
6782 compression scheme means that the compression tables are implicitly
6783 spread all over the archive. If you lose a few blocks, the dynamic
6784 construction of the compression tables becomes unsynchronized, and there
6785 is little chance that you could recover later in the archive.
6787 There are pending suggestions for having a per-volume or per-file
6788 compression in @GNUTAR{}. This would allow for viewing the
6789 contents without decompression, and for resynchronizing decompression at
6790 every volume or file, in case of corrupted archives. Doing so, we might
6791 lose some compressibility. But this would have make recovering easier.
6792 So, there are pros and cons. We'll see!
6797 Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
6802 Filter the archive through @command{compress}. Otherwise like
6805 @item --use-compress-program=@var{prog}
6806 Filter through @var{prog} (must accept @samp{-d}).
6809 @value{op-compress} stores an archive in compressed format. This
6810 option is useful in saving time over networks and space in pipes, and
6811 when storage space is at a premium. @value{op-compress} causes
6812 @command{tar} to compress when writing the archive, or to uncompress when
6813 reading the archive.
6815 To perform compression and uncompression on the archive, @command{tar}
6816 runs the @command{compress} utility. @command{tar} uses the default
6817 compression parameters; if you need to override them, avoid the
6818 @value{op-compress} option and run the @command{compress} utility
6819 explicitly. It is useful to be able to call the @command{compress}
6820 utility from within @command{tar} because the @command{compress} utility by
6821 itself cannot access remote tape drives.
6823 The @value{op-compress} option will not work in conjunction with the
6824 @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
6825 and @value{op-delete} operations. @xref{Operations}, for
6826 more information on these operations.
6828 If there is no compress utility available, @command{tar} will report an error.
6829 @strong{Please note} that the @command{compress} program may be covered by
6830 a patent, and therefore we recommend you stop using it.
6832 @value{op-bzip2} acts like @value{op-compress}, except that it uses
6833 the @code{bzip2} utility.
6840 When this option is specified, @command{tar} will compress (when
6841 writing an archive), or uncompress (when reading an archive). Used in
6842 conjunction with the @value{op-create}, @value{op-extract},
6843 @value{op-list} and @value{op-compare} operations.
6846 You can have archives be compressed by using the @value{op-gzip} option.
6847 This will arrange for @command{tar} to use the @command{gzip} program to be
6848 used to compress or uncompress the archive wren writing or reading it.
6850 To use the older, obsolete, @command{compress} program, use the
6851 @value{op-compress} option. The @acronym{GNU} Project recommends you not use
6852 @command{compress}, because there is a patent covering the algorithm it
6853 uses. You could be sued for patent infringement merely by running
6856 I have one question, or maybe it's a suggestion if there isn't a way
6857 to do it now. I would like to use @value{op-gzip}, but I'd also like
6858 the output to be fed through a program like @acronym{GNU}
6859 @command{ecc} (actually, right now that's @samp{exactly} what I'd like
6860 to use :-)), basically adding ECC protection on top of compression.
6861 It seems as if this should be quite easy to do, but I can't work out
6862 exactly how to go about it. Of course, I can pipe the standard output
6863 of @command{tar} through @command{ecc}, but then I lose (though I
6864 haven't started using it yet, I confess) the ability to have
6865 @command{tar} use @command{rmt} for it's I/O (I think).
6867 I think the most straightforward thing would be to let me specify a
6868 general set of filters outboard of compression (preferably ordered,
6869 so the order can be automatically reversed on input operations, and
6870 with the options they require specifiable), but beggars shouldn't be
6871 choosers and anything you decide on would be fine with me.
6873 By the way, I like @command{ecc} but if (as the comments say) it can't
6874 deal with loss of block sync, I'm tempted to throw some time at adding
6875 that capability. Supposing I were to actually do such a thing and
6876 get it (apparently) working, do you accept contributed changes to
6877 utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
6879 Isn't that exactly the role of the @value{op-use-compress-prog} option?
6880 I never tried it myself, but I suspect you may want to write a
6881 @var{prog} script or program able to filter stdin to stdout to
6882 way you want. It should recognize the @samp{-d} option, for when
6883 extraction is needed rather than creation.
6885 It has been reported that if one writes compressed data (through the
6886 @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
6887 the DLT compression mode, the data will actually get bigger and one will
6888 end up with less space on the tape.
6891 @subsection Archiving Sparse Files
6892 @cindex Sparse Files
6898 Handle sparse files efficiently.
6901 This option causes all files to be put in the archive to be tested for
6902 sparseness, and handled specially if they are. The @value{op-sparse}
6903 option is useful when many @code{dbm} files, for example, are being
6904 backed up. Using this option dramatically decreases the amount of
6905 space needed to store such a file.
6907 In later versions, this option may be removed, and the testing and
6908 treatment of sparse files may be done automatically with any special
6909 @acronym{GNU} options. For now, it is an option needing to be specified on
6910 the command line with the creation or updating of an archive.
6912 Files in the filesystem occasionally have ``holes.'' A hole in a file
6913 is a section of the file's contents which was never written. The
6914 contents of a hole read as all zeros. On many operating systems,
6915 actual disk storage is not allocated for holes, but they are counted
6916 in the length of the file. If you archive such a file, @command{tar}
6917 could create an archive longer than the original. To have @command{tar}
6918 attempt to recognize the holes in a file, use @value{op-sparse}. When
6919 you use the @value{op-sparse} option, then, for any file using less
6920 disk space than would be expected from its length, @command{tar} searches
6921 the file for consecutive stretches of zeros. It then records in the
6922 archive for the file where the consecutive stretches of zeros are, and
6923 only archives the ``real contents'' of the file. On extraction (using
6924 @value{op-sparse} is not needed on extraction) any such files have
6925 holes created wherever the continuous stretches of zeros were found.
6926 Thus, if you use @value{op-sparse}, @command{tar} archives won't take
6927 more space than the original.
6929 A file is sparse if it contains blocks of zeros whose existence is
6930 recorded, but that have no space allocated on disk. When you specify
6931 the @value{op-sparse} option in conjunction with the @value{op-create}
6932 operation, @command{tar} tests all files for sparseness while archiving.
6933 If @command{tar} finds a file to be sparse, it uses a sparse representation of
6934 the file in the archive. @value{xref-create}, for more information
6935 about creating archives.
6937 @value{op-sparse} is useful when archiving files, such as dbm files,
6938 likely to contain many nulls. This option dramatically
6939 decreases the amount of space needed to store such an archive.
6942 @strong{Please Note:} Always use @value{op-sparse} when performing file
6943 system backups, to avoid archiving the expanded forms of files stored
6944 sparsely in the system.
6946 Even if your system has no sparse files currently, some may be
6947 created in the future. If you use @value{op-sparse} while making file
6948 system backups as a matter of course, you can be assured the archive
6949 will never take more space on the media than the files take on disk
6950 (otherwise, archiving a disk filled with sparse files might take
6951 hundreds of tapes). @FIXME-xref{incremental when node name is set.}
6954 @command{tar} ignores the @value{op-sparse} option when reading an archive.
6959 Files stored sparsely in the file system are represented sparsely in
6960 the archive. Use in conjunction with write operations.
6963 However, users should be well aware that at archive creation time,
6964 @GNUTAR{} still has to read whole disk file to
6965 locate the @dfn{holes}, and so, even if sparse files use little space
6966 on disk and in the archive, they may sometimes require inordinate
6967 amount of time for reading and examining all-zero blocks of a file.
6968 Although it works, it's painfully slow for a large (sparse) file, even
6969 though the resulting tar archive may be small. (One user reports that
6970 dumping a @file{core} file of over 400 megabytes, but with only about
6971 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
6972 ELC, with full CPU utilization.)
6974 This reading is required in all cases and is not related to the fact
6975 the @value{op-sparse} option is used or not, so by merely @emph{not}
6976 using the option, you are not saving time@footnote{Well! We should say
6977 the whole truth, here. When @value{op-sparse} is selected while creating
6978 an archive, the current @command{tar} algorithm requires sparse files to be
6979 read twice, not once. We hope to develop a new archive format for saving
6980 sparse files in which one pass will be sufficient.}.
6982 Programs like @command{dump} do not have to read the entire file; by
6983 examining the file system directly, they can determine in advance
6984 exactly where the holes are and thus avoid reading through them. The
6985 only data it need read are the actual allocated data blocks.
6986 @GNUTAR{} uses a more portable and straightforward
6987 archiving approach, it would be fairly difficult that it does
6988 otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
6992 What I did say is that you cannot tell the difference between a hole and an
6993 equivalent number of nulls without reading raw blocks. @code{st_blocks} at
6994 best tells you how many holes there are; it doesn't tell you @emph{where}.
6995 Just as programs may, conceivably, care what @code{st_blocks} is (care
6996 to name one that does?), they may also care where the holes are (I have
6997 no examples of this one either, but it's equally imaginable).
6999 I conclude from this that good archivers are not portable. One can
7000 arguably conclude that if you want a portable program, you can in good
7001 conscience restore files with as many holes as possible, since you can't
7006 @section Handling File Attributes
7009 When @command{tar} reads files, this causes them to have the access
7010 times updated. To have @command{tar} attempt to set the access times
7011 back to what they were before they were read, use the
7012 @value{op-atime-preserve} option.
7014 Handling of file attributes
7017 @item --atime-preserve
7018 Preserve access times on files that are read.
7019 This doesn't work for files that
7020 you don't own, unless you're root, and it doesn't interact with
7021 incremental dumps nicely (@pxref{Backups}), and it can set access or
7022 modification times incorrectly if other programs access the file while
7023 @command{tar} is running; but it is good enough for some purposes.
7027 Do not extract file modified time.
7029 When this option is used, @command{tar} leaves the modification times
7030 of the files it extracts as the time when the files were extracted,
7031 instead of setting it to the time recorded in the archive.
7033 This option is meaningless with @value{op-list}.
7036 Create extracted files with the same ownership they have in the
7039 This is the default behavior for the superuser,
7040 so this option is meaningful only for non-root users, when @command{tar}
7041 is executed on those systems able to give files away. This is
7042 considered as a security flaw by many people, at least because it
7043 makes quite difficult to correctly account users for the disk space
7044 they occupy. Also, the @code{suid} or @code{sgid} attributes of
7045 files are easily and silently lost when files are given away.
7047 When writing an archive, @command{tar} writes the user id and user name
7048 separately. If it can't find a user name (because the user id is not
7049 in @file{/etc/passwd}), then it does not write one. When restoring,
7050 and doing a @code{chmod} like when you use @value{op-same-permissions},
7051 @FIXME{same-owner?}it tries to look the name (if one was written)
7052 up in @file{/etc/passwd}. If it fails, then it uses the user id
7053 stored in the archive instead.
7055 @item --no-same-owner
7057 Do not attempt to restore ownership when extracting. This is the
7058 default behavior for ordinary users, so this option has an effect
7059 only for the superuser.
7061 @item --numeric-owner
7062 The @value{op-numeric-owner} option allows (ANSI) archives to be written
7063 without user/group name information or such information to be ignored
7064 when extracting. It effectively disables the generation and/or use
7065 of user/group name information. This option forces extraction using
7066 the numeric ids from the archive, ignoring the names.
7068 This is useful in certain circumstances, when restoring a backup from
7069 an emergency floppy with different passwd/group files for example.
7070 It is otherwise impossible to extract files with the right ownerships
7071 if the password file in use during the extraction does not match the
7072 one belonging to the filesystem(s) being extracted. This occurs,
7073 for example, if you are restoring your files after a major crash and
7074 had booted from an emergency floppy with no password file or put your
7075 disk into another machine to do the restore.
7077 The numeric ids are @emph{always} saved into @command{tar} archives.
7078 The identifying names are added at create time when provided by the
7079 system, unless @value{op-old-archive} is used. Numeric ids could be
7080 used when moving archives between a collection of machines using
7081 a centralized management for attribution of numeric ids to users
7082 and groups. This is often made through using the NIS capabilities.
7084 When making a @command{tar} file for distribution to other sites, it
7085 is sometimes cleaner to use a single owner for all files in the
7086 distribution, and nicer to specify the write permission bits of the
7087 files as stored in the archive independently of their actual value on
7088 the file system. The way to prepare a clean distribution is usually
7089 to have some Makefile rule creating a directory, copying all needed
7090 files in that directory, then setting ownership and permissions as
7091 wanted (there are a lot of possible schemes), and only then making a
7092 @command{tar} archive out of this directory, before cleaning
7093 everything out. Of course, we could add a lot of options to
7094 @GNUTAR{} for fine tuning permissions and ownership.
7095 This is not the good way, I think. @GNUTAR{} is
7096 already crowded with options and moreover, the approach just explained
7097 gives you a great deal of control already.
7100 @itemx --same-permissions
7101 @itemx --preserve-permissions
7102 Extract all protection information.
7104 This option causes @command{tar} to set the modes (access permissions) of
7105 extracted files exactly as recorded in the archive. If this option
7106 is not used, the current @code{umask} setting limits the permissions
7109 This option is meaningless with @value{op-list}.
7112 Same as both @value{op-same-permissions} and @value{op-same-order}.
7114 The @value{op-preserve} option has no equivalent short option name.
7115 It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
7117 @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
7122 @section Basic Tar Format
7125 While an archive may contain many files, the archive itself is a
7126 single ordinary file. Like any other file, an archive file can be
7127 written to a storage device such as a tape or disk, sent through a
7128 pipe or over a network, saved on the active file system, or even
7129 stored in another archive. An archive file is not easy to read or
7130 manipulate without using the @command{tar} utility or Tar mode in
7131 @acronym{GNU} Emacs.
7133 Physically, an archive consists of a series of file entries terminated
7134 by an end-of-archive entry, which consists of two 512 blocks of zero
7136 entry usually describes one of the files in the archive (an
7137 @dfn{archive member}), and consists of a file header and the contents
7138 of the file. File headers contain file names and statistics, checksum
7139 information which @command{tar} uses to detect file corruption, and
7140 information about file types.
7142 Archives are permitted to have more than one member with the same
7143 member name. One way this situation can occur is if more than one
7144 version of a file has been stored in the archive. For information
7145 about adding new versions of a file to an archive, see @ref{update}.
7146 @FIXME-xref{To learn more about having more than one archive member with the
7147 same name, see -backup node, when it's written.}
7149 In addition to entries describing archive members, an archive may
7150 contain entries which @command{tar} itself uses to store information.
7151 @value{xref-label}, for an example of such an archive entry.
7153 A @command{tar} archive file contains a series of blocks. Each block
7154 contains @code{BLOCKSIZE} bytes. Although this format may be thought
7155 of as being on magnetic tape, other media are often used.
7157 Each file archived is represented by a header block which describes
7158 the file, followed by zero or more blocks which give the contents
7159 of the file. At the end of the archive file there are two 512-byte blocks
7160 filled with binary zeros as an end-of-file marker. A reasonable system
7161 should write such end-of-file marker at the end of an archive, but
7162 must not assume that such a block exists when reading an archive. In
7163 particular @GNUTAR{} always issues a warning if it does not encounter it.
7165 The blocks may be @dfn{blocked} for physical I/O operations.
7166 Each record of @var{n} blocks (where @var{n} is set by the
7167 @value{op-blocking-factor} option to @command{tar}) is written with a single
7168 @w{@samp{write ()}} operation. On magnetic tapes, the result of
7169 such a write is a single record. When writing an archive,
7170 the last record of blocks should be written at the full size, with
7171 blocks after the zero block containing all zeros. When reading
7172 an archive, a reasonable system should properly handle an archive
7173 whose last record is shorter than the rest, or which contains garbage
7174 records after a zero block.
7176 The header block is defined in C as follows. In the @GNUTAR{}
7177 distribution, this is part of file @file{src/tar.h}:
7180 @include header.texi
7183 All characters in header blocks are represented by using 8-bit
7184 characters in the local variant of ASCII. Each field within the
7185 structure is contiguous; that is, there is no padding used within
7186 the structure. Each character on the archive medium is stored
7189 Bytes representing the contents of files (after the header block
7190 of each file) are not translated in any way and are not constrained
7191 to represent characters in any character set. The @command{tar} format
7192 does not distinguish text files from binary files, and no translation
7193 of file contents is performed.
7195 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
7196 @code{gname} are null-terminated character strings. All other fields
7197 are zero-filled octal numbers in ASCII. Each numeric field of width
7198 @var{w} contains @var{w} minus 1 digits, and a null.
7200 The @code{name} field is the file name of the file, with directory names
7201 (if any) preceding the file name, separated by slashes.
7203 @FIXME{how big a name before field overflows?}
7205 The @code{mode} field provides nine bits specifying file permissions
7206 and three bits to specify the Set UID, Set GID, and Save Text
7207 (@dfn{sticky}) modes. Values for these bits are defined above.
7208 When special permissions are required to create a file with a given
7209 mode, and the user restoring files from the archive does not hold such
7210 permissions, the mode bit(s) specifying those special permissions
7211 are ignored. Modes which are not supported by the operating system
7212 restoring files from the archive will be ignored. Unsupported modes
7213 should be faked up when creating or updating an archive; e.g.@: the
7214 group permission could be copied from the @emph{other} permission.
7216 The @code{uid} and @code{gid} fields are the numeric user and group
7217 ID of the file owners, respectively. If the operating system does
7218 not support numeric user or group IDs, these fields should be ignored.
7220 The @code{size} field is the size of the file in bytes; linked files
7221 are archived with this field specified as zero. @FIXME-xref{Modifiers, in
7222 particular the @value{op-incremental} option.}
7224 The @code{mtime} field is the modification time of the file at the time
7225 it was archived. It is the ASCII representation of the octal value of
7226 the last time the file was modified, represented as an integer number of
7227 seconds since January 1, 1970, 00:00 Coordinated Universal Time.
7229 The @code{chksum} field is the ASCII representation of the octal value
7230 of the simple sum of all bytes in the header block. Each 8-bit
7231 byte in the header is added to an unsigned integer, initialized to
7232 zero, the precision of which shall be no less than seventeen bits.
7233 When calculating the checksum, the @code{chksum} field is treated as
7234 if it were all blanks.
7236 The @code{typeflag} field specifies the type of file archived. If a
7237 particular implementation does not recognize or permit the specified
7238 type, the file will be extracted as if it were a regular file. As this
7239 action occurs, @command{tar} issues a warning to the standard error.
7241 The @code{atime} and @code{ctime} fields are used in making incremental
7242 backups; they store, respectively, the particular file's access time
7243 and last inode-change time.
7245 The @code{offset} is used by the @value{op-multi-volume} option, when
7246 making a multi-volume archive. The offset is number of bytes into
7247 the file that we need to restart at to continue the file on the next
7248 tape, i.e., where we store the location that a continued file is
7251 The following fields were added to deal with sparse files. A file
7252 is @dfn{sparse} if it takes in unallocated blocks which end up being
7253 represented as zeros, i.e., no useful data. A test to see if a file
7254 is sparse is to look at the number blocks allocated for it versus the
7255 number of characters in the file; if there are fewer blocks allocated
7256 for the file than would normally be allocated for a file of that
7257 size, then the file is sparse. This is the method @command{tar} uses to
7258 detect a sparse file, and once such a file is detected, it is treated
7259 differently from non-sparse files.
7261 Sparse files are often @code{dbm} files, or other database-type files
7262 which have data at some points and emptiness in the greater part of
7263 the file. Such files can appear to be very large when an @samp{ls
7264 -l} is done on them, when in truth, there may be a very small amount
7265 of important data contained in the file. It is thus undesirable
7266 to have @command{tar} think that it must back up this entire file, as
7267 great quantities of room are wasted on empty blocks, which can lead
7268 to running out of room on a tape far earlier than is necessary.
7269 Thus, sparse files are dealt with so that these empty blocks are
7270 not written to the tape. Instead, what is written to the tape is a
7271 description, of sorts, of the sparse file: where the holes are, how
7272 big the holes are, and how much data is found at the end of the hole.
7273 This way, the file takes up potentially far less room on the tape,
7274 and when the file is extracted later on, it will look exactly the way
7275 it looked beforehand. The following is a description of the fields
7276 used to handle a sparse file:
7278 The @code{sp} is an array of @code{struct sparse}. Each @code{struct
7279 sparse} contains two 12-character strings which represent an offset
7280 into the file and a number of bytes to be written at that offset.
7281 The offset is absolute, and not relative to the offset in preceding
7284 The header can hold four of these @code{struct sparse} at the moment;
7285 if more are needed, they are not stored in the header.
7287 The @code{isextended} flag is set when an @code{extended_header}
7288 is needed to deal with a file. Note that this means that this flag
7289 can only be set when dealing with a sparse file, and it is only set
7290 in the event that the description of the file will not fit in the
7291 allotted room for sparse structures in the header. In other words,
7292 an extended_header is needed.
7294 The @code{extended_header} structure is used for sparse files which
7295 need more sparse structures than can fit in the header. The header can
7296 fit 4 such structures; if more are needed, the flag @code{isextended}
7297 gets set and the next block is an @code{extended_header}.
7299 Each @code{extended_header} structure contains an array of 21
7300 sparse structures, along with a similar @code{isextended} flag
7301 that the header had. There can be an indeterminate number of such
7302 @code{extended_header}s to describe a sparse file.
7306 @item @code{REGTYPE}
7307 @itemx @code{AREGTYPE}
7308 These flags represent a regular file. In order to be compatible
7309 with older versions of @command{tar}, a @code{typeflag} value of
7310 @code{AREGTYPE} should be silently recognized as a regular file.
7311 New archives should be created using @code{REGTYPE}. Also, for
7312 backward compatibility, @command{tar} treats a regular file whose name
7313 ends with a slash as a directory.
7315 @item @code{LNKTYPE}
7316 This flag represents a file linked to another file, of any type,
7317 previously archived. Such files are identified in Unix by each
7318 file having the same device and inode number. The linked-to name is
7319 specified in the @code{linkname} field with a trailing null.
7321 @item @code{SYMTYPE}
7322 This represents a symbolic link to another file. The linked-to name
7323 is specified in the @code{linkname} field with a trailing null.
7325 @item @code{CHRTYPE}
7326 @itemx @code{BLKTYPE}
7327 These represent character special files and block special files
7328 respectively. In this case the @code{devmajor} and @code{devminor}
7329 fields will contain the major and minor device numbers respectively.
7330 Operating systems may map the device specifications to their own
7331 local specification, or may ignore the entry.
7333 @item @code{DIRTYPE}
7334 This flag specifies a directory or sub-directory. The directory
7335 name in the @code{name} field should end with a slash. On systems where
7336 disk allocation is performed on a directory basis, the @code{size} field
7337 will contain the maximum number of bytes (which may be rounded to
7338 the nearest disk block allocation unit) which the directory may
7339 hold. A @code{size} field of zero indicates no such limiting. Systems
7340 which do not support limiting in this manner should ignore the
7343 @item @code{FIFOTYPE}
7344 This specifies a FIFO special file. Note that the archiving of a
7345 FIFO file archives the existence of this file and not its contents.
7347 @item @code{CONTTYPE}
7348 This specifies a contiguous file, which is the same as a normal
7349 file except that, in operating systems which support it, all its
7350 space is allocated contiguously on the disk. Operating systems
7351 which do not allow contiguous allocation should silently treat this
7352 type as a normal file.
7354 @item @code{A} @dots{} @code{Z}
7355 These are reserved for custom implementations. Some of these are
7356 used in the @acronym{GNU} modified format, as described below.
7360 Other values are reserved for specification in future revisions of
7361 the P1003 standard, and should not be used by any @command{tar} program.
7363 The @code{magic} field indicates that this archive was output in
7364 the P1003 archive format. If this field contains @code{TMAGIC},
7365 the @code{uname} and @code{gname} fields will contain the ASCII
7366 representation of the owner and group of the file respectively.
7367 If found, the user and group IDs are used rather than the values in
7368 the @code{uid} and @code{gid} fields.
7370 For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
7371 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
7372 IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
7373 (section E.4.48) for @cite{pax - Portable archive interchange}.
7376 @section @acronym{GNU} Extensions to the Archive Format
7379 The @acronym{GNU} format uses additional file types to describe new types of
7380 files in an archive. These are listed below.
7383 @item GNUTYPE_DUMPDIR
7385 This represents a directory and a list of files created by the
7386 @value{op-incremental} option. The @code{size} field gives the total
7387 size of the associated list of files. Each file name is preceded by
7388 either a @samp{Y} (the file should be in this archive) or an @samp{N}.
7389 (The file is a directory, or is not stored in the archive.) Each file
7390 name is terminated by a null. There is an additional null after the
7393 @item GNUTYPE_MULTIVOL
7395 This represents a file continued from another volume of a multi-volume
7396 archive created with the @value{op-multi-volume} option. The original
7397 type of the file is not given here. The @code{size} field gives the
7398 maximum size of this piece of the file (assuming the volume does
7399 not end before the file is written out). The @code{offset} field
7400 gives the offset from the beginning of the file where this part of
7401 the file begins. Thus @code{size} plus @code{offset} should equal
7402 the original size of the file.
7404 @item GNUTYPE_SPARSE
7406 This flag indicates that we are dealing with a sparse file. Note
7407 that archiving a sparse file requires special operations to find
7408 holes in the file, which mark the positions of these holes, along
7409 with the number of bytes of data to be found after the hole.
7411 @item GNUTYPE_VOLHDR
7413 This file type is used to mark the volume header that was given with
7414 the @value{op-label} option when the archive was created. The @code{name}
7415 field contains the @code{name} given after the @value{op-label} option.
7416 The @code{size} field is zero. Only the first file in each volume
7417 of an archive should have this type.
7421 You may have trouble reading a @acronym{GNU} format archive on a
7422 non-@acronym{GNU} system if the options @value{op-incremental},
7423 @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
7424 used when writing the archive. In general, if @command{tar} does not
7425 use the @acronym{GNU}-added fields of the header, other versions of
7426 @command{tar} should be able to read the archive. Otherwise, the
7427 @command{tar} program will give an error, the most likely one being a
7431 @section Comparison of @command{tar} and @command{cpio}
7434 @FIXME{Reorganize the following material}
7436 The @command{cpio} archive formats, like @command{tar}, do have maximum
7437 pathname lengths. The binary and old ASCII formats have a max path
7438 length of 256, and the new ASCII and CRC ASCII formats have a max
7439 path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
7440 with arbitrary pathname lengths, but other @command{cpio} implementations
7441 may crash unexplainedly trying to read them.
7443 @command{tar} handles symbolic links in the form in which it comes in BSD;
7444 @command{cpio} doesn't handle symbolic links in the form in which it comes
7445 in System V prior to SVR4, and some vendors may have added symlinks
7446 to their system without enhancing @command{cpio} to know about them.
7447 Others may have enhanced it in a way other than the way I did it
7448 at Sun, and which was adopted by AT&T (and which is, I think, also
7449 present in the @command{cpio} that Berkeley picked up from AT&T and put
7450 into a later BSD release---I think I gave them my changes).
7452 (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
7453 can handle @command{tar} format input, and write it on output, and it
7454 probably handles symbolic links. They may not have bothered doing
7455 anything to enhance @command{tar} as a result.)
7457 @command{cpio} handles special files; traditional @command{tar} doesn't.
7459 @command{tar} comes with V7, System III, System V, and BSD source;
7460 @command{cpio} comes only with System III, System V, and later BSD
7461 (4.3-tahoe and later).
7463 @command{tar}'s way of handling multiple hard links to a file can handle
7464 file systems that support 32-bit inumbers (e.g., the BSD file system);
7465 @command{cpio}s way requires you to play some games (in its "binary"
7466 format, i-numbers are only 16 bits, and in its "portable ASCII" format,
7467 they're 18 bits---it would have to play games with the "file system ID"
7468 field of the header to make sure that the file system ID/i-number pairs
7469 of different files were always different), and I don't know which
7470 @command{cpio}s, if any, play those games. Those that don't might get
7471 confused and think two files are the same file when they're not, and
7472 make hard links between them.
7474 @command{tar}s way of handling multiple hard links to a file places only
7475 one copy of the link on the tape, but the name attached to that copy
7476 is the @emph{only} one you can use to retrieve the file; @command{cpio}s
7477 way puts one copy for every link, but you can retrieve it using any
7481 What type of check sum (if any) is used, and how is this calculated.
7484 See the attached manual pages for @command{tar} and @command{cpio} format.
7485 @command{tar} uses a checksum which is the sum of all the bytes in the
7486 @command{tar} header for a file; @command{cpio} uses no checksum.
7489 If anyone knows why @command{cpio} was made when @command{tar} was present
7493 It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
7494 generally-available version of UNIX had @command{tar} at the time. I don't
7495 know whether any version that was generally available @emph{within AT&T}
7496 had @command{tar}, or, if so, whether the people within AT&T who did
7497 @command{cpio} knew about it.
7499 On restore, if there is a corruption on a tape @command{tar} will stop at
7500 that point, while @command{cpio} will skip over it and try to restore the
7503 The main difference is just in the command syntax and header format.
7505 @command{tar} is a little more tape-oriented in that everything is blocked
7506 to start on a record boundary.
7509 Is there any differences between the ability to recover crashed
7510 archives between the two of them. (Is there any chance of recovering
7511 crashed archives at all.)
7514 Theoretically it should be easier under @command{tar} since the blocking
7515 lets you find a header with some variation of @samp{dd skip=@var{nn}}.
7516 However, modern @command{cpio}'s and variations have an option to just
7517 search for the next file header after an error with a reasonable chance
7518 of resyncing. However, lots of tape driver software won't allow you to
7519 continue past a media error which should be the only reason for getting
7520 out of sync unless a file changed sizes while you were writing the
7524 If anyone knows why @command{cpio} was made when @command{tar} was present
7525 at the unix scene, please tell me about this too.
7528 Probably because it is more media efficient (by not blocking everything
7529 and using only the space needed for the headers where @command{tar}
7530 always uses 512 bytes per file header) and it knows how to archive
7533 You might want to look at the freely available alternatives. The
7534 major ones are @command{afio}, @GNUTAR{}, and
7535 @command{pax}, each of which have their own extensions with some
7536 backwards compatibility.
7538 Sparse files were @command{tar}red as sparse files (which you can
7539 easily test, because the resulting archive gets smaller, and
7540 @acronym{GNU} @command{cpio} can no longer read it).
7543 @chapter Tapes and Other Archive Media
7546 A few special cases about tape handling warrant more detailed
7547 description. These special cases are discussed below.
7549 Many complexities surround the use of @command{tar} on tape drives. Since
7550 the creation and manipulation of archives located on magnetic tape was
7551 the original purpose of @command{tar}, it contains many features making
7552 such manipulation easier.
7554 Archives are usually written on dismountable media---tape cartridges,
7555 mag tapes, or floppy disks.
7557 The amount of data a tape or disk holds depends not only on its size,
7558 but also on how it is formatted. A 2400 foot long reel of mag tape
7559 holds 40 megabytes of data when formatted at 1600 bits per inch. The
7560 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
7562 Magnetic media are re-usable---once the archive on a tape is no longer
7563 needed, the archive can be erased and the tape or disk used over.
7564 Media quality does deteriorate with use, however. Most tapes or disks
7565 should be discarded when they begin to produce data errors. EXABYTE
7566 tape cartridges should be discarded when they generate an @dfn{error
7567 count} (number of non-usable bits) of more than 10k.
7569 Magnetic media are written and erased using magnetic fields, and
7570 should be protected from such fields to avoid damage to stored data.
7571 Sticking a floppy disk to a filing cabinet using a magnet is probably
7575 * Device:: Device selection and switching
7576 * Remote Tape Server::
7577 * Common Problems and Solutions::
7578 * Blocking:: Blocking
7579 * Many:: Many archives on one tape
7580 * Using Multiple Tapes:: Using Multiple Tapes
7581 * label:: Including a Label in the Archive
7583 * Write Protection::
7587 @section Device Selection and Switching
7591 @item -f [@var{hostname}:]@var{file}
7592 @itemx --file=[@var{hostname}:]@var{file}
7593 Use archive file or device @var{file} on @var{hostname}.
7596 This option is used to specify the file name of the archive @command{tar}
7599 If the file name is @samp{-}, @command{tar} reads the archive from standard
7600 input (when listing or extracting), or writes it to standard output
7601 (when creating). If the @samp{-} file name is given when updating an
7602 archive, @command{tar} will read the original archive from its standard
7603 input, and will write the entire new archive to its standard output.
7605 If the file name contains a @samp{:}, it is interpreted as
7606 @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
7607 sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
7608 either case, @command{tar} will invoke the command @command{rsh} (or
7609 @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
7610 you give an alternate login name, it will be given to the @command{rsh}.
7611 Naturally, the remote machine must have an executable @file{/etc/rmt}.
7612 This program is free software from the University of California, and a
7613 copy of the source code can be found with the sources for @command{tar};
7614 it's compiled and installed by default.
7616 If this option is not given, but the environment variable @env{TAPE}
7617 is set, its value is used; otherwise, old versions of @command{tar}
7618 used a default archive name (which was picked when @command{tar} was
7619 compiled). The default is normally set up to be the @dfn{first} tape
7620 drive or other transportable I/O medium on the system.
7622 Starting with version 1.11.5, @GNUTAR{} uses
7623 standard input and standard output as the default device, and I will
7624 not try anymore supporting automatic device detection at installation
7625 time. This was failing really in too many cases, it was hopeless.
7626 This is now completely left to the installer to override standard
7627 input and standard output for default device, if this seems
7628 preferable. Further, I think @emph{most} actual usages of
7629 @command{tar} are done with pipes or disks, not really tapes,
7630 cartridges or diskettes.
7632 Some users think that using standard input and output is running
7633 after trouble. This could lead to a nasty surprise on your screen if
7634 you forget to specify an output file name---especially if you are going
7635 through a network or terminal server capable of buffering large amounts
7636 of output. We had so many bug reports in that area of configuring
7637 default tapes automatically, and so many contradicting requests, that
7638 we finally consider the problem to be portably intractable. We could
7639 of course use something like @samp{/dev/tape} as a default, but this
7640 is @emph{also} running after various kind of trouble, going from hung
7641 processes to accidental destruction of real tapes. After having seen
7642 all this mess, using standard input and output as a default really
7643 sounds like the only clean choice left, and a very useful one too.
7645 @GNUTAR{} reads and writes archive in records, I
7646 suspect this is the main reason why block devices are preferred over
7647 character devices. Most probably, block devices are more efficient
7648 too. The installer could also check for @samp{DEFTAPE} in
7649 @file{<sys/mtio.h>}.
7653 Archive file is local even if it contains a colon.
7655 @item --rsh-command=@var{command}
7656 Use remote @var{command} instead of @command{rsh}. This option exists
7657 so that people who use something other than the standard @command{rsh}
7658 (e.g., a Kerberized @command{rsh}) can access a remote device.
7660 When this command is not used, the shell command found when
7661 the @command{tar} program was installed is used instead. This is
7662 the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
7663 @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
7664 The installer may have overridden this by defining the environment
7665 variable @env{RSH} @emph{at installation time}.
7668 Specify drive and density.
7671 @itemx --multi-volume
7672 Create/list/extract multi-volume archive.
7674 This option causes @command{tar} to write a @dfn{multi-volume} archive---one
7675 that may be larger than will fit on the medium used to hold it.
7676 @xref{Multi-Volume Archives}.
7679 @itemx --tape-length=@var{num}
7680 Change tape after writing @var{num} x 1024 bytes.
7682 This option might be useful when your tape drivers do not properly
7683 detect end of physical tapes. By being slightly conservative on the
7684 maximum tape length, you might avoid the problem entirely.
7687 @itemx --info-script=@var{file}
7688 @itemx --new-volume-script=@var{file}
7689 Execute @file{file} at end of each tape. If @file{file} exits with
7690 nonzero status, exit. This implies @value{op-multi-volume}.
7693 @node Remote Tape Server
7694 @section The Remote Tape Server
7696 @cindex remote tape drive
7698 In order to access the tape drive on a remote machine, @command{tar}
7699 uses the remote tape server written at the University of California at
7700 Berkeley. The remote tape server must be installed as @file{/etc/rmt}
7701 on any machine whose tape drive you want to use. @command{tar} calls
7702 @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
7703 machine, optionally using a different login name if one is supplied.
7705 A copy of the source for the remote tape server is provided. It is
7706 Copyright @copyright{} 1983 by the Regents of the University of
7707 California, but can be freely distributed. Instructions for compiling
7708 and installing it are included in the @file{Makefile}.
7710 @cindex absolute file names
7711 Unless you use the @value{op-absolute-names} option, @GNUTAR{}
7712 will not allow you to create an archive that contains
7713 absolute file names (a file name beginning with @samp{/}.) If you try,
7714 @command{tar} will automatically remove the leading @samp{/} from the
7715 file names it stores in the archive. It will also type a warning
7716 message telling you what it is doing.
7718 When reading an archive that was created with a different
7719 @command{tar} program, @GNUTAR{} automatically
7720 extracts entries in the archive which have absolute file names as if
7721 the file names were not absolute. This is an important feature. A
7722 visitor here once gave a @command{tar} tape to an operator to restore;
7723 the operator used Sun @command{tar} instead of @GNUTAR{},
7724 and the result was that it replaced large portions of
7725 our @file{/bin} and friends with versions from the tape; needless to
7726 say, we were unhappy about having to recover the file system from
7729 For example, if the archive contained a file @file{/usr/bin/computoy},
7730 @GNUTAR{} would extract the file to @file{usr/bin/computoy},
7731 relative to the current directory. If you want to extract the files in
7732 an archive to the same absolute names that they had when the archive
7733 was created, you should do a @samp{cd /} before extracting the files
7734 from the archive, or you should either use the @value{op-absolute-names}
7735 option, or use the command @samp{tar -C / @dots{}}.
7737 @cindex Ultrix 3.1 and write failure
7738 Some versions of Unix (Ultrix 3.1 is known to have this problem),
7739 can claim that a short write near the end of a tape succeeded,
7740 when it actually failed. This will result in the -M option not
7741 working correctly. The best workaround at the moment is to use a
7742 significantly larger blocking factor than the default 20.
7744 In order to update an archive, @command{tar} must be able to backspace the
7745 archive in order to reread or rewrite a record that was just read (or
7746 written). This is currently possible only on two kinds of files: normal
7747 disk files (or any other file that can be backspaced with @samp{lseek}),
7748 and industry-standard 9-track magnetic tape (or any other kind of tape
7749 that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
7751 This means that the @value{op-append}, @value{op-update},
7752 @value{op-concatenate}, and @value{op-delete} commands will not work on any
7753 other kind of file. Some media simply cannot be backspaced, which
7754 means these commands and options will never be able to work on them.
7755 These non-backspacing media include pipes and cartridge tape drives.
7757 Some other media can be backspaced, and @command{tar} will work on them
7758 once @command{tar} is modified to do so.
7760 Archives created with the @value{op-multi-volume}, @value{op-label}, and
7761 @value{op-incremental} options may not be readable by other version
7762 of @command{tar}. In particular, restoring a file that was split over
7763 a volume boundary will require some careful work with @command{dd}, if
7764 it can be done at all. Other versions of @command{tar} may also create
7765 an empty file whose name is that of the volume header. Some versions
7766 of @command{tar} may create normal files instead of directories archived
7767 with the @value{op-incremental} option.
7769 @node Common Problems and Solutions
7770 @section Some Common Problems and their Solutions
7777 no such file or directory
7780 errors from @command{tar}:
7781 directory checksum error
7784 errors from media/system:
7795 @dfn{Block} and @dfn{record} terminology is rather confused, and it
7796 is also confusing to the expert reader. On the other hand, readers
7797 who are new to the field have a fresh mind, and they may safely skip
7798 the next two paragraphs, as the remainder of this manual uses those
7799 two terms in a quite consistent way.
7801 John Gilmore, the writer of the public domain @command{tar} from which
7802 @GNUTAR{} was originally derived, wrote (June 1995):
7805 The nomenclature of tape drives comes from IBM, where I believe
7806 they were invented for the IBM 650 or so. On IBM mainframes, what
7807 is recorded on tape are tape blocks. The logical organization of
7808 data is into records. There are various ways of putting records into
7809 blocks, including @code{F} (fixed sized records), @code{V} (variable
7810 sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
7811 to a block), @code{VB} (variable size records, @var{n} to a block),
7812 @code{VSB} (variable spanned blocked: variable sized records that can
7813 occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
7814 parameter specified this to the operating system.
7816 The Unix man page on @command{tar} was totally confused about this.
7817 When I wrote @code{PD TAR}, I used the historically correct terminology
7818 (@command{tar} writes data records, which are grouped into blocks).
7819 It appears that the bogus terminology made it into @sc{posix} (no surprise
7820 here), and now Fran@,{c}ois has migrated that terminology back
7821 into the source code too.
7824 The term @dfn{physical block} means the basic transfer chunk from or
7825 to a device, after which reading or writing may stop without anything
7826 being lost. In this manual, the term @dfn{block} usually refers to
7827 a disk physical block, @emph{assuming} that each disk block is 512
7828 bytes in length. It is true that some disk devices have different
7829 physical blocks, but @command{tar} ignore these differences in its own
7830 format, which is meant to be portable, so a @command{tar} block is always
7831 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
7832 The term @dfn{logical block} often represents the basic chunk of
7833 allocation of many disk blocks as a single entity, which the operating
7834 system treats somewhat atomically; this concept is only barely used
7837 The term @dfn{physical record} is another way to speak of a physical
7838 block, those two terms are somewhat interchangeable. In this manual,
7839 the term @dfn{record} usually refers to a tape physical block,
7840 @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
7841 It is true that archives may be put on disk or used with pipes,
7842 but nevertheless, @command{tar} tries to read and write the archive one
7843 @dfn{record} at a time, whatever the medium in use. One record is made
7844 up of an integral number of blocks, and this operation of putting many
7845 disk blocks into a single tape block is called @dfn{reblocking}, or
7846 more simply, @dfn{blocking}. The term @dfn{logical record} refers to
7847 the logical organization of many characters into something meaningful
7848 to the application. The term @dfn{unit record} describes a small set
7849 of characters which are transmitted whole to or by the application,
7850 and often refers to a line of text. Those two last terms are unrelated
7851 to what we call a @dfn{record} in @GNUTAR{}.
7853 When writing to tapes, @command{tar} writes the contents of the archive
7854 in chunks known as @dfn{records}. To change the default blocking
7855 factor, use the @value{op-blocking-factor} option. Each record will
7856 then be composed of @var{512-size} blocks. (Each @command{tar} block is
7857 512 bytes. @xref{Standard}.) Each file written to the archive uses
7858 at least one full record. As a result, using a larger record size
7859 can result in more wasted space for small files. On the other hand, a
7860 larger record size can often be read and written much more efficiently.
7862 Further complicating the problem is that some tape drives ignore the
7863 blocking entirely. For these, a larger record size can still improve
7864 performance (because the software layers above the tape drive still
7865 honor the blocking), but not as dramatically as on tape drives that
7868 When reading an archive, @command{tar} can usually figure out the
7869 record size on itself. When this is the case, and a non-standard
7870 record size was used when the archive was created, @command{tar} will
7871 print a message about a non-standard blocking factor, and then operate
7872 normally. On some tape devices, however, @command{tar} cannot figure
7873 out the record size itself. On most of those, you can specify a
7874 blocking factor (with @value{op-blocking-factor}) larger than the
7875 actual blocking factor, and then use the @value{op-read-full-records}
7876 option. (If you specify a blocking factor with
7877 @value{op-blocking-factor} and don't use the
7878 @value{op-read-full-records} option, then @command{tar} will not
7879 attempt to figure out the recording size itself.) On some devices,
7880 you must always specify the record size exactly with
7881 @value{op-blocking-factor} when reading, because @command{tar} cannot
7882 figure it out. In any case, use @value{op-list} before doing any
7883 extractions to see whether @command{tar} is reading the archive
7886 @command{tar} blocks are all fixed size (512 bytes), and its scheme for
7887 putting them into records is to put a whole number of them (one or
7888 more) into each record. @command{tar} records are all the same size;
7889 at the end of the file there's a block containing all zeros, which
7890 is how you tell that the remainder of the last record(s) are garbage.
7892 In a standard @command{tar} file (no options), the block size is 512
7893 and the record size is 10240, for a blocking factor of 20. What the
7894 @value{op-blocking-factor} option does is sets the blocking factor,
7895 changing the record size while leaving the block size at 512 bytes.
7896 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
7897 most tape drives these days prefer much bigger records in order to
7898 stream and not waste tape. When writing tapes for myself, some tend
7899 to use a factor of the order of 2048, say, giving a record size of
7900 around one megabyte.
7902 If you use a blocking factor larger than 20, older @command{tar}
7903 programs might not be able to read the archive, so we recommend this
7904 as a limit to use in practice. @GNUTAR{}, however,
7905 will support arbitrarily large record sizes, limited only by the
7906 amount of virtual memory or the physical characteristics of the tape
7910 * Format Variations:: Format Variations
7911 * Blocking Factor:: The Blocking Factor of an Archive
7914 @node Format Variations
7915 @subsection Format Variations
7916 @cindex Format Parameters
7917 @cindex Format Options
7918 @cindex Options, archive format specifying
7919 @cindex Options, format specifying
7922 Format parameters specify how an archive is written on the archive
7923 media. The best choice of format parameters will vary depending on
7924 the type and number of files being archived, and on the media used to
7927 To specify format parameters when accessing or creating an archive,
7928 you can use the options described in the following sections.
7929 If you do not specify any format parameters, @command{tar} uses
7930 default parameters. You cannot modify a compressed archive.
7931 If you create an archive with the @value{op-blocking-factor} option
7932 specified (@value{pxref-blocking-factor}), you must specify that
7933 blocking-factor when operating on the archive. @xref{Formats}, for other
7934 examples of format parameter considerations.
7936 @node Blocking Factor
7937 @subsection The Blocking Factor of an Archive
7938 @cindex Blocking Factor
7940 @cindex Number of blocks per record
7941 @cindex Number of bytes per record
7942 @cindex Bytes per record
7943 @cindex Blocks per record
7946 The data in an archive is grouped into blocks, which are 512 bytes.
7947 Blocks are read and written in whole number multiples called
7948 @dfn{records}. The number of blocks in a record (ie. the size of a
7949 record in units of 512 bytes) is called the @dfn{blocking factor}.
7950 The @value{op-blocking-factor} option specifies the blocking factor of
7951 an archive. The default blocking factor is typically 20 (ie.@:
7952 10240 bytes), but can be specified at installation. To find out
7953 the blocking factor of an existing archive, use @samp{tar --list
7954 --file=@var{archive-name}}. This may not work on some devices.
7956 Records are separated by gaps, which waste space on the archive media.
7957 If you are archiving on magnetic tape, using a larger blocking factor
7958 (and therefore larger records) provides faster throughput and allows you
7959 to fit more data on a tape (because there are fewer gaps). If you are
7960 archiving on cartridge, a very large blocking factor (say 126 or more)
7961 greatly increases performance. A smaller blocking factor, on the other
7962 hand, may be useful when archiving small files, to avoid archiving lots
7963 of nulls as @command{tar} fills out the archive to the end of the record.
7964 In general, the ideal record size depends on the size of the
7965 inter-record gaps on the tape you are using, and the average size of the
7966 files you are archiving. @xref{create}, for information on
7969 @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
7971 Archives with blocking factors larger than 20 cannot be read
7972 by very old versions of @command{tar}, or by some newer versions
7973 of @command{tar} running on old machines with small address spaces.
7974 With @GNUTAR{}, the blocking factor of an archive is limited
7975 only by the maximum record size of the device containing the archive,
7976 or by the amount of available virtual memory.
7978 Also, on some systems, not using adequate blocking factors, as sometimes
7979 imposed by the device drivers, may yield unexpected diagnostics. For
7980 example, this has been reported:
7983 Cannot write to /dev/dlt: Invalid argument
7987 In such cases, it sometimes happen that the @command{tar} bundled by
7988 the system is aware of block size idiosyncrasies, while @GNUTAR{}
7989 requires an explicit specification for the block size,
7990 which it cannot guess. This yields some people to consider
7991 @GNUTAR{} is misbehaving, because by comparison,
7992 @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
7993 for example, might resolve the problem.
7995 If you use a non-default blocking factor when you create an archive, you
7996 must specify the same blocking factor when you modify that archive. Some
7997 archive devices will also require you to specify the blocking factor when
7998 reading that archive, however this is not typically the case. Usually, you
7999 can use @value{op-list} without specifying a blocking factor---@command{tar}
8000 reports a non-default record size and then lists the archive members as
8001 it would normally. To extract files from an archive with a non-standard
8002 blocking factor (particularly if you're not sure what the blocking factor
8003 is), you can usually use the @value{op-read-full-records} option while
8004 specifying a blocking factor larger then the blocking factor of the archive
8005 (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
8006 @xref{list}, for more information on the @value{op-list}
8007 operation. @xref{Reading}, for a more detailed explanation of that option.
8010 @item --blocking-factor=@var{number}
8011 @itemx -b @var{number}
8012 Specifies the blocking factor of an archive. Can be used with any
8013 operation, but is usually not necessary with @value{op-list}.
8019 @item -b @var{blocks}
8020 @itemx --blocking-factor=@var{blocks}
8021 Set record size to @math{@var{blocks} * 512} bytes.
8023 This option is used to specify a @dfn{blocking factor} for the archive.
8024 When reading or writing the archive, @command{tar}, will do reads and writes
8025 of the archive in records of @math{@var{block}*512} bytes. This is true
8026 even when the archive is compressed. Some devices requires that all
8027 write operations be a multiple of a certain size, and so, @command{tar}
8028 pads the archive out to the next record boundary.
8030 The default blocking factor is set when @command{tar} is compiled, and is
8031 typically 20. Blocking factors larger than 20 cannot be read by very
8032 old versions of @command{tar}, or by some newer versions of @command{tar}
8033 running on old machines with small address spaces.
8035 With a magnetic tape, larger records give faster throughput and fit
8036 more data on a tape (because there are fewer inter-record gaps).
8037 If the archive is in a disk file or a pipe, you may want to specify
8038 a smaller blocking factor, since a large one will result in a large
8039 number of null bytes at the end of the archive.
8041 When writing cartridge or other streaming tapes, a much larger
8042 blocking factor (say 126 or more) will greatly increase performance.
8043 However, you must specify the same blocking factor when reading or
8044 updating the archive.
8046 Apparently, Exabyte drives have a physical block size of 8K bytes.
8047 If we choose our blocksize as a multiple of 8k bytes, then the problem
8048 seems to disappear. Id est, we are using block size of 112 right
8049 now, and we haven't had the problem since we switched@dots{}
8051 With @GNUTAR{} the blocking factor is limited only
8052 by the maximum record size of the device containing the archive, or by
8053 the amount of available virtual memory.
8055 However, deblocking or reblocking is virtually avoided in a special
8056 case which often occurs in practice, but which requires all the
8057 following conditions to be simultaneously true:
8060 the archive is subject to a compression option,
8062 the archive is not handled through standard input or output, nor
8063 redirected nor piped,
8065 the archive is directly handled to a local disk, instead of any special
8068 @value{op-blocking-factor} is not explicitly specified on the @command{tar}
8072 If the output goes directly to a local disk, and not through
8073 stdout, then the last write is not extended to a full record size.
8074 Otherwise, reblocking occurs. Here are a few other remarks on this
8080 @command{gzip} will complain about trailing garbage if asked to
8081 uncompress a compressed archive on tape, there is an option to turn
8082 the message off, but it breaks the regularity of simply having to use
8083 @samp{@var{prog} -d} for decompression. It would be nice if gzip was
8084 silently ignoring any number of trailing zeros. I'll ask Jean-loup
8085 Gailly, by sending a copy of this message to him.
8088 @command{compress} does not show this problem, but as Jean-loup pointed
8089 out to Michael, @samp{compress -d} silently adds garbage after
8090 the result of decompression, which tar ignores because it already
8091 recognized its end-of-file indicator. So this bug may be safely
8095 @samp{gzip -d -q} will be silent about the trailing zeros indeed,
8096 but will still return an exit status of 2 which tar reports in turn.
8097 @command{tar} might ignore the exit status returned, but I hate doing
8098 that, as it weakens the protection @command{tar} offers users against
8099 other possible problems at decompression time. If @command{gzip} was
8100 silently skipping trailing zeros @emph{and} also avoiding setting the
8101 exit status in this innocuous case, that would solve this situation.
8104 @command{tar} should become more solid at not stopping to read a pipe at
8105 the first null block encountered. This inelegantly breaks the pipe.
8106 @command{tar} should rather drain the pipe out before exiting itself.
8110 @itemx --ignore-zeros
8111 Ignore blocks of zeros in archive (means EOF).
8113 The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
8114 of zeros in the archive. Normally a block of zeros indicates the
8115 end of the archive, but when reading a damaged archive, or one which
8116 was created by concatenating several archives together, this option
8117 allows @command{tar} to read the entire archive. This option is not on
8118 by default because many versions of @command{tar} write garbage after
8121 Note that this option causes @command{tar} to read to the end of the
8122 archive file, which may sometimes avoid problems when multiple files
8123 are stored on a single physical tape.
8126 @itemx --read-full-records
8127 Reblock as we read (for reading 4.2BSD pipes).
8129 If @value{op-read-full-records} is used, @command{tar} will not panic if an
8130 attempt to read a record from the archive does not return a full record.
8131 Instead, @command{tar} will keep reading until it has obtained a full
8134 This option is turned on by default when @command{tar} is reading
8135 an archive from standard input, or from a remote machine. This is
8136 because on BSD Unix systems, a read of a pipe will return however
8137 much happens to be in the pipe, even if it is less than @command{tar}
8138 requested. If this option was not used, @command{tar} would fail as
8139 soon as it read an incomplete record from the pipe.
8141 This option is also useful with the commands for updating an archive.
8147 @FIXME{Appropriate options should be moved here from elsewhere.}
8149 @cindex blocking factor
8150 @cindex tape blocking
8152 When handling various tapes or cartridges, you have to take care of
8153 selecting a proper blocking, that is, the number of disk blocks you
8154 put together as a single tape block on the tape, without intervening
8155 tape gaps. A @dfn{tape gap} is a small landing area on the tape
8156 with no information on it, used for decelerating the tape to a
8157 full stop, and for later regaining the reading or writing speed.
8158 When the tape driver starts reading a record, the record has to
8159 be read whole without stopping, as a tape gap is needed to stop the
8160 tape motion without loosing information.
8162 @cindex Exabyte blocking
8163 @cindex DAT blocking
8164 Using higher blocking (putting more disk blocks per tape block) will use
8165 the tape more efficiently as there will be less tape gaps. But reading
8166 such tapes may be more difficult for the system, as more memory will be
8167 required to receive at once the whole record. Further, if there is a
8168 reading error on a huge record, this is less likely that the system will
8169 succeed in recovering the information. So, blocking should not be too
8170 low, nor it should be too high. @command{tar} uses by default a blocking of
8171 20 for historical reasons, and it does not really matter when reading or
8172 writing to disk. Current tape technology would easily accommodate higher
8173 blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
8174 We were told that for some DLT drives, the blocking should be a multiple
8175 of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
8176 Other manufacturers may use different recommendations for the same tapes.
8177 This might also depends of the buffering techniques used inside modern
8178 tape controllers. Some imposes a minimum blocking, or a maximum blocking.
8179 Others request blocking to be some exponent of two.
8181 So, there is no fixed rule for blocking. But blocking at read time
8182 should ideally be the same as blocking used at write time. At one place
8183 I know, with a wide variety of equipment, they found it best to use a
8184 blocking of 32 to guarantee that their tapes are fully interchangeable.
8186 I was also told that, for recycled tapes, prior erasure (by the same
8187 drive unit that will be used to create the archives) sometimes lowers
8188 the error rates observed at rewriting time.
8190 I might also use @samp{--number-blocks} instead of
8191 @samp{--block-number}, so @samp{--block} will then expand to
8192 @samp{--blocking-factor} unambiguously.
8195 @section Many Archives on One Tape
8197 @FIXME{Appropriate options should be moved here from elsewhere.}
8199 @findex ntape @r{device}
8200 Most tape devices have two entries in the @file{/dev} directory, or
8201 entries that come in pairs, which differ only in the minor number for
8202 this device. Let's take for example @file{/dev/tape}, which often
8203 points to the only or usual tape device of a given system. There might
8204 be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
8205 name is the @emph{rewinding} version of the device, while the name
8206 having @samp{nr} in it is the @emph{no rewinding} version of the same
8209 A rewinding tape device will bring back the tape to its beginning point
8210 automatically when this device is opened or closed. Since @command{tar}
8211 opens the archive file before using it and closes it afterwards, this
8212 means that a simple:
8215 $ @kbd{tar cf /dev/tape @var{directory}}
8219 will reposition the tape to its beginning both prior and after saving
8220 @var{directory} contents to it, thus erasing prior tape contents and
8221 making it so that any subsequent write operation will destroy what has
8224 @cindex tape positioning
8225 So, a rewinding device is normally meant to hold one and only one file.
8226 If you want to put more than one @command{tar} archive on a given tape, you
8227 will need to avoid using the rewinding version of the tape device. You
8228 will also have to pay special attention to tape positioning. Errors in
8229 positioning may overwrite the valuable data already on your tape. Many
8230 people, burnt by past experiences, will only use rewinding devices and
8231 limit themselves to one file per tape, precisely to avoid the risk of
8232 such errors. Be fully aware that writing at the wrong position on a
8233 tape loses all information past this point and most probably until the
8234 end of the tape, and this destroyed information @emph{cannot} be
8237 To save @var{directory-1} as a first archive at the beginning of a
8238 tape, and leave that tape ready for a second archive, you should use:
8241 $ @kbd{mt -f /dev/nrtape rewind}
8242 $ @kbd{tar cf /dev/nrtape @var{directory-1}}
8246 @dfn{Tape marks} are special magnetic patterns written on the tape
8247 media, which are later recognizable by the reading hardware. These
8248 marks are used after each file, when there are many on a single tape.
8249 An empty file (that is to say, two tape marks in a row) signal the
8250 logical end of the tape, after which no file exist. Usually,
8251 non-rewinding tape device drivers will react to the close request issued
8252 by @command{tar} by first writing two tape marks after your archive, and by
8253 backspacing over one of these. So, if you remove the tape at that time
8254 from the tape drive, it is properly terminated. But if you write
8255 another file at the current position, the second tape mark will be
8256 erased by the new information, leaving only one tape mark between files.
8258 So, you may now save @var{directory-2} as a second archive after the
8259 first on the same tape by issuing the command:
8262 $ @kbd{tar cf /dev/nrtape @var{directory-2}}
8266 and so on for all the archives you want to put on the same tape.
8268 Another usual case is that you do not write all the archives the same
8269 day, and you need to remove and store the tape between two archive
8270 sessions. In general, you must remember how many files are already
8271 saved on your tape. Suppose your tape already has 16 files on it, and
8272 that you are ready to write the 17th. You have to take care of skipping
8273 the first 16 tape marks before saving @var{directory-17}, say, by using
8277 $ @kbd{mt -f /dev/nrtape rewind}
8278 $ @kbd{mt -f /dev/nrtape fsf 16}
8279 $ @kbd{tar cf /dev/nrtape @var{directory-17}}
8282 In all the previous examples, we put aside blocking considerations, but
8283 you should do the proper things for that as well. @xref{Blocking}.
8286 * Tape Positioning:: Tape Positions and Tape Marks
8287 * mt:: The @command{mt} Utility
8290 @node Tape Positioning
8291 @subsection Tape Positions and Tape Marks
8294 Just as archives can store more than one file from the file system,
8295 tapes can store more than one archive file. To keep track of where
8296 archive files (or any other type of file stored on tape) begin and
8297 end, tape archive devices write magnetic @dfn{tape marks} on the
8298 archive media. Tape drives write one tape mark between files,
8299 two at the end of all the file entries.
8301 If you think of data as a series of records "rrrr"'s, and tape marks as
8302 "*"'s, a tape might look like the following:
8305 rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
8308 Tape devices read and write tapes using a read/write @dfn{tape
8309 head}---a physical part of the device which can only access one
8310 point on the tape at a time. When you use @command{tar} to read or
8311 write archive data from a tape device, the device will begin reading
8312 or writing from wherever on the tape the tape head happens to be,
8313 regardless of which archive or what part of the archive the tape
8314 head is on. Before writing an archive, you should make sure that no
8315 data on the tape will be overwritten (unless it is no longer needed).
8316 Before reading an archive, you should make sure the tape head is at
8317 the beginning of the archive you want to read. (The @code{restore}
8318 script will find the archive automatically. @FIXME{There is no such
8319 restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
8320 an explanation of the tape moving utility.
8322 If you want to add new archive file entries to a tape, you should
8323 advance the tape to the end of the existing file entries, backspace
8324 over the last tape mark, and write the new archive file. If you were
8325 to add two archives to the example above, the tape might look like the
8329 rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
8333 @subsection The @command{mt} Utility
8336 @FIXME{Is it true that this only works on non-block devices?
8337 should explain the difference, (fixed or variable).}
8338 @value{xref-blocking-factor}.
8340 You can use the @command{mt} utility to advance or rewind a tape past a
8341 specified number of archive files on the tape. This will allow you
8342 to move to the beginning of an archive before extracting or reading
8343 it, or to the end of all the archives before writing a new one.
8344 @FIXME{Why isn't there an "advance 'til you find two tape marks
8347 The syntax of the @command{mt} command is:
8350 @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
8353 where @var{tapename} is the name of the tape device, @var{number} is
8354 the number of times an operation is performed (with a default of one),
8355 and @var{operation} is one of the following:
8357 @FIXME{is there any use for record operations?}
8362 Writes @var{number} tape marks at the current position on the tape.
8365 Moves tape position forward @var{number} files.
8368 Moves tape position back @var{number} files.
8371 Rewinds the tape. (Ignores @var{number}).
8375 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
8378 Prints status information about the tape unit.
8382 @FIXME{Is there a better way to frob the spacing on the list?}
8384 If you don't specify a @var{tapename}, @command{mt} uses the environment
8385 variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
8388 @command{mt} returns a 0 exit status when the operation(s) were
8389 successful, 1 if the command was unrecognized, and 2 if an operation
8392 @FIXME{New node on how to find an archive?}
8394 If you use @value{op-extract} with the @value{op-label} option specified,
8395 @command{tar} will read an archive label (the tape head has to be positioned
8396 on it) and print an error if the archive label doesn't match the
8397 @var{archive-name} specified. @var{archive-name} can be any regular
8398 expression. If the labels match, @command{tar} extracts the archive.
8400 @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
8401 references}@samp{tar --list --label} will cause @command{tar} to print the
8404 @FIXME{Program to list all the labels on a tape?}
8406 @node Using Multiple Tapes
8407 @section Using Multiple Tapes
8410 Often you might want to write a large archive, one larger than will fit
8411 on the actual tape you are using. In such a case, you can run multiple
8412 @command{tar} commands, but this can be inconvenient, particularly if you
8413 are using options like @value{op-exclude} or dumping entire filesystems.
8414 Therefore, @command{tar} supports multiple tapes automatically.
8416 Use @value{op-multi-volume} on the command line, and then @command{tar} will,
8417 when it reaches the end of the tape, prompt for another tape, and
8418 continue the archive. Each tape will have an independent archive, and
8419 can be read without needing the other. (As an exception to this, the
8420 file that @command{tar} was archiving when it ran out of tape will usually
8421 be split between the two archives; in this case you need to extract from
8422 the first archive, using @value{op-multi-volume}, and then put in the
8423 second tape when prompted, so @command{tar} can restore both halves of the
8426 @GNUTAR{} multi-volume archives do not use a truly
8427 portable format. You need @GNUTAR{} at both end to
8428 process them properly.
8430 When prompting for a new tape, @command{tar} accepts any of the following
8435 Request @command{tar} to explain possible responses
8437 Request @command{tar} to exit immediately.
8438 @item n @var{file name}
8439 Request @command{tar} to write the next volume on the file @var{file name}.
8441 Request @command{tar} to run a subshell.
8443 Request @command{tar} to begin writing the next volume.
8446 (You should only type @samp{y} after you have changed the tape;
8447 otherwise @command{tar} will write over the volume it just finished.)
8449 If you want more elaborate behavior than this, give @command{tar} the
8450 @value{op-info-script} option. The file @var{script-name} is expected
8451 to be a program (or shell script) to be run instead of the normal
8452 prompting procedure. If the program fails, @command{tar} exits;
8453 otherwise, @command{tar} begins writing the next volume. The behavior
8455 @samp{n} response to the normal tape-change prompt is not available
8456 if you use @value{op-info-script}.
8458 The method @command{tar} uses to detect end of tape is not perfect, and
8459 fails on some operating systems or on some devices. You can use the
8460 @value{op-tape-length} option if @command{tar} can't detect the end of the
8461 tape itself. This option selects @value{op-multi-volume} automatically.
8462 The @var{size} argument should then be the usable size of the tape.
8463 But for many devices, and floppy disks in particular, this option is
8464 never required for real, as far as we know.
8466 The volume number used by @command{tar} in its tape-change prompt
8467 can be changed; if you give the @value{op-volno-file} option, then
8468 @var{file-of-number} should be an unexisting file to be created, or else,
8469 a file already containing a decimal number. That number will be used
8470 as the volume number of the first volume written. When @command{tar} is
8471 finished, it will rewrite the file with the now-current volume number.
8472 (This does not change the volume number written on a tape label, as
8473 per @value{ref-label}, it @emph{only} affects the number used in
8476 If you want @command{tar} to cycle through a series of tape drives, then
8477 you can use the @samp{n} response to the tape-change prompt. This is
8478 error prone, however, and doesn't work at all with @value{op-info-script}.
8479 Therefore, if you give @command{tar} multiple @value{op-file} options, then
8480 the specified files will be used, in sequence, as the successive volumes
8481 of the archive. Only when the first one in the sequence needs to be
8482 used again will @command{tar} prompt for a tape change (or run the info
8485 Multi-volume archives
8487 With @value{op-multi-volume}, @command{tar} will not abort when it cannot
8488 read or write any more data. Instead, it will ask you to prepare a new
8489 volume. If the archive is on a magnetic tape, you should change tapes
8490 now; if the archive is on a floppy disk, you should change disks, etc.
8492 Each volume of a multi-volume archive is an independent @command{tar}
8493 archive, complete in itself. For example, you can list or extract any
8494 volume alone; just don't specify @value{op-multi-volume}. However, if one
8495 file in the archive is split across volumes, the only way to extract
8496 it successfully is with a multi-volume extract command @samp{--extract
8497 --multi-volume} (@samp{-xM}) starting on or before the volume where
8500 For example, let's presume someone has two tape drives on a system
8501 named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
8502 to switch to the second drive when it needs to write the
8503 second tape, and then back to the first tape, etc., just do either of:
8506 $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
8507 $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
8511 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
8512 * Tape Files:: Tape Files
8515 @node Multi-Volume Archives
8516 @subsection Archives Longer than One Tape or Disk
8517 @cindex Multi-volume archives
8520 To create an archive that is larger than will fit on a single unit of
8521 the media, use the @value{op-multi-volume} option in conjunction with
8522 the @value{op-create} option (@pxref{create}). A
8523 @dfn{multi-volume} archive can be manipulated like any other archive
8524 (provided the @value{op-multi-volume} option is specified), but is
8525 stored on more than one tape or disk.
8527 When you specify @value{op-multi-volume}, @command{tar} does not report an
8528 error when it comes to the end of an archive volume (when reading), or
8529 the end of the media (when writing). Instead, it prompts you to load
8530 a new storage volume. If the archive is on a magnetic tape, you
8531 should change tapes when you see the prompt; if the archive is on a
8532 floppy disk, you should change disks; etc.
8534 You can read each individual volume of a multi-volume archive as if it
8535 were an archive by itself. For example, to list the contents of one
8536 volume, use @value{op-list}, without @value{op-multi-volume} specified.
8537 To extract an archive member from one volume (assuming it is described
8538 that volume), use @value{op-extract}, again without
8539 @value{op-multi-volume}.
8541 If an archive member is split across volumes (ie. its entry begins on
8542 one volume of the media and ends on another), you need to specify
8543 @value{op-multi-volume} to extract it successfully. In this case, you
8544 should load the volume where the archive member starts, and use
8545 @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
8546 volumes as it needs them. @xref{extracting archives}, for more
8547 information about extracting archives.
8549 @value{op-info-script} is like @value{op-multi-volume}, except that
8550 @command{tar} does not prompt you directly to change media volumes when
8551 a volume is full---instead, @command{tar} runs commands you have stored
8552 in @var{script-name}. For example, this option can be used to eject
8553 cassettes, or to broadcast messages such as @samp{Someone please come
8554 change my tape} when performing unattended backups. When @var{script-name}
8555 is done, @command{tar} will assume that the media has been changed.
8557 Multi-volume archives can be modified like any other archive. To add
8558 files to a multi-volume archive, you need to only mount the last
8559 volume of the archive media (and new volumes, if needed). For all
8560 other operations, you need to use the entire archive.
8562 If a multi-volume archive was labeled using @value{op-label}
8563 (@value{pxref-label}) when it was created, @command{tar} will not
8564 automatically label volumes which are added later. To label subsequent
8565 volumes, specify @value{op-label} again in conjunction with the
8566 @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
8568 @cindex Labeling multi-volume archives
8571 @FIXME{There should be a sample program here, including an exit
8572 before end. Is the exit status even checked in tar? :-(}
8575 @item --multi-volume
8577 Creates a multi-volume archive, when used in conjunction with
8578 @value{op-create}. To perform any other operation on a multi-volume
8579 archive, specify @value{op-multi-volume} in conjunction with that
8582 @item --info-script=@var{program-file}
8583 @itemx -F @var{program-file}
8584 Creates a multi-volume archive via a script. Used in conjunction with
8588 Beware that there is @emph{no} real standard about the proper way, for
8589 a @command{tar} archive, to span volume boundaries. If you have a
8590 multi-volume created by some vendor's @command{tar}, there is almost
8591 no chance you could read all the volumes with @GNUTAR{}.
8592 The converse is also true: you may not expect
8593 multi-volume archives created by @GNUTAR{} to be
8594 fully recovered by vendor's @command{tar}. Since there is little
8595 chance that, in mixed system configurations, some vendor's
8596 @command{tar} will work on another vendor's machine, and there is a
8597 great chance that @GNUTAR{} will work on most of
8598 them, your best bet is to install @GNUTAR{} on all
8599 machines between which you know exchange of files is possible.
8602 @subsection Tape Files
8605 To give the archive a name which will be recorded in it, use the
8606 @value{op-label} option. This will write a special block identifying
8607 @var{volume-label} as the name of the archive to the front of the archive
8608 which will be displayed when the archive is listed with @value{op-list}.
8609 If you are creating a multi-volume archive with
8610 @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
8611 volume label will have
8612 @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
8613 the number of the volume of the archive. (If you use the @value{op-label}
8614 option when reading an archive, it checks to make sure the label on the
8615 tape matches the one you give. @value{xref-label}.
8617 When @command{tar} writes an archive to tape, it creates a single
8618 tape file. If multiple archives are written to the same tape, one
8619 after the other, they each get written as separate tape files. When
8620 extracting, it is necessary to position the tape at the right place
8621 before running @command{tar}. To do this, use the @command{mt} command.
8622 For more information on the @command{mt} command and on the organization
8623 of tapes into a sequence of tape files, see @ref{mt}.
8625 People seem to often do:
8628 @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
8631 or such, for pushing a common date in all volumes or an archive set.
8634 @section Including a Label in the Archive
8635 @cindex Labeling an archive
8636 @cindex Labels on the archive media
8641 @itemx --label=@var{name}
8642 Create archive with volume name @var{name}.
8645 This option causes @command{tar} to write out a @dfn{volume header} at
8646 the beginning of the archive. If @value{op-multi-volume} is used, each
8647 volume of the archive will have a volume header of @samp{@var{name}
8648 Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
8651 @FIXME{Should the arg to --label be a quoted string?? No.}
8653 To avoid problems caused by misplaced paper labels on the archive
8654 media, you can include a @dfn{label} entry---an archive member which
8655 contains the name of the archive---in the archive itself. Use the
8656 @value{op-label} option in conjunction with the @value{op-create} operation
8657 to include a label entry in the archive as it is being created.
8659 If you create an archive using both @value{op-label} and
8660 @value{op-multi-volume}, each volume of the archive will have an
8661 archive label of the form @samp{@var{archive-label} Volume @var{n}},
8662 where @var{n} is 1 for the first volume, 2 for the next, and so on.
8663 @FIXME-xref{Multi-Volume Archives, for information on creating multiple
8666 If you list or extract an archive using @value{op-label}, @command{tar} will
8667 print an error if the archive label doesn't match the @var{archive-label}
8668 specified, and will then not list nor extract the archive. In those cases,
8669 @var{archive-label} argument is interpreted as a globbing-style pattern
8670 which must match the actual magnetic volume label. @xref{exclude}, for
8671 a precise description of how match is attempted@footnote{Previous versions
8672 of @command{tar} used full regular expression matching, or before that, only
8673 exact string matching, instead of wildcard matchers. We decided for the
8674 sake of simplicity to use a uniform matching device through @command{tar}.}.
8675 If the switch @value{op-multi-volume} is being used, the volume label
8676 matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
8677 if the initial match fails, before giving up. Since the volume numbering
8678 is automatically added in labels at creation time, it sounded logical to
8679 equally help the user taking care of it when the archive is being read.
8681 The @value{op-label} was once called @samp{--volume}, but is not available
8682 under that name anymore.
8684 To find out an archive's label entry (or to find out if an archive has
8685 a label at all), use @samp{tar --list --verbose}. @command{tar} will
8686 print the label first, and then print archive member information, as
8687 in the example below:
8690 $ @kbd{tar --verbose --list --file=iamanarchive}
8691 V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
8692 -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
8696 @item --label=@var{archive-label}
8697 @itemx -V @var{archive-label}
8698 Includes an @dfn{archive-label} at the beginning of the archive when
8699 the archive is being created, when used in conjunction with the
8700 @value{op-create} option. Checks to make sure the archive label
8701 matches the one specified (when used in conjunction with the
8702 @value{op-extract} option.
8705 To get a common information on all tapes of a series, use the
8706 @value{op-label} option. For having this information different in each
8707 series created through a single script used on a regular basis, just
8708 manage to get some date string as part of the label. For example:
8711 $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
8712 $ @kbd{tar --create --file=/dev/tape --multi-volume \
8713 --volume="Daily backup for `date +%Y-%m-%d`"}
8716 Also note that each label has its own date and time, which corresponds
8717 to when @GNUTAR{} initially attempted to write it,
8718 often soon after the operator launches @command{tar} or types the
8719 carriage return telling that the next tape is ready. Comparing date
8720 labels does give an idea of tape throughput only if the delays for
8721 rewinding tapes and the operator switching them were negligible, which
8722 is usually not the case.
8724 @FIXME{was --volume}
8727 @section Verifying Data as It is Stored
8728 @cindex Verifying a write operation
8729 @cindex Double-checking a write operation
8734 Attempt to verify the archive after writing.
8737 This option causes @command{tar} to verify the archive after writing it.
8738 Each volume is checked after it is written, and any discrepancies
8739 are recorded on the standard error output.
8741 Verification requires that the archive be on a back-space-able medium.
8742 This means pipes, some cartridge tape drives, and some other devices
8745 You can insure the accuracy of an archive by comparing files in the
8746 system with archive members. @command{tar} can compare an archive to the
8747 file system as the archive is being written, to verify a write
8748 operation, or can compare a previously written archive, to insure that
8751 To check for discrepancies in an archive immediately after it is
8752 written, use the @value{op-verify} option in conjunction with
8753 the @value{op-create} operation. When this option is
8754 specified, @command{tar} checks archive members against their counterparts
8755 in the file system, and reports discrepancies on the standard error.
8757 To verify an archive, you must be able to read it from before the end
8758 of the last written entry. This option is useful for detecting data
8759 errors on some tapes. Archives written to pipes, some cartridge tape
8760 drives, and some other devices cannot be verified.
8762 One can explicitly compare an already made archive with the file system
8763 by using the @value{op-compare} option, instead of using the more automatic
8764 @value{op-verify} option. @value{xref-compare}.
8766 Note that these two options have a slightly different intent. The
8767 @value{op-compare} option how identical are the logical contents of some
8768 archive with what is on your disks, while the @value{op-verify} option is
8769 really for checking if the physical contents agree and if the recording
8770 media itself is of dependable quality. So, for the @value{op-verify}
8771 operation, @command{tar} tries to defeat all in-memory cache pertaining to
8772 the archive, while it lets the speed optimization undisturbed for the
8773 @value{op-compare} option. If you nevertheless use @value{op-compare} for
8774 media verification, you may have to defeat the in-memory cache yourself,
8775 maybe by opening and reclosing the door latch of your recording unit,
8776 forcing some doubt in your operating system about the fact this is really
8777 the same volume as the one just written or read.
8779 The @value{op-verify} option would not be necessary if drivers were indeed
8780 able to detect dependably all write failures. This sometimes require many
8781 magnetic heads, some able to read after the writes occurred. One would
8782 not say that drivers unable to detect all cases are necessarily flawed,
8783 as long as programming is concerned.
8785 The @value{op-verify} option will not work in conjunction with the
8786 @value{op-multi-volume} option or the @value{op-append},
8787 @value{op-update} and @value{op-delete} operations. @xref{Operations},
8788 for more information on these operations.
8790 Also, since @command{tar} normally strips leading @samp{/} from file
8791 names (@pxref{absolute}), a command like @samp{tar --verify -cf
8792 /tmp/foo.tar /etc} will work as desired only if the working directory is
8793 @file{/}, as @command{tar} uses the archive's relative member names
8794 (e.g., @file{etc/motd}) when verifying the archive.
8796 @node Write Protection
8797 @section Write Protection
8799 Almost all tapes and diskettes, and in a few rare cases, even disks can
8800 be @dfn{write protected}, to protect data on them from being changed.
8801 Once an archive is written, you should write protect the media to prevent
8802 the archive from being accidentally overwritten or deleted. (This will
8803 protect the archive from being changed with a tape or floppy drive---it
8804 will not protect it from magnet fields or other physical hazards).
8806 The write protection device itself is usually an integral part of the
8807 physical media, and can be a two position (write enabled/write
8808 disabled) switch, a notch which can be popped out or covered, a ring
8809 which can be removed from the center of a tape reel, or some other
8812 @node Free Software Needs Free Documentation
8813 @appendix Free Software Needs Free Documentation
8814 @include freemanuals.texi
8816 @node Copying This Manual
8817 @appendix Copying This Manual
8820 * GNU Free Documentation License:: License for copying this manual
8835 @c texinfo-column-for-description: 32