1 \input texinfo @c -*-texinfo-*-
4 @settitle The Tar Manual: DRAFT
8 @c Note: the edition number and date is listed in *two* places; please update.
9 @c subtitle and top node; search for !!set
11 @c Search for comments marked with !! or <<< (or >>>)
13 @c <<< CONVENTIONS: this manual refers to "ordinary files" , "directory
14 files" (or "directories"), "archive files", "archive members", and
15 various I/O devices (which have names and file names).>>>
17 @c <<< it's "file name" (not filename) unless we are talking about an
18 argument, ie. @var{file-name}. also, you "use" a "file-name argument"
19 to "specify" a "file".>>>
21 @c <<< @code{tar} is always lower case, in bold. >>>
23 @c <<< it's "operations of tar", "options to tar" also, it's " @samp{tar
24 --foo}" or "the @samp{--foo} operation". MIB doesn't like using
25 operations and options as separate concepts. I disagree --- would be a
26 mess to explain otherwise
28 @c <<< (don't forget to comment these out in final draft) -ringo
30 @c <<< please dont' change this without sending me e-mail. some things
31 @c are in progress or waiting to be edited in hardcopy. -ringo
39 This file documents @code{tar}, a utility used to store, backup, and
42 Copyright (C) 1992 Free Software Foundation, Inc. DRAFT!
43 @c Need to put distribution information here when ready.
46 @c !!set edition number and date here
49 @subtitle The GNU Tape Archiver
50 @subtitle Edition 0.01, for @code{tar} Version 1.10
52 @c remove preceding today line when ready
55 @c subtitle insert month here when ready
57 @author Amy Gorin, Michael I. Bushnell, and Jay Fenlason
58 @c <<<best to have hack read this over and see if anything is left he
59 @c wrote. I don't think so. -ringo>>>>
62 @vskip 0pt plus 1filll
63 Copyright @copyright{} 1992 Free Software Foundation, Inc.
66 This draft is not yet ready for distribution.
70 @node Top, Introduction, (dir), (dir)
73 This file documents @code{tar}, a utility used to store, backup, and
76 @c !!set edition number and date here
77 This is DRAFT Edition 0.01 of the @code{tar} documentation, @today{}, for @code{tar}
81 @c <<< The menus need to be gone over, and node names fixed.
83 * Introduction:: @code{tar}: The GNU Tape Archiver
84 * Invoking @code{tar}:: How to invoke @code{tar}
85 * Tutorial:: Getting started
86 * Wizardry:: Some More Advanced Uses for @code{tar}
87 * Archive Structure:: The structure of an archive
88 * Reading and Writing:: Reading and writing archives
89 * Insuring Accuracy:: How to insure the accuracy of an archive
90 * Selecting Archive Members:: How to select archive members
91 * User Interaction:: How @code{tar} interacts with people.
92 * Backups and Restoration:: How to restore files and perform backups
93 * Media:: Using tapes and other archive media
94 * Quick Reference:: A quick reference guide to
95 @code{tar} operations and options
96 * Data Format Details:: Details of the archive data format
97 * Concept Index:: Concept Index
100 @node Introduction, Invoking @code{tar}, Top, Top
101 @chapter @code{tar}: The GNU Tape Archiver
103 You can use @code{tar} to create an @dfn{archive}---a single file
104 which contains other files' contents as well as a listing of those
105 files' characteristics. You can also use @code{tar} to read, add to,
106 or manipulate already existing archives. Because an archive created
107 by @code{tar} is capable of preserving file information and directory
108 structure, @code{tar} is ideal for performing full and incremental
109 backups, as well as for transferring groups of files between disks and
112 The name @code{tar} comes from the words ``Tape ARchiver'', but
113 @code{tar} can actually process archives wherever they are stored; on
114 tapes and disk files, for example. In addition, tar can read archives
115 from standard input or write them to standard output. (This is often
116 useful if redirected another program with a pipe.)
118 @c <<< this menu will conflict with menu above in info mode. -ringo
120 * Invoking @code{tar}:: How to invoke @code{tar} and specify arguments.
121 * Tutorial:: An introduction to @code{tar}.
122 * Operations:: What you can use @code{tar} to do.
123 * Options:: How to change the way @code{tar} behaves.
124 * Problems:: Common problems with @code{tar}.
126 @chapter Tutorial Introduction to @code{tar}
128 This chapter guides you through some basic examples of @code{tar}
129 operations. If you already know how to use some other version of
130 @code{tar}, then you probably don't need to read this chapter. This
131 chapter omits complicated details about many of the ways @code{tar}
132 works. See later chapters for full information.
135 * Creating Archives:: Creating Archives
136 * Extracting Files:: Extracting Files from an Archive
137 * Listing Archive Contents:: Listing the Contents of an Archive
138 * Comparing Files:: Comparing Archives with the File System
139 * Adding to Archives:: Adding Files to Existing Archives
140 * Concatenate:: Concatenating Archives
141 * Deleting Files:: Deleting Files From an Archive
144 @section What @code{tar} Does
146 The @code{tar} program is used to create and manipulate @code{tar}
147 archives. An @dfn{archive} is a single file which contains within it
148 the contents of many files. In addition, the archive identifies the
149 names of the files, their owner, and so forth.
151 You can use @code{tar} archives in many ways. Initially, @code{tar}
152 archives were used to store files conveniently on magnetic tape. The
153 name @samp{tar} comes from this use; it stands for Tape ARchiver.
154 Often, @code{tar} archives are used to store related files for
155 convenient file transfer over a network. For example, the GNU Project
156 distributes its software bundled into @code{tar} archives, so that all
157 the files relating to a particular program (or set of related programs)
158 can be transferred as a single unit.
160 The files inside an archive are called @dfn{members}. Within this
161 manual, we use the term @dfn{file} to refer only to files accessible in
162 the normal ways (by @code{ls}, @code{cat}, and so forth), and the term
163 @dfn{members} to refer only to the members of an archive. Similarly, a
164 @dfn{file name} is the name of a file, as it resides in the filesystem,
165 and a @dfn{member name} is the name of an archive member within the
168 The @code{tar} program provides the ability to create @code{tar}
169 archives, as well as for various other kinds of manipulation. The term
170 @dfn{extraction} is used to refer to the process of copying an archive
171 member into a file in the filesystem. One might speak of extracting a
172 single member. Extracting all the members of an archive is often called
173 extracting the archive. Often the term @dfn{unpack} is used to refer to
174 the extraction of many or all the members of an archive.
176 Conventionally, @code{tar} archives are given names ending with
177 @samp{.tar}. This is not necessary for @code{tar} to operate properly,
178 but this manual follows the convention in order to get the reader used
181 Occasionally archive members are referred to as files. For people
182 familiar with the operation of @code{tar}, this causes no difficulty.
183 However, this manual consistently uses the terminology above in
184 referring to files and archive members, to make it easier to learn how
187 @section Creating Archives
189 To create a new archive, use @samp{tar --create}. You should generally
190 use the @samp{--file} option to specify the name the tar archive will
191 have. Then specify the names of the files you wish to place in the new
192 archive. For example, to place the files @file{apple}, @file{angst},
193 and @file{asparagus} into an archive named @file{afiles.tar}, use the
197 tar --create --file=afiles.tar apple angst asparagus
200 The order of the arguments is not important. You could also say:
203 tar apple --create angst --file=afiles.tar asparagus
206 This order is harder to understand however. In this manual, we will
207 list the arguments in a reasonable order to make the commands easier to
208 understand, but you can type them in any order you wish.
210 If you don't specify the names of any files to put in the archive, then
211 tar will create an empty archive. So, the following command will create
212 an archive with nothing in it:
215 tar --create --file=empty-archive.tar
218 Whenever you use @samp{tar --create}, @code{tar} will erase the current
219 contents of the file named by @samp{--file} if it exists. To add files
220 to an existing archive, you need to use a different option.
221 @xref{Adding to Archives} for information on how to do this.
223 When @samp{tar --create} creates an archive, the member names of the
224 members of the archive are exactly the same as the file names as you
225 typed them in the @code{tar} command. So, the member names of
226 @file{afiles} (as created by the first example above) are @file{apple},
227 @file{angst}, and @file{asparagus}. However, suppose an archive were
228 created with this command:
231 tar --create --file=bfiles.tar ./balloons baboon ./bodacious
234 Then, the three files @file{balloons}, @file{baboon}, and
235 @file{bodacious} would get placed in the archive (because @file{./} is a
236 synonym for the current directory), but their member names would be
237 @file{./balloons}, @file{baboon}, and @file{./bodacious}.
239 If you want to see the progress of tar as it writes files into the
240 archive, you can use the @samp{--verbose} option.
242 If one of the files named to @samp{tar --create} is a directory, then
243 the operation of tar is more complicated. @xref{Tar and Directories},
244 the last section of this tutorial, for more information.
246 If you don't specify the @samp{--file} option, then @code{tar} will use
247 a default. Usually this default is some physical tape drive attached to
248 your machine. If there is no tape drive attached, or the default is not
249 meaningful, then tar will print an error message. This error message
250 might look roughly like one of the following:
253 tar: can't open /dev/rmt8 : No such device or address
254 tar: can't open /dev/rsmt0 : I/O error
257 If you get an error like this, mentioning a file you didn't specify
258 (@file{/dev/rmt8} or @file{/dev/rsmt0} in the examples above), then @code{tar}
259 is using a default value for @samp{--file}. You should generally specify a
260 @samp{--file} argument whenever you use @code{tar}, rather than relying
263 @section Listing Archives
265 Use @samp{tar --list} to print the names of members stored in an
266 archive. Use a @samp{--file} option just as with @samp{tar --create} to
267 specify the name of the archive. For example, the archive
268 @file{afiles.tar} created in the last section could be examined with the
269 command @samp{tar --list --file=afiles.tar}. The output of tar would
278 The archive @file{bfiles.tar} would list as follows:
286 (Of course, @samp{tar --list --file=empty-archive.tar} would produce no
289 If you use the @samp{--verbose} option with @samp{tar --list}, then tar
290 will print out a listing reminiscent of @samp{ls -l}, showing owner,
291 file size, and so forth.
293 You can also specify member names when using @samp{tar --list}. In this
294 case, tar will only list the names of members you identify. For
295 example, @samp{tar --list --file=afiles.tar apple} would only print
296 @samp{apple}. It is essential when specifying member names to tar that
297 you give the exact member names. For example, @samp{tar --list
298 --file=bfiles baloons} would produce no output, because there is no
299 member named @file{baloons}, only one named @file{./baloons}. While the
300 file names @file{baloons} and @file{./baloons} name the same file,
301 member names are compared using a simplistic name comparison, in which
302 an exact match is necessary.
304 @section Extracting Members from an Archive
306 In order to extract members from an archive, use @samp{tar --extract}.
307 Specify the name of the archive with @samp{--file}. To extract specific
308 archive members, give their member names as arguments. It essential to
309 give their exact member name, as printed by @samp{tar --list}. This
310 will create a copy of the archive member, with a file name the same as
311 its name in the archive.
313 Keeping the example of the two archives created at the beginning of this
314 tutorial, @samp{tar --extract --file=afiles.tar apple} would create a
315 file @file{apple} in the current directory with the contents of the
316 archive member @file{apple}. It would remove any file named
317 @file{apple} already present in the directory, but it would not change
318 the archive in any way.
320 Remember that specifying the exact member name is important. @samp{tar
321 --extract --file=bfiles.tar baloons} will fail, because there is no
322 member named @file{baloons}. To extract the member named
323 @file{./baloons} you would need to specify @samp{tar --extract
324 --file=bfiles.tar ./baloons}. To find the exact member names of the
325 members of an archive, use @samp{tar --list} (@pxref{Listing
328 If you do not list any archive member names, then @samp{tar --extract}
329 will extract all the members of the archive.
331 If you give the @samp{--verbose} option, then @samp{tar --extract} will
332 print the names of the archive members as it extracts them.
334 @section Adding Files to Existing Archives
336 If you want to add files to an existing archive, then don't use
337 @samp{tar --create}. That will erase the archive and create a new one
338 in its place. Instead, use @samp{tar --append}. The command @samp{tar
339 --append --file=afiles.tar arbalest} would add the file @file{arbalest}
340 to the existing archive @file{afiles.tar}. The archive must already
341 exist in order to use @samp{tar --append}.
343 As with @samp{tar --create}, the member names of the newly added files
344 will be the exact same as their names given on the command line. The
345 @samp{--verbose} option will print out the names of the files as they
346 are written into the archive.
348 If you add a file to an archive using @samp{tar --append} with the
349 same name as an archive member already present in the archive, then the
350 old member is not deleted. What does happen, however, is somewhat
351 complex. @xref{Multiple Members with the Same Name}. If you want to
352 replace an archive member, use @samp{tar --delete} first, and then use
355 @section Deleting Members from Archives
357 You can delete members from an archive using @samp{tar --delete}.
358 Specify the name of the archive with @samp{--file}. List the member
359 names of the members to be deleted. (If you list no member names, then
360 nothing will be deleted.) The @samp{--verbose} option will cause
361 @code{tar} to print the names of the members as they are deleted. As
362 with @samp{tar --extract}, it is important that you give the exact
363 member names when using @samp{tar --delete}. Use @samp{tar --list} to
364 find out the exact member names in an archive (@pxref{Listing
367 The @samp{tar --delete} command only works with archives stored on disk.
368 You cannot delete members from an archive stored on a tape.
372 When the names of files or members specify directories, the operation of
373 @code{tar} is more complex. Generally, when a directory is named,
374 @code{tar} also operates on all the contents of the directory,
375 recursively. Thus, to @code{tar}, the file name @file{/} names the
378 To archive the entire contents of a directory, use @samp{tar --create}
379 (or @samp{tar --append}) as usual, and specify the name of the
380 directory. For example, to archive all the contents of the current
381 directory, use @samp{tar --create --file=@var{archive-name} .}. Doing
382 this will give the archive members names starting with @samp{./}. To
383 archive the contents of a directory named @file{foodir}, use @samp{tar
384 --create --file=@var{archive-name} foodir}. In this case, the member
385 names will all start with @samp{foodir/}.
387 If you give @code{tar} a command such as @samp{tar --create
388 --file=foo.tar .}, it will report @samp{tar: foo.tar is the archive; not
389 dumped}. This happens because the archive @file{foo.tar} is created
390 before putting any files into it. Then, when @code{tar} attempts to add
391 all the files in the directory @file{.} to the archive, it notices that
392 the file @file{foo.tar} is the same as the archive, and skips it. (It
393 makes no sense to put an archive into itself.) GNU @code{tar} will
394 continue in this case, and create the archive as normal, except for the
395 exclusion of that one file. Other versions of @code{tar}, however, are
396 not so clever, and will enter an infinite loop when this happens, so you
397 should not depend on this behavior. In general, make sure that the
398 archive is not inside a directory being dumped.
400 When extracting files, you can also name directory archive members on
401 the command line. In this case, @code{tar} extracts all the archive
402 members whose names begin with the name of the directory. As usual,
403 @code{tar} is not particularly clever about interpreting member names.
404 The command @samp{tar --extract --file=@var{archive-name} .} will not
405 extract all the contents of the archive, but only those members whose
406 member names begin with @samp{./}.
408 @section Shorthand names
410 Most of the options to @code{tar} come in both long forms and short
411 forms. The options described in this tutorial have the following
412 abbreviations (except @samp{--delete}, which has no shorthand form):
425 @item --file=@var{archive-name}
426 @samp{-f @var{archive-name}}
429 These options make typing long @code{tar} commands easier. For example,
432 tar --create --file=/tmp/afiles.tar --verbose apple angst asparagus
436 tar -c -f /tmp/afiles.tar -v apple angst asparagus
439 For more information on option syntax, @ref{Invoking @code{tar}}. In
440 the remainder of this manual, short forms and long forms are given
441 together when an option is discussed.
443 @chapter Invoking @code{tar}
445 The usual way to invoke tar is
448 @code{tar} @var{options}... [@var{file-or-member-names}...]
451 All the options start with @samp{-}. You can actually type in arguments
452 in any order, but in this manual the options always precede the other
453 arguments, to make examples easier to understand.
456 * Option Form:: The Forms of Arguments
457 * Argument Functions:: The Functions of Arguments
458 * Old Syntax for Commands:: An Old, but Still Supported, Syntax
459 for @code{tar} Commands
462 @section The Forms of Arguments
464 Most options of @code{tar} have a single letter form (a single letter
465 preceded by @samp{-}), and at least one mnemonic form (a word or
466 abbreviation preceded by @samp{--}). The forms are absolutely
467 identical in function. For example, you can use either @samp{tar -t}
468 or @samp{tar --list} to list the contents of an archive. In addition,
469 mnemonic names can be given unique abbreviations. For example,
470 @samp{--cre} can be used in place of @samp{--create} because there is
471 no other option which begins with @samp{cre}.
473 Some options require an additional argument. Single letter options
474 which require arguments use the immediately following argument.
475 Mnemonic options are separated from their arguments by an @samp{=}
476 sign. For example, to create an an archive file named
477 @file{george.tar}, use either @samp{tar --create --file=george.tar} or
478 @samp{tar --create -f george.tar}. Both
479 @samp{--file=@var{archive-name}} and @samp{-f @var{archive-name}} denote
480 the option to give the archive a non-default name, which in the example
481 is @file{george.tar}.
483 You can mix single letter and mnemonic forms in the same command. You
484 could type the above example as @samp{tar -c --file=george} or
485 @samp{tar --create -f george}. However, @code{tar} operations and
486 options are case sensitive. You would not type the above example as
487 @samp{tar -C --file=george}, because @samp{-C} is an option that
488 causes @code{tar} to change directories, not an operation that creates
489 an archive. In fact, @samp{-C} requires a further argument (the name
490 of the directory which to change to). In this case, tar would think
491 it needs to change to a directory named @samp{--file=george}, and
492 wouldn't interpret @samp{--file-george} as an option at all!
494 @section The Functions of Arguments
496 You must give exactly one option from the following list to tar. This
497 option specifies the basic operation for @code{tar} to perform.
501 Print a summary of the options to @code{tar} and do nothing else
510 Add the contents of one or more archives to another archive
514 Add files to an existing archive
518 List the members in an archive
521 Delete members from an archive
526 Extract members from an archive
531 Compare members in an archive with files in the file system
535 Update an archive by appending newer versions of already stored files
538 The remaining options to @code{tar} change details of the operation,
539 such as archive format, archive name, or level of user interaction.
540 You can specify more than one option.
542 The remaining arguments are interpreted either as file names or as
543 member names, depending on the basic operation @code{tar} is
544 performing. For @samp{--append} and @samp{--create} these arguments
545 specify the names of files (which must already exist) to place in the
546 archive. For the remaining operation types, the additional arguments
547 specify archive members to compare, delete, extract, list, or update.
548 When naming archive members, you must give the exact name of the member
549 in the archive, as it is printed by @code{tar --list}. When naming
550 files, the normal file name rules apply.
552 If you don't use any additional arguments, @samp{--append},
553 @samp{--catenate}, and @samp{--delete} will do nothing. Naturally,
554 @samp{--create} will make an empty archive if given no files to add.
555 The other operations of @code{tar} (@samp{--list}, @samp{--extract},
556 @samp{--compare}, and @samp{--update}) will act on the entire contents
559 If you give the name of a directory as either a file name or a member
560 name, then @code{tar} acts recursively on all the files and directories
561 beneath that directory. For example, the name @file{/} identifies all
562 the files in the filesystem to @code{tar}.
564 @section An Old, but Still Supported, Syntax for @code{tar} Commands
566 For historical reasons, GNU @code{tar} also accepts a syntax for
567 commands which splits options that require additional arguments into
568 two parts. That syntax is of the form:
571 @code{tar} @var{option-letters}... [@var{option-arguments}...] [@var{file-names}...]@refill
575 where arguments to the options appear in the same order as the letters
576 to which they correspond, and the operation and all the option letters
577 appear as a single argument, without separating spaces.
579 This command syntax is useful because it lets you type the single
580 letter forms of the operation and options as a single argument to
581 @code{tar}, without writing preceding @samp{-}s or inserting spaces
582 between letters. @samp{tar cv} or @samp{tar -cv} are equivalent to
585 On the other hand, this old style syntax makes it difficult to match
586 option letters with their corresponding arguments, and is often
587 confusing. In the command @samp{tar cvbf 20 /dev/rmt0}, for example,
588 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
589 argument for @samp{-f}, and @samp{-v} does not have a corresponding
590 argument. The modern syntax---@samp{tar -c -v -b 20 -f
591 /dev/rmt0}---is clearer.
593 @chapter Basic @code{tar} Operations
595 This chapter describes the basic operations supported by the @code{tar}
596 program. A given invocation of @code{tar} will do exactly one of these
599 @section Creating a New Archive
601 The @samp{--create} (@code{-c}) option causes @code{tar} to create a new
602 archive. The files to be archived are then named on the command line.
603 Each file will be added to the archive with a member name exactly the
604 same as the name given on the command line. (When you give an absolute
605 file name @code{tar} actually modifies it slightly, @ref{Absolute
606 Paths}.) If you list no files to be archived, then an empty archive is
609 If there are two many files to conveniently list on the command line,
610 you can list the names in a file, and @code{tar} will read that file.
611 @xref{Reading Names from a File}.
613 If you name a directory, then @code{tar} will archive not only the
614 directory, but all its contents, recursively. For example, if you name
615 @file{/}, then @code{tar} will archive the entire filesystem.
617 Do not use the option to add files to an existing archive; it will
618 delete the archive and write a new one. Use @samp{--append} instead.
619 (@xref{Adding to an Existing Archive}.)
621 There are various ways of causing @code{tar} to skip over some files,
622 and not archive them. @xref{Specifying Names to @code{tar}}.
624 @section Adding to an Existing Archive
626 The @samp{--append} (@code{-r}) option will case @code{tar} to add new
627 files to an existing archive. It interprets file names and member names
628 in exactly the same manner as @samp{--create}. Nothing happens if you
629 don't list any names.
631 This option never deletes members. If a new member is added under the
632 same name as an existing member, then both will be in the archive, with
633 the new member after the old one. For information on how this affects
634 reading the archive, @ref{Multiple Members with the Same Name}.
636 This operation cannot be performed on some tape drives, unfortunately,
637 due to deficiencies in the formats thoes tape drives use.
639 @section Combining Archives
641 The @samp{--catenate} (or @code{--concatenate}, or @code{-A}) causes
642 @code{tar} to add the contents of several archives to an existing
645 Name the archives to be catenated on the command line. (Nothing happens
646 if you don't list any.) The members, and their member names, will be
647 copied verbatim from those archives. If this causes multiple members to
648 have the same name, it does not delete either; all the members with the
649 same name coexist. For information on how this affects reading the
650 archive, @ref{Multiple Members with the Same Name}.
652 You must use this option to concatenate archives. If you just combine
653 them with @code{cat}, the result will not be a valid @code{tar} format
656 This operation cannot be performed on some tape drives, unfortunately,
657 due to deficiencies in the formats thoes tape drives use.
659 @section Removing Archive Members
661 You can use the @samp{--delete} option to remove members from an
662 archive. Name the members on the command line to be deleted. This
663 option will rewrite the archive; because of this, it does not work on
664 tape drives. If you list no members to be deleted, nothing happens.
666 @section Listing Archive Members
668 The @samp{--list} (@samp{-t}) option will list the names of members of
669 the archive. Name the members to be listed on the command line (to
670 modify the way these names are interpreted, @pxref{Specifying Names to
671 @code{tar}}). If you name no members, then @samp{--list} will list the
672 names of all the members of the archive.
677 @chapter Specifying Names to @code{tar}
679 When specifying the names of files or members to @code{tar}, it by
680 default takes the names of the files from the command line. There are
681 other ways, however, to specify file or member names, or to modify the
682 manner in which @code{tar} selects the files or members upon which to
683 operate. In general, these methods work both for specifying the names
684 of files and archive members.
686 @section Reading Names from a File
688 Instead of giving the names of files or archive members on the command
689 line, you can put the names into a file, and then use the
690 @samp{--files-from=@var{file-name-list}} (@samp{-T
691 @var{file-name-list}}) option to @code{tar}. Give the name of the file
692 which contains the list as the argument to @samp{--files-from}. The
693 file names should be separated by newlines in the list.
695 If you want to specify names that might contain newlines, use the
696 @samp{--null} option. Then, the filenames should be separated by NUL
697 characters (ASCII 000) instead of newlines. In addition, the
698 @samp{--null} option turns off the @samp{-C} option (@pxref{Changing
701 @section Excluding Some Files
703 The @samp{--exclude=@var{pattern}} option will prevent any file or
704 member which matches the regular expression @var{pattern} from being
705 operated on. For example, if you want to create an archive with all the
706 contents of @file{/tmp} except the file @file{/tmp/foo}, you can use the
707 command @samp{tar --create --file=arch.tar --exclude=foo}.
709 If there are many files you want to exclude, you can use the
710 @samp{--exclude-from=@var{exclude-list}} (@samp{-X @var{exclude-list}})
711 option. This works just like the
712 @samp{--files-from=@var{file-name-list}} option: specify the name of a
713 file as @var{exclude-list} which contains the list of patterns you want
716 @xref{Regular Expressions} for more information on the syntax and
717 meaning of regular expressions.
719 @section Operating Only on New Files
721 The @samp{--newer=@var{date}} (@samp{--after-date=@var{date}} or
722 @samp{-N @var{date}}) limits @code{tar} to only operating on files which
723 have been modified after the date specified. (For more information on
724 how to specify a date, @xref{Date Formats}.) A file is considered to
725 have changed if the contents have been modified, or if the owner,
726 permissions, and so forth, have been changed.
728 If you only want @code{tar} make the date comparison on the basis of the
729 actual contents of the file's modification, then use the
730 @samp{--newer-mtime=@var{date}} option.
732 You should never use this option for making incremental dumps. To learn
733 how to use @code{tar} to make backups, @ref{Making Backups}.
735 @section Crossing Filesystem Boundaries
737 The @samp{--one-file-system} option causes @code{tar} to modify its
738 normal behavior in archiving the contents of directories. If a file in
739 a directory is not on the same filesystem as the directory itself
740 (because it is a mounted filesystem in its own right), then @code{tar}
741 will not archive that file, or (if it is a directory itself) anything
744 This does not necessarily limit @code{tar} to only archiving the
745 contents of a single filesystem, because all files named on the command
746 line (or through the @samp{--files-from} option) will always be
749 @chapter Changing the Names of Members when Archiing
751 @section Changing Directory
753 The @samp{--directory=@var{directory}} (@samp{-C @var{directory}})
754 option causes @code{tar} to change its current working directory to
755 @var{directory}. Unlike most options, this one is processed at the
756 point it occurs within the list of files to be processed. Consider the
759 tar --create --file=foo.tar -C /etc passwd hosts -C /lib libc.a
762 This command will place the files @file{/etc/passwd}, @file{/etc/hosts},
763 and @file{/lib/libc.a} into the archive. However, the names of the
764 archive members will be exactly what they were on the command line:
765 @file{passwd}, @file{hosts}, and @file{libc.a}. The @samp{--directory}
766 option is frequently used to make the archive independent of the
767 original name of the directory holding the files.
769 Note that @samp{--directory} options are interpreted consecutively. If
770 @samp{--directory} option specifies a relative pathname, it is
771 interpreted relative to the then current directory, which might not be
772 the same as the original current working directory of @code{tar}, due to
773 a previous @samp{--directory} option.
775 When using @samp{--files-from} (@pxref{Reading Names from a File}), you
776 can put @samp{-C} options in the file list. Unfortunately, you cannot
777 put @samp{--directory} options in the file list. (This interpretation
778 can be disabled by using the @samp{--null} option.)
780 @section Absolute Path Names
782 When @code{tar} extracts archive members from an archive, it strips any
783 leading slashes (@code{/}) from the member name. This causes absolute
784 member names in the archive to be treated as relative file names. This
785 allows you to have such members extracted wherever you want, instead of
786 being restricted to extracting the member in the exact directory named
787 in the archive. For example, if the archive member has the name
788 @file{/etc/passwd}, @code{tar} will extract it as if the name were
789 really @file{etc/passwd}.
791 Other @code{tar} programs do not do this. As a result, if you create an
792 archive whose member names start with a slash, they will be difficult
793 for other people with an inferior @code{tar} program to use. Therefore,
794 GNU @code{tar} also strips leading slashes from member names when
795 putting members into the archive. For example, if you ask @code{tar} to
796 add the file @file{/bin/ls} to an archive, it will do so, but the member
797 name will be @file{bin/ls}.
799 If you use the @samp{--absolute-paths} option, @code{tar} will do
800 neither of these transformations.
802 @section Symbolic Links
804 Normally, when @code{tar} archives a symbolic link, it writes a record
805 to the archive naming the target of the link. In that way, the
806 @code{tar} archive is a faithful record of the filesystem contents.
807 However, if you want @code{tar} to actually dump the contents of the
808 target of the symbolic link, then use the @samp{--dereference} option.
816 @node Wizardry, Archive Structure, Tutorial, Top
819 <<<This section needs to be written -ringo
821 @strong{To come:} using Unix file linking capability to recreate directory
822 structures---linking files into one subdirectory and then tarring that
825 @strong{to come:} nice hairy example using absolute-paths, newer, etc.
828 Piping one @code{tar} to another is an easy way to copy a directory's
829 contents from one disk to another, while preserving the dates, modes, owners
830 and link-structure of all the files therein.
833 cd sourcedirectory; tar cf - . | (cd targetdir; tar xf -)
839 <<< the following using standard input/output correct??
841 cd sourcedirectory; tar --create --file=- . | (cd targetdir; tar --extract --file=-)
846 Archive files can be used for transporting a group of files from one system
847 to another: put all relevant files into an archive on one computer system,
848 transfer the archive to another, and extract the contents there. The basic
849 transfer medium might be magnetic tape, Internet FTP, or even electronic
850 mail (though you must encode the archive with @code{uuencode} in order to
851 transport it properly by mail). Both machines do not have to use the same
852 operating system, as long as they both support the @code{tar} program.
854 <<< mention uuencode on a paragraph of its own
856 <<<<<end construction>>>>>
858 @node Archive Structure, Reading and Writing, Wizardry, Top
859 @chapter The Structure of an Archive
861 While an archive may contain many files, the archive itself is a
862 single ordinary file. Like any other file, an archive file can be
863 written to a storage device such as a tape or disk, sent through a
864 pipe or over a network, saved on the active file system, or even
865 stored in another archive. An archive file is not easy to read or
866 manipulate without using the @code{tar} utility or Tar mode in Emacs.
869 Physically, an archive consists of a series of file entries terminated
870 by an end-of-archive entry, which consists of 512 zero bytes. A file
871 entry usually describes one of the files in the archive (an
872 @dfn{archive member}), and consists of a file header and the contents
873 of the file. File headers contain file names and statistics, checksum
874 information which @code{tar} uses to detect file corruption, and
875 information about file types.
877 More than archive member can have the same file name. One way this
878 situation can occur is if more than one version of a file has been
879 stored in the archive. For information about adding new versions of a
880 file to an archive, @pxref{Modifying}.
882 In addition to entries describing archive members, an archive may contain
883 entries which @code{tar} itself uses to store information.
884 @xref{Archive Label}, for an example of such an archive entry.
887 * Old Style File Information:: Old Style File Information
889 * Format Variations::
892 @node Old Style File Information, Archive Label, Archive Structure, Archive Structure
893 @section Old Style File Information
894 @cindex Format, old style
895 @cindex Old style format
896 @cindex Old style archives
898 Archives record not only an archive member's contents, but also its
899 file name or names, its access permissions, user and group, size in
900 bytes, and last modification time. Some archives also record the file
901 names in each archived directory, as well as other file and directory
904 Certain old versions of @code{tar} cannot handle additional
905 information recorded by newer @code{tar} programs. To create an
906 archive which can be read by these old versions, specify the
907 @samp{--old-archive} option in conjunction with the @samp{tar --create}
908 operation. When you specify this option, @code{tar} leaves out
909 information about directories, pipes, fifos, contiguous files, and
910 device files, and specifies file ownership by group and user ids
913 The @samp{--old-archive} option is needed only if the archive must be
914 readable by an older tape archive program which cannot handle the new format.
915 Most @code{tar} programs do not have this limitation, so this option
923 @c has portability been changed to portable?
924 Creates an archive that can be read by an old @code{tar} program.
925 Used in conjunction with the @samp{tar --create} operation.
928 @node Archive Label, Format Variations, Old Style File Information, Archive Structure
929 @section Including a Label in the Archive
930 @cindex Labeling an archive
931 @cindex Labels on the archive media
933 @c !! Should the arg to --label be a quoted string?? no - ringo
934 To avoid problems caused by misplaced paper labels on the archive
935 media, you can include a @dfn{label} entry---an archive member which
936 contains the name of the archive---in the archive itself. Use the
937 @samp{--label=@var{archive-label}} option in conjunction with the
938 @samp{--create} operation to include a label entry in the archive as it
941 If you create an archive using both @samp{--label=@var{archive-label}}
942 and @samp{--multi-volume}, each volume of the archive will have an
943 archive label of the form @samp{@var{archive-label} Volume @var{n}},
944 where @var{n} is 1 for the first volume, 2 for the next, and so on.
945 @xref{Multi-Volume Archives}, for information on creating multiple
948 If you extract an archive using @samp{--label=@var{archive-label}},
949 @code{tar} will print an error if the archive label doesn't match the
950 @var{archive-label} specified, and will then not extract the archive.
951 You can include a regular expression in @var{archive-label}, in this
953 @c >>> why is a reg. exp. useful here? (to limit extraction to a
954 @c >>>specific group? ie for multi-volume??? -ringo
956 To find out an archive's label entry (or to find out if an archive has
957 a label at all), use @samp{tar --list --verbose}. @code{tar} will print the
958 label first, and then print archive member information, as in the
962 % tar --verbose --list --file=iamanarchive
963 V--------- 0/0 0 Mar 7 12:01 1992 iamalabel--Volume Header--
964 -rw-rw-rw- ringo/user 40 May 21 13:30 1990 iamafilename
968 @item --label=@var{archive-label}
969 @itemx -V @var{archive-label}
970 Includes an @dfn{archive-label} at the beginning of the archive when
971 the archive is being created (when used in conjunction with the
972 @samp{tar --create} operation). Checks to make sure the archive label
973 matches the one specified (when used in conjunction with the @samp{tar
974 --extract} operation.
978 @node Format Variations, , Archive Label, Archive Structure
979 @section Format Variations
980 @cindex Format Parameters
981 @cindex Format Options
982 @cindex Options to specify archive format.
984 Format parameters specify how an archive is written on the archive
985 media. The best choice of format parameters will vary depending on
986 the type and number of files being archived, and on the media used to
989 To specify format parameters when accessing or creating an archive,
990 you can use the options described in the following sections. If you
991 do not specify any format parameters, @code{tar} uses default
992 parameters. You cannot modify a compressed archive. If you create an
993 archive with the @samp{--block-size} option specified (@pxref{Blocking
994 Factor}), you must specify that block-size when operating on the
995 archive. @xref{Matching Format Parameters}, for other examples of
996 format parameter considerations.
1000 * Multi-Volume Archives::
1003 * Compressed Archives::
1006 @node Multi-Volume Archives, Sparse Files, Format Variations, Format Variations
1007 @subsection Archives Longer than One Tape or Disk
1008 @cindex Multi-volume archives
1010 To create an archive that is larger than will fit on a single unit of
1011 the media, use the @samp{--multi-volume} option in conjunction with the
1012 @samp{tar --create} operation (@pxref{Creating Archives}). A
1013 @dfn{multi-volume} archive can be manipulated like any other archive
1014 (provided the @samp{--multi-volume} option is specified), but is stored
1015 on more than one tape or disk.
1017 When you specify @samp{--multi-volume}, @code{tar} does not report an
1018 error when it comes to the end of an archive volume (when reading), or
1019 the end of the media (when writing). Instead, it prompts you to load
1020 a new storage volume. If the archive is on a magnetic tape, you
1021 should change tapes when you see the prompt; if the archive is on a
1022 floppy disk, you should change disks; etc.
1024 You can read each individual volume of a multi-volume archive as if it
1025 were an archive by itself. For example, to list the contents of one
1026 volume, use @samp{tar --list}, without @samp{--multi-volume} specified.
1027 To extract an archive member from one volume (assuming it is described
1028 that volume), use @samp{tar --extract}, again without
1029 @samp{--multi-volume}.
1031 If an archive member is split across volumes (ie. its entry begins on
1032 one volume of the media and ends on another), you need to specify
1033 @samp{--multi-volume} to extract it successfully. In this case, you
1034 should load the volume where the archive member starts, and use
1035 @samp{tar --extract --multi-volume}---@code{tar} will prompt for later
1036 volumes as it needs them. @xref{Extracting From Archives} for more
1037 information about extracting archives.
1039 @samp{--info-script=@var{program-file}} is like @samp{--multi-volume},
1040 except that @code{tar} does not prompt you directly to change media
1041 volumes when a volume is full---instead, @code{tar} runs commands you
1042 have stored in @var{program-file}. This option can be used to
1043 broadcast messages such as @samp{someone please come change my tape}
1044 when performing unattended backups. When @var{program-file} is done,
1045 @code{tar} will assume that the media has been changed.
1048 <<< There should be a sample program here, including an exit before
1052 @item --multi-volume
1054 Creates a multi-volume archive, when used in conjunction with
1055 @samp{tar --create}. To perform any other operation on a multi-volume
1056 archive, specify @samp{--multi-volume} in conjunction with that
1059 @item --info-script=@var{program-file}
1060 @itemx -F @var{program-file}
1061 Creates a multi-volume archive via a script. Used in conjunction with
1062 @samp{tar --create}.
1065 @node Sparse Files, Blocking Factor, Multi-Volume Archives, Format Variations
1066 @subsection Archiving Sparse Files
1067 @cindex Sparse Files
1069 A file is sparse if it contains blocks of zeros whose existance is
1070 recorded, but that have no space allocated on disk. When you specify
1071 the @samp{--sparse} option in conjunction with the @samp{--create}
1072 operation, @code{tar} tests all files for sparseness while archiving.
1073 If @code{tar} finds a file to be sparse, it uses a sparse
1074 representation of the file in the archive. @xref{Creating Archives},
1075 for more information about creating archives.
1077 @samp{--sparse} is useful when archiving files, such as dbm files,
1078 likely to contain many nulls. This option dramatically
1079 decreases the amount of space needed to store such an archive.
1082 @strong{Please Note:} Always use @samp{--sparse} when performing file
1083 system backups, to avoid archiving the expanded forms of files stored
1084 sparsely in the system.@refill
1086 Even if your system has no no sparse files currently, some may be
1087 created in the future. If you use @samp{--sparse} while making file
1088 system backups as a matter of course, you can be assured the archive
1089 will always take no more space on the media than the files take on
1090 disk (otherwise, archiving a disk filled with sparse files might take
1091 hundreds of tapes).@refill
1092 <<< xref incremental when node name is set.
1095 @code{tar} ignores the @samp{--sparse} option when reading an archive.
1100 Files stored sparsely in the file system are represented sparsely in
1101 the archive. Use in conjunction with write operations.
1104 @node Blocking Factor, Compressed Archives, Sparse Files, Format Variations
1105 @subsection The Blocking Factor of an Archive
1106 @cindex Blocking Factor
1108 @cindex Number of records per block
1109 @cindex Number of bytes per block
1110 @cindex Bytes per block
1111 @cindex Records per block
1113 The data in an archive is grouped into records, which are 512 bytes.
1114 Records are read and written in whole number multiples called
1115 @dfn{blocks}. The number of records in a block (ie. the size of a
1116 block in units of 512 bytes) is called the @dfn{blocking factor}. The
1117 @samp{--block-size=@var{number}} option specifies the blocking factor
1118 of an archive. The default blocking factor is typically 20 (ie.@:
1119 10240 bytes), but can be specified at installation. To find out the
1120 blocking factor of an existing archive, use @samp {tar --list
1121 --file=@var{archive-name}}. This may not work on some devices.
1123 Blocks are seperated by gaps, which waste space on the archive media.
1124 If you are archiving on magnetic tape, using a larger blocking factor
1125 (and therefore larger blocks) provides faster throughput and allows
1126 you to fit more data on a tape (because there are fewer gaps). If you
1127 are archiving on cartridge, a very large blocking factor (say 126 or
1128 more) greatly increases performance. A
1129 smaller blocking factor, on the other hand, may be usefull when
1130 archiving small files, to avoid archiving lots of nulls as @code{tar}
1131 fills out the archive to the end of the block. In general, the ideal block size
1132 depends on the size of the inter-block gaps on the tape you are using,
1133 and the average size of the files you are archiving. @xref{Creating
1134 Archives}, for information on writing archives.
1136 Archives with blocking factors larger than 20 cannot be read by very
1137 old versions of @code{tar}, or by some newer versions of @code{tar}
1138 running on old machines with small address spaces. With GNU
1139 @code{tar}, the blocking factor of an archive is limited only by the
1140 maximum block size of the device containing the archive, or by the
1141 amount of available virtual memory.
1143 If you use a non-default blocking factor when you create an archive,
1144 you must specify the same blocking factor when you modify that
1145 archive. Some archive devices will also require you to specify the
1146 blocking factor when reading that archive, however this is not
1147 typically the case. Usually, you can use @samp{tar --list} without
1148 specifying a blocking factor---@code{tar} reports a non-default block
1149 size and then lists the archive members as it would normally. To
1150 extract files from an archive with a non-standard blocking factor
1151 (particularly if you're not sure what the blocking factor is), you can
1152 usually use the {--read-full-blocks} option while specifying a blocking
1153 factor larger then the blocking factor of the archive (ie. @samp{tar
1154 --extract --read-full-blocks --block-size=300}. @xref{Listing Contents}
1155 for more information on the @samp{--list} operation.
1156 @xref{read-full-blocks} for a more detailed explanation of that
1160 @item --block-size=@var{number}
1161 @itemx -b @var{number}
1162 Specifies the blocking factor of an archive. Can be used with any
1163 operation, but is usually not necessary with @samp{tar --list}.
1166 @node Compressed Archives, , Blocking Factor, Format Variations
1167 @subsection Creating and Reading Compressed Archives
1168 @cindex Compressed archives
1169 @cindex Storing archives in compressed format
1171 @samp{--compress} indicates an archive stored in compressed format.
1172 The @samp{--compress} option is useful in saving time over networks and
1173 space in pipes, and when storage space is at a premium.
1174 @samp{--compress} causes @code{tar} to compress when writing the
1175 archive, or to uncompress when reading the archive.
1177 To perform compression and uncompression on the archive, @code{tar}
1178 runs the @code{compress} utility. @code{tar} uses the default
1179 compression parameters; if you need to override them, avoid the
1180 @samp{--compress} option and run the @code{compress} utility
1181 explicitly. It is useful to be able to call the @code{compress}
1182 utility from within @code{tar} because the @code{compress} utility by
1183 itself cannot access remote tape drives.
1185 The @samp{--compress} option will not work in conjunction with the
1186 @samp{--multi-volume} option or the @samp{--add-file}, @samp{--update},
1187 @samp{--add-file} and @samp{--delete} operations. @xref{Modifying}, for
1188 more information on these operations.
1190 If there is no compress utility available, @code{tar} will report an
1193 @samp{--compress-block} is like @samp{--compress}, but when used in
1194 conjunction with @samp{--create} also causes @code{tar} to pad the last
1195 block of the archive out to the next block boundary as it is written.
1196 This is useful with certain devices which require all write operations
1197 be a multiple of a specific size.
1200 @strong{Please Note:} The @code{compress} program may be covered by a patent,
1201 and therefore we recommend you stop using it. We hope to have a
1202 different compress program in the future. We may change the name of
1203 this option at that time.
1211 When this option is specified, @code{tar} will compress (when writing
1212 an archive), or uncompress (when reading an archive). Used in
1213 conjunction with the @samp{--create}, @samp{--extract}, @samp{--list} and
1214 @samp{--compare} operations.
1216 @item --compress-block
1218 Acts like @samp{--compress}, but pads the archive out to the next block
1219 boundary as it is written when used in conjunction with the
1220 @samp{--create} operation.
1223 @c >>> MIB -- why not use -Z instead of -z -z ? -ringo
1225 @node Reading and Writing, Insuring Accuracy, Archive Structure, Top
1226 @chapter Reading and Writing Archives
1228 The @samp{--create} operation writes a new archive, and the
1229 @samp{--extract} operation reads files from an archive and writes them
1230 into the file system. You can use other @code{tar} operations to
1231 write new information into an existing archive (adding files to it,
1232 adding another archive to it, or deleting files from it), and you can
1233 read a list of the files in an archive without extracting it using the
1234 @samp{--list} operation.
1237 * Archive Name:: The name of an archive
1238 * Creating in Detail:: Creating in detail
1239 * Modifying:: Modifying archives
1240 * Listing Contents:: Listing the contents of an archive
1241 * Extracting From Archives:: Extracting files from an archive
1244 @node Archive Name, Creating in Detail, Reading and Writing, Reading and Writing
1245 @section The Name of an Archive
1246 @cindex Naming an archive
1247 @cindex Archive Name
1248 @cindex Directing output
1249 @cindex Where is the archive?
1251 An archive can be saved as a file in the file system, sent through a
1252 pipe or over a network, or written to an I/O device such as a tape or
1253 disk drive. To specify the name of the archive, use the
1254 @samp{--file=@var{archive-name}} option.
1256 An archive name can be the name of an ordinary file or the name of an
1257 I/O device. @code{tar} always needs an archive name---if you do not
1258 specify an archive name, the archive name comes from the environment
1259 variable @code{TAPE} or, if that variable is not specified, a default
1260 archive name, which is usually the name of tape unit zero (ie.
1263 If you use @file{-} as an @var{archive-name}, @code{tar} reads the
1264 archive from standard input (when listing or extracting files), or
1265 writes it to standard output (when creating an archive). If you use
1266 @file{-} as an @var{archive-name} when modifying an archive,
1267 @code{tar} reads the original archive from its standard input and
1268 writes the entire new archive to its standard output.
1270 @c >>> MIB--does standard input and output redirection work with all
1272 @c >>> need example for standard input and output (screen and keyboard?)
1274 @cindex Standard input and output
1275 @cindex tar to standard input and output
1277 To specify an archive file on a device attached to a remote machine,
1281 --file=@var{hostname}:/@var{dev}/@var{file name}
1285 @code{tar} will complete the remote connection, if possible, and
1286 prompt you for a username and password. If you use
1287 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @code{tar}
1288 will complete the remote connection, if possible, using your username
1289 as the username on the remote machine.
1291 @c >>>MIB --- is this clear?
1294 @item --file=@var{archive-name}
1295 @itemx -f @var{archive-name}
1296 Names the archive to create or operate on. Use in conjunction with
1300 @node Creating in Detail, Modifying, Archive Name, Reading and Writing
1301 @section Creating in Detail
1302 @c operations should probably have examples, not tables.
1303 @cindex Writing new archives
1304 @cindex Archive creation
1306 To create an archive, use @samp{tar --create}. To name the archive,
1307 use @samp{--file=@var{archive-name}} in conjunction with the
1308 @samp{--create} operation (@pxref{Archive Name}). If you do not name
1309 the archive, @code{tar} uses the value of the environment variable
1310 @code{TAPE} as the file name for the archive, or, if that is not
1311 available, @code{tar} uses a default archive name, usually that for tape
1312 unit zero. @xref{Archive Name}, for more information about specifying
1315 The following example creates an archive named @file{stooges},
1316 containing the files @file{larry}, @file{moe} and @file{curley}:
1319 tar --create --file=stooges larry moe curley
1322 If you specify a directory name as a file-name argument, @code{tar}
1323 will archive all the files in that directory. The following example
1324 creates an archive named @file{hail/hail/fredonia}, containing the
1325 contents of the directory @file{marx}:
1328 tar --create --file=hail/hail/fredonia marx
1331 If you don't specify files to put in the archive, @code{tar} archives
1332 all the files in the working directory. The following example creates
1333 an archive named @file{home} containing all the files in the working
1337 tar --create --file=home
1340 @xref{File Name Lists}, for other ways to specify files to archive.
1342 Note: In the example above, an archive containing all the files in the
1343 working directory is being written to the working directory. GNU
1344 @code{tar} stores files in the working directory in an archive which
1345 is itself in the working directory without falling into an infinite
1346 loop. Other versions of @code{tar} may fall into this trap.
1348 @node Modifying, Listing Contents, Creating in Detail, Reading and Writing
1349 @section Modifying Archives
1350 @cindex Modifying archives
1352 Once an archive is created, you can add new archive members to it, add
1353 the contents of another archive, add newer versions of members already
1354 stored, or delete archive members already stored.
1356 To find out what files are already stored in an archive, use @samp{tar
1357 --list --file=@var{archive-name}}. @xref{Listing Contents}.
1361 * Appending Archives::
1362 * Deleting Archive Files:: Deleting Files From an Archive
1363 * Matching Format Parameters::
1366 @node Adding Files, Appending Archives, Modifying, Modifying
1367 @subsection Adding Files to an Archive
1368 @cindex Adding files to an archive
1369 @cindex Updating an archive
1371 To add files to an archive, use @samp{tar --add-file}. The archive to
1372 be added to must already exist and be in proper archive format (which
1373 normally means it was created previously using @code{tar}). If the
1374 archive was created with a different block size than now specified,
1375 @code{tar} will report an error (@pxref{Blocking Factor}). If the
1376 archive is not a valid @code{tar} archive, the results will be
1377 unpredictable. You cannot add files to a compressed archive, however
1378 you can add files to the last volume of a multi-volume archive.
1379 @xref{Matching Format Parameters}.
1381 The following example adds the file @file{shemp} to the archive
1382 @file{stooges} created above:
1385 tar --add-file --file=stooges shemp
1388 You must specify the files to be added; there is no default.
1390 @samp{tar --update} acts like @samp{tar --add-file}, but does not add
1391 files to the archive if there is already a file entry with that name
1392 in the archive that has the same modification time.
1394 Both @samp{--update} and @samp{--add-file} work by adding to the end of
1395 the archive. When you extract a file from the archive, only the
1396 version stored last will wind up in the file system. Because
1397 @samp{tar --extract} extracts files from an archive in sequence, and
1398 overwrites files with the same name in the file system, if a file name
1399 appears more than once in an archive the last version of the file will
1400 overwrite the previous versions which have just been extracted. You
1401 should avoid storing older versions of a file later in the archive.
1403 Note: @samp{--update} is not suitable for performing backups, because
1404 it doesn't change directory content entries, and because it lengthens
1405 the archive every time it is used.
1406 @c <<< xref to scripted backup, listed incremental, for info on backups.
1408 @node Appending Archives, Deleting Archive Files, Adding Files, Modifying
1409 @subsection Appending One Archive's Contents to Another Archive
1410 @cindex Adding archives to an archive
1411 @cindex Concatenating Archives
1413 To append copies of an archive or archives to the end of another
1414 archive, use @samp{tar --add-archive}. The source and target archives
1415 must already exist and have been created using compatable format
1416 parameters (@pxref{Matching Format Parameters}).
1418 @code{tar} will stop reading an archive if it encounters an
1419 end-of-archive marker. The @code{cat} utility does not remove
1420 end-of-archive markers, and is therefore unsuitable for concatenating
1421 archives. @samp{tar --add-archive} removes the end-of-archive marker
1422 from the target archive before each new archive is appended.
1423 @c <<< xref ignore-zeros
1425 You must specify the source archives using
1426 @samp{--file=@var{archive-name}} (@pxref{Archive Name}). If you do not
1427 specify the target archive , @code{tar} uses the value of the
1428 environment variable @code{TAPE}, or, if this has not been set, the
1429 default archive name.
1431 The following example adds the contents of the archive
1432 @file{hail/hail/fredonia} to the archive @file{stooges} (both archives
1433 were created in examples above):
1436 tar --add-archive --file=stooges hail/hail/fredonia
1439 If you need to retrieve files from an archive that was added to using
1440 the @code{cat} utility, use the @samp{--ignore-zeros} option
1441 (@pxref{Archive Reading Options}).
1443 @node Deleting Archive Files, Matching Format Parameters, Appending Archives, Modifying
1444 @subsection Deleting Files From an Archive
1445 @cindex Deleting files from an archive
1446 @cindex Removing files from an archive
1448 To delete archive members from an archive, use @samp{tar --delete}.
1449 You must specify the file names of the members to be deleted. All
1450 archive members with the specified file names will be removed from the
1453 The following example removes the file @file{curley} from the archive
1457 tar --delete --file=stooges curley
1460 You can only use @samp{tar --delete} on an archive if the archive
1461 device allows you to write to any point on the media.
1464 @strong{Warning:} Don't try to delete an archive member from a
1465 magnetic tape, lest you scramble the archive. There is no safe way
1466 (except by completely re-writing the archive) to delete files from
1467 most kinds of magnetic tape.
1470 @c <<< MIB -- how about automatic detection of archive media? give error
1471 @c <<< unless the archive device is either an ordinary file or different
1472 @c <<< input and output (--file=-).
1474 @node Matching Format Parameters, , Deleting Archive Files, Modifying
1475 @subsection Matching the Format Parameters
1477 Some format parameters must be taken into consideration when modifying
1480 Compressed archives cannot be modified.
1482 You have to specify the block size of the archive when modifying an
1483 archive with a non-default block size.
1485 Multi-volume archives can be modified like any other archive. To add
1486 files to a multi-volume archive, you need to only mount the last
1487 volume of the archive media (and new volumes, if needed). For all
1488 other operations, you need to use the entire archive.
1490 If a multi-volume archive was labeled using @samp{--label}
1491 (@pxref{Archive Label}) when it was created, @code{tar} will not
1492 automatically label volumes which are added later. To label
1493 subsequent volumes, specify @samp{--label=@var{archive-label}} again in
1494 conjunction with the @samp{--add-file}, @samp{--update} or
1495 @samp{--add-archive} operation.
1496 @cindex Labelling multi-volume archives
1499 @c <<< xref somewhere, for more information about format parameters.
1501 @node Listing Contents, Extracting From Archives, Modifying, Reading and Writing
1502 @section Listing the Contents of an Archive
1503 @cindex Names of the files in an archive
1504 @cindex Archive contents, list of
1505 @cindex Archive members, list of
1507 @samp{tar --list} prints a list of the file names of the archive
1508 members on the standard output. If you specify @var{file-name}
1509 arguments on the command line (or using the @samp{--files-from} option,
1510 @pxref{File Name Lists}), only the files you specify will be listed,
1511 and only if they exist in the archive. Files not specified will be
1512 ignored, unless they are under a specific directory.
1514 If you include the @samp{--verbose} option, @code{tar} prints an
1515 @samp{ls -l} type listing for the archive. @pxref{Additional
1516 Information}, for a description of the @samp{--verbose} option.
1518 If the blocking factor of the archive differs from the default,
1519 @code{tar} reports this. @xref{Blocking Factor}.
1521 @xref{Archive Reading Options} for a list of options which can be used
1522 to modify @samp{--list}'s operation.
1524 This example prints a list of the archive members of the archive
1528 tar --list --file=stooges
1532 @code{tar} responds:
1543 This example generates a verbose list of the archive members of the
1544 archive file @file{dwarves}, which has a blocking factor of two:
1547 tar --list -v --file=blocks
1551 @code{tar} responds:
1554 tar: Blocksize = 2 records
1555 -rw------- ringo/user 42 May 1 13:29 1990 .bashful
1556 -rw-rw-rw- ringo/user 42 Oct 4 13:29 1990 doc
1557 -rw-rw-rw- ringo/user 42 Jul 20 18:01 1969 dopey
1558 -rw-rw---- ringo/user 42 Nov 26 13:42 1963 grumpy
1559 -rw-rw-rw- ringo/user 42 May 5 13:29 1990 happy
1560 -rw-rw-rw- ringo/user 42 May 1 12:00 1868 sleepy
1561 -rw-rw-rw- ringo/user 42 Jul 4 17:29 1776 sneezy
1564 @node Extracting From Archives, , Listing Contents, Reading and Writing
1565 @section Extracting Files from an Archive
1567 @cindex Retrieving files from an archive
1568 @cindex Resurrecting files from an archive
1570 To read archive members from the archive and write them into the file
1571 system, use @samp{tar --extract}. The archive itself is left
1574 If you do not specify the files to extract, @code{tar} extracts all
1575 the files in the archive. If you specify the name of a directory as a
1576 file-name argument, @code{tar} will extract all files which have been
1577 stored as part of that directory. If a file was stored with a
1578 directory name as part of its file name, and that directory does not
1579 exist under the working directory when the file is extracted,
1580 @code{tar} will create the directory. @xref{Selecting Archive
1581 Members}, for information on specifying files to extract.
1583 The following example shows the extraction of the archive
1584 @file{stooges} into an empty directory:
1587 tar --extract --file=stooges
1591 Generating a listing of the directory (@samp{ls}) produces:
1601 The subdirectory @file{marx} contains the files @file{julius},
1602 @file{alexander} and @file{karl}.
1604 If you wanted to just extract the files in the subdirectory
1605 @file{marx}, you could specify that directory as a file-name argument
1606 in conjunction with the @samp{--extract} operation:
1609 tar --extract --file=stooges marx
1613 @strong{Warning:} Extraction can overwrite files in the file system.
1614 To avoid losing files in the file system when extracting files from
1615 the archive with the same name, use the @samp{--keep-old-files} option
1616 (@pxref{File Writing Options}).
1619 If the archive was created using @samp{--block-size}, @samp{--compress}
1620 or @samp{--multi-volume}, you must specify those format options again
1621 when extracting files from the archive (@pxref{Format Variations}).
1624 * Archive Reading Options::
1625 * File Writing Options::
1626 * Scarce Disk Space:: Recovering From Scarce Disk Space
1629 @node Archive Reading Options, File Writing Options, Extracting From Archives, Extracting From Archives
1630 @subsection Options to Help Read Archives
1631 @cindex Options when reading archives
1632 @cindex Reading incomplete blocks
1633 @cindex Blocks, incomplete
1634 @cindex End of archive markers, ignoring
1635 @cindex Ignoring end of archive markers
1636 @cindex Large lists of file names on small machines
1637 @cindex Small memory
1638 @cindex Running out of space
1640 @c <<< each option wants its own node. summary after menu
1642 Normally, @code{tar} will request data in full block increments from
1643 an archive storage device. If the device cannot return a full block,
1644 @code{tar} will report an error. However, some devices do not always
1645 return full blocks, or do not require the last block of an archive to
1646 be padded out to the next block boundary. To keep reading until you
1647 obtain a full block, or to accept an incomplete block if it contains
1648 an end-of-archive marker, specify the @samp{--read-full-blocks} option
1649 in conjunction with the @samp{--extract} or @samp{--list} operations.
1650 @xref{Listing Contents}.
1652 The @samp{--read-full-blocks} option is turned on by default when
1653 @code{tar} reads an archive from standard input, or from a remote
1654 machine. This is because on BSD Unix systems, attempting to read a
1655 pipe returns however much happens to be in the pipe, even if it is
1656 less than was requested. If this option were not enabled, @code{tar}
1657 would fail as soon as it read an incomplete block from the pipe.
1659 If you're not sure of the blocking factor of an archive, you can read
1660 the archive by specifying @samp{--read-full-blocks} and
1661 @samp{--block-size=@var{n}}, where @var{n} is a blocking factor larger
1662 than the blocking factor of the archive. This lets you avoid having
1663 to determine the blocking factor of an archive. @xref{Blocking
1667 @item --read-full-blocks
1669 Use in conjunction with @samp{tar --extract} to read an archive which
1670 contains incomplete blocks, or one which has a blocking factor less
1671 than the one specified.
1674 Normally @code{tar} stops reading when it encounters a block of zeros
1675 between file entries (which usually indicates the end of the archive).
1676 @samp{--ignore-zeros} allows @code{tar} to completely read an archive
1677 which contains a block of zeros before the end (i.e.@: a damaged
1678 archive, or one which was created by @code{cat}-ing several archives
1681 The @samp{--ignore-zeros} option is turned off by default because many
1682 versions of @code{tar} write garbage after the end of archive entry,
1683 since that part of the media is never supposed to be read. GNU
1684 @code{tar} does not write after the end of an archive, but seeks to
1685 maintain compatablity among archiving utilities.
1688 @item --ignore-zeros
1690 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
1691 encountered while reading an archive. Use in conjunction with
1692 @samp{tar --extract} or @samp{tar --list}.
1695 If you are using a machine with a small amount of memory, and you need
1696 to process large list of file-names, you can reduce the amount of
1697 space @code{tar} needs to process the list. To do so, specify the
1698 @samp{--same-order} option and provide an ordered list of file names.
1699 This option tells @code{tar} that the @file{file-name} arguments
1700 (provided on the command line, or read from a file using the
1701 @samp{--files-from} option) are listed in the same order as the files
1704 You can create a file containing an ordered list of files in the
1705 archive by storing the output produced by @samp{tar --list
1706 --file=@var{archive-name}}. @xref{Listing Contents}, for information
1707 on the @samp{--list} operation.
1709 This option is probably never needed on modern computer systems.
1713 @itemx --preserve-order
1715 To process large lists of file-names on machines with small amounts of
1716 memory. Use in conjunction with @samp{tar --compare}, @samp{tar --list}
1717 or @samp{tar --extract}.
1720 @c we don't need/want --preserve to exist any more
1722 @node File Writing Options, Scarce Disk Space, Archive Reading Options, Extracting From Archives
1723 @subsection Changing How @code{tar} Writes Files
1724 @c <<< find a better title
1725 @cindex Overwriting old files, prevention
1726 @cindex Protecting old files
1727 @cindex Modification times of extracted files
1728 @cindex Permissions of extracted files
1729 @cindex Modes of extracted files
1730 @cindex Writing extracted files to standard output
1731 @cindex Standard output, writing extracted files to
1733 Normally, @code{tar} writes extracted files into the file system
1734 without regard to the files already on the system---files with the
1735 same name as archive members are overwritten. To prevent @code{tar}
1736 from extracting an archive member from an archive, if doing so will
1737 overwrite a file in the file system, use @samp{--keep-old-files} in
1738 conjunction with the @samp{--extract} operation. When this option is
1739 specified, @code{tar} reports an error stating the name of the files
1740 in conflict, instead of writing the file from the archive.
1743 @item --keep-old files
1745 Prevents @code{tar} from overwriting files in the file system during
1749 Normally, @code{tar} sets the modification times of extracted files to
1750 the modification times recorded for the files in the archive, but
1751 limits the permissions of extracted files by the current @code{umask}
1754 To set the modification times of extracted files to the time when
1755 the files were extracted, use the @samp{--modification-time} option in
1756 conjunction with @samp{tar --extract}.
1759 @item --modification-time
1761 Sets the modification time of extracted archive members to the time
1762 they were extracted, not the time recorded for them in the archive.
1763 Use in conjunction with @samp{--extract}.
1766 To set the modes (access permissions) of extracted files to those
1767 recorded for those files in the archive, use the
1768 @samp{--preserve-permissions} option in conjunction with the
1769 @samp{--extract} operation.
1770 @c <<<mib --- should be aliased to ignore-umask.
1773 @item --preserve-permission
1774 @itemx --same-permission
1775 @itemx --ignore-umask
1777 Set modes of extracted archive members to those recorded in the
1778 archive, instead of current umask settings. Use in conjunction with
1782 @c <<< following paragraph needs to be rewritten:
1783 @c <<< why doesnt' this cat files together, why is this useful. is it
1784 @c <<< really useful with more than one file?
1785 To write the files extracted to the standard output, instead of
1786 creating the files on the file system, use @samp{--to-stdout} in
1787 conjunction with @samp{tar --extract}. This option is useful if you
1788 are extracting files to send them through a pipe, and do not need to
1789 preserve them in the file system.
1794 Writes files to the standard output. Used in conjunction with
1798 @c <<< why would you want to do such a thing, how are files separated on
1799 @c <<< the standard output? is this useful with more that one file? are
1800 @c <<< pipes the real reason?
1802 @node Scarce Disk Space, , File Writing Options, Extracting From Archives
1803 @subsection Recovering From Scarce Disk Space
1804 @cindex Middle of the archive, starting in the
1805 @cindex Running out of space during extraction
1806 @cindex Disk space, running out of
1807 @cindex Space on the disk, recovering from lack of
1809 If a previous attempt to extract files failed due to lack of disk
1810 space, you can use @samp{--starting-file=@var{file-name}} to start
1811 extracting only after file @var{file-name} when extracting files from
1812 the archive. This assumes, of course, that there is now free space,
1813 or that you are now extracting into a different file system.
1816 @item --starting-file=@var{file-name}
1817 @itemx -K @var{file-name}
1818 Starts an operation in the middle of an archive. Use in conjunction
1819 with @samp{--extract} or @samp{--list}.
1822 If you notice you are running out of disk space during an extraction
1823 operation, you can also suspend @code{tar}, remove unnecessary files
1824 from the file system, and then restart the same @code{tar} operation.
1825 In this case, @samp{--starting-file} is not necessary.
1827 @c <<< xref incremental, xref --interactive, xref --exclude
1829 @node Insuring Accuracy, Selecting Archive Members, Reading and Writing, Top
1830 @chapter Insuring the Accuracy of an Archive
1832 You can insure the accuracy of an archive by comparing files in the
1833 system with archive members. @code{tar} can compare an archive to the
1834 file system as the archive is being written, to verify a write
1835 operation, or can compare a previously written archive, to insure that
1839 * Write Verification::
1843 @node Write Verification, Comparing, Insuring Accuracy, Insuring Accuracy
1844 @section Verifying Data as It is Stored
1845 @cindex Verifying a write operation
1846 @cindex Double-checking a write operation
1848 To check for discrepancies in an archive immediately after it is
1849 written, use the @samp{--verify} option in conjunction with the
1850 @samp{tar --create} operation. When this option is specified,
1851 @code{tar} checks archive members against their counterparts in the file
1852 system, and reports discrepancies on the standard error. In
1853 multi-volume archives, each volume is verified after it is written,
1854 before the next volume is written.
1856 To verify an archive, you must be able to read it from before the end
1857 of the last written entry. This option is useful for detecting data
1858 errors on some tapes. Archives written to pipes, some cartridge tape
1859 drives, and some other devices cannot be verified.
1864 Checks for discrepancies in the archive immediately after it is
1865 written. Use in conjunction with @samp{tar --create}.
1868 @node Comparing, , Write Verification, Insuring Accuracy
1869 @section Comparing an Archive with the File System
1870 @cindex Verifying the currency of an archive
1872 @samp{tar --compare} compares archive members in an existing archive
1873 with their counterparts in the file system, and reports differences in
1874 file size, mode, owner, modification date and contents. If a file is
1875 represented in the archive but does not exist in the file system,
1876 @code{tar} reports a difference.
1878 If you use @var{file-name} arguments in conjunction with @samp{tar
1879 --compare}, @code{tar} compares the archived versions of the files
1880 specified with their counterparts in the file system. If you specify
1881 a file that is not in the archive, @code{tar} will report an error. If
1882 you don't specify any files, @code{tar} compares all the files in the
1885 Because @code{tar} only checks files in the archive against files in
1886 the file system, and not vice versa, it ignores files in the file
1887 system that do not exist in the archive.
1889 The following example compares the archive members @file{larry},
1890 @file{moe} and @file{curly} in the archive @file{stooges} with files
1891 of the same name in the file system.
1894 tar --compare --file=stooges larry moe curly
1898 If a file, for example @file{curly}, did not exist in the archive,
1899 @code{tar} would report an error, as follows:
1902 curly: does not exist
1905 @node Selecting Archive Members, User Interaction, Insuring Accuracy, Top
1906 @chapter Selecting Archive Members
1907 @cindex Specifying files to act on
1908 @cindex Specifying archive members
1910 @dfn{File-name arguments} specify which files in the file system
1911 @code{tar} operates on, when creating or adding to an archive, or
1912 which archive members @code{tar} operates on, when reading or
1913 deleting from an archive. (@pxref{Reading and Writing}.)
1915 To specify file names, you can include them as the last arguments on
1916 the command line, as follows:
1918 tar @var{operation} [@var{option1} @var{option2} ..] [@var{file-name-1} @var{file-name-2} ...]
1921 If you specify a directory name as a file name argument, all the files
1922 in that directory are operated on by @code{tar}.
1924 If you do not specify files when @code{tar} is invoked, @code{tar}
1925 operates on all the non-directory files in the working directory (if
1926 the operation is @samp{--create}), all the archive members in the
1927 archive (if a read operation is specified), or does nothing (if any
1928 other operation is specified).
1931 * File Name Lists:: Reading File Names from a File
1932 * File Name Interpretation:: this needs a better title
1933 * File Exclusion:: so does this
1936 @node File Name Lists, File Name Interpretation, Selecting Archive Members, Selecting Archive Members
1937 @section Reading a List of File Names from a File
1938 @cindex Lists of file names
1939 @cindex File-name arguments, alternatives
1941 To read file names from a file on the file system, instead of from the
1942 command line, use the @samp{--files-from=@var{file}} option. If you
1943 specify @samp{-} as @var{file}, the file names are read from standard
1944 input. Note that using both @samp{--files-from=-} and @samp{--file=-}
1945 in the same command will not work unless the operation is
1946 @samp{--create}. @xref{Archive Name}, for an explanation of the
1947 @samp{--file} option.
1950 @item --files-from=@var{file}
1951 @itemx -T @var{file}
1952 Reads file-name arguments from a file on the file system, instead of
1953 from the command line. Use in conjunction with any operation.
1956 @node File Name Interpretation, File Exclusion, File Name Lists, Selecting Archive Members
1957 @section File Name Interpretation
1958 @cindex File Names, interpreting
1960 @c <<<<add some text -ringo
1963 * Absolute File Names::
1964 * Changing Working Directory::
1965 * Archiving with Symbolic Links:: Archiving Using Symbolic Links
1968 @node Absolute File Names, Changing Working Directory, File Name Interpretation, File Name Interpretation
1969 @subsection Storing and Extracting Files Relative to Root
1971 @c <<< is this what this does, or does it just preserve the slash?
1972 @c <<< is it still called --absolute-paths?
1974 @c To archive or extract files relative to the root directory, specify
1975 @c the @samp{--absolute-paths} option.
1977 @c Normally, @code{tar} acts on files relative to the working
1978 @c directory---ignoring superior directory names when archiving, and
1979 @c ignoring leading slashes when extracting.
1981 @c When you specify @samp{--absolute-paths}, @code{tar} stores file names
1982 @c including all superior directory names, and preserves leading slashes.
1983 @c If you only invoked @code{tar} from the root directory you would never
1984 @c need the @samp{--absolute-paths} option, but using this option may be
1985 @c more convenient than switching to root.
1987 @c >>> should be an example in the tutorial/wizardry section using this
1988 @c >>> to transfer files between systems.
1990 @c >>> is write access an issue?
1993 @item --absolute-paths
1994 Preserves full file names (inclusing superior dirctory names) when
1995 archiving files. Preserves leading slash when extracting files.
1998 @node Changing Working Directory, Archiving with Symbolic Links, Absolute File Names, File Name Interpretation
1999 @subsection Changing the Working Directory Within a List of File-names
2000 @cindex Directory, changing in mid-stream
2001 @cindex Working directory, specifying
2003 To change working directory in the middle of a list of file names,
2004 (either on the command line or in a file specified using
2005 @samp{--files-from}), use @samp{--directory=@var{directory}}. This will
2006 change the working directory to the directory @var{directory} after
2007 that point in the list. For example,
2010 tar --create iggy ziggy --directory=baz melvin
2014 will place the files @file{iggy} and @file{ziggy} from the current
2015 directory into the archive, followed by the file @file{melvin} from
2016 the directory @file{baz}. This option is especially useful when you
2017 have several widely separated files that you want to store in the same
2018 directory in the archive.
2020 Note that the file @file{melvin} is recorded in the archive under the
2021 precise name @file{melvin}, @emph{not} @file{baz/melvin}. Thus, the
2022 archive will contain three files that all appear to have come from the
2023 same directory; if the archive is extracted with plain @samp{tar
2024 --extract}, all three files will be written in the current directory.
2026 Contrast this with the command
2029 tar -c iggy ziggy bar/melvin
2033 which records the third file in the archive under the name
2034 @file{bar/melvin} so that, if the archive is extracted using @samp{tar
2035 --extract}, the third file will be written in a subdirectory named
2039 @item --directory=@file{directory}
2040 @itemx -C @file{directory}
2041 Changes the working directory.
2044 @c <<<need to test how extract deals with this, and add an example -ringo
2046 @node Archiving with Symbolic Links, , Changing Working Directory, File Name Interpretation
2047 @subsection Archiving Using Symbolic Links
2048 @cindex File names, using symbolic links
2049 @cindex Symbolic link as file name
2051 @samp{--dereference} is used with @samp{tar --create}, and causes
2052 @code{tar} to archive files which are referenced by a symbolic link,
2053 using the name of the link as the file name.
2055 <<<this needs to be checked by MIB and then re-written, with an example
2056 The name under which the file is stored in the file system is not
2057 recorded in the archive. To record both the symbolic link name and
2058 the file name in the system, archive the file under both names. If
2059 all links were recorded automatically by @code{tar}, an extracted file
2060 might be linked to a file name that no longer exists in the file
2063 @c <<< is the following still true? - ringo
2064 If a linked-to file is encountered again by @code{tar} while creating
2065 the same archive, an entire second copy of it will be stored. This
2066 could be considered a bug.
2071 Stores files referenced by a symbolic link, using the name of the link
2072 as the file name. Use in conjunction with any write operation.
2075 @node File Exclusion, , File Name Interpretation, Selecting Archive Members
2076 @section Selecting Files by Characteristic
2077 @cindex File names, excluding files by
2078 @cindex Excluding files by name and pattern
2079 @cindex Excluding files by file system
2080 @cindex File system boundaries, not crossing
2081 @cindex Excluding file by age
2082 @cindex Modification time, excluding files by
2083 @cindex Age, excluding files by
2085 To avoid crossing file system boundaries when archiving parts of a
2086 directory tree, use @samp{--one-file-system}. This option only affects
2087 files that are archived because they are in a directory that is being
2088 archived; files explicitly named on the command line are archived
2089 regardless of where they reside.
2091 This option is useful for making full or incremental archival backups
2094 If this option is used in conjunction with @samp{--verbose}, files that
2095 are excluded are mentioned by name on the standard error.
2098 @item --one-file-system
2100 Prevents @code{tar} from crossing file system boundaries when
2101 archiving. Use in conjunction with any write operation.
2104 To avoid operating on files whose names match a particular pattern,
2105 use the @samp{--exclude=@var{pattern}} or
2106 @samp{--exclude-from=@var{file}} options.
2108 When you specify the @samp{--exclude=@var{pattern}} option, @code{tar}
2109 ignores files which match the @var{pattern}, which can be a single
2110 file name or a more complex expression. Thus, if you invoke
2111 @code{tar} with @samp{tar --create --exclude=*.o}, no files whose names
2112 end in @file{.o} are included in the archive.
2113 @c <<< what other things can you use besides "*"?
2115 @samp{--exclude-from=@var{file}} acts like @samp{--exclude}, but
2116 specifies a file @var{file} containing a list of patterns. @code{tar}
2117 ignores files with names that fit any of these patterns.
2119 You can use either option more than once in a single command.
2122 @item --exclude=@var{pattern}
2123 Causes @code{tar} to ignore files that match the @var{pattern}.
2125 @item --exclude-from=@var{file}
2126 Causes @code{tar} to ignore files that match the patterns listed in
2129 @c --exclude-from used to be "--exclude", --exclude didn't used to exist.
2131 To operate only on files with modification or status-change times
2132 after a particular date, use @samp{--after-date=@var{date}}. You can
2133 use this option with @samp{tar --create} or @samp{tar --add-file} to
2134 insure only new files are archived, or with @samp{tar --extract} to
2135 insure only recent files are resurrected. @refill
2136 @c --after-date @var{date} or --newer @var{date}
2138 @samp{--newer-mtime=@var{date}} acts like @samp{--after-date=@var{date}},
2139 but tests just the modification times of the files, ignoring
2140 status-change times.
2142 @c <<<need example of --newer-mtime with quoted argument
2143 Remember that the entire date argument should be quoted if it contains
2147 @strong{Please Note:} @samp{--after-date} and @samp{--newer-mtime}
2148 should not be used for incremental backups. Some files (such as those
2149 in renamed directories) are not selected up properly by these options.
2150 @c xref to incremental backup chapter when node name is decided.
2153 @item --after-date=@var{date}
2154 @itemx --newer=@var{date}
2155 @itemx -N @var{date}
2156 Acts on files only if their modification or inode-changed times are
2157 later than @var{date}. Use in conjunction with any operation.
2158 @item --newer-mtime=@var{date}
2159 Acts like @samp{--after-date}, but only looks at modification times.
2162 @c <<< following is the getdate date format --- needs to be re-written,
2163 @c <<< made a sub-node:
2165 Time/Date Formats Accepted by getdate
2166 (omitting obscure constructions)
2168 The input consists of one or more of: time zone day date year
2171 Those in turn consist of (`|' and `/' mean `or', `[]' means `optional'):
2173 time: H am/pm | H:M [am/pm] | H:M:S [am/pm]
2174 zone: timezone-name | timezone-name dst
2175 day: day-name | day-name, | N day-name
2176 date: M/D | M/D/Y | month-name D | month-name D, Y | D month-name | D month-name Y
2179 am can also be a.m., pm can also be p.m.
2180 case and spaces around punctuation are not significant.
2181 month and day names can be abbreviated. >>>
2183 @node User Interaction, Backups and Restoration, Selecting Archive Members, Top
2184 @chapter User Interaction
2185 @cindex Getting more information during the operation
2186 @cindex Information during operation
2187 @cindex Feedback from @code{tar}
2189 Once you have typed a @code{tar}command, it is usually performed
2190 without any further information required of the user, or provided by
2191 @code{tar}. The following options allow you to generate progress and
2192 status information during an operation, or to confirm operations on
2193 files as they are performed.
2196 * Additional Information::
2197 * Interactive Operation::
2200 @node Additional Information, Interactive Operation, User Interaction, User Interaction
2201 @section Progress and Status Information
2202 @cindex Progress information
2203 @cindex Status information
2204 @cindex Information on progress and status of operations
2205 @cindex Verbose operation
2206 @cindex Record number where error occured
2207 @cindex Error message, record number of
2208 @cindex Version of the @code{tar} program
2210 Typically, @code{tar} performs most operations without reporting any
2211 information to the user except error messages. If you have
2212 encountered a problem when operating on an archive, however, you may
2213 need more information than just an error message in order to solve the
2214 problem. The following options can be helpful diagnostic tools.
2216 When used with most operations, @samp{--verbose} causes @code{tar} to
2217 print the file names of the files or archive members it is operating
2218 on. When used with @samp{tar --list}, the verbose option causes
2219 @code{tar} to print out an @samp{ls -l} type listing of the files in
2222 Verbose output appears on the standard output except when an archive
2223 is being written to the standard output (as with @samp{tar --create
2224 --file=- --verbose}). In that case @code{tar} writes verbose output to
2225 the standard error stream.
2230 Prints the names of files or archive members as they are being
2231 operated on. Can be used in conjunction with any operation. When
2232 used with @samp{--list}, generates an @samp{ls -l} type listing.
2235 To find out where in an archive a message was triggered, use
2236 @samp{--record-number}. @samp{--record-number} causes @code{tar} to
2237 print, along with every message it produces, the record number within
2238 the archive where the message was triggered.
2240 This option is especially useful when reading damaged archives, since
2241 it helps pinpoint the damaged sections. It can also be used with
2242 @samp{tar --list} when listing a file-system backup tape, allowing you
2243 to choose among several backup tapes when retrieving a file later, in
2244 favor of the tape where the file appears earliest (closest to the
2246 @c <<< xref when the node name is set and the backup section written
2249 @item --record-number
2251 Prints the record number whenever a message is generated by
2252 @code{tar}. Use in conjunction with any operation.
2256 To print the version number of the @code{tar} program, use @samp{tar
2257 --version}. @code{tar} prints the version number to the standard
2268 GNU tar version 1.09
2270 @c used to be an option. has been fixed.
2272 @node Interactive Operation, , Additional Information, User Interaction
2273 @section Asking for Confirmation During Operations
2274 @cindex Interactive operation
2276 Typically, @code{tar} carries out a command without stopping for
2277 further instructions. In some situations however, you
2278 may want to exclude some files and archive members from the operation
2279 (for instance if disk or storage space is tight). You can do this by
2280 excluding certain files automatically (@pxref{File Exclusion}), or by
2281 performing an operation interactively, using the @samp{--interactive}
2284 When the @samp{--interactive} option is specified, @code{tar} asks for
2285 confirmation before reading, writing, or deleting each file it
2286 encounters while carrying out an operation. To confirm the action you
2287 must type a line of input beginning with @samp{y}. If your input line
2288 begins with anything other than @samp{y}, @code{tar} skips that file.
2290 Commands which might be useful to perform interactively include
2291 appending files to an archive, extracting files from an archive,
2292 deleting a file from an archive, and deleting a file from disk during
2293 an incremental restore.
2295 If @code{tar} is reading the archive from the standard input,
2296 @code{tar} opens the file @file{/dev/tty} to support the interactive
2298 <<< this aborts if you won't OK the working directory. this is a bug. -ringo
2302 @itemx --confirmation
2304 Asks for confirmation before reading, writing or deleting an archive
2305 member (when listing, comparing or writing an archive or deleting
2306 archive members), or before writing or deleting a file (when
2307 extracting an archive).
2310 @node Backups and Restoration, Media, User Interaction, Top
2311 @chapter Performing Backups and Restoring Files
2313 To @dfn{back up} a file system means to create archives that contain
2314 all the files in that file system. Those archives can then be used to
2315 restore any or all of those files (for instance if a disk crashes or a
2316 file is accidently deleted). File system @dfn{backups} are also
2320 * Backup Levels:: Levels of backups
2321 * Backup Scripts:: Using scripts to perform backups
2323 * incremental and listed-incremental:: The --incremental
2324 and --listed-incremental Options
2325 * Problems:: Some common problems and their solutions
2328 @node Backup Levels, Backup Scripts, Backups and Restoration, Backups and Restoration
2329 @section Levels of Backups
2331 An archive containing all the files in the file system is called a
2332 @dfn{full backup} or @dfn{full dump}. You could insure your data by
2333 creating a full dump every day. This strategy, however, would waste a
2334 substantial amount of archive media and user time, as unchanged files
2335 are daily re-archived.
2337 It is more efficient to do a full dump only occasionally. To back up
2338 files between full dumps, you can a incremental dump. A @dfn{level
2339 one} dump archives all the files that have changed since the last full
2342 A typical dump strategy would be to perform a full dump once a week,
2343 and a level one dump once a day. This means some versions of files
2344 will in fact be archived more than once, but this dump strategy makes
2345 it possible to restore a file system to within one day of accuracy by
2346 only extracting two archives---the last weekly (full) dump and the
2347 last daily (level one) dump. The only information lost would be in
2348 files changed or created since the last daily backup. (Doing dumps
2349 more than once a day is usually not worth the trouble).
2351 @node Backup Scripts, incremental and listed-incremental, Backup Levels, Backups and Restoration
2352 @section Using Scripts to Perform Backups and Restoration
2354 GNU @code{tar} comes with scripts you can use to do full and level-one
2355 dumps. Using scripts (shell programs) to perform backups and
2356 restoration is a convenient and reliable alternative to typing out
2357 file name lists and @code{tar} commands by hand.
2359 Before you use these scripts, you need to edit the file
2360 @file{backup-specs}, which specifies parameters used by the backup
2361 scripts and by the restore script. @xref{Script Syntax}.
2362 Once the backup parameters are set, you can perform backups or
2363 restoration by running the appropriate script.
2365 The name of the restore script is @code{restore}. The names of the
2366 level one and full backup scripts are, respectively, @code{level-1} and
2367 @code{level-0}. The @code{level-0} script also exists under the name
2368 @code{weekly}, and the @code{level-1} under the name
2369 @code{daily}---these additional names can be changed according to your
2370 backup schedule. @xref{Scripted Restoration}, for more information
2371 on running the restoration script. @xref{Scripted Backups}, for more
2372 information on running the backup scripts.
2374 @emph{Please Note:} The backup scripts and the restoration scripts are
2375 designed to be used together. While it is possible to restore files
2376 by hand from an archive which was created using a backup script, and
2377 to create an archive by hand which could then be extracted using the
2378 restore script, it is easier to use the scripts. @xref{incremental
2379 and listed-incremental}, before making such an attempt.
2381 @c shorten node names
2383 * Backup Parameters:: Setting parameters for backups and restoration
2384 * Scripted Backups:: Using the backup scripts
2385 * Scripted Restoration:: Using the restore script
2388 @node Backup Parameters, Scripted Backups, Backup Scripts, Backup Scripts
2389 @subsection Setting Parameters for Backups and Restoration
2391 The file @file{backup-specs} specifies backup parameters for the
2392 backup and restoration scripts provided with @code{tar}. You must
2393 edit @file{backup-specs} to fit your system configuration and schedule
2394 before using these scripts.
2396 @c <<< This about backup scripts needs to be written:
2397 @c <<<BS is a shell script .... thus ... @file{backup-specs} is in shell
2398 @c script syntax. @xref{Script Syntax}, for an explanation of this
2401 @c whats a parameter .... looked at by the backup scripts ... which will
2402 @c be expecting to find ... now syntax ... value is linked to lame ...
2403 @c @file{backup-specs} specifies the following parameters:
2408 The user name of the backup administrator.
2411 The hour at which the backups are done. This can be a number from 0
2412 to 23, or the string @samp{now}.
2415 The device @code{tar} writes the archive to. This device should be
2416 attached to the host on which the dump scripts are run.
2417 @c <<< examples for all ...
2420 The command to use to obtain the status of the archive device,
2421 including error count. On some tape drives there may not be such a
2422 command; in that case, simply use `TAPE_STATUS=false'.
2425 The blocking factor @code{tar} will use when writing the dump archive.
2426 @xref{Blocking Factor}.
2429 A list of file systems to be dumped. You can include any directory
2430 name in the list---subdirectories on that file system will be
2431 included, regardless of how they may look to other networked machines.
2432 Subdirectories on other file systems will be ignored.
2434 The host name specifies which host to run @code{tar} on, and should
2435 normally be the host that actually contains the file system. However,
2436 the host machine must have GNU @code{tar} installed, and must be able
2437 to access the directory containing the backup scripts and their
2438 support files using the same file name that is used on the machine
2439 where the scripts are run (ie. what @code{pwd} will print when in that
2440 directory on that machine). If the host that contains the file system
2441 does not have this capability, you can specify another host as long as
2442 it can access the file system through NFS.
2445 A list of individual files to be dumped. These should be accessible
2446 from the machine on which the backup script is run.
2447 @c <<<same file name, be specific. through nfs ...
2451 * backup-specs example:: An Example Text of @file{Backup-specs}
2452 * Script Syntax:: Syntax for @file{Backup-specs}
2455 @node backup-specs example, Script Syntax, Backup Parameters, Backup Parameters
2456 @subsubsection An Example Text of @file{Backup-specs}
2458 The following is the text of @file{backup-specs} as it appears at FSF:
2461 # site-specific parameters for file system backup.
2463 ADMINISTRATOR=friedman
2465 TAPE_FILE=/dev/nrsmt0
2466 TAPE_STATUS="mts -t $TAPE_FILE"
2481 apple-gunkies:/com/mailer/gnu
2482 apple-gunkies:/com/archive/gnu"
2484 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
2488 @node Script Syntax, , backup-specs example, Backup Parameters
2489 @subsubsection Syntax for @file{Backup-specs}
2491 @file{backup-specs} is in shell script syntax. The following
2492 conventions should be considered when editing the script:
2493 @c <<< "conventions?"
2495 A quoted string is considered to be contiguous, even if it is on more
2496 than one line. Therefore, you cannot include commented-out lines
2497 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
2498 the two most likely parameters to be multi-line.
2500 A quoted string typically cannot contain wildcards. In
2501 @file{backup-specs}, however, the parameters BACKUP_DIRS and
2502 BACKUP_FILES can contain wildcards.
2504 @node Scripted Backups, Scripted Restoration, Backup Parameters, Backup Scripts
2505 @subsection Using the Backup Scripts
2507 The syntax for running a backup script is:
2510 @file{script-name} [@var{time-to-be-run}]
2513 where @var{time-to-be-run} can be a specific system time, or can be
2514 @kbd{now}. If you do not specify a time, the script runs at the time
2515 specified in @file{backup-specs} (@pxref{Script Syntax}).
2517 You should start a script with a tape or disk mounted. Once you start
2518 a script, it prompts you for new tapes or disks as it needs them.
2519 Media volumes don't have to correspond to archive files---a
2520 multi-volume archive can be started in the middle of a tape that
2521 already contains the end of another multi-volume archive. The
2522 @code{restore} script prompts for media by its archive volume, so to
2523 avoid an error message you should keep track of which tape (or disk)
2524 contains which volume of the archive. @xref{Scripted Restoration}.
2526 @c <<<have file names changed? -ringo
2527 The backup scripts write two files on the file system. The first is a
2528 record file in @file{/etc/tar-backup/}, which is used by the scripts
2529 to store and retrieve information about which files were dumped. This
2530 file is not meant to be read by humans, and should not be deleted by
2531 them. @xref{incremental and listed-incremental}, for a more
2532 detailed explanation of this file.
2534 The second file is a log file containing the names of the file systems
2535 and files dumped, what time the backup was made, and any error
2536 messages that were generated, as well as how much space was left in
2537 the media volume after the last volume of the archive was written.
2538 You should check this log file after every backup. The file name is
2539 @file{log-@var{mmm-ddd-yyyy}-level-1} or
2540 @file{log-@var{mmm-ddd-yyyy}-full}.
2542 The script also prints the name of each system being dumped to the
2544 @c <<<the section on restore scripts is commented out.
2545 @c <<< a section on non-scripted testore mya be a good idea
2547 @node Scripted Restoration, , Scripted Backups, Backup Scripts
2548 @subsection Using the Restore Script
2549 @c subject to change as things develop
2551 To restore files that were archived using a scripted backup, use the
2552 @code{restore} script. The syntax for the script is:
2555 where ##### are the file systems to restore from, and
2556 ##### is a regular expression which specifies which files to
2557 restore. If you specify --all, the script restores all the files
2560 You should start the restore script with the media containing the
2561 first volume of the archive mounted. The script will prompt for other
2562 volumes as they are needed. If the archive is on tape, you don't need
2563 to rewind the tape to to its beginning---if the tape head is
2564 positioned past the beginning of the archive, the script will rewind
2565 the tape as needed. @xref{Media}, for a discussion of tape
2568 If you specify @samp{--all} as the @var{files} argument, the
2569 @code{restore} script extracts all the files in the archived file
2570 system into the active file system.
2573 @strong{Warning:}The script will delete files from the active file
2574 system if they were not in the file system when the archive was made.
2577 @xref{incremental and listed-incremental}, for an explanation of how
2578 the script makes that determination.
2579 @c this may be an option, not a given
2582 @node incremental and listed-incremental, Problems, Backup Scripts, Backups and Restoration
2583 @section The @code{--incremental} and @code{--listed-incremental} Options
2585 @samp{--incremental} is used in conjunction with @samp{--create},
2586 @samp{--extract} or @samp{--list} when backing up and restoring file
2587 systems. An archive cannot be extracted or listed with the
2588 @samp{--incremental} option specified unless it was created with the
2589 option specified. This option should only be used by a script, not by
2590 the user, and is usually disregarded in favor of
2591 @samp{--listed-incremental}, which is described below.
2593 @samp{--incremental} in conjunction with @samp{--create} causes
2594 @code{tar} to write, at the beginning of the archive, an entry for
2595 each of the directories that will be archived. The entry for a
2596 directory includes a list of all the files in the directory at the
2597 time the archive was created and a flag for each file indicating
2598 whether or not the file is going to be put in the archive.
2600 Note that this option causes @code{tar} to create a non-standard
2601 archive that may not be readable by non-GNU versions of the @code{tar}
2604 @samp{--incremental} in conjunction with @samp{--extract} causes
2605 @code{tar} to read the lists of directory contents previously stored
2606 in the archive, @emph{delete} files in the file system that did not
2607 exist in their directories when the archive was created, and then
2608 extract the files in the archive.
2610 This behavior is convenient when restoring a damaged file system from
2611 a succession of incremental backups: it restores the entire state of
2612 the file system to that which obtained when the backup was made. If
2613 @samp{--incremental} isn't specified, the file system will probably
2614 fill up with files that shouldn't exist any more.
2616 @samp{--incremental} in conjunction with @samp{--list}, causes
2617 @code{tar} to print, for each directory in the archive, the list of
2618 files in that directory at the time the archive was created. This
2619 information is put out in a format that is not easy for humans to
2620 read, but which is unambiguous for a program: each file name is
2621 preceded by either a @samp{Y} if the file is present in the archive,
2622 an @samp{N} if the file is not included in the archive, or a @samp{D}
2623 if the file is a directory (and is included in the archive). Each
2624 file name is terminated by a null character. The last file is followed
2625 by an additional null and a newline to indicate the end of the data.
2627 @samp{--listed-incremental}=@var{file} acts like @samp{--incremental},
2628 but when used in conjunction with @samp{--create} will also cause
2629 @code{tar} to use the file @var{file}, which contains information
2630 about the state of the file system at the time of the last backup, to
2631 decide which files to include in the archive being created. That file
2632 will then be updated by @code{tar}. If the file @var{file} does not
2633 exist when this option is specified, @code{tar} will create it, and
2634 include all appropriate files in the archive.
2636 The file @var{file}, which is archive independent, contains the date
2637 it was last modified and a list of devices, inode numbers and
2638 directory names. @code{tar} will archive files with newer mod dates
2639 or inode change times, and directories with an unchanged inode number
2640 and device but a changed directory name. The file is updated after
2641 the files to be archived are determined, but before the new archive is
2644 @c <<< this section needs to be written
2645 @node Problems, , incremental and listed-incremental, Backups and Restoration
2646 @section Some Common Problems and their Solutions
2650 no such file or directory
2654 directory checksum error
2657 errors from media/system:
2661 @node Media, Quick Reference, Backups and Restoration, Top
2662 @chapter Tapes and Other Archive Media
2664 Archives are usually written on dismountable media---tape cartridges,
2665 mag tapes, or floppy disks.
2667 The amount of data a tape or disk holds depends not only on its size,
2668 but also on how it is formatted. A 2400 foot long reel of mag tape
2669 holds 40 megabytes of data when formated at 1600 bits per inch. The
2670 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
2672 Magnetic media are re-usable---once the archive on a tape is no longer
2673 needed, the archive can be erased and the tape or disk used over.
2674 Media quality does deteriorate with use, however. Most tapes or disks
2675 should be disgarded when they begin to produce data errors. EXABYTE
2676 tape cartridges should be disgarded when they generate an @dfn{error
2677 count} (number of non-usable bits) of more than 10k.
2679 Magnetic media are written and erased using magnetic fields, and
2680 should be protected from such fields to avoid damage to stored data.
2681 Sticking a floppy disk to a filing cabinet using a magnet is probably
2686 * Write Protection:: Write Protection
2687 * Tape Positioning:: Tape Positions and Tape Marks
2690 @node Write Protection, Tape Positioning, Media, Media
2691 @section Write Protection
2693 All tapes and disks can be @dfn{write protected}, to protect data on
2694 them from being changed. Once an archive is written, you should write
2695 protect the media to prevent the archive from being accidently
2696 overwritten or deleted. (This will protect the archive from being
2697 changed with a tape or floppy drive---it will not protect it from
2698 magnet fields or other physical hazards).
2700 The write protection device itself is usually an integral part of the
2701 physical media, and can be a two position (write enabled/write
2702 disabled) switch, a notch which can be popped out or covered, a ring
2703 which can be removed from the center of a tape reel, or some other
2706 @node Tape Positioning, , Write Protection, Media
2707 @section Tape Positions and Tape Marks
2709 Just as archives can store more than one file from the file system,
2710 tapes can store more than one archive file. To keep track of where
2711 archive files (or any other type of file stored on tape) begin and
2712 end, tape archive devices write magnetic @dfn{tape marks} on the
2713 archive media. Tape drives write one tape mark between files,
2714 two at the end of all the file entries.
2716 If you think of data as a series of "0000"'s, and tape marks as "x"'s,
2717 a tape might look like the following:
2720 0000x000000x00000x00x00000xx-------------------------
2723 Tape devices read and write tapes using a read/write @dfn{tape
2724 head}---a physical part of the device which can only access one point
2725 on the tape at a time. When you use @code{tar} to read or write
2726 archive data from a tape device, the device will begin reading or
2727 writing from wherever on the tape the tape head happens to be,
2728 regardless of which archive or what part of the archive the tape head
2729 is on. Before writing an archive, you should make sure that no data
2730 on the tape will be overwritten (unless it is no longer needed).
2731 Before reading an archive, you should make sure the tape head is at
2732 the beginning of the archive you want to read. (The @code{restore}
2733 script will find the archive automatically. @xref{Scripted
2734 Restoration}). @xref{mt}, for an explanation of the tape moving
2737 If you want to add new archive file entries to a tape, you should
2738 advance the tape to the end of the existing file entries, backspace
2739 over the last tape mark, and write the new archive file. If you were
2740 to add two archives to the example above, the tape might look like the
2744 0000x000000x00000x00x00000x000x0000xx----------------
2748 * mt:: The @code{mt} Utility
2751 @node mt, , Tape Positioning, Tape Positioning
2752 @subsection The @code{mt} Utility
2754 <<< is it true that this only works on non-block devices? should
2755 <<< explain the difference, xref to block-size (fixed or variable).
2757 You can use the @code{mt} utility to advance or rewind a tape past a
2758 specified number of archive files on the tape. This will allow you to
2759 move to the beginning of an archive before extracting or reading it,
2760 or to the end of all the archives before writing a new one.
2761 @c why isn't there an "advance 'til you find two tape marks together"?
2763 The syntax of the @code{mt} command is:
2766 mt [-f @var{tapename}] @var{operation} [@var{number}]
2769 where @var{tapename} is the name of the tape device, @var{number} is
2770 the number of times an operation is performed (with a default of one),
2771 and @var{operation} is one of the following:
2776 Writes @var{number} tape marks at the current position on the tape.
2780 Moves tape position forward @var{number} files.
2784 Moves tape position back @var{number} files.
2788 Rewinds the tape. (Ignores @var{number}).
2793 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
2797 Prints status information about the tape unit.
2799 <<< is there a better way to frob the spacing on the list? -ringo
2801 If you don't specify a @var{tapename}, @code{mt} uses the environment
2802 variable TAPE; if TAPE does not exist, @code{mt} uses the device
2805 @code{mt} returns a 0 exit status when the operation(s) were
2806 successful, 1 if the command was unrecognized, and 2 if an operation
2809 @c <<< new node on how to find an archive? -ringo
2810 If you use @code{tar --extract} with the
2811 @samp{--label=@var{archive-name}} option specified, @code{tar} will
2812 read an archive label (the tape head has to be positioned on it) and
2813 print an error if the archive label doesn't match the
2814 @var{archive-name} specified. @var{archive-name} can be any regular
2815 expression. If the labels match, @code{tar} extracts the archive.
2816 @xref{Archive Label}. @xref{Matching Format Parameters}.
2817 <<< fix cross references
2819 @code{tar --list --label} will cause @code{tar} to print the label.
2821 @c <<< MIB -- program to list all the labels on a tape?
2823 @node Quick Reference, Data Format Details, Media, Top
2824 @appendix A Quick Reference Guide to @code{tar} Operations and Options
2825 @c put in proper form for appendix. (unnumbered?)
2828 * Operations:: A Table of Operations
2829 * Options:: Table of Options
2832 @node Operations, Options, Quick Reference, Quick Reference
2833 @appendixsec A Table of Operations
2834 @c add xrefs, note synonyms
2836 The operation argument to @code{tar} specifies which action you want to
2841 Adds copies of an archive or archives to the end of another archive.
2844 Creates a new archive.
2847 Compares files in the archive with their counterparts in the file
2848 system, and reports differences in file size, mode, owner,
2849 modification date and contents.
2852 Adds files to the end of the archive.
2855 Prints a list of the contents of the archive.
2858 Reads files from the archive and writes them into the active file
2862 Adds files to the end of the archive, but only if they are newer than
2863 their counterparts already in the archive, or if they do not already
2864 exist in the archive.
2867 Adds copies of an archive or archives to the end of another archive.
2870 Adds files to the end of the archive.
2873 Adds files to the end of the archive.
2876 Adds copies of an archive or archives to the end of another archive.
2879 Compares files in the archive with their counterparts in the file
2880 system, and reports differences in file size, mode, owner,
2881 modification date and contents.
2884 Adds copies of an archive or archives to the end of another archive.
2887 Creates a new archive.
2890 Deletes files from the archive. All versions of the files are deleted.
2893 Compares files in the archive with their counterparts in the file
2894 system, and reports differences in file size, mode, owner,
2895 modification date and contents.
2898 Reads files from the archive and writes them into the active file
2902 Reads files from the archive and writes them into the active file
2906 Prints a list of @code{tar} operations and options.
2909 Prints a list of the contents of the archive.
2912 Adds files to the end of the archive, but only if they are newer than
2913 their counterparts already in the archive, or if they do not already
2914 exist in the archive.
2917 Prints the version number of the @code{tar} program to the standard
2921 @node Options, , Operations, Quick Reference
2922 @appendixsec Table of Options
2924 Options change the way @code{tar} performs an operation.
2927 @item --absolute-paths
2928 WILL BE INPUT WHEN QUESTION IS RESOLVED
2930 @item --after-date=@var{date}
2931 Limit the operation to files changed after the given date.
2932 @xref{File Exclusion}.
2934 @item --block-size=@var{number}
2935 Specify the blocking factor of an archive. @xref{Blocking Factor}.
2938 Specify a compressed archive. @xref{Compressed Archives}.
2940 @item --compress-block.
2941 Create a whole block sized compressed archive. @xref{Compressed Archives}.
2943 @item --confirmation
2944 Solicit confirmation for each file. @xref{Interactive Operation}
2945 <<< --selective should be a synonym.
2948 Treat a symbolic link as an alternate name for the file the link
2949 points to. @xref{Symbolic Links}.
2951 @item --directory=@file{directory}
2952 Change the working directory. @xref{Changing Working Directory}.
2954 @item --exclude=@var{pattern}
2955 Exclude files which match the regular expression @var{pattern}.
2956 @xref{File Exclusion}.
2958 @item --exclude-from=@file{file}
2959 Exclude files which match any of the regular expressions listed in
2960 the file @file{file}. @xref{File Exclusion}.
2962 @item --file=@var{archive-name}
2963 Name the archive. @xref{Archive Name}).
2965 @item --files-from=@file{file}
2966 Read file-name arguments from a file on the file system.
2967 @xref{File Name Lists}.
2969 @item --ignore-umask
2970 Set modes of extracted files to those recorded in the archive.
2971 @xref{File Writing Options}.
2973 @item --ignore-zeros
2974 Ignore end-of-archive entries. @xref{Archive Reading Options}.
2975 <<< this should be changed to --ignore-end
2977 @item --listed-incremental=@var{file-name} (-g)
2978 Take a file name argument always. If the file doesn't exist, run a level
2979 zero dump, creating the file. If the file exists, uses that file to see
2982 @item --incremental (-G)
2985 @item --tape-length=@var{n} (-L)
2986 @c <<<alternate way of doing multi archive, will go to that length and
2987 @c prompts for new tape, automatically turns on multi-volume. >>>
2988 @c <<< this needs to be written into main body as well -ringo
2990 @item --info-script=@var{program-file}
2991 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
2994 Ask for confirmation before performing any operation on a file or
2997 @item --keep-old-files
2998 Prevent overwriting during extraction. @xref{File Writing Options}.
3000 @item --label=@var{archive-label}
3001 Include an archive-label in the archive being created. @xref{Archive
3004 @item --modification-time
3005 Set the modification time of extracted files to the time they were
3006 extracted. @xref{File Writing Options}.
3008 @item --multi-volume
3009 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
3011 @item --newer=@var{date}
3012 Limit the operation to files changed after the given date.
3013 @xref{File Exclusion}.
3015 @item --newer-mtime=@var{date}
3016 Limit the operation to files modified after the given date. @xref{File
3020 Create an old format archive. @xref{Old Style File Information}.
3021 @c <<< did we agree this should go away as a synonym?
3024 Create an old format archive. @xref{Old Style File Information}.
3026 @item --one-file-system
3027 Prevent @code{tar} from crossing file system boundaries when
3028 archiving. @xref{File Exclusion}.
3031 Create an old format archive. @xref{Old Style File Information}.
3032 @c <<< was portability, may still need to be changed
3034 @item --preserve-order
3035 Help process large lists of file-names on machines with small amounts of
3036 memory. @xref{Archive Reading Options}.
3038 @item --preserve-permission
3039 Set modes of extracted files to those recorded in the archive.
3040 @xref{File Writing Options}.
3042 @item --read-full-blocks
3043 Read an archive with a smaller than specified block size or which
3044 contains incomplete blocks. @xref{Archive Reading Options}).
3045 @c should be --partial-blocks (!!!)
3047 @item --record-number
3048 Print the record number where a message is generated.
3049 @xref{Additional Information}.
3052 Help process large lists of file-names on machines with small amounts of
3053 memory. @xref{Archive Reading Options}.
3055 @item --same-permission
3056 Set the modes of extracted files to those recorded in the archive.
3057 @xref{File Writing Options}.
3060 Archive sparse files sparsely. @xref{Sparse Files}.
3062 @item --starting-file=@var{file-name}
3063 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
3066 Write files to the standard output. @xref{File Writing Options}.
3069 Specifdo a compressed archive. @xref{Compressed Archives}.
3071 @item -V @var{archive-label}
3072 Include an archive-label in the archive being created. @xref{Archive
3077 Print the names of files or archive members as they are being
3078 operated on. @xref{Additional Information}.
3081 Check for discrepancies in the archive immediately after it is
3082 written. @xref{Write Verification}.
3085 Read an archive with a smaller than specified block size or which
3086 contains incomplete blocks. @xref{Archive Reading Options}).
3088 @item -K @var{file-name}
3089 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
3092 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
3095 Limit operation to files changed after the given date. @xref{File Exclusion}.
3098 Write files to the standard output. @xref{File Writing Options}.
3100 @c <<<<- P is absolute paths, add when resolved. -ringo>>>
3103 Print the record number where a message is generated.
3104 @xref{Additional Information}.
3107 Archive sparse files sparsely. @xref{Sparse Files}.
3110 Read file-name arguments from a file on the file system.
3111 @xref{File Name Lists}.
3114 Check for discrepancies in the archive immediately after it is
3115 written. @xref{Write Verification}.
3118 Specify a compressed archive. @xref{Compressed Archives}.
3120 @item -b @var{number}
3121 Specify the blocking factor of an archive. @xref{Blocking Factor}.
3123 @item -f @var{archive-name}
3124 Name the archive. @xref{Archive Name}).
3127 Treat a symbolic link as an alternate name for the file the link
3128 points to. @xref{Symbolic Links}.
3131 Ignore end-of-archive entries. @xref{Archive Reading Options}.
3134 Prevent overwriting during extraction. @xref{File Writing Options}.
3137 Prevent @code{tar} from crossing file system boundaries when
3138 archiving. @xref{File Exclusion}.
3141 Set the modification time of extracted files to the time they were
3142 extracted. @xref{File Writing Options}.
3145 Create an old format archive. @xref{Old Style File Information}.
3148 Set the modes of extracted files to those recorded in the archive.
3149 @xref{File Writing Options}.
3152 Help process large lists of file-names on machines with small amounts of
3153 memory. @xref{Archive Reading Options}.
3156 Print the names of files or archive members they are being operated
3157 on. @xref{Additional Information}.
3160 @c <<<see --interactive. WILL BE INPUT WHEN QUESTIONS ARE RESOLVED.>>>
3163 Specify a compressed archive. @xref{Compressed Archives}.
3166 Create a whole block sized compressed archive. @xref{Compressed Archives}.
3167 @c I would rather this were -Z. it is the only double letter short
3170 @item -C @file{directory}
3171 Change the working directory. @xref{Changing Working Directory}.
3173 @item -F @var{program-file}
3174 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
3176 @item -X @file{file}
3177 Exclude files which match any of the regular expressions listed in
3178 the file @file{file}. @xref{File Exclusion}.
3181 @node Data Format Details, Concept Index, Quick Reference, Top
3182 @appendix Details of the Archive Data Format
3184 This chapter is based heavily on John Gilmore's @i{tar}(5) manual page
3185 for the public domain @code{tar} that GNU @code{tar} is based on.
3186 @c it's been majorly edited since, we may be able to lose this.
3188 The archive media contains a series of records, each of which contains
3189 512 bytes. Each archive member is represented by a header record,
3190 which describes the file, followed by zero or more records which
3191 represent the contents of the file. At the end of the archive file
3192 there may be a record consisting of a series of binary zeros, as an
3193 end-of-archive marker. GNU @code{tar} writes a record of zeros at the
3194 end of an archive, but does not assume that such a record exists when
3197 Records may be grouped into @dfn{blocks} for I/O operations. A block
3198 of records is written with a single @code{write()} operation. The
3199 number of records in a block is specified using the @samp{--block-size}
3200 option. @xref{Blocking Factor}, for more information about specifying
3204 * Header Data:: The Distribution of Data in the Header
3205 * Header Fields:: The Meaning of Header Fields
3206 * Sparse File Handling:: Fields to Handle Sparse Files
3209 @node Header Data, Header Fields, Data Format Details, Data Format Details
3210 @appendixsec The Distribution of Data in the Header
3212 The header record is defined in C as follows:
3213 @c I am taking the following code on faith.
3216 @r{Standard Archive Format - Standard TAR - USTAR}
3218 #define RECORDSIZE 512
3222 #define SPARSE_EXT_HDR 21
3223 #define SPARSE_IN_HDR 4
3231 char charptr[RECORDSIZE];
3241 char linkname[NAMSIZ];
3243 char uname[TUNMLEN];
3244 char gname[TGNMLEN];
3248 @r{The following fields were added by gnu and are not used by other}
3249 @r{versions of @code{tar}}.
3254 @r{The next three fields were added by gnu to deal with shrinking down}
3256 struct sparse sp[SPARSE_IN_HDR];
3258 @r{This is the number of nulls at the end of the file, if any.}
3259 char ending_blanks[12];
3263 struct extended_header @{
3264 struct sparse sp[21];
3269 @c <<< this whole thing needs to be put into better english
3271 @r{The checksum field is filled with this while the checksum is computed.}
3272 #define CHKBLANKS " " @r{8 blanks, no null}
3274 @r{Inclusion of this field marks an archive as being in standard}
3275 @r{Posix format (though GNU tar itself is not Posix conforming). GNU}
3276 @r{tar puts "ustar" in this field if uname and gname are valid.}
3277 #define TMAGIC "ustar " @r{7 chars and a null}
3279 @r{The magic field is filled with this if this is a GNU format dump entry.}
3280 #define GNUMAGIC "GNUtar " @r{7 chars and a null}
3282 @r{The linkflag defines the type of file.}
3283 #define LF_OLDNORMAL '\0' @r{Normal disk file, Unix compatible}
3284 #define LF_NORMAL '0' @r{Normal disk file}
3285 #define LF_LINK '1' @r{Link to previously dumped file}
3286 #define LF_SYMLINK '2' @r{Symbolic link}
3287 #define LF_CHR '3' @r{Character special file}
3288 #define LF_BLK '4' @r{Block special file}
3289 #define LF_DIR '5' @r{Directory}
3290 #define LF_FIFO '6' @r{FIFO special file}
3291 #define LF_CONTIG '7' @r{Contiguous file}
3293 @r{hhe following are further link types which were defined later.}
3295 @r{This is a dir entry that contains the names of files that were in}
3296 @r{the dir at the time the dump was made.}
3297 #define LF_DUMPDIR 'D'
3299 @r{This is the continuation of a file that began on another volume}
3300 #define LF_MULTIVOL 'M'
3302 @r{This is for sparse files}
3303 #define LF_SPARSE 'S'
3305 @r{This file is a tape/volume header. Ignore it on extraction.}
3306 #define LF_VOLHDR 'V'
3308 @r{These are bits used in the mode field - the values are in octal}
3309 #define TSUID 04000 @r{Set UID on execution}
3310 #define TSGID 02000 @r{Set GID on execution}
3311 #define TSVTX 01000 @r{Save text (sticky bit)}
3313 @r{These are file permissions}
3314 #define TUREAD 00400 @r{read by owner}
3315 #define TUWRITE 00200 @r{write by owner}
3316 #define TUEXEC 00100 @r{execute/search by owner}
3317 #define TGREAD 00040 @r{read by group}
3318 #define TGWRITE 00020 @r{write by group}
3319 #define TGEXEC 00010 @r{execute/search by group}
3320 #define TOREAD 00004 @r{read by other}
3321 #define TOWRITE 00002 @r{write by other}
3322 #define TOEXEC 00001 @r{execute/search by other}
3326 All characters in headers are 8-bit characters in the local variant of
3327 ASCII. Each field in the header is contiguous; that is, there is no
3328 padding in the header format.
3330 Data representing the contents of files is not translated in any way
3331 and is not constrained to represent characters in any character set.
3332 @code{tar} does not distinguish between text files and binary files.
3334 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
3335 @code{gname} fields contain null-terminated character strings. All
3336 other fields contain zero-filled octal numbers in ASCII. Each numeric
3337 field of width @var{w} contains @var{w} @minus{} 2 digits, a space, and a
3338 null, except @code{size} and @code{mtime}, which do not contain the
3341 @node Header Fields, Sparse File Handling, Header Data, Data Format Details
3342 @appendixsec The Meaning of Header Fields
3344 The @code{name} field contains the name of the file.
3345 <<< how big a name before field overflows?
3347 The @code{mode} field contains nine bits which specify file
3348 permissions, and three bits which specify the Set UID, Set GID, and
3349 Save Text (``stick'') modes. Values for these bits are defined above.
3350 @xref{File Writing Options}, for information on how file permissions
3351 and modes are used by @code{tar}.
3353 The @code{uid} and @code{gid} fields contain the numeric user and
3354 group IDs of the file owners. If the operating system does not
3355 support numeric user or group IDs, these fields should be ignored.
3358 The @code{size} field contains the size of the file in bytes; this
3359 field contains a zero if the header describes a link to a file.
3361 The @code{mtime} field contains the modification time of the file.
3362 This is the ASCII representation of the octal value of the last time
3363 the file was modified, represented as an integer number of seconds
3364 since January 1, 1970, 00:00 Coordinated Universal Time.
3365 @xref{File Writing Options}, for a description of how @code{tar} uses
3368 The @code{chksum} field contains the ASCII representation of the octal
3369 value of the simple sum of all bytes in the header record. To
3370 generate this sum, each 8-bit byte in the header is added to an
3371 unsigned integer, which has been initialized to zero. The precision
3372 of the integer is seventeen bits. When calculating the checksum, the
3373 @code{chksum} field itself is treated as blank.
3375 The @code{atime} and @code{ctime} fields are used when making
3376 incremental backups; they store, respectively, the file's access time
3377 and last inode-change time.
3379 The value in the @code{offset} field is used when making a
3380 multi-volume archive. The offset is number of bytes into the file
3381 that we need to go to pick up where we left off in the previous
3382 volume, i.e the location that a continued file is continued from.
3384 The @code{longnames} field supports a feature that is not yet
3385 implemented. This field should be empty.
3387 The @code{magic} field indicates that this archive was output in the
3388 P1003 archive format. If this field contains @code{TMAGIC}, the
3389 @code{uname} and @code{gname} fields will contain the ASCII
3390 representation of the owner and group of the file respectively. If
3391 found, the user and group IDs are used rather than the values in the
3392 @code{uid} and @code{gid} fields.
3394 The @code{sp} field is used to archive sparse files efficiently.
3395 @xref{Sparse File Handling}, for a description of this field, and
3396 other fields it may imply.
3398 The @code{typeflag} field specifies the file's type. If a particular
3399 implementation does not recognize or permit the specified type,
3400 @code{tar} extracts the file as if it were a regular file, and reports
3401 the discrepancy on the standard error. @xref{File Types}. @xref{GNU
3405 * File Types:: File Types
3406 * GNU File Types:: Additional File Types Supported by GNU
3409 @node File Types, GNU File Types, Header Fields, Header Fields
3410 @appendixsubsec File Types
3412 The following flags are used to describe file types:
3417 Indicates a regular file. In order to be compatible with older
3418 versions of @code{tar}, a @code{typeflag} value of @code{LF_OLDNORMAL}
3419 should be silently recognized as a regular file. New archives should
3420 be created using @code{LF_NORMAL} for regular files. For backward
3421 compatibility, @code{tar} treats a regular file whose name ends with a
3422 slash as a directory.
3425 Indicates a link to another file, of any type, which has been
3426 previously archived. @code{tar} identifies linked files in Unix by
3427 matching device and inode numbers. The linked-to name is specified in
3428 the @code{linkname} field with a trailing null.
3431 Indicates a symbolic link to another file. The linked-to
3432 name is specified in the @code{linkname} field with a trailing null.
3433 @xref{File Writing Options}, for information on archiving files
3434 referenced by a symbolic link.
3438 Indicate character special files and block special files,
3439 respectively. In this case the @code{devmajor} and @code{devminor}
3440 fields will contain the major and minor device numbers. Operating
3441 systems may map the device specifications to their own local
3442 specification, or may ignore the entry.
3445 Indicates a directory or sub-directory. The directory name in the
3446 @code{name} field should end with a slash. On systems where disk
3447 allocation is performed on a directory basis, the @code{size} field
3448 will contain the maximum number of bytes (which may be rounded to the
3449 nearest disk block allocation unit) that the directory can hold. A
3450 @code{size} field of zero indicates no size limitations. Systems that
3451 do not support size limiting in this manner should ignore the
3455 Indicates a FIFO special file. Note that archiving a FIFO file
3456 archives the existence of the file and not its contents.
3459 Indicates a contiguous file. Contiguous files are the same as normal
3460 files except that, in operating systems that support it, all the
3461 files' disk space is allocated contiguously. Operating systems which
3462 do not allow contiguous allocation should silently treat this type as
3467 These are reserved for custom implementations. Some of these are used
3468 in the GNU modified format, which is described below. @xref{GNU File
3472 Certain other flag values are reserved for specification in future
3473 revisions of the P1003 standard, and should not be used by any
3476 @node GNU File Types, , File Types, Header Fields
3477 @appendixsubsec Additional File Types Supported by GNU
3479 GNU @code{tar} uses additional file types to describe new types of
3480 files in an archive. These are listed below.
3485 Indicates a directory and a list of files created by the
3486 @samp{--incremental} option. The @code{size} field gives the total
3487 size of the associated list of files. Each file name is preceded by
3488 either a @code{'Y'} (the file should be in this archive) or an
3489 @code{'N'} (the file is a directory, or is not stored in the archive).
3490 Each file name is terminated by a null. There is an additional null
3491 after the last file name.
3495 Indicates a file continued from another volume of a multi-volume
3496 archive (@pxref{Multi-Volume Archives}). The original type of the file is not
3497 given here. The @code{size} field gives the maximum size of this
3498 piece of the file (assuming the volume does not end before the file is
3499 written out). The @code{offset} field gives the offset from the
3500 beginning of the file where this part of the file begins. Thus
3501 @code{size} plus @code{offset} should equal the original size of the
3506 Indicates a sparse file. @xref{Sparse Files}. @xref{Sparse File
3511 Marks an archive label that was created using the @samp{--label} option
3512 when the archive was created (@pxref{Archive Label}. The @code{name}
3513 field contains the argument to the option. The @code{size} field is
3514 zero. Only the first file in each volume of an archive should have
3518 @node Sparse File Handling, , Header Fields, Data Format Details
3519 @appendixsec Fields to Handle Sparse Files
3521 The following header information was added to deal with sparse files
3522 (@pxref{Sparse Files}):
3525 The @code{sp} field (fields? something else?) is an array of
3526 @code{struct sparse}. Each @code{struct sparse} contains two
3527 12-character strings, which represent the offset into the file and the
3528 number of bytes to be written at that offset. The offset is absolute,
3529 and not relative to the offset in preceding array elements.
3531 The header can contain four of these @code{struct sparse}; if more are
3532 needed, they are not stored in the header, instead, the flag
3533 @code{isextended} is set and the next record is an
3534 @code{extended_header}.
3535 @c @code{extended_header} or @dfn{extended_header} ??? the next
3536 @c record after the header, or in the middle of it.
3538 The @code{isextended} flag is only set for sparse files, and then only
3539 if extended header records are needed when archiving the file.
3541 Each extended header record can contain an array of 21 sparse
3542 structures, as well as another @code{isextended} flag. There is no
3543 limit (except that implied by the archive media) on the number of
3544 extended header records that can be used to describe a sparse file.
3546 @c so is @code{extended_header} the right way to write this?
3548 @node Concept Index, , Data Format Details, Top
3549 @unnumbered Concept Index