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 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 file's 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 Despite the utility's name, which comes from the words @samp{T(ape)}
113 @samp{AR(chiver)}, @code{tar}'s output can be directed to any
114 available device. For instance, @code{tar} archives can be stored in
115 a file or sent to another program via a pipe.
117 @c <<< this menu will conflict with menu above in info mode. -ringo
119 * Invoking @code{tar}:: How to invoke @code{tar} and specify arguments.
120 * Tutorial:: An introduction to @code{tar}.
121 * Operations:: What you can use @code{tar} to do.
122 * Options:: How to change the way @code{tar} behaves.
123 * Problems:: Common problems with @code{tar}.
126 @node Invoking @code{tar}, Tutorial, Introduction, Top
127 @chapter How To Invoke @code{tar}
129 You can use @code{tar} to store files in an archive, to extract them
130 from an archive, and to do other types of archive manipulation. The
131 primary argument to @code{tar}, which is called the @dfn{operation},
132 specifies which action to take. The other arguments to @code{tar} are
133 either @dfn{options}, which change the way @code{tar} performs an
134 operation, or @dfn{file-names}, which specify the files @code{tar} is
135 to act on. The typical @code{tar} command line syntax is:
138 @code{tar} @var{operation} [@var{options}...] [@var{file-names}...]
141 Note: You can actually type in arguments in any order. In this manual
142 the operation is always first, the options second and the file-name
143 arguments last, to make examples easier to understand.
146 * Argument Functions:: The Functions of Arguments
147 * Argument Form:: The Forms of Arguments
148 * Old Syntax for Commands:: An Old, but Still Supported, Syntax
149 for @code{tar} Commands
152 @node Argument Functions, Argument Form, Invoking @code{tar}, Invoking @code{tar}
153 @section The Functions of Arguments
155 The primary argument to @code{tar} is the @dfn{operation}, which
156 specifies what @code{tar} does. @code{tar} can be used to:
160 Add files to an existing archive (@samp{+add-file}, @samp+{append} or
164 Compare files in an archive with files in the file system
165 (@samp{+compare}, @samp{+diff} or @samp{-d})
166 @c !!! is diff still working?? --- yes -ringo
169 Add archives to another archive (@samp{+add-archive}, @samp{+catenate}
171 @c was +concatenate. -ringo
174 Create an archive (@samp{+create} or @samp{-c})
177 Delete files from an archive (@samp{+delete})
178 @c -D should have been removed -ringo
181 Extract files from an archive (@samp{+extract}, @samp{+get} or @samp{-x})
184 List the files in an archive (@samp{+list} or @samp{-t})
187 Update an archive by appending newer versions of already stored files
188 (@samp{+update} or @samp{-u})
191 @xref{Reading and Writing}, for more information about these
194 @dfn{Option} arguments to @code{tar} change details of the operation,
195 such as archive format, archive name, or level of user interaction.
196 You can specify more than one option. All options are optional.
198 @dfn{File-name} arguments specify which files (including directory
199 files) to archive, extract, delete or otherwise operate on.
201 If you don't use any file-name arguments, @samp{+add-file},
202 @samp{+update} and @samp{+delete} will do nothing. The other
203 operations of @code{tar} will act on defaults.
205 When you use a file-name argument to specify a directory file,
206 @code{tar} acts on all the files in that directory, including
209 @node Argument Form, Old Syntax for Commands, Argument Functions, Invoking @code{tar}
210 @section The Forms of Arguments
212 Most operations of @code{tar} have a single letter form (a single
213 letter preceded by a @samp{-}), and at least one mnemonic form (a
214 word or abbreviation preceded by a @samp{+}). The forms are
215 identical in function. For example, you can use either @samp{tar -t}
216 or @samp{tar +list} to list the contents of an archive
218 Options, like operations, have both single letter and mnemonic forms.
219 Options, however, may also incorporate an argument. Single letter
220 options are separated from their arguments by a space. Mnemonic
221 options are separated from their arguments by an @samp{=} sign. For
222 example, to create an an archive file named @file{george}, use either
223 @samp{tar +create +file=george} or @samp{tar +create -f george}. Both
224 @samp{+file=@var{archive-name}} and @samp{-f @var{archive-name}}
225 denote the option to give the archive a non-default name, which in the
226 example is @samp{george}.
228 You can mix single letter and mnemonic forms in the same command. You
229 could type the above example as @samp{tar -c +file=george} or
230 @samp{tar +create -f george}. However, @code{tar} operations and
231 options are case sensitive. You would not type the above example as
232 @samp{tar -C +file=george}, because @samp{-C} is an option that causes
233 @code{tar} to change directories, not an operation that creates an
236 File-name arguments are the names of files (including directories).
237 These names can be specified on the command line or read from a text
238 file in the file system (using the @samp{+files-from} option). Files
239 stored in an archive are called @dfn{archive members}. The operations
240 @samp{+delete}, @samp{+extract}, @samp{+list}, @samp{+compare} and
241 @samp{+update} take the names of archive members as file-name
242 arguments. The other operations take the names of files in the file
245 @code{tar} interprets relative file names as being relative to the
246 working directory. @code{tar} will make all file names relative (by
247 removing leading @samp{/}s when archiving or restoring files), unless
248 you specify otherwise (using the @samp{+absolute-paths} option).
249 @xref{File Name Interpretation}, for more information about
250 @samp{+absolute-paths}.
251 @c >>> yet another node name that is probably wrong.
253 @node Old Syntax for Commands, , Argument Form, Invoking @code{tar}
254 @section An Old, but Still Supported, Syntax for @code{tar} Commands
256 For historical reasons, GNU @code{tar} also accepts a syntax for
257 commands which splits options that include arguments into two parts.
258 That syntax is of the form:
261 @code{tar} @var{operation}[@var{option-letters}...] [@var{option-arguments}...] [@var{file-names}...]@refill
265 where arguments to the options appear in the same order as the letters
266 to which they correspond, and the operation and all the option letters
267 appear as a single argument, without separating spaces.
269 This command syntax is useful because it lets you type the single
270 letter forms of the operation and options as a single argument to
271 @code{tar}, without writing preceding @samp{-}s or inserting spaces
272 between letters. @samp{tar cv} or @samp{tar -cv} are equivalent to
275 This old style syntax makes it difficult to match option letters with
276 their corresponding arguments, and is often confusing. In the command
277 @samp{tar cvbf 20 /dev/rmt0}, for example, @samp{20} is the argument
278 for @samp{-b}, @samp{/dev/rmt0} is the argument for @samp{-f}, and
279 @samp{-v} does not have a corresponding argument. The modern
280 syntax---@samp{tar -c -v -b 20 -f /dev/rmt0}---is clearer.
282 @node Tutorial, Wizardry, Invoking @code{tar}, Top
283 @chapter Getting Started With @code{tar}
285 This chapter guides you through some basic examples of @code{tar}
286 operations. In the examples, the lines you should type are preceded
287 by a @samp{%}, which is a typical shell prompt. We use mnemonic forms
288 of operations and options in the examples, and in discussions in the
289 text, but short forms produce the same result.
292 * Creating Archives:: Creating Archives
293 * Extracting Files:: Extracting Files from an Archive
294 * Listing Archive Contents:: Listing the Contents of an Archive
295 * Comparing Files:: Comparing Archives with the File System
296 * Adding to Archives:: Adding Files to Existing Archives
297 * Concatenate:: Concatenating Archives
298 * Deleting Files:: Deleting Files From an Archive
301 @node Creating Archives, Listing Archive Contents, Tutorial, Tutorial
302 @section Creating Archives
304 To create a new archive, use @code{tar +create} (or @code{tar -c}).
305 You can use options to specify the name and format of the archive (as
306 well as other characteristics), and you can use file-name arguments to
307 specify which files to put in the archive. If you don't use any
308 options or file-name arguments, @code{tar} will use default values.
309 @xref{Creating Example}, for more information about the @samp{+create}
313 * Creating Example:: Creating Archives of Files
314 * Subdirectory:: Creating an Archive of a Subdirectory
317 @node Creating Example, Subdirectory, Creating Archives, Creating Archives
318 @subsection Creating Archives of Files
320 This example shows you how to create an archive file in the working
321 directory containing other files in the working directory. The three
322 files you archive in this example are called @file{blues},
323 @file{folk}, and @file{jazz}. The archive file is called
324 @file{records}. While the archive in this example is written to the
325 file system, it could also be written to any other device.
327 (If you want to follow along with this and future examples, create a
328 directory called @file{practice} containing files called @file{blues},
329 @file{folk} and @file{jazz}. To create the directory, type
330 @samp{mkdir practice} at the system prompt. It will probably be
331 easiest to create the files using a text editor, such as Emacs.)
333 First, change into the directory containing the files you want to
341 @file{~/practice} is now your working directory.
343 Then, check that the files to be archived do in fact exist in the
344 working directory, and make sure there isn't already a file in the
345 working directory with the archive name you intend to use. If you
346 specify an archive file name that is already in use, @code{tar} will
347 overwrite the old file and its contents will be lost.
349 To list the names of files in the working directory, type:
366 Create a new archive (@samp{tar -c} or @samp{tar +create})
369 Explicitly name the archive file being created (@samp{-f
370 @var{archive-name}} or @samp{+file=@var{archive-name}}). If you don't
371 use this option @code{tar} will write the archive to the default
372 storage device, which varies from system to system.
373 @c <<< this syntax may change. OK now---check before printing -ringo
375 @code{tar} interprets archive file names relative to the working
376 directory. Make sure you have write access to the working directory
377 before using @code{tar}.
380 Specify which files to put into the archive (@code{tar} interprets
381 file names relative to the working directory). If you don't use any
382 @var{file-name} arguments, @code{tar} will archive everything in the
389 % tar +create +file=records blues folk jazz
393 If you now list the contents of the working directory (@samp{ls}), you
394 will find the archive file listed as well as the files you saw
399 blues folk jazz records
404 * Listing Files:: Listing files in an archive
405 * Verbose:: Using @code{tar} in Verbose Mode
408 @node Listing Files, Verbose, Creating Example, Creating Example
409 @subsubsection Listing files in an archive
411 You can list the contents of an archive with another operation of
412 @code{tar}---@samp{+list} or @samp{-l}. To list the contents of the
413 archive you just created, type:
416 % tar +list +file=records
420 @code{tar} will respond:
426 @xref{Listing Archive Contents}, for a more detailed tutorial of the
427 @samp{+list} operation. @xref{Listing Contents}, for more information
428 about the @samp{+list} operation.
430 @node Verbose, , Listing Files, Creating Example
431 @subsubsection Using @code{tar} in Verbose Mode
433 If you include the @samp{+verbose} or @samp{-v} option on the command
434 line, @code{tar} will list the files it is acting on as it is working.
435 In verbose mode, the creation example above would appear as:
436 @cindex Verbose mode example
437 @findex -v (verbose mode example)
440 % tar +create +file=records +verbose blues folk jazz
447 The first line is the command typed in by the user. The remaining
448 lines are generated by @code{tar}. In the following examples we
449 usually use verbose mode, though it is almost never required.
451 @node Subdirectory, Changing, Creating Example, Creating Archives
452 @subsection Creating an Archive of a Subdirectory
454 You can store a directory in an archive by using the directory name as
455 a file-name argument to @code{tar}. When you specify a directory
456 file, @code{tar} archives the directory file and all the files it
457 contains. The names of the directory and the files it contains are
458 stored in the archive relative to the current working directory---when
459 the directory is extracted they will be written into the file system
460 relative to the working directory at that time.
461 @c <<< add an xref to +absolute-paths -ringo
463 To archive a directory, first move to its superior directory. If you
464 have been following the tutorial, you should type:
471 Once in the superior directory, specify the subdirectory using a
472 file-name argument. To store the directory file @file{~/practice} in
473 the archive file @file{music}, type:
476 % tar +create +verbose +file=music practice
480 @code{tar} should respond:
490 Note that @file{~/practice/records}, another archive file, has
491 itself been archived. @code{tar} will accept any file as a file to be
492 archived, even an archive file.
494 @c >>> symbolic links and changing directories are now in main body, not in
495 @c >>> tutorial. -ringo
497 @node Extracting Files
498 @section Extracting Files from an Archive
500 Creating an archive is only half the job---there would be no point in
501 storing files in an archive if you couldn't retrieve them. To extract
502 files from an archive, use the @samp{+extract} or @samp{-x} operation.
504 To extract specific files, use their names as file-name arguments. If
505 you use a directory name as a file-name argument, @code{tar} extracts
506 all the files (including subdirectories) in that directory. If you
507 don't use any file-name arguments, @code{tar} extracts all the files
510 Note: @code{tar} will extract an archive member into the file system
511 without checking to see if there is already a file with the archive
512 member's file name. If there is a file with that name, @code{tar}
513 will @strong{overwrite} that file and its contents will be lost.
514 @c <<<xref keep-old -ringo
516 @node Extracting Specific Files, , ,
517 @subsection Extracting Specific Files
519 To extract specific files, specify them using file-name arguments.
521 In an example above, you created the archive file
522 @file{~/practice/records}, which contained the files @file{blues},
523 @file{folk} and @file{jazz} in the @file{practice} directory. If, for
524 some reason, you were to lose one of those text files (@samp{rm
525 ~/practice/blues}), you could extract it from the archive file.
527 First, change into the @file{practice} directory. Then,
531 Invoke @code{tar} and specify the @samp{+extract} operation
532 (@samp{+extract}, @samp{+get} or @samp{-x})
535 Specify the archive that the files will be extracted from
536 (@samp{+file=@var{archive-name}} or @samp{-f @var{archive-name}})
539 Specify the files to extract, using file-name arguments (if you don't
540 specify any files, @code{tar} extracts all the archive members)
544 % tar +extract +file=records blues
547 If you list the contents of the directory, you will see that
548 @file{blues} is back:
558 @node Extracting Directories, , ,
559 @subsection Extracting Directories
561 To extract a directory and all the files it contains, use the
562 directory's name as a file-name argument in conjunction with @samp{tar
563 +extract}. Remember---@code{tar} stores and extracts file names
564 relative to the working directory.
566 In a previous example you stored the directory @file{~/practice} in
567 the archive file @file{~/music}. If you delete the contents of
568 @file{practice}, you can restore them using @code{tar}.
570 First, change into the @file{practice} subdirectory (@samp{cd
571 ~/practice}). Then, remove all the files in @samp{~/practice}
572 (@samp{rm *}). If you list the contents of the directory, you should
573 now see that it is empty:
580 @noindent Let's try to restore the contents of @file{practice} by extracting
581 them from the archive file @file{~/music}:
584 tar +extract +file=~/music practice
587 @noindent Now, list the contents of @file{practice} again:
594 What happened to the files? When you created @file{~/music}, your
595 working directory was your home directory. When you extracted
596 @file{~/music}, your working directory was @file{~/practice}.
597 @code{tar} stored the files in @file{practice} relative to your home
598 directory, and then extracted them relative to @file{~/practice}. The
599 files are now in a new subdirectory, called
600 @file{~/practice/practice}.
602 To restore your files to their old positions, delete the new directory
603 and its contents, and then redo the example above with your home
604 directory as the working directory:
607 % rm ~/practice/practice/*
610 % tar +extract +file=music practice
613 @noindent (@code{tar} will report that it is unable to create the
614 directory @file{~/practice} because it already exists. This will not
615 effect the extraction of the other archive members.)
617 @node Listing Archive Contents, Adding to Archives, Creating Archives, Tutorial
618 @section Listing the Contents of an Archive
620 Use @samp{+list} or @samp{-t} to print the names of files stored in an
621 archive. If you use file-name arguments with this operation,
622 @code{tar} prints the names of the specified files if they are stored
623 in the archive. If you use a directory name as a file-name argument,
624 @code{tar} also prints the names of all underlying files, including
625 sub-directories. If you use no file-name arguments, @code{tar} prints
626 the names of all the archive members.
628 You can use @samp{+list} with the @samp{+verbose} option to print
629 archive members' attributes (owner, size, etc.).
632 * Listing names:: Listing the names of stored files
633 * Additional File Info:: Getting Additional File Information
634 * Specific File:: List A Specific File in an Archive
635 * Listing Directories:: Listing the Contents of a Stored Directory
638 @node Listing names, Additional File Info, Listing Archive Contents, Listing Archive Contents
639 @subsection Listing the names of stored files
641 To list the names of files stored in an archive, use the @samp{+list}
642 operation of @code{tar}.
644 In a previous example, you created the archive @file{~/music}. To
645 list the contents of @file{music}, while in your home directory:
649 List the contents of an archive (@samp{tar -t} or @samp{tar +list})
652 Specify the archive to be listed (@samp{-f @var{archive-name}} or
653 @samp{+file=@var{archive-name}}) @refill
659 % tar +list +file=music
667 @node Additional File Info, Specific File, Listing names, Listing Archive Contents
668 @subsection Listing Additional File Information
670 To get more information when you list the names of files stored in an
671 archive, specify the @samp{+verbose} option in conjunction with
672 @samp{tar +list}. @code{tar} will print archive member's file
673 protection, owner and group ID, size, and date and time of creation.
678 % tar +list +verbose +file=music
679 drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
680 -rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
681 -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
682 -rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
683 -rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
687 Note that when you use @samp{+verbose} with @samp{+list}, @code{tar}
688 doesn't print the names of files as they are being acted on, though
689 the @samp{+verbose} option will have this effect when used with all
692 @node Specific File, Comparing Files, Additional File Info, Listing Archive Contents
693 @subsection List A Specific File in an Archive
695 To to see if a particular file is in an archive, use the name of the
696 file in question as a file-name argument while specifying the
697 @samp{+list} operation. For example, to see whether the file
698 @file{folk} is in the archive file @file{music}, do the following:
702 Invoke @code{tar}, and specify the @samp{+list} operation
703 (@samp{+list} or @samp{-t}).
706 Specify the archive file to be acted on (@samp{+file
707 @var{archive-name}} or @samp{-f @var{archive-name}}).
710 Specify the files to look for, by typing their names as file-name
711 arguments. You have to type the file name as it appears in the
712 archive (normally, as it is relative to the relative to the directory
713 from which the archive was created). <<< xref absolute-paths -ringo
719 % tar +list +file=music practice/folk
730 If the file were not stored in the archive (for example, the file
731 @file{practice/rock}), the example above would look like:
734 % tar +list +file=music practice/rock
735 tar: practice/rock not found in archive
739 If you had used @samp{+verbose} mode, the example above would look
743 % tar +list +file=music practice/folk
744 -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
747 @node Listing Directories, , ,
748 @subsection Listing the Contents of a Stored Directory
750 To get information about the contents of an archived directory, use
751 the directory name as a file-name argument in conjunction with
752 @samp{+list}. To find out file attributes, include the
753 @samp{+verbose} option.
755 For example, to find out about files in the directory @file{practice},
756 in the archive file @file{music}, type:
759 % tar +list +file=music practice
762 @noindent @code{tar} responds:
765 drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
766 -rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
767 -rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
768 -rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
769 -rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
772 When you use a directory name as a file-name argument, @code{tar} acts
773 on all the files (including sub-directories) in that directory.
775 @node Comparing Files, , ,
776 @section Comparing Files in an Archive with Files in the File System
778 To compare the attributes of archive members with the attributes of
779 their counterparts in the file system, use the @samp{+compare},
780 @samp{+diff}, or @samp{-d}) operation. While you could use
781 @samp{+list +verbose} to manually compare some file attributes, it is
782 simpler to have @code{tar} itself compare file attributes and report
783 back on file differences.
784 @c <<<"manually"? suggestions? -ringo
786 The @samp{+compare} operation, as its name implies, compares archive
787 members with files of the same name in the file system, and reports
788 back differences in file size, mode, owner and modification date.
789 @samp{tar +compare} acts only on archive members---it ignores files in
790 the file system that are not stored in the archive. If you give
791 @samp{tar +compare} a file-name argument that does not correspond to
792 the name of an archive member, @code{tar} responds with an error
795 To compare archive members in the archive file @file{records} with
796 files in the @file{~/practice} directory, first change into the
797 @file{practice} directory. Then:
801 Invoke @code{tar} and specify the @samp{+compare} operation.
802 (@samp{+compare}, @samp{+diff}, or @samp{-d}).
805 Specify the archive where the files to be compared are stored
806 (@samp{+file=@var{archive-name}} or @samp{-f @var{archive-name}})
809 Specify the archive members to be compared. (In this example you are
810 comparing all the archive members in the archive. Since this is the
811 default, you don't need to use any file-name arguments).
815 % tar +compare +file=records
820 While it looks like nothing has happened, @code{tar} has, in fact,
821 done the comparison---and found nothing to report.
823 Use the @samp{+verbose} option to list the names of archive members as
824 they are being compared with their counterparts of the same name in
828 % tar +compare +verbose +file=records
836 If @code{tar} had had anything to report, it would have done so as it
837 was comparing each file.
839 If you remove the file @file{jazz} from the file system (@samp{rm
840 jazz}), and modify the file @file{blues} (for instance, by adding text
841 to it with an editor such as Emacs), the above example would look
845 % tar +compare +verbose +file=records
847 blues: mod time differs
855 Note again that while @samp{tar +compare} reports the names of archive
856 members that do not have counterparts in the file system, @samp{tar
857 +compare} ignores files in the file system that do not have
858 counterparts in the archive. To demonstrate this, create a file in
859 the @file{practice} directory called @file{rock} (using any text
860 editor). The new file appears when you list the directory's contents:
864 blues folk records rock
868 If you type the @samp{+compare} example again, @code{tar} prints the
872 % tar +compare +verbose +file=records
874 blues: mod time differs
883 @code{tar} ignores the file @file{rock} because @code{tar} is
884 comparing archive members to files in the file system, not vice versa.
886 If you specify @file{rock} explicitly (using a file-name argument),
887 @code{tar} prints an error message:
890 % tar +compare +verbose +file=records rock
891 tar: rock not found in archive
896 * Comparing Directories:: Using Compare on Directories
899 @node Comparing Directories, , ,
900 @subsubsection Using Compare on Directories
902 In addition to using @samp{+compare} to compare text files, you can
903 use @samp{+compare} to compare directories. To illustrate this,
904 re-create the examples above using your home directory as the working
905 directory, and using the archive file @file{~/music} instead of the
906 archive file @file{~/practice/records}.
908 First, change into your home directory (@samp{cd ~}). Then, try the
909 above example using @file{music} as the specified archive file, and
910 @file{practice} as a file-name argument.
913 % tar +compare +verbose +file=music practice
917 If you have been following along with the tutorial, @code{tar} will
923 practice/blues: mod time differs
924 practice/blues: size differs
927 practice/jazz: does not exist
931 @node Adding to Archives, Concatenate, Listing Archive Contents, Tutorial
932 @section Adding Files to Existing Archives
934 @c >>> we want people to use the script for backups, so I an not going to
935 @c >>> use backups as an explanation in the tutorial. (people can still
936 @c >>> do it if they really want to) -ringo
938 While you can use @code{tar} to create a new archive every time you
939 want to store a file, it is more sometimes efficient to add files to
942 To add new files to an existing archive, use the @samp{+add-file},
943 @samp{+append} or @samp{-r} operation. To add newer versions of
944 archive members to an archive, use the @samp{+update} or @samp{-u}
948 * Append:: Appending Files to an Archive
949 * Update:: Updating Files in an Archive
952 @node Append, Update, Adding to Archives, Adding to Archives
953 @subsection Appending Files to an Archive
955 The simplest method of adding a file to an existing archive is the
956 @samp{+add-file}, @samp{-r} or @samp{+append} operation, which writes
957 files into the archive without regard to whether or not they are
958 already archive members. When you use @samp{+add-file} you must use
959 file-name arguments; there is no default. If you specify a file that
960 is already stored in the archive, @code{tar} adds another copy of the
963 If you have been following the previous examples, you should have a
964 text file called @file{~/practice/rock} which has not been stored in
965 either the archive file @file{~/practice/records}, or the archive file
966 @file{~/music}. To add @file{rock} to @file{records}, first make
967 @file{practice} the working directory (@samp{cd practice}). Then:
971 Invoke @code{tar} and specify the @samp{+add-file} operation
972 (@samp{+add-file}, @samp{-r} or @samp{+append})
975 Specify the archive to which the file will be added
976 (@samp{+file=@var{archive-name}} or @samp{-f @var{archive-name}})
979 Specify the files to be added to the archive, using file-name
987 % tar +add-file +file=records rock
991 If you list the archive members in @file{records}, you will see that
992 @file{rock} has been added to the archive:
995 % tar +list +file=records
1002 @c <<< this should be some kind of node.
1004 You can use @samp{+add-file} to keep archive members current with
1005 active files. Because @samp{+add-file} stores a file whether or not
1006 there is already an archive member with the same file name, you can
1007 use @samp{+add-file} to add newer versions of archive members to an
1008 archive. When you extract the file, only the version stored last will
1009 wind up in the file system. Because @samp{tar +extract} extracts
1010 files from an archive in sequence, and overwrites files with the same
1011 name in the file system, if a file name appears more than once in an
1012 archive the last version of the file will overwrite the previous
1013 versions which have just been extracted.
1015 If you recall from the examples using @samp{+compare} above,
1016 @file{blues} was changed after the archive @file{records} was created.
1017 It is simple, however, to use @samp{+add-file} to add the new version
1018 of @file{blues} to @file{records}:
1021 % tar +add-file +verbose +file=records blues
1026 If you now list the contents of the archive, you will obtain the following:
1029 % tar +list -f records
1038 The newest version of @file{blues} is at the end of the archive. When
1039 the files in @file{records} are extracted, the newer version of
1040 @file{blues} (which has the same name as the older) will overwrite the
1041 version stored first. When @samp{tar +extract} is finished, only the
1042 newer version of @file{blues} is in the file system. <<<xref
1045 @node Update, , Append, Adding to Archives
1046 @subsection Updating Files in an Archive
1048 To keep archive members up to date with their counterparts of the same
1049 name in the file system, use the @samp{+update} or @samp{-u}
1050 operation. @samp{tar +update} adds a specified file to an archive if
1051 no file of that name is already stored in the archive. If there is
1052 already an archive member with the same name, @code{tar} checks the
1053 modification date of the archive member, and adds the file only if its
1054 modification date is later. If a file is stored in the archive but no
1055 longer exists under the same name in the active file system,
1056 @code{tar} reports an error.
1058 You could use the @samp{+add-file} option to keep an archive current,
1059 but do so you would either have to use the @samp{+compare} and
1060 @samp{+list} options to determine what files needed to be re-archived
1061 (which could waste a lot of time), or you would have to be willing to
1062 add identical copies of already archived files to the archive (which
1063 could waste a lot of space).
1065 You must use file-name arguments with the @samp{+update}
1066 operation---if you don't specify any files, @code{tar} won't act on
1069 To see the @samp{+update} option at work, create a new file,
1070 @file{~/practice/classical}, and modify the file
1071 @file{~/practice/blues} (you can use a text editor, such as Emacs, to
1072 do both these things). Then, with @file{practice} as your working
1073 directory, invoke @samp{tar +update} using the names of all the files
1074 in the practice directory as file-name arguments, and specifying the
1075 @samp{+verbose} option:
1078 % tar +update +verbose +file=records blues folk rock classical
1085 Because you specified verbose mode, @code{tar} printed out the names
1086 of the files it acted on. If you now list the archive members of the
1087 archive, (@samp{tar +list +file=records}), you will see that the file
1088 @file{classical} and another version of the file @file{blues} have
1089 been added to @file{records}.
1091 Note: When you update an archive, @code{tar} does not overwrite old
1092 archive members when it stores newer versions of a file. This is
1093 because archive members appear in an archive in the order in which
1094 they are stored, and some archive devices do not allow writing in the
1095 middle of an archive.
1097 @node Concatenate, Extracting Files Example, Adding to Archives, Tutorial
1098 @comment node-name, next, previous, up
1099 @section Concatenating Archives
1101 To concatenate archive files, use @samp{tar +concatenate} or @samp{tar
1102 -A}. This operation adds other archives to the end of an archive.
1103 While it may seem intuitive to concatenate archives using @code{cat},
1104 the utility for adding files together, archive files which have been
1105 "catted" together cannot be read properly by @code{tar}. Archive
1106 files incorporate an end of file marker---if archives are concatenated
1107 using @code{cat}, this marker will appear before the end of the new
1108 archive. This will interfere with operations on that archive.
1109 @c <<<xref ignore-zeros>>>
1111 In earlier examples, you stored the @file{~/practice} directory in an
1112 archive file, @file{~/music}. If you have been following the
1113 examples, you have since changed the contents of the @file{~/practice}
1114 directory. There is a current version of the files in the
1115 @file{practice} directory, however, stored in the archive file
1116 @file{~/practice/records}.
1118 To store current versions of the files in @file{practice} in the
1119 archive file @file{music}, you can use @samp{tar +concatenate} to add
1120 the archive file @file{~/practice/records} to @file{music}. First,
1121 make sure you are in your home directory (@samp{cd ~}). Then:
1125 Invoke @code{tar}, and specify the @samp{+concatenate} operation
1126 (@samp{-A} or @samp{+concatenate})
1129 Specify the archive file to be added to
1130 (@samp{+file=@var{archive-name}} or @samp{-f @var{archive-name}})
1133 Specify the archives to be added, using file-name arguments. In this
1134 case, the file-name arguments are, unusually, the names of archive
1135 files. (Remember to include the path in the archive name, if the
1136 archive file is not in your working directory.)
1141 % tar +concatenate +file=music practice/records
1144 If you now list the contents of the @file{music}, you see it now
1145 contains the archive members of @file{practice/records}:
1148 %tar +list +file=music
1162 @node Deleting Files, , , Tutorial
1163 @comment node-name, next, previous, up
1164 @section Deleting Files From an Archive
1166 In some instances, you may want to remove some files from an archive
1170 @emph{Caution:} you should never delete files from an archive stored
1171 on tape---because of the linear nature of tape storage, doing this is
1172 likely to scramble the archive.
1175 To remove archive members from an archive, use the @samp{+delete}
1176 operation. You must specify the names of files to be removed as
1177 file-name arguments. All versions of the named file are removed from
1180 Execution of the @samp{+delete} operation can be very slow.
1182 To delete all versions of the file @file{blues} from the archive
1183 @file{records} in the @file{practice} directory, make sure you are in
1184 that directory, and then:
1188 List the contents of the archive file @file{records} (see above for
1189 the steps involved) to insure that the file(s) you wish to delete are
1190 stored in the archive. (This step is optional)
1193 Invoke @code{tar} and specify the @samp{+delete} operation
1197 Specify the name of the archive file that the file(s) will be deleted
1198 from (@samp{+file=@var{archive-name}} or @samp{-f @var{archive-name}})
1201 Specify the files to be deleted, using file-name arguments.
1204 List the contents of the archive file again---note that the files have
1205 been removed. (this step is also optional)
1209 % tar +list +file=records
1213 % tar +delete +file=records blues
1214 % tar +list +file=records
1220 @node Wizardry, Archive Structure, Tutorial, Top
1223 <<<This section needs to be written -ringo
1225 @strong{To come:} using Unix file linking capability to recreate directory
1226 structures---linking files into one subdirectory and then tarring that
1229 @strong{to come:} nice hairy example using absolute-paths, newer, etc.
1232 Piping one @code{tar} to another is an easy way to copy a directory's
1233 contents from one disk to another, while preserving the dates, modes, owners
1234 and link-structure of all the files therein.
1237 cd sourcedirectory; tar cf - . | (cd targetdir; tar xf -)
1243 <<< the following using standard input/output correct??
1245 cd sourcedirectory; tar +create +file=- . | (cd targetdir; tar +extract +file=-)
1250 Archive files can be used for transporting a group of files from one system
1251 to another: put all relevant files into an archive on one computer system,
1252 transfer the archive to another, and extract the contents there. The basic
1253 transfer medium might be magnetic tape, Internet FTP, or even electronic
1254 mail (though you must encode the archive with @code{uuencode} in order to
1255 transport it properly by mail). Both machines do not have to use the same
1256 operating system, as long as they both support the @code{tar} program.
1258 <<< mention uuencode on a paragraph of its own
1260 <<<<<end construction>>>>>
1262 @node Archive Structure, Reading and Writing, Wizardry, Top
1263 @chapter The Structure of an Archive
1265 While an archive may contain many files, the archive itself is a
1266 single ordinary file. Like any other file, an archive file can be
1267 written to a storage device such as a tape or disk, sent through a
1268 pipe or over a network, saved on the active file system, or even
1269 stored in another archive. An archive file is not easy to read or
1270 manipulate without using the @code{tar} utility or Tar mode in Emacs.
1273 Physically, an archive consists of a series of file entries terminated
1274 by an end-of-archive entry, which consists of 512 zero bytes. A file
1275 entry usually describes one of the files in the archive (an
1276 @dfn{archive member}), and consists of a file header and the contents
1277 of the file. File headers contain file names and statistics, checksum
1278 information which @code{tar} uses to detect file corruption, and
1279 information about file types.
1281 More than archive member can have the same file name. One way this
1282 situation can occur is if more than one version of a file has been
1283 stored in the archive. For information about adding new versions of a
1284 file to an archive, @pxref{Modifying}.
1286 In addition to entries describing archive members, an archive may contain
1287 entries which @code{tar} itself uses to store information.
1288 @xref{Archive Label}, for an example of such an archive entry.
1291 * Old Style File Information:: Old Style File Information
1293 * Format Variations::
1296 @node Old Style File Information, Archive Label, Archive Structure, Archive Structure
1297 @section Old Style File Information
1298 @cindex Format, old style
1299 @cindex Old style format
1300 @cindex Old style archives
1302 Archives record not only an archive member's contents, but also its
1303 file name or names, its access permissions, user and group, size in
1304 bytes, and last modification time. Some archives also record the file
1305 names in each archived directory, as well as other file and directory
1308 Certain old versions of @code{tar} cannot handle additional
1309 information recorded by newer @code{tar} programs. To create an
1310 archive which can be read by these old versions, specify the
1311 @samp{+old-archive} option in conjunction with the @samp{tar +create}
1312 operation. When you specify this option, @code{tar} leaves out
1313 information about directories, pipes, fifos, contiguous files, and
1314 device files, and specifies file ownership by group and user ids
1317 The @samp{+old-archive} option is needed only if the archive must be
1318 readable by an older tape archive program which cannot handle the new format.
1319 Most @code{tar} programs do not have this limitation, so this option
1327 @c has portability been changed to portable?
1328 Creates an archive that can be read by an old @code{tar} program.
1329 Used in conjunction with the @samp{tar +create} operation.
1332 @node Archive Label, Format Variations, Old Style File Information, Archive Structure
1333 @section Including a Label in the Archive
1334 @cindex Labeling an archive
1335 @cindex Labels on the archive media
1337 @c !! Should the arg to +label be a quoted string?? no - ringo
1338 To avoid problems caused by misplaced paper labels on the archive
1339 media, you can include a @dfn{label} entry---an archive member which
1340 contains the name of the archive---in the archive itself. Use the
1341 @samp{+label=@var{archive-label}} option in conjunction with the
1342 @samp{+create} operation to include a label entry in the archive as it
1345 If you create an archive using both @samp{+label=@var{archive-label}}
1346 and @samp{+multi-volume}, each volume of the archive will have an
1347 archive label of the form @samp{@var{archive-label} Volume @var{n}},
1348 where @var{n} is 1 for the first volume, 2 for the next, and so on.
1349 @xref{Multi-Volume Archives}, for information on creating multiple
1352 If you extract an archive using @samp{+label=@var{archive-label}},
1353 @code{tar} will print an error if the archive label doesn't match the
1354 @var{archive-label} specified, and will then not extract the archive.
1355 You can include a regular expression in @var{archive-label}, in this
1357 @c >>> why is a reg. exp. useful here? (to limit extraction to a
1358 @c >>>specific group? ie for multi-volume??? -ringo
1360 To find out an archive's label entry (or to find out if an archive has
1361 a label at all), use @samp{tar +list +verbose}. @code{tar} will print the
1362 label first, and then print archive member information, as in the
1366 % tar +verbose +list +file=iamanarchive
1367 V--------- 0/0 0 Mar 7 12:01 1992 iamalabel--Volume Header--
1368 -rw-rw-rw- ringo/user 40 May 21 13:30 1990 iamafilename
1372 @item +label=@var{archive-label}
1373 @itemx -V @var{archive-label}
1374 Includes an @dfn{archive-label} at the beginning of the archive when
1375 the archive is being created (when used in conjunction with the
1376 @samp{tar +create} operation). Checks to make sure the archive label
1377 matches the one specified (when used in conjunction with the @samp{tar
1378 +extract} operation.
1382 @node Format Variations, , Archive Label, Archive Structure
1383 @section Format Variations
1384 @cindex Format Parameters
1385 @cindex Format Options
1386 @cindex Options to specify archive format.
1388 Format parameters specify how an archive is written on the archive
1389 media. The best choice of format parameters will vary depending on
1390 the type and number of files being archived, and on the media used to
1393 To specify format parameters when accessing or creating an archive,
1394 you can use the options described in the following sections. If you
1395 do not specify any format parameters, @code{tar} uses default
1396 parameters. You cannot modify a compressed archive. If you create an
1397 archive with the @samp{+block-size} option specified (@pxref{Blocking
1398 Factor}), you must specify that block-size when operating on the
1399 archive. @xref{Matching Format Parameters}, for other examples of
1400 format parameter considerations.
1404 * Multi-Volume Archives::
1407 * Compressed Archives::
1410 @node Multi-Volume Archives, Sparse Files, Format Variations, Format Variations
1411 @subsection Archives Longer than One Tape or Disk
1412 @cindex Multi-volume archives
1414 To create an archive that is larger than will fit on a single unit of
1415 the media, use the @samp{+multi-volume} option in conjunction with the
1416 @samp{tar +create} operation (@pxref{Creating Archives}). A
1417 @dfn{multi-volume} archive can be manipulated like any other archive
1418 (provided the @samp{+multi-volume} option is specified), but is stored
1419 on more than one tape or disk.
1421 When you specify @samp{+multi-volume}, @code{tar} does not report an
1422 error when it comes to the end of an archive volume (when reading), or
1423 the end of the media (when writing). Instead, it prompts you to load
1424 a new storage volume. If the archive is on a magnetic tape, you
1425 should change tapes when you see the prompt; if the archive is on a
1426 floppy disk, you should change disks; etc.
1428 You can read each individual volume of a multi-volume archive as if it
1429 were an archive by itself. For example, to list the contents of one
1430 volume, use @samp{tar +list}, without @samp{+multi-volume} specified.
1431 To extract an archive member from one volume (assuming it is described
1432 that volume), use @samp{tar +extract}, again without
1433 @samp{+multi-volume}.
1435 If an archive member is split across volumes (ie. its entry begins on
1436 one volume of the media and ends on another), you need to specify
1437 @samp{+multi-volume} to extract it successfully. In this case, you
1438 should load the volume where the archive member starts, and use
1439 @samp{tar +extract +multi-volume}---@code{tar} will prompt for later
1440 volumes as it needs them. @xref{Extracting From Archives} for more
1441 information about extracting archives.
1443 @samp{+info-script=@var{program-file}} is like @samp{+multi-volume},
1444 except that @code{tar} does not prompt you directly to change media
1445 volumes when a volume is full---instead, @code{tar} runs commands you
1446 have stored in @var{program-file}. This option can be used to
1447 broadcast messages such as @samp{someone please come change my tape}
1448 when performing unattended backups. When @var{program-file} is done,
1449 @code{tar} will assume that the media has been changed.
1452 <<< There should be a sample program here, including an exit before
1458 Creates a multi-volume archive, when used in conjunction with
1459 @samp{tar +create}. To perform any other operation on a multi-volume
1460 archive, specify @samp{+multi-volume} in conjunction with that
1463 @item +info-script=@var{program-file}
1464 @itemx -F @var{program-file}
1465 Creates a multi-volume archive via a script. Used in conjunction with
1469 @node Sparse Files, Blocking Factor, Multi-Volume Archives, Format Variations
1470 @subsection Archiving Sparse Files
1471 @cindex Sparse Files
1473 A file is sparse if it contains blocks of zeros whose existance is
1474 recorded, but that have no space allocated on disk. When you specify
1475 the @samp{+sparse} option in conjunction with the @samp{+create}
1476 operation, @code{tar} tests all files for sparseness while archiving.
1477 If @code{tar} finds a file to be sparse, it uses a sparse
1478 representation of the file in the archive. @xref{Creating Archives},
1479 for more information about creating archives.
1481 @samp{+sparse} is useful when archiving files, such as dbm files,
1482 likely to contain many nulls. This option dramatically
1483 decreases the amount of space needed to store such an archive.
1486 @strong{Please Note:} Always use @samp{+sparse} when performing file
1487 system backups, to avoid archiving the expanded forms of files stored
1488 sparsely in the system.@refill
1490 Even if your system has no no sparse files currently, some may be
1491 created in the future. If you use @samp{+sparse} while making file
1492 system backups as a matter of course, you can be assured the archive
1493 will always take no more space on the media than the files take on
1494 disk (otherwise, archiving a disk filled with sparse files might take
1495 hundreds of tapes).@refill
1496 <<< xref incremental when node name is set.
1499 @code{tar} ignores the @samp{+sparse} option when reading an archive.
1504 Files stored sparsely in the file system are represented sparsely in
1505 the archive. Use in conjunction with write operations.
1508 @node Blocking Factor, Compressed Archives, Sparse Files, Format Variations
1509 @subsection The Blocking Factor of an Archive
1510 @cindex Blocking Factor
1512 @cindex Number of records per block
1513 @cindex Number of bytes per block
1514 @cindex Bytes per block
1515 @cindex Records per block
1517 The data in an archive is grouped into records, which are 512 bytes.
1518 Records are read and written in whole number multiples called
1519 @dfn{blocks}. The number of records in a block (ie. the size of a
1520 block in units of 512 bytes) is called the @dfn{blocking factor}. The
1521 @samp{+block-size=@var{number}} option specifies the blocking factor
1522 of an archive. The default blocking factor is typically 20 (ie.@:
1523 10240 bytes), but can be specified at installation. To find out the
1524 blocking factor of an existing archive, use @samp {tar +list
1525 +file=@var{archive-name}}. This may not work on some devices.
1527 Blocks are seperated by gaps, which waste space on the archive media.
1528 If you are archiving on magnetic tape, using a larger blocking factor
1529 (and therefore larger blocks) provides faster throughput and allows
1530 you to fit more data on a tape (because there are fewer gaps). If you
1531 are archiving on cartridge, a very large blocking factor (say 126 or
1532 more) greatly increases performance. A
1533 smaller blocking factor, on the other hand, may be usefull when
1534 archiving small files, to avoid archiving lots of nulls as @code{tar}
1535 fills out the archive to the end of the block. In general, the ideal block size
1536 depends on the size of the inter-block gaps on the tape you are using,
1537 and the average size of the files you are archiving. @xref{Creating
1538 Archives}, for information on writing archives.
1540 Archives with blocking factors larger than 20 cannot be read by very
1541 old versions of @code{tar}, or by some newer versions of @code{tar}
1542 running on old machines with small address spaces. With GNU
1543 @code{tar}, the blocking factor of an archive is limited only by the
1544 maximum block size of the device containing the archive, or by the
1545 amount of available virtual memory.
1547 If you use a non-default blocking factor when you create an archive,
1548 you must specify the same blocking factor when you modify that
1549 archive. Some archive devices will also require you to specify the
1550 blocking factor when reading that archive, however this is not
1551 typically the case. Usually, you can use @samp{tar +list} without
1552 specifying a blocking factor---@code{tar} reports a non-default block
1553 size and then lists the archive members as it would normally. To
1554 extract files from an archive with a non-standard blocking factor
1555 (particularly if you're not sure what the blocking factor is), you can
1556 usually use the {+read-full-blocks} option while specifying a blocking
1557 factor larger then the blocking factor of the archive (ie. @samp{tar
1558 +extract +read-full-blocks +block-size=300}. @xref{Listing Contents}
1559 for more information on the @samp{+list} operation.
1560 @xref{read-full-blocks} for a more detailed explanation of that
1564 @item +block-size=@var{number}
1565 @itemx -b @var{number}
1566 Specifies the blocking factor of an archive. Can be used with any
1567 operation, but is usually not necessary with @samp{tar +list}.
1570 @node Compressed Archives, , Blocking Factor, Format Variations
1571 @subsection Creating and Reading Compressed Archives
1572 @cindex Compressed archives
1573 @cindex Storing archives in compressed format
1575 @samp{+compress} indicates an archive stored in compressed format.
1576 The @samp{+compress} option is useful in saving time over networks and
1577 space in pipes, and when storage space is at a premium.
1578 @samp{+compress} causes @code{tar} to compress when writing the
1579 archive, or to uncompress when reading the archive.
1581 To perform compression and uncompression on the archive, @code{tar}
1582 runs the @code{compress} utility. @code{tar} uses the default
1583 compression parameters; if you need to override them, avoid the
1584 @samp{+compress} option and run the @code{compress} utility
1585 explicitly. It is useful to be able to call the @code{compress}
1586 utility from within @code{tar} because the @code{compress} utility by
1587 itself cannot access remote tape drives.
1589 The @samp{+compress} option will not work in conjunction with the
1590 @samp{+multi-volume} option or the @samp{+add-file}, @samp{+update},
1591 @samp{+add-file} and @samp{+delete} operations. @xref{Modifying}, for
1592 more information on these operations.
1594 If there is no compress utility available, @code{tar} will report an
1597 @samp{+compress-block} is like @samp{+compress}, but when used in
1598 conjunction with @samp{+create} also causes @code{tar} to pad the last
1599 block of the archive out to the next block boundary as it is written.
1600 This is useful with certain devices which require all write operations
1601 be a multiple of a specific size.
1604 @strong{Please Note:} The @code{compress} program may be covered by a patent,
1605 and therefore we recommend you stop using it. We hope to have a
1606 different compress program in the future. We may change the name of
1607 this option at that time.
1615 When this option is specified, @code{tar} will compress (when writing
1616 an archive), or uncompress (when reading an archive). Used in
1617 conjunction with the @samp{+create}, @samp{+extract}, @samp{+list} and
1618 @samp{+compare} operations.
1620 @item +compress-block
1622 Acts like @samp{+compress}, but pads the archive out to the next block
1623 boundary as it is written when used in conjunction with the
1624 @samp{+create} operation.
1627 @c >>> MIB -- why not use -Z instead of -z -z ? -ringo
1629 @node Reading and Writing, Insuring Accuracy, Archive Structure, Top
1630 @chapter Reading and Writing Archives
1632 The @samp{+create} operation writes a new archive, and the
1633 @samp{+extract} operation reads files from an archive and writes them
1634 into the file system. You can use other @code{tar} operations to
1635 write new information into an existing archive (adding files to it,
1636 adding another archive to it, or deleting files from it), and you can
1637 read a list of the files in an archive without extracting it using the
1638 @samp{+list} operation.
1641 * Archive Name:: The name of an archive
1642 * Creating in Detail:: Creating in detail
1643 * Modifying:: Modifying archives
1644 * Listing Contents:: Listing the contents of an archive
1645 * Extracting From Archives:: Extracting files from an archive
1648 @node Archive Name, Creating in Detail, Reading and Writing, Reading and Writing
1649 @section The Name of an Archive
1650 @cindex Naming an archive
1651 @cindex Archive Name
1652 @cindex Directing output
1653 @cindex Where is the archive?
1655 An archive can be saved as a file in the file system, sent through a
1656 pipe or over a network, or written to an I/O device such as a tape or
1657 disk drive. To specify the name of the archive, use the
1658 @samp{+file=@var{archive-name}} option.
1660 An archive name can be the name of an ordinary file or the name of an
1661 I/O device. @code{tar} always needs an archive name---if you do not
1662 specify an archive name, the archive name comes from the environment
1663 variable @code{TAPE} or, if that variable is not specified, a default
1664 archive name, which is usually the name of tape unit zero (ie.
1667 If you use @file{-} as an @var{archive-name}, @code{tar} reads the
1668 archive from standard input (when listing or extracting files), or
1669 writes it to standard output (when creating an archive). If you use
1670 @file{-} as an @var{archive-name} when modifying an archive,
1671 @code{tar} reads the original archive from its standard input and
1672 writes the entire new archive to its standard output.
1674 @c >>> MIB--does standard input and output redirection work with all
1676 @c >>> need example for standard input and output (screen and keyboard?)
1678 @cindex Standard input and output
1679 @cindex tar to standard input and output
1681 To specify an archive file on a device attached to a remote machine,
1685 +file=@var{hostname}:/@var{dev}/@var{file name}
1689 @code{tar} will complete the remote connection, if possible, and
1690 prompt you for a username and password. If you use
1691 @samp{+file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @code{tar}
1692 will complete the remote connection, if possible, using your username
1693 as the username on the remote machine.
1695 @c >>>MIB --- is this clear?
1698 @item +file=@var{archive-name}
1699 @itemx -f @var{archive-name}
1700 Names the archive to create or operate on. Use in conjunction with
1704 @node Creating in Detail, Modifying, Archive Name, Reading and Writing
1705 @section Creating in Detail
1706 @c operations should probably have examples, not tables.
1707 @cindex Writing new archives
1708 @cindex Archive creation
1710 To create an archive, use @samp{tar +create}. To name the archive,
1711 use @samp{+file=@var{archive-name}} in conjunction with the
1712 @samp{+create} operation (@pxref{Archive Name}). If you do not name
1713 the archive, @code{tar} uses the value of the environment variable
1714 @code{TAPE} as the file name for the archive, or, if that is not
1715 available, @code{tar} uses a default archive name, usually that for tape
1716 unit zero. @xref{Archive Name}, for more information about specifying
1719 The following example creates an archive named @file{stooges},
1720 containing the files @file{larry}, @file{moe} and @file{curley}:
1723 tar +create +file=stooges larry moe curley
1726 If you specify a directory name as a file-name argument, @code{tar}
1727 will archive all the files in that directory. The following example
1728 creates an archive named @file{hail/hail/fredonia}, containing the
1729 contents of the directory @file{marx}:
1732 tar +create +file=hail/hail/fredonia marx
1735 If you don't specify files to put in the archive, @code{tar} archives
1736 all the files in the working directory. The following example creates
1737 an archive named @file{home} containing all the files in the working
1741 tar +create +file=home
1744 @xref{File Name Lists}, for other ways to specify files to archive.
1746 Note: In the example above, an archive containing all the files in the
1747 working directory is being written to the working directory. GNU
1748 @code{tar} stores files in the working directory in an archive which
1749 is itself in the working directory without falling into an infinite
1750 loop. Other versions of @code{tar} may fall into this trap.
1752 @node Modifying, Listing Contents, Creating in Detail, Reading and Writing
1753 @section Modifying Archives
1754 @cindex Modifying archives
1756 Once an archive is created, you can add new archive members to it, add
1757 the contents of another archive, add newer versions of members already
1758 stored, or delete archive members already stored.
1760 To find out what files are already stored in an archive, use @samp{tar
1761 +list +file=@var{archive-name}}. @xref{Listing Contents}.
1765 * Appending Archives::
1766 * Deleting Archive Files:: Deleting Files From an Archive
1767 * Matching Format Parameters::
1770 @node Adding Files, Appending Archives, Modifying, Modifying
1771 @subsection Adding Files to an Archive
1772 @cindex Adding files to an archive
1773 @cindex Updating an archive
1775 To add files to an archive, use @samp{tar +add-file}. The archive to
1776 be added to must already exist and be in proper archive format (which
1777 normally means it was created previously using @code{tar}). If the
1778 archive was created with a different block size than now specified,
1779 @code{tar} will report an error (@pxref{Blocking Factor}). If the
1780 archive is not a valid @code{tar} archive, the results will be
1781 unpredictable. You cannot add files to a compressed archive, however
1782 you can add files to the last volume of a multi-volume archive.
1783 @xref{Matching Format Parameters}.
1785 The following example adds the file @file{shemp} to the archive
1786 @file{stooges} created above:
1789 tar +add-file +file=stooges shemp
1792 You must specify the files to be added; there is no default.
1794 @samp{tar +update} acts like @samp{tar +add-file}, but does not add
1795 files to the archive if there is already a file entry with that name
1796 in the archive that has the same modification time.
1798 Both @samp{+update} and @samp{+add-file} work by adding to the end of
1799 the archive. When you extract a file from the archive, only the
1800 version stored last will wind up in the file system. Because
1801 @samp{tar +extract} extracts files from an archive in sequence, and
1802 overwrites files with the same name in the file system, if a file name
1803 appears more than once in an archive the last version of the file will
1804 overwrite the previous versions which have just been extracted. You
1805 should avoid storing older versions of a file later in the archive.
1807 Note: @samp{+update} is not suitable for performing backups, because
1808 it doesn't change directory content entries, and because it lengthens
1809 the archive every time it is used.
1810 @c <<< xref to scripted backup, listed incremental, for info on backups.
1812 @node Appending Archives, Deleting Archive Files, Adding Files, Modifying
1813 @subsection Appending One Archive's Contents to Another Archive
1814 @cindex Adding archives to an archive
1815 @cindex Concatenating Archives
1817 To append copies of an archive or archives to the end of another
1818 archive, use @samp{tar +add-archive}. The source and target archives
1819 must already exist and have been created using compatable format
1820 parameters (@pxref{Matching Format Parameters}).
1822 @code{tar} will stop reading an archive if it encounters an
1823 end-of-archive marker. The @code{cat} utility does not remove
1824 end-of-archive markers, and is therefore unsuitable for concatenating
1825 archives. @samp{tar +add-archive} removes the end-of-archive marker
1826 from the target archive before each new archive is appended.
1827 @c <<< xref ignore-zeros
1829 You must specify the source archives using
1830 @samp{+file=@var{archive-name}} (@pxref{Archive Name}). If you do not
1831 specify the target archive , @code{tar} uses the value of the
1832 environment variable @code{TAPE}, or, if this has not been set, the
1833 default archive name.
1835 The following example adds the contents of the archive
1836 @file{hail/hail/fredonia} to the archive @file{stooges} (both archives
1837 were created in examples above):
1840 tar +add-archive +file=stooges hail/hail/fredonia
1843 If you need to retrieve files from an archive that was added to using
1844 the @code{cat} utility, use the @samp{+ignore-zeros} option
1845 (@pxref{Archive Reading Options}).
1847 @node Deleting Archive Files, Matching Format Parameters, Appending Archives, Modifying
1848 @subsection Deleting Files From an Archive
1849 @cindex Deleting files from an archive
1850 @cindex Removing files from an archive
1852 To delete archive members from an archive, use @samp{tar +delete}.
1853 You must specify the file names of the members to be deleted. All
1854 archive members with the specified file names will be removed from the
1857 The following example removes the file @file{curley} from the archive
1861 tar +delete +file=stooges curley
1864 You can only use @samp{tar +delete} on an archive if the archive
1865 device allows you to write to any point on the media.
1868 @strong{Warning:} Don't try to delete an archive member from a
1869 magnetic tape, lest you scramble the archive. There is no safe way
1870 (except by completely re-writing the archive) to delete files from
1871 most kinds of magnetic tape.
1874 @c <<< MIB -- how about automatic detection of archive media? give error
1875 @c <<< unless the archive device is either an ordinary file or different
1876 @c <<< input and output (+file=-).
1878 @node Matching Format Parameters, , Deleting Archive Files, Modifying
1879 @subsection Matching the Format Parameters
1881 Some format parameters must be taken into consideration when modifying
1884 Compressed archives cannot be modified.
1886 You have to specify the block size of the archive when modifying an
1887 archive with a non-default block size.
1889 Multi-volume archives can be modified like any other archive. To add
1890 files to a multi-volume archive, you need to only mount the last
1891 volume of the archive media (and new volumes, if needed). For all
1892 other operations, you need to use the entire archive.
1894 If a multi-volume archive was labeled using @samp{+label}
1895 (@pxref{Archive Label}) when it was created, @code{tar} will not
1896 automatically label volumes which are added later. To label
1897 subsequent volumes, specify @samp{+label=@var{archive-label}} again in
1898 conjunction with the @samp{+add-file}, @samp{+update} or
1899 @samp{+add-archive} operation.
1900 @cindex Labelling multi-volume archives
1903 @c <<< xref somewhere, for more information about format parameters.
1905 @node Listing Contents, Extracting From Archives, Modifying, Reading and Writing
1906 @section Listing the Contents of an Archive
1907 @cindex Names of the files in an archive
1908 @cindex Archive contents, list of
1909 @cindex Archive members, list of
1911 @samp{tar +list} prints a list of the file names of the archive
1912 members on the standard output. If you specify @var{file-name}
1913 arguments on the command line (or using the @samp{+files-from} option,
1914 @pxref{File Name Lists}), only the files you specify will be listed,
1915 and only if they exist in the archive. Files not specified will be
1916 ignored, unless they are under a specific directory.
1918 If you include the @samp{+verbose} option, @code{tar} prints an
1919 @samp{ls -l} type listing for the archive. @pxref{Additional
1920 Information}, for a description of the @samp{+verbose} option.
1922 If the blocking factor of the archive differs from the default,
1923 @code{tar} reports this. @xref{Blocking Factor}.
1925 @xref{Archive Reading Options} for a list of options which can be used
1926 to modify @samp{+list}'s operation.
1928 This example prints a list of the archive members of the archive
1932 tar +list +file=stooges
1936 @code{tar} responds:
1947 This example generates a verbose list of the archive members of the
1948 archive file @file{dwarves}, which has a blocking factor of two:
1951 tar +list -v +file=blocks
1955 @code{tar} responds:
1958 tar: Blocksize = 2 records
1959 -rw------- ringo/user 42 May 1 13:29 1990 .bashful
1960 -rw-rw-rw- ringo/user 42 Oct 4 13:29 1990 doc
1961 -rw-rw-rw- ringo/user 42 Jul 20 18:01 1969 dopey
1962 -rw-rw---- ringo/user 42 Nov 26 13:42 1963 grumpy
1963 -rw-rw-rw- ringo/user 42 May 5 13:29 1990 happy
1964 -rw-rw-rw- ringo/user 42 May 1 12:00 1868 sleepy
1965 -rw-rw-rw- ringo/user 42 Jul 4 17:29 1776 sneezy
1968 @node Extracting From Archives, , Listing Contents, Reading and Writing
1969 @section Extracting Files from an Archive
1971 @cindex Retrieving files from an archive
1972 @cindex Resurrecting files from an archive
1974 To read archive members from the archive and write them into the file
1975 system, use @samp{tar +extract}. The archive itself is left
1978 If you do not specify the files to extract, @code{tar} extracts all
1979 the files in the archive. If you specify the name of a directory as a
1980 file-name argument, @code{tar} will extract all files which have been
1981 stored as part of that directory. If a file was stored with a
1982 directory name as part of its file name, and that directory does not
1983 exist under the working directory when the file is extracted,
1984 @code{tar} will create the directory. @xref{Selecting Archive
1985 Members}, for information on specifying files to extract.
1987 The following example shows the extraction of the archive
1988 @file{stooges} into an empty directory:
1991 tar +extract +file=stooges
1995 Generating a listing of the directory (@samp{ls}) produces:
2005 The subdirectory @file{marx} contains the files @file{julius},
2006 @file{alexander} and @file{karl}.
2008 If you wanted to just extract the files in the subdirectory
2009 @file{marx}, you could specify that directory as a file-name argument
2010 in conjunction with the @samp{+extract} operation:
2013 tar +extract +file=stooges marx
2017 @strong{Warning:} Extraction can overwrite files in the file system.
2018 To avoid losing files in the file system when extracting files from
2019 the archive with the same name, use the @samp{+keep-old-files} option
2020 (@pxref{File Writing Options}).
2023 If the archive was created using @samp{+block-size}, @samp{+compress}
2024 or @samp{+multi-volume}, you must specify those format options again
2025 when extracting files from the archive (@pxref{Format Variations}).
2028 * Archive Reading Options::
2029 * File Writing Options::
2030 * Scarce Disk Space:: Recovering From Scarce Disk Space
2033 @node Archive Reading Options, File Writing Options, Extracting From Archives, Extracting From Archives
2034 @subsection Options to Help Read Archives
2035 @cindex Options when reading archives
2036 @cindex Reading incomplete blocks
2037 @cindex Blocks, incomplete
2038 @cindex End of archive markers, ignoring
2039 @cindex Ignoring end of archive markers
2040 @cindex Large lists of file names on small machines
2041 @cindex Small memory
2042 @cindex Running out of space
2044 @c <<< each option wants its own node. summary after menu
2046 Normally, @code{tar} will request data in full block increments from
2047 an archive storage device. If the device cannot return a full block,
2048 @code{tar} will report an error. However, some devices do not always
2049 return full blocks, or do not require the last block of an archive to
2050 be padded out to the next block boundary. To keep reading until you
2051 obtain a full block, or to accept an incomplete block if it contains
2052 an end-of-archive marker, specify the @samp{+read-full-blocks} option
2053 in conjunction with the @samp{+extract} or @samp{+list} operations.
2054 @xref{Listing Contents}.
2056 The @samp{+read-full-blocks} option is turned on by default when
2057 @code{tar} reads an archive from standard input, or from a remote
2058 machine. This is because on BSD Unix systems, attempting to read a
2059 pipe returns however much happens to be in the pipe, even if it is
2060 less than was requested. If this option were not enabled, @code{tar}
2061 would fail as soon as it read an incomplete block from the pipe.
2063 If you're not sure of the blocking factor of an archive, you can read
2064 the archive by specifying @samp{+read-full-blocks} and
2065 @samp{+block-size=@var{n}}, where @var{n} is a blocking factor larger
2066 than the blocking factor of the archive. This lets you avoid having
2067 to determine the blocking factor of an archive. @xref{Blocking
2071 @item +read-full-blocks
2073 Use in conjunction with @samp{tar +extract} to read an archive which
2074 contains incomplete blocks, or one which has a blocking factor less
2075 than the one specified.
2078 Normally @code{tar} stops reading when it encounters a block of zeros
2079 between file entries (which usually indicates the end of the archive).
2080 @samp{+ignore-zeros} allows @code{tar} to completely read an archive
2081 which contains a block of zeros before the end (i.e.@: a damaged
2082 archive, or one which was created by @code{cat}-ing several archives
2085 The @samp{+ignore-zeros} option is turned off by default because many
2086 versions of @code{tar} write garbage after the end of archive entry,
2087 since that part of the media is never supposed to be read. GNU
2088 @code{tar} does not write after the end of an archive, but seeks to
2089 maintain compatablity among archiving utilities.
2094 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
2095 encountered while reading an archive. Use in conjunction with
2096 @samp{tar +extract} or @samp{tar +list}.
2099 If you are using a machine with a small amount of memory, and you need
2100 to process large list of file-names, you can reduce the amount of
2101 space @code{tar} needs to process the list. To do so, specify the
2102 @samp{+same-order} option and provide an ordered list of file names.
2103 This option tells @code{tar} that the @file{file-name} arguments
2104 (provided on the command line, or read from a file using the
2105 @samp{+files-from} option) are listed in the same order as the files
2108 You can create a file containing an ordered list of files in the
2109 archive by storing the output produced by @samp{tar +list
2110 +file=@var{archive-name}}. @xref{Listing Contents}, for information
2111 on the @samp{+list} operation.
2113 This option is probably never needed on modern computer systems.
2117 @itemx +preserve-order
2119 To process large lists of file-names on machines with small amounts of
2120 memory. Use in conjunction with @samp{tar +compare}, @samp{tar +list}
2121 or @samp{tar +extract}.
2124 @c we don't need/want +preserve to exist any more
2126 @node File Writing Options, Scarce Disk Space, Archive Reading Options, Extracting From Archives
2127 @subsection Changing How @code{tar} Writes Files
2128 @c <<< find a better title
2129 @cindex Overwriting old files, prevention
2130 @cindex Protecting old files
2131 @cindex Modification times of extracted files
2132 @cindex Permissions of extracted files
2133 @cindex Modes of extracted files
2134 @cindex Writing extracted files to standard output
2135 @cindex Standard output, writing extracted files to
2137 Normally, @code{tar} writes extracted files into the file system
2138 without regard to the files already on the system---files with the
2139 same name as archive members are overwritten. To prevent @code{tar}
2140 from extracting an archive member from an archive, if doing so will
2141 overwrite a file in the file system, use @samp{+keep-old-files} in
2142 conjunction with the @samp{+extract} operation. When this option is
2143 specified, @code{tar} reports an error stating the name of the files
2144 in conflict, instead of writing the file from the archive.
2147 @item +keep-old files
2149 Prevents @code{tar} from overwriting files in the file system during
2153 Normally, @code{tar} sets the modification times of extracted files to
2154 the modification times recorded for the files in the archive, but
2155 limits the permissions of extracted files by the current @code{umask}
2158 To set the modification times of extracted files to the time when
2159 the files were extracted, use the @samp{+modification-time} option in
2160 conjunction with @samp{tar +extract}.
2163 @item +modification-time
2165 Sets the modification time of extracted archive members to the time
2166 they were extracted, not the time recorded for them in the archive.
2167 Use in conjunction with @samp{+extract}.
2170 To set the modes (access permissions) of extracted files to those
2171 recorded for those files in the archive, use the
2172 @samp{+preserve-permissions} option in conjunction with the
2173 @samp{+extract} operation.
2174 @c <<<mib --- should be aliased to ignore-umask.
2177 @item +preserve-permission
2178 @itemx +same-permission
2179 @itemx +ignore-umask
2181 Set modes of extracted archive members to those recorded in the
2182 archive, instead of current umask settings. Use in conjunction with
2186 @c <<< following paragraph needs to be rewritten:
2187 @c <<< why doesnt' this cat files together, why is this useful. is it
2188 @c <<< really useful with more than one file?
2189 To write the files extracted to the standard output, instead of
2190 creating the files on the file system, use @samp{+to-stdout} in
2191 conjunction with @samp{tar +extract}. This option is useful if you
2192 are extracting files to send them through a pipe, and do not need to
2193 preserve them in the file system.
2198 Writes files to the standard output. Used in conjunction with
2202 @c <<< why would you want to do such a thing, how are files separated on
2203 @c <<< the standard output? is this useful with more that one file? are
2204 @c <<< pipes the real reason?
2206 @node Scarce Disk Space, , File Writing Options, Extracting From Archives
2207 @subsection Recovering From Scarce Disk Space
2208 @cindex Middle of the archive, starting in the
2209 @cindex Running out of space during extraction
2210 @cindex Disk space, running out of
2211 @cindex Space on the disk, recovering from lack of
2213 If a previous attempt to extract files failed due to lack of disk
2214 space, you can use @samp{+starting-file=@var{file-name}} to start
2215 extracting only after file @var{file-name} when extracting files from
2216 the archive. This assumes, of course, that there is now free space,
2217 or that you are now extracting into a different file system.
2220 @item +starting-file=@var{file-name}
2221 @itemx -K @var{file-name}
2222 Starts an operation in the middle of an archive. Use in conjunction
2223 with @samp{+extract} or @samp{+list}.
2226 If you notice you are running out of disk space during an extraction
2227 operation, you can also suspend @code{tar}, remove unnecessary files
2228 from the file system, and then restart the same @code{tar} operation.
2229 In this case, @samp{+starting-file} is not necessary.
2231 @c <<< xref incremental, xref +interactive, xref +exclude
2233 @node Insuring Accuracy, Selecting Archive Members, Reading and Writing, Top
2234 @chapter Insuring the Accuracy of an Archive
2236 You can insure the accuracy of an archive by comparing files in the
2237 system with archive members. @code{tar} can compare an archive to the
2238 file system as the archive is being written, to verify a write
2239 operation, or can compare a previously written archive, to insure that
2243 * Write Verification::
2247 @node Write Verification, Comparing, Insuring Accuracy, Insuring Accuracy
2248 @section Verifying Data as It is Stored
2249 @cindex Verifying a write operation
2250 @cindex Double-checking a write operation
2252 To check for discrepancies in an archive immediately after it is
2253 written, use the @samp{+verify} option in conjunction with the
2254 @samp{tar +create} operation. When this option is specified,
2255 @code{tar} checks archive members against their counterparts in the file
2256 system, and reports discrepancies on the standard error. In
2257 multi-volume archives, each volume is verified after it is written,
2258 before the next volume is written.
2260 To verify an archive, you must be able to read it from before the end
2261 of the last written entry. This option is useful for detecting data
2262 errors on some tapes. Archives written to pipes, some cartridge tape
2263 drives, and some other devices cannot be verified.
2268 Checks for discrepancies in the archive immediately after it is
2269 written. Use in conjunction with @samp{tar +create}.
2272 @node Comparing, , Write Verification, Insuring Accuracy
2273 @section Comparing an Archive with the File System
2274 @cindex Verifying the currency of an archive
2276 @samp{tar +compare} compares archive members in an existing archive
2277 with their counterparts in the file system, and reports differences in
2278 file size, mode, owner, modification date and contents. If a file is
2279 represented in the archive but does not exist in the file system,
2280 @code{tar} reports a difference.
2282 If you use @var{file-name} arguments in conjunction with @samp{tar
2283 +compare}, @code{tar} compares the archived versions of the files
2284 specified with their counterparts in the file system. If you specify
2285 a file that is not in the archive, @code{tar} will report an error. If
2286 you don't specify any files, @code{tar} compares all the files in the
2289 Because @code{tar} only checks files in the archive against files in
2290 the file system, and not vice versa, it ignores files in the file
2291 system that do not exist in the archive.
2293 The following example compares the archive members @file{larry},
2294 @file{moe} and @file{curly} in the archive @file{stooges} with files
2295 of the same name in the file system.
2298 tar +compare +file=stooges larry moe curly
2302 If a file, for example @file{curly}, did not exist in the archive,
2303 @code{tar} would report an error, as follows:
2306 curly: does not exist
2309 @node Selecting Archive Members, User Interaction, Insuring Accuracy, Top
2310 @chapter Selecting Archive Members
2311 @cindex Specifying files to act on
2312 @cindex Specifying archive members
2314 @dfn{File-name arguments} specify which files in the file system
2315 @code{tar} operates on, when creating or adding to an archive, or
2316 which archive members @code{tar} operates on, when reading or
2317 deleting from an archive. (@pxref{Reading and Writing}.)
2319 To specify file names, you can include them as the last arguments on
2320 the command line, as follows:
2322 tar @var{operation} [@var{option1} @var{option2} ..] [@var{file-name-1} @var{file-name-2} ...]
2325 If you specify a directory name as a file name argument, all the files
2326 in that directory are operated on by @code{tar}.
2328 If you do not specify files when @code{tar} is invoked, @code{tar}
2329 operates on all the non-directory files in the working directory (if
2330 the operation is @samp{+create}), all the archive members in the
2331 archive (if a read operation is specified), or does nothing (if any
2332 other operation is specified).
2335 * File Name Lists:: Reading File Names from a File
2336 * File Name Interpretation:: this needs a better title
2337 * File Exclusion:: so does this
2340 @node File Name Lists, File Name Interpretation, Selecting Archive Members, Selecting Archive Members
2341 @section Reading a List of File Names from a File
2342 @cindex Lists of file names
2343 @cindex File-name arguments, alternatives
2345 To read file names from a file on the file system, instead of from the
2346 command line, use the @samp{+files-from=@var{file}} option. If you
2347 specify @samp{-} as @var{file}, the file names are read from standard
2348 input. Note that using both @samp{+files-from=-} and @samp{+file=-}
2349 in the same command will not work unless the operation is
2350 @samp{+create}. @xref{Archive Name}, for an explanation of the
2351 @samp{+file} option.
2354 @item +files-from=@var{file}
2355 @itemx -T @var{file}
2356 Reads file-name arguments from a file on the file system, instead of
2357 from the command line. Use in conjunction with any operation.
2360 @node File Name Interpretation, File Exclusion, File Name Lists, Selecting Archive Members
2361 @section File Name Interpretation
2362 @cindex File Names, interpreting
2364 @c <<<<add some text -ringo
2367 * Absolute File Names::
2368 * Changing Working Directory::
2369 * Archiving with Symbolic Links:: Archiving Using Symbolic Links
2372 @node Absolute File Names, Changing Working Directory, File Name Interpretation, File Name Interpretation
2373 @subsection Storing and Extracting Files Relative to Root
2375 @c <<< is this what this does, or does it just preserve the slash?
2376 @c <<< is it still called +absolute-paths?
2378 @c To archive or extract files relative to the root directory, specify
2379 @c the @samp{+absolute-paths} option.
2381 @c Normally, @code{tar} acts on files relative to the working
2382 @c directory---ignoring superior directory names when archiving, and
2383 @c ignoring leading slashes when extracting.
2385 @c When you specify @samp{+absolute-paths}, @code{tar} stores file names
2386 @c including all superior directory names, and preserves leading slashes.
2387 @c If you only invoked @code{tar} from the root directory you would never
2388 @c need the @samp{+absolute-paths} option, but using this option may be
2389 @c more convenient than switching to root.
2391 @c >>> should be an example in the tutorial/wizardry section using this
2392 @c >>> to transfer files between systems.
2394 @c >>> is write access an issue?
2397 @item +absolute-paths
2398 Preserves full file names (inclusing superior dirctory names) when
2399 archiving files. Preserves leading slash when extracting files.
2402 @node Changing Working Directory, Archiving with Symbolic Links, Absolute File Names, File Name Interpretation
2403 @subsection Changing the Working Directory Within a List of File-names
2404 @cindex Directory, changing in mid-stream
2405 @cindex Working directory, specifying
2407 To change working directory in the middle of a list of file names,
2408 (either on the command line or in a file specified using
2409 @samp{+files-from}), use @samp{+directory=@var{directory}}. This will
2410 change the working directory to the directory @var{directory} after
2411 that point in the list. For example,
2414 tar +create iggy ziggy +directory=baz melvin
2418 will place the files @file{iggy} and @file{ziggy} from the current
2419 directory into the archive, followed by the file @file{melvin} from
2420 the directory @file{baz}. This option is especially useful when you
2421 have several widely separated files that you want to store in the same
2422 directory in the archive.
2424 Note that the file @file{melvin} is recorded in the archive under the
2425 precise name @file{melvin}, @emph{not} @file{baz/melvin}. Thus, the
2426 archive will contain three files that all appear to have come from the
2427 same directory; if the archive is extracted with plain @samp{tar
2428 +extract}, all three files will be written in the current directory.
2430 Contrast this with the command
2433 tar -c iggy ziggy bar/melvin
2437 which records the third file in the archive under the name
2438 @file{bar/melvin} so that, if the archive is extracted using @samp{tar
2439 +extract}, the third file will be written in a subdirectory named
2443 @item +directory=@file{directory}
2444 @itemx -C @file{directory}
2445 Changes the working directory.
2448 @c <<<need to test how extract deals with this, and add an example -ringo
2450 @node Archiving with Symbolic Links, , Changing Working Directory, File Name Interpretation
2451 @subsection Archiving Using Symbolic Links
2452 @cindex File names, using symbolic links
2453 @cindex Symbolic link as file name
2455 @samp{+dereference} is used with @samp{tar +create}, and causes
2456 @code{tar} to archive files which are referenced by a symbolic link,
2457 using the name of the link as the file name.
2459 <<<this needs to be checked by MIB and then re-written, with an example
2460 The name under which the file is stored in the file system is not
2461 recorded in the archive. To record both the symbolic link name and
2462 the file name in the system, archive the file under both names. If
2463 all links were recorded automatically by @code{tar}, an extracted file
2464 might be linked to a file name that no longer exists in the file
2467 @c <<< is the following still true? - ringo
2468 If a linked-to file is encountered again by @code{tar} while creating
2469 the same archive, an entire second copy of it will be stored. This
2470 could be considered a bug.
2475 Stores files referenced by a symbolic link, using the name of the link
2476 as the file name. Use in conjunction with any write operation.
2479 @node File Exclusion, , File Name Interpretation, Selecting Archive Members
2480 @section Selecting Files by Characteristic
2481 @cindex File names, excluding files by
2482 @cindex Excluding files by name and pattern
2483 @cindex Excluding files by file system
2484 @cindex File system boundaries, not crossing
2485 @cindex Excluding file by age
2486 @cindex Modification time, excluding files by
2487 @cindex Age, excluding files by
2489 To avoid crossing file system boundaries when archiving parts of a
2490 directory tree, use @samp{+one-file-system}. This option only affects
2491 files that are archived because they are in a directory that is being
2492 archived; files explicitly named on the command line are archived
2493 regardless of where they reside.
2495 This option is useful for making full or incremental archival backups
2498 If this option is used in conjunction with @samp{+verbose}, files that
2499 are excluded are mentioned by name on the standard error.
2502 @item +one-file-system
2504 Prevents @code{tar} from crossing file system boundaries when
2505 archiving. Use in conjunction with any write operation.
2508 To avoid operating on files whose names match a particular pattern,
2509 use the @samp{+exclude=@var{pattern}} or
2510 @samp{+exclude-from=@var{file}} options.
2512 When you specify the @samp{+exclude=@var{pattern}} option, @code{tar}
2513 ignores files which match the @var{pattern}, which can be a single
2514 file name or a more complex expression. Thus, if you invoke
2515 @code{tar} with @samp{tar +create +exclude=*.o}, no files whose names
2516 end in @file{.o} are included in the archive.
2517 @c <<< what other things can you use besides "*"?
2519 @samp{+exclude-from=@var{file}} acts like @samp{+exclude}, but
2520 specifies a file @var{file} containing a list of patterns. @code{tar}
2521 ignores files with names that fit any of these patterns.
2523 You can use either option more than once in a single command.
2526 @item +exclude=@var{pattern}
2527 Causes @code{tar} to ignore files that match the @var{pattern}.
2529 @item +exclude-from=@var{file}
2530 Causes @code{tar} to ignore files that match the patterns listed in
2533 @c +exclude-from used to be "+exclude", +exclude didn't used to exist.
2535 To operate only on files with modification or status-change times
2536 after a particular date, use @samp{+after-date=@var{date}}. You can
2537 use this option with @samp{tar +create} or @samp{tar +add-file} to
2538 insure only new files are archived, or with @samp{tar +extract} to
2539 insure only recent files are resurrected. @refill
2540 @c +after-date @var{date} or +newer @var{date}
2542 @samp{+newer-mtime=@var{date}} acts like @samp{+after-date=@var{date}},
2543 but tests just the modification times of the files, ignoring
2544 status-change times.
2546 @c <<<need example of +newer-mtime with quoted argument
2547 Remember that the entire date argument should be quoted if it contains
2551 @strong{Please Note:} @samp{+after-date} and @samp{+newer-mtime}
2552 should not be used for incremental backups. Some files (such as those
2553 in renamed directories) are not selected up properly by these options.
2554 @c xref to incremental backup chapter when node name is decided.
2557 @item +after-date=@var{date}
2558 @itemx +newer=@var{date}
2559 @itemx -N @var{date}
2560 Acts on files only if their modification or inode-changed times are
2561 later than @var{date}. Use in conjunction with any operation.
2562 @item +newer-mtime=@var{date}
2563 Acts like @samp{+after-date}, but only looks at modification times.
2566 @c <<< following is the getdate date format --- needs to be re-written,
2567 @c <<< made a sub-node:
2569 Time/Date Formats Accepted by getdate
2570 (omitting obscure constructions)
2572 The input consists of one or more of: time zone day date year
2575 Those in turn consist of (`|' and `/' mean `or', `[]' means `optional'):
2577 time: H am/pm | H:M [am/pm] | H:M:S [am/pm]
2578 zone: timezone-name | timezone-name dst
2579 day: day-name | day-name, | N day-name
2580 date: M/D | M/D/Y | month-name D | month-name D, Y | D month-name | D month-name Y
2583 am can also be a.m., pm can also be p.m.
2584 case and spaces around punctuation are not significant.
2585 month and day names can be abbreviated. >>>
2587 @node User Interaction, Backups and Restoration, Selecting Archive Members, Top
2588 @chapter User Interaction
2589 @cindex Getting more information during the operation
2590 @cindex Information during operation
2591 @cindex Feedback from @code{tar}
2593 Once you have typed a @code{tar}command, it is usually performed
2594 without any further information required of the user, or provided by
2595 @code{tar}. The following options allow you to generate progress and
2596 status information during an operation, or to confirm operations on
2597 files as they are performed.
2600 * Additional Information::
2601 * Interactive Operation::
2604 @node Additional Information, Interactive Operation, User Interaction, User Interaction
2605 @section Progress and Status Information
2606 @cindex Progress information
2607 @cindex Status information
2608 @cindex Information on progress and status of operations
2609 @cindex Verbose operation
2610 @cindex Record number where error occured
2611 @cindex Error message, record number of
2612 @cindex Version of the @code{tar} program
2614 Typically, @code{tar} performs most operations without reporting any
2615 information to the user except error messages. If you have
2616 encountered a problem when operating on an archive, however, you may
2617 need more information than just an error message in order to solve the
2618 problem. The following options can be helpful diagnostic tools.
2620 When used with most operations, @samp{+verbose} causes @code{tar} to
2621 print the file names of the files or archive members it is operating
2622 on. When used with @samp{tar +list}, the verbose option causes
2623 @code{tar} to print out an @samp{ls -l} type listing of the files in
2626 Verbose output appears on the standard output except when an archive
2627 is being written to the standard output (as with @samp{tar +create
2628 +file=- +verbose}). In that case @code{tar} writes verbose output to
2629 the standard error stream.
2634 Prints the names of files or archive members as they are being
2635 operated on. Can be used in conjunction with any operation. When
2636 used with @samp{+list}, generates an @samp{ls -l} type listing.
2639 To find out where in an archive a message was triggered, use
2640 @samp{+record-number}. @samp{+record-number} causes @code{tar} to
2641 print, along with every message it produces, the record number within
2642 the archive where the message was triggered.
2644 This option is especially useful when reading damaged archives, since
2645 it helps pinpoint the damaged sections. It can also be used with
2646 @samp{tar +list} when listing a file-system backup tape, allowing you
2647 to choose among several backup tapes when retrieving a file later, in
2648 favor of the tape where the file appears earliest (closest to the
2650 @c <<< xref when the node name is set and the backup section written
2653 @item +record-number
2655 Prints the record number whenever a message is generated by
2656 @code{tar}. Use in conjunction with any operation.
2660 To print the version number of the @code{tar} program, use @samp{tar
2661 +version}. @code{tar} prints the version number to the standard
2672 GNU tar version 1.09
2674 @c used to be an option. has been fixed.
2676 @node Interactive Operation, , Additional Information, User Interaction
2677 @section Asking for Confirmation During Operations
2678 @cindex Interactive operation
2680 Typically, @code{tar} carries out a command without stopping for
2681 further instructions. In some situations however, you
2682 may want to exclude some files and archive members from the operation
2683 (for instance if disk or storage space is tight). You can do this by
2684 excluding certain files automatically (@pxref{File Exclusion}), or by
2685 performing an operation interactively, using the @samp{+interactive}
2688 When the @samp{+interactive} option is specified, @code{tar} asks for
2689 confirmation before reading, writing, or deleting each file it
2690 encounters while carrying out an operation. To confirm the action you
2691 must type a line of input beginning with @samp{y}. If your input line
2692 begins with anything other than @samp{y}, @code{tar} skips that file.
2694 Commands which might be useful to perform interactively include
2695 appending files to an archive, extracting files from an archive,
2696 deleting a file from an archive, and deleting a file from disk during
2697 an incremental restore.
2699 If @code{tar} is reading the archive from the standard input,
2700 @code{tar} opens the file @file{/dev/tty} to support the interactive
2702 <<< this aborts if you won't OK the working directory. this is a bug. -ringo
2706 @itemx +confirmation
2708 Asks for confirmation before reading, writing or deleting an archive
2709 member (when listing, comparing or writing an archive or deleting
2710 archive members), or before writing or deleting a file (when
2711 extracting an archive).
2714 @node Backups and Restoration, Media, User Interaction, Top
2715 @chapter Performing Backups and Restoring Files
2717 To @dfn{back up} a file system means to create archives that contain
2718 all the files in that file system. Those archives can then be used to
2719 restore any or all of those files (for instance if a disk crashes or a
2720 file is accidently deleted). File system @dfn{backups} are also
2724 * Backup Levels:: Levels of backups
2725 * Backup Scripts:: Using scripts to perform backups
2727 * incremental and listed-incremental:: The +incremental
2728 and +listed-incremental Options
2729 * Problems:: Some common problems and their solutions
2732 @node Backup Levels, Backup Scripts, Backups and Restoration, Backups and Restoration
2733 @section Levels of Backups
2735 An archive containing all the files in the file system is called a
2736 @dfn{full backup} or @dfn{full dump}. You could insure your data by
2737 creating a full dump every day. This strategy, however, would waste a
2738 substantial amount of archive media and user time, as unchanged files
2739 are daily re-archived.
2741 It is more efficient to do a full dump only occasionally. To back up
2742 files between full dumps, you can a incremental dump. A @dfn{level
2743 one} dump archives all the files that have changed since the last full
2746 A typical dump strategy would be to perform a full dump once a week,
2747 and a level one dump once a day. This means some versions of files
2748 will in fact be archived more than once, but this dump strategy makes
2749 it possible to restore a file system to within one day of accuracy by
2750 only extracting two archives---the last weekly (full) dump and the
2751 last daily (level one) dump. The only information lost would be in
2752 files changed or created since the last daily backup. (Doing dumps
2753 more than once a day is usually not worth the trouble).
2755 @node Backup Scripts, incremental and listed-incremental, Backup Levels, Backups and Restoration
2756 @section Using Scripts to Perform Backups and Restoration
2758 GNU @code{tar} comes with scripts you can use to do full and level-one
2759 dumps. Using scripts (shell programs) to perform backups and
2760 restoration is a convenient and reliable alternative to typing out
2761 file name lists and @code{tar} commands by hand.
2763 Before you use these scripts, you need to edit the file
2764 @file{backup-specs}, which specifies parameters used by the backup
2765 scripts and by the restore script. @xref{Script Syntax}.
2766 Once the backup parameters are set, you can perform backups or
2767 restoration by running the appropriate script.
2769 The name of the restore script is @code{restore}. The names of the
2770 level one and full backup scripts are, respectively, @code{level-1} and
2771 @code{level-0}. The @code{level-0} script also exists under the name
2772 @code{weekly}, and the @code{level-1} under the name
2773 @code{daily}---these additional names can be changed according to your
2774 backup schedule. @xref{Scripted Restoration}, for more information
2775 on running the restoration script. @xref{Scripted Backups}, for more
2776 information on running the backup scripts.
2778 @emph{Please Note:} The backup scripts and the restoration scripts are
2779 designed to be used together. While it is possible to restore files
2780 by hand from an archive which was created using a backup script, and
2781 to create an archive by hand which could then be extracted using the
2782 restore script, it is easier to use the scripts. @xref{incremental
2783 and listed-incremental}, before making such an attempt.
2785 @c shorten node names
2787 * Backup Parameters:: Setting parameters for backups and restoration
2788 * Scripted Backups:: Using the backup scripts
2789 * Scripted Restoration:: Using the restore script
2792 @node Backup Parameters, Scripted Backups, Backup Scripts, Backup Scripts
2793 @subsection Setting Parameters for Backups and Restoration
2795 The file @file{backup-specs} specifies backup parameters for the
2796 backup and restoration scripts provided with @code{tar}. You must
2797 edit @file{backup-specs} to fit your system configuration and schedule
2798 before using these scripts.
2800 @c <<< This about backup scripts needs to be written:
2801 @c <<<BS is a shell script .... thus ... @file{backup-specs} is in shell
2802 @c script syntax. @xref{Script Syntax}, for an explanation of this
2805 @c whats a parameter .... looked at by the backup scripts ... which will
2806 @c be expecting to find ... now syntax ... value is linked to lame ...
2807 @c @file{backup-specs} specifies the following parameters:
2812 The user name of the backup administrator.
2815 The hour at which the backups are done. This can be a number from 0
2816 to 23, or the string @samp{now}.
2819 The device @code{tar} writes the archive to. This device should be
2820 attached to the host on which the dump scripts are run.
2821 @c <<< examples for all ...
2824 The command to use to obtain the status of the archive device,
2825 including error count. On some tape drives there may not be such a
2826 command; in that case, simply use `TAPE_STATUS=false'.
2829 The blocking factor @code{tar} will use when writing the dump archive.
2830 @xref{Blocking Factor}.
2833 A list of file systems to be dumped. You can include any directory
2834 name in the list---subdirectories on that file system will be
2835 included, regardless of how they may look to other networked machines.
2836 Subdirectories on other file systems will be ignored.
2838 The host name specifies which host to run @code{tar} on, and should
2839 normally be the host that actually contains the file system. However,
2840 the host machine must have GNU @code{tar} installed, and must be able
2841 to access the directory containing the backup scripts and their
2842 support files using the same file name that is used on the machine
2843 where the scripts are run (ie. what @code{pwd} will print when in that
2844 directory on that machine). If the host that contains the file system
2845 does not have this capability, you can specify another host as long as
2846 it can access the file system through NFS.
2849 A list of individual files to be dumped. These should be accessible
2850 from the machine on which the backup script is run.
2851 @c <<<same file name, be specific. through nfs ...
2855 * backup-specs example:: An Example Text of @file{Backup-specs}
2856 * Script Syntax:: Syntax for @file{Backup-specs}
2859 @node backup-specs example, Script Syntax, Backup Parameters, Backup Parameters
2860 @subsubsection An Example Text of @file{Backup-specs}
2862 The following is the text of @file{backup-specs} as it appears at FSF:
2865 # site-specific parameters for file system backup.
2867 ADMINISTRATOR=friedman
2869 TAPE_FILE=/dev/nrsmt0
2870 TAPE_STATUS="mts -t $TAPE_FILE"
2885 apple-gunkies:/com/mailer/gnu
2886 apple-gunkies:/com/archive/gnu"
2888 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
2892 @node Script Syntax, , backup-specs example, Backup Parameters
2893 @subsubsection Syntax for @file{Backup-specs}
2895 @file{backup-specs} is in shell script syntax. The following
2896 conventions should be considered when editing the script:
2897 @c <<< "conventions?"
2899 A quoted string is considered to be contiguous, even if it is on more
2900 than one line. Therefore, you cannot include commented-out lines
2901 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
2902 the two most likely parameters to be multi-line.
2904 A quoted string typically cannot contain wildcards. In
2905 @file{backup-specs}, however, the parameters BACKUP_DIRS and
2906 BACKUP_FILES can contain wildcards.
2908 @node Scripted Backups, Scripted Restoration, Backup Parameters, Backup Scripts
2909 @subsection Using the Backup Scripts
2911 The syntax for running a backup script is:
2914 @file{script-name} [@var{time-to-be-run}]
2917 where @var{time-to-be-run} can be a specific system time, or can be
2918 @kbd{now}. If you do not specify a time, the script runs at the time
2919 specified in @file{backup-specs} (@pxref{Script Syntax}).
2921 You should start a script with a tape or disk mounted. Once you start
2922 a script, it prompts you for new tapes or disks as it needs them.
2923 Media volumes don't have to correspond to archive files---a
2924 multi-volume archive can be started in the middle of a tape that
2925 already contains the end of another multi-volume archive. The
2926 @code{restore} script prompts for media by its archive volume, so to
2927 avoid an error message you should keep track of which tape (or disk)
2928 contains which volume of the archive. @xref{Scripted Restoration}.
2930 @c <<<have file names changed? -ringo
2931 The backup scripts write two files on the file system. The first is a
2932 record file in @file{/etc/tar-backup/}, which is used by the scripts
2933 to store and retrieve information about which files were dumped. This
2934 file is not meant to be read by humans, and should not be deleted by
2935 them. @xref{incremental and listed-incremental}, for a more
2936 detailed explanation of this file.
2938 The second file is a log file containing the names of the file systems
2939 and files dumped, what time the backup was made, and any error
2940 messages that were generated, as well as how much space was left in
2941 the media volume after the last volume of the archive was written.
2942 You should check this log file after every backup. The file name is
2943 @file{log-@var{mmm-ddd-yyyy}-level-1} or
2944 @file{log-@var{mmm-ddd-yyyy}-full}.
2946 The script also prints the name of each system being dumped to the
2948 @c <<<the section on restore scripts is commented out.
2949 @c <<< a section on non-scripted testore mya be a good idea
2951 @node Scripted Restoration, , Scripted Backups, Backup Scripts
2952 @subsection Using the Restore Script
2953 @c subject to change as things develop
2955 To restore files that were archived using a scripted backup, use the
2956 @code{restore} script. The syntax for the script is:
2959 where ##### are the file systems to restore from, and
2960 ##### is a regular expression which specifies which files to
2961 restore. If you specify +all, the script restores all the files
2964 You should start the restore script with the media containing the
2965 first volume of the archive mounted. The script will prompt for other
2966 volumes as they are needed. If the archive is on tape, you don't need
2967 to rewind the tape to to its beginning---if the tape head is
2968 positioned past the beginning of the archive, the script will rewind
2969 the tape as needed. @xref{Media}, for a discussion of tape
2972 If you specify @samp{+all} as the @var{files} argument, the
2973 @code{restore} script extracts all the files in the archived file
2974 system into the active file system.
2977 @strong{Warning:}The script will delete files from the active file
2978 system if they were not in the file system when the archive was made.
2981 @xref{incremental and listed-incremental}, for an explanation of how
2982 the script makes that determination.
2983 @c this may be an option, not a given
2986 @node incremental and listed-incremental, Problems, Backup Scripts, Backups and Restoration
2987 @section The @code{+incremental} and @code{+listed-incremental} Options
2989 @samp{+incremental} is used in conjunction with @samp{+create},
2990 @samp{+extract} or @samp{+list} when backing up and restoring file
2991 systems. An archive cannot be extracted or listed with the
2992 @samp{+incremental} option specified unless it was created with the
2993 option specified. This option should only be used by a script, not by
2994 the user, and is usually disregarded in favor of
2995 @samp{+listed-incremental}, which is described below.
2997 @samp{+incremental} in conjunction with @samp{+create} causes
2998 @code{tar} to write, at the beginning of the archive, an entry for
2999 each of the directories that will be archived. The entry for a
3000 directory includes a list of all the files in the directory at the
3001 time the archive was created and a flag for each file indicating
3002 whether or not the file is going to be put in the archive.
3004 Note that this option causes @code{tar} to create a non-standard
3005 archive that may not be readable by non-GNU versions of the @code{tar}
3008 @samp{+incremental} in conjunction with @samp{+extract} causes
3009 @code{tar} to read the lists of directory contents previously stored
3010 in the archive, @emph{delete} files in the file system that did not
3011 exist in their directories when the archive was created, and then
3012 extract the files in the archive.
3014 This behavior is convenient when restoring a damaged file system from
3015 a succession of incremental backups: it restores the entire state of
3016 the file system to that which obtained when the backup was made. If
3017 @samp{+incremental} isn't specified, the file system will probably
3018 fill up with files that shouldn't exist any more.
3020 @samp{+incremental} in conjunction with @samp{+list}, causes
3021 @code{tar} to print, for each directory in the archive, the list of
3022 files in that directory at the time the archive was created. This
3023 information is put out in a format that is not easy for humans to
3024 read, but which is unambiguous for a program: each file name is
3025 preceded by either a @samp{Y} if the file is present in the archive,
3026 an @samp{N} if the file is not included in the archive, or a @samp{D}
3027 if the file is a directory (and is included in the archive). Each
3028 file name is terminated by a null character. The last file is followed
3029 by an additional null and a newline to indicate the end of the data.
3031 @samp{+listed-incremental}=@var{file} acts like @samp{+incremental},
3032 but when used in conjunction with @samp{+create} will also cause
3033 @code{tar} to use the file @var{file}, which contains information
3034 about the state of the file system at the time of the last backup, to
3035 decide which files to include in the archive being created. That file
3036 will then be updated by @code{tar}. If the file @var{file} does not
3037 exist when this option is specified, @code{tar} will create it, and
3038 include all appropriate files in the archive.
3040 The file @var{file}, which is archive independent, contains the date
3041 it was last modified and a list of devices, inode numbers and
3042 directory names. @code{tar} will archive files with newer mod dates
3043 or inode change times, and directories with an unchanged inode number
3044 and device but a changed directory name. The file is updated after
3045 the files to be archived are determined, but before the new archive is
3048 @c <<< this section needs to be written
3049 @node Problems, , incremental and listed-incremental, Backups and Restoration
3050 @section Some Common Problems and their Solutions
3054 no such file or directory
3058 directory checksum error
3061 errors from media/system:
3065 @node Media, Quick Reference, Backups and Restoration, Top
3066 @chapter Tapes and Other Archive Media
3068 Archives are usually written on dismountable media---tape cartridges,
3069 mag tapes, or floppy disks.
3071 The amount of data a tape or disk holds depends not only on its size,
3072 but also on how it is formatted. A 2400 foot long reel of mag tape
3073 holds 40 megabytes of data when formated at 1600 bits per inch. The
3074 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
3076 Magnetic media are re-usable---once the archive on a tape is no longer
3077 needed, the archive can be erased and the tape or disk used over.
3078 Media quality does deteriorate with use, however. Most tapes or disks
3079 should be disgarded when they begin to produce data errors. EXABYTE
3080 tape cartridges should be disgarded when they generate an @dfn{error
3081 count} (number of non-usable bits) of more than 10k.
3083 Magnetic media are written and erased using magnetic fields, and
3084 should be protected from such fields to avoid damage to stored data.
3085 Sticking a floppy disk to a filing cabinet using a magnet is probably
3090 * Write Protection:: Write Protection
3091 * Tape Positioning:: Tape Positions and Tape Marks
3094 @node Write Protection, Tape Positioning, Media, Media
3095 @section Write Protection
3097 All tapes and disks can be @dfn{write protected}, to protect data on
3098 them from being changed. Once an archive is written, you should write
3099 protect the media to prevent the archive from being accidently
3100 overwritten or deleted. (This will protect the archive from being
3101 changed with a tape or floppy drive---it will not protect it from
3102 magnet fields or other physical hazards).
3104 The write protection device itself is usually an integral part of the
3105 physical media, and can be a two position (write enabled/write
3106 disabled) switch, a notch which can be popped out or covered, a ring
3107 which can be removed from the center of a tape reel, or some other
3110 @node Tape Positioning, , Write Protection, Media
3111 @section Tape Positions and Tape Marks
3113 Just as archives can store more than one file from the file system,
3114 tapes can store more than one archive file. To keep track of where
3115 archive files (or any other type of file stored on tape) begin and
3116 end, tape archive devices write magnetic @dfn{tape marks} on the
3117 archive media. Tape drives write one tape mark between files,
3118 two at the end of all the file entries.
3120 If you think of data as a series of "0000"'s, and tape marks as "x"'s,
3121 a tape might look like the following:
3124 0000x000000x00000x00x00000xx-------------------------
3127 Tape devices read and write tapes using a read/write @dfn{tape
3128 head}---a physical part of the device which can only access one point
3129 on the tape at a time. When you use @code{tar} to read or write
3130 archive data from a tape device, the device will begin reading or
3131 writing from wherever on the tape the tape head happens to be,
3132 regardless of which archive or what part of the archive the tape head
3133 is on. Before writing an archive, you should make sure that no data
3134 on the tape will be overwritten (unless it is no longer needed).
3135 Before reading an archive, you should make sure the tape head is at
3136 the beginning of the archive you want to read. (The @code{restore}
3137 script will find the archive automatically. @xref{Scripted
3138 Restoration}). @xref{mt}, for an explanation of the tape moving
3141 If you want to add new archive file entries to a tape, you should
3142 advance the tape to the end of the existing file entries, backspace
3143 over the last tape mark, and write the new archive file. If you were
3144 to add two archives to the example above, the tape might look like the
3148 0000x000000x00000x00x00000x000x0000xx----------------
3152 * mt:: The @code{mt} Utility
3155 @node mt, , Tape Positioning, Tape Positioning
3156 @subsection The @code{mt} Utility
3158 <<< is it true that this only works on non-block devices? should
3159 <<< explain the difference, xref to block-size (fixed or variable).
3161 You can use the @code{mt} utility to advance or rewind a tape past a
3162 specified number of archive files on the tape. This will allow you to
3163 move to the beginning of an archive before extracting or reading it,
3164 or to the end of all the archives before writing a new one.
3165 @c why isn't there an "advance 'til you find two tape marks together"?
3167 The syntax of the @code{mt} command is:
3170 mt [-f @var{tapename}] @var{operation} [@var{number}]
3173 where @var{tapename} is the name of the tape device, @var{number} is
3174 the number of times an operation is performed (with a default of one),
3175 and @var{operation} is one of the following:
3180 Writes @var{number} tape marks at the current position on the tape.
3184 Moves tape position forward @var{number} files.
3188 Moves tape position back @var{number} files.
3192 Rewinds the tape. (Ignores @var{number}).
3197 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
3201 Prints status information about the tape unit.
3203 <<< is there a better way to frob the spacing on the list? -ringo
3205 If you don't specify a @var{tapename}, @code{mt} uses the environment
3206 variable TAPE; if TAPE does not exist, @code{mt} uses the device
3209 @code{mt} returns a 0 exit status when the operation(s) were
3210 successful, 1 if the command was unrecognized, and 2 if an operation
3213 @c <<< new node on how to find an archive? -ringo
3214 If you use @code{tar +extract} with the
3215 @samp{+label=@var{archive-name}} option specified, @code{tar} will
3216 read an archive label (the tape head has to be positioned on it) and
3217 print an error if the archive label doesn't match the
3218 @var{archive-name} specified. @var{archive-name} can be any regular
3219 expression. If the labels match, @code{tar} extracts the archive.
3220 @xref{Archive Label}. @xref{Matching Format Parameters}.
3221 <<< fix cross references
3223 @code{tar +list +label} will cause @code{tar} to print the label.
3225 @c <<< MIB -- program to list all the labels on a tape?
3227 @node Quick Reference, Data Format Details, Media, Top
3228 @appendix A Quick Reference Guide to @code{tar} Operations and Options
3229 @c put in proper form for appendix. (unnumbered?)
3232 * Operations:: A Table of Operations
3233 * Options:: Table of Options
3236 @node Operations, Options, Quick Reference, Quick Reference
3237 @appendixsec A Table of Operations
3238 @c add xrefs, note synonyms
3240 The operation argument to @code{tar} specifies which action you want to
3245 Adds copies of an archive or archives to the end of another archive.
3248 Creates a new archive.
3251 Compares files in the archive with their counterparts in the file
3252 system, and reports differences in file size, mode, owner,
3253 modification date and contents.
3256 Adds files to the end of the archive.
3259 Prints a list of the contents of the archive.
3262 Reads files from the archive and writes them into the active file
3266 Adds files to the end of the archive, but only if they are newer than
3267 their counterparts already in the archive, or if they do not already
3268 exist in the archive.
3271 Adds copies of an archive or archives to the end of another archive.
3274 Adds files to the end of the archive.
3277 Adds files to the end of the archive.
3280 Adds copies of an archive or archives to the end of another archive.
3283 Compares files in the archive with their counterparts in the file
3284 system, and reports differences in file size, mode, owner,
3285 modification date and contents.
3288 Adds copies of an archive or archives to the end of another archive.
3291 Creates a new archive.
3294 Deletes files from the archive. All versions of the files are deleted.
3297 Compares files in the archive with their counterparts in the file
3298 system, and reports differences in file size, mode, owner,
3299 modification date and contents.
3302 Reads files from the archive and writes them into the active file
3306 Reads files from the archive and writes them into the active file
3310 Prints a list of @code{tar} operations and options.
3313 Prints a list of the contents of the archive.
3316 Adds files to the end of the archive, but only if they are newer than
3317 their counterparts already in the archive, or if they do not already
3318 exist in the archive.
3321 Prints the version number of the @code{tar} program to the standard
3325 @node Options, , Operations, Quick Reference
3326 @appendixsec Table of Options
3328 Options change the way @code{tar} performs an operation.
3331 @item +absolute-paths
3332 WILL BE INPUT WHEN QUESTION IS RESOLVED
3334 @item +after-date=@var{date}
3335 Limit the operation to files changed after the given date.
3336 @xref{File Exclusion}.
3338 @item +block-size=@var{number}
3339 Specify the blocking factor of an archive. @xref{Blocking Factor}.
3342 Specify a compressed archive. @xref{Compressed Archives}.
3344 @item +compress-block.
3345 Create a whole block sized compressed archive. @xref{Compressed Archives}.
3348 Solicit confirmation for each file. @xref{Interactive Operation}
3349 <<< +selective should be a synonym.
3352 Treat a symbolic link as an alternate name for the file the link
3353 points to. @xref{Symbolic Links}.
3355 @item +directory=@file{directory}
3356 Change the working directory. @xref{Changing Working Directory}.
3358 @item +exclude=@var{pattern}
3359 Exclude files which match the regular expression @var{pattern}.
3360 @xref{File Exclusion}.
3362 @item +exclude-from=@file{file}
3363 Exclude files which match any of the regular expressions listed in
3364 the file @file{file}. @xref{File Exclusion}.
3366 @item +file=@var{archive-name}
3367 Name the archive. @xref{Archive Name}).
3369 @item +files-from=@file{file}
3370 Read file-name arguments from a file on the file system.
3371 @xref{File Name Lists}.
3374 Set modes of extracted files to those recorded in the archive.
3375 @xref{File Writing Options}.
3378 Ignore end-of-archive entries. @xref{Archive Reading Options}.
3379 <<< this should be changed to +ignore-end
3381 @item +listed-incremental=@var{file-name} (-g)
3382 Take a file name argument always. If the file doesn't exist, run a level
3383 zero dump, creating the file. If the file exists, uses that file to see
3386 @item +incremental (-G)
3389 @item +tape-length=@var{n} (-L)
3390 @c <<<alternate way of doing multi archive, will go to that length and
3391 @c prompts for new tape, automatically turns on multi-volume. >>>
3392 @c <<< this needs to be written into main body as well -ringo
3394 @item +info-script=@var{program-file}
3395 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
3398 Ask for confirmation before performing any operation on a file or
3401 @item +keep-old-files
3402 Prevent overwriting during extraction. @xref{File Writing Options}.
3404 @item +label=@var{archive-label}
3405 Include an archive-label in the archive being created. @xref{Archive
3408 @item +modification-time
3409 Set the modification time of extracted files to the time they were
3410 extracted. @xref{File Writing Options}.
3413 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
3415 @item +newer=@var{date}
3416 Limit the operation to files changed after the given date.
3417 @xref{File Exclusion}.
3419 @item +newer-mtime=@var{date}
3420 Limit the operation to files modified after the given date. @xref{File
3424 Create an old format archive. @xref{Old Style File Information}.
3425 @c <<< did we agree this should go away as a synonym?
3428 Create an old format archive. @xref{Old Style File Information}.
3430 @item +one-file-system
3431 Prevent @code{tar} from crossing file system boundaries when
3432 archiving. @xref{File Exclusion}.
3435 Create an old format archive. @xref{Old Style File Information}.
3436 @c <<< was portability, may still need to be changed
3438 @item +preserve-order
3439 Help process large lists of file-names on machines with small amounts of
3440 memory. @xref{Archive Reading Options}.
3442 @item +preserve-permission
3443 Set modes of extracted files to those recorded in the archive.
3444 @xref{File Writing Options}.
3446 @item +read-full-blocks
3447 Read an archive with a smaller than specified block size or which
3448 contains incomplete blocks. @xref{Archive Reading Options}).
3449 @c should be +partial-blocks (!!!)
3451 @item +record-number
3452 Print the record number where a message is generated.
3453 @xref{Additional Information}.
3456 Help process large lists of file-names on machines with small amounts of
3457 memory. @xref{Archive Reading Options}.
3459 @item +same-permission
3460 Set the modes of extracted files to those recorded in the archive.
3461 @xref{File Writing Options}.
3464 Archive sparse files sparsely. @xref{Sparse Files}.
3466 @item +starting-file=@var{file-name}
3467 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
3470 Write files to the standard output. @xref{File Writing Options}.
3473 Specifdo a compressed archive. @xref{Compressed Archives}.
3475 @item -V @var{archive-label}
3476 Include an archive-label in the archive being created. @xref{Archive
3481 Print the names of files or archive members as they are being
3482 operated on. @xref{Additional Information}.
3485 Check for discrepancies in the archive immediately after it is
3486 written. @xref{Write Verification}.
3489 Read an archive with a smaller than specified block size or which
3490 contains incomplete blocks. @xref{Archive Reading Options}).
3492 @item -K @var{file-name}
3493 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
3496 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
3499 Limit operation to files changed after the given date. @xref{File Exclusion}.
3502 Write files to the standard output. @xref{File Writing Options}.
3504 @c <<<<- P is absolute paths, add when resolved. -ringo>>>
3507 Print the record number where a message is generated.
3508 @xref{Additional Information}.
3511 Archive sparse files sparsely. @xref{Sparse Files}.
3514 Read file-name arguments from a file on the file system.
3515 @xref{File Name Lists}.
3518 Check for discrepancies in the archive immediately after it is
3519 written. @xref{Write Verification}.
3522 Specify a compressed archive. @xref{Compressed Archives}.
3524 @item -b @var{number}
3525 Specify the blocking factor of an archive. @xref{Blocking Factor}.
3527 @item -f @var{archive-name}
3528 Name the archive. @xref{Archive Name}).
3531 Treat a symbolic link as an alternate name for the file the link
3532 points to. @xref{Symbolic Links}.
3535 Ignore end-of-archive entries. @xref{Archive Reading Options}.
3538 Prevent overwriting during extraction. @xref{File Writing Options}.
3541 Prevent @code{tar} from crossing file system boundaries when
3542 archiving. @xref{File Exclusion}.
3545 Set the modification time of extracted files to the time they were
3546 extracted. @xref{File Writing Options}.
3549 Create an old format archive. @xref{Old Style File Information}.
3552 Set the modes of extracted files to those recorded in the archive.
3553 @xref{File Writing Options}.
3556 Help process large lists of file-names on machines with small amounts of
3557 memory. @xref{Archive Reading Options}.
3560 Print the names of files or archive members they are being operated
3561 on. @xref{Additional Information}.
3564 @c <<<see +interactive. WILL BE INPUT WHEN QUESTIONS ARE RESOLVED.>>>
3567 Specify a compressed archive. @xref{Compressed Archives}.
3570 Create a whole block sized compressed archive. @xref{Compressed Archives}.
3571 @c I would rather this were -Z. it is the only double letter short
3574 @item -C @file{directory}
3575 Change the working directory. @xref{Changing Working Directory}.
3577 @item -F @var{program-file}
3578 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
3580 @item -X @file{file}
3581 Exclude files which match any of the regular expressions listed in
3582 the file @file{file}. @xref{File Exclusion}.
3585 @node Data Format Details, Concept Index, Quick Reference, Top
3586 @appendix Details of the Archive Data Format
3588 This chapter is based heavily on John Gilmore's @i{tar}(5) manual page
3589 for the public domain @code{tar} that GNU @code{tar} is based on.
3590 @c it's been majorly edited since, we may be able to lose this.
3592 The archive media contains a series of records, each of which contains
3593 512 bytes. Each archive member is represented by a header record,
3594 which describes the file, followed by zero or more records which
3595 represent the contents of the file. At the end of the archive file
3596 there may be a record consisting of a series of binary zeros, as an
3597 end-of-archive marker. GNU @code{tar} writes a record of zeros at the
3598 end of an archive, but does not assume that such a record exists when
3601 Records may be grouped into @dfn{blocks} for I/O operations. A block
3602 of records is written with a single @code{write()} operation. The
3603 number of records in a block is specified using the @samp{+block-size}
3604 option. @xref{Blocking Factor}, for more information about specifying
3608 * Header Data:: The Distribution of Data in the Header
3609 * Header Fields:: The Meaning of Header Fields
3610 * Sparse File Handling:: Fields to Handle Sparse Files
3613 @node Header Data, Header Fields, Data Format Details, Data Format Details
3614 @appendixsec The Distribution of Data in the Header
3616 The header record is defined in C as follows:
3617 @c I am taking the following code on faith.
3620 @r{Standard Archive Format - Standard TAR - USTAR}
3622 #define RECORDSIZE 512
3626 #define SPARSE_EXT_HDR 21
3627 #define SPARSE_IN_HDR 4
3635 char charptr[RECORDSIZE];
3645 char linkname[NAMSIZ];
3647 char uname[TUNMLEN];
3648 char gname[TGNMLEN];
3652 @r{The following fields were added by gnu and are not used by other}
3653 @r{versions of @code{tar}}.
3658 @r{The next three fields were added by gnu to deal with shrinking down}
3660 struct sparse sp[SPARSE_IN_HDR];
3662 @r{This is the number of nulls at the end of the file, if any.}
3663 char ending_blanks[12];
3667 struct extended_header @{
3668 struct sparse sp[21];
3673 @c <<< this whole thing needs to be put into better english
3675 @r{The checksum field is filled with this while the checksum is computed.}
3676 #define CHKBLANKS " " @r{8 blanks, no null}
3678 @r{Inclusion of this field marks an archive as being in standard}
3679 @r{Posix format (though GNU tar itself is not Posix conforming). GNU}
3680 @r{tar puts "ustar" in this field if uname and gname are valid.}
3681 #define TMAGIC "ustar " @r{7 chars and a null}
3683 @r{The magic field is filled with this if this is a GNU format dump entry.}
3684 #define GNUMAGIC "GNUtar " @r{7 chars and a null}
3686 @r{The linkflag defines the type of file.}
3687 #define LF_OLDNORMAL '\0' @r{Normal disk file, Unix compatible}
3688 #define LF_NORMAL '0' @r{Normal disk file}
3689 #define LF_LINK '1' @r{Link to previously dumped file}
3690 #define LF_SYMLINK '2' @r{Symbolic link}
3691 #define LF_CHR '3' @r{Character special file}
3692 #define LF_BLK '4' @r{Block special file}
3693 #define LF_DIR '5' @r{Directory}
3694 #define LF_FIFO '6' @r{FIFO special file}
3695 #define LF_CONTIG '7' @r{Contiguous file}
3697 @r{hhe following are further link types which were defined later.}
3699 @r{This is a dir entry that contains the names of files that were in}
3700 @r{the dir at the time the dump was made.}
3701 #define LF_DUMPDIR 'D'
3703 @r{This is the continuation of a file that began on another volume}
3704 #define LF_MULTIVOL 'M'
3706 @r{This is for sparse files}
3707 #define LF_SPARSE 'S'
3709 @r{This file is a tape/volume header. Ignore it on extraction.}
3710 #define LF_VOLHDR 'V'
3712 @r{These are bits used in the mode field - the values are in octal}
3713 #define TSUID 04000 @r{Set UID on execution}
3714 #define TSGID 02000 @r{Set GID on execution}
3715 #define TSVTX 01000 @r{Save text (sticky bit)}
3717 @r{These are file permissions}
3718 #define TUREAD 00400 @r{read by owner}
3719 #define TUWRITE 00200 @r{write by owner}
3720 #define TUEXEC 00100 @r{execute/search by owner}
3721 #define TGREAD 00040 @r{read by group}
3722 #define TGWRITE 00020 @r{write by group}
3723 #define TGEXEC 00010 @r{execute/search by group}
3724 #define TOREAD 00004 @r{read by other}
3725 #define TOWRITE 00002 @r{write by other}
3726 #define TOEXEC 00001 @r{execute/search by other}
3730 All characters in headers are 8-bit characters in the local variant of
3731 ASCII. Each field in the header is contiguous; that is, there is no
3732 padding in the header format.
3734 Data representing the contents of files is not translated in any way
3735 and is not constrained to represent characters in any character set.
3736 @code{tar} does not distinguish between text files and binary files.
3738 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
3739 @code{gname} fields contain null-terminated character strings. All
3740 other fields contain zero-filled octal numbers in ASCII. Each numeric
3741 field of width @var{w} contains @var{w} @minus{} 2 digits, a space, and a
3742 null, except @code{size} and @code{mtime}, which do not contain the
3745 @node Header Fields, Sparse File Handling, Header Data, Data Format Details
3746 @appendixsec The Meaning of Header Fields
3748 The @code{name} field contains the name of the file.
3749 <<< how big a name before field overflows?
3751 The @code{mode} field contains nine bits which specify file
3752 permissions, and three bits which specify the Set UID, Set GID, and
3753 Save Text (``stick'') modes. Values for these bits are defined above.
3754 @xref{File Writing Options}, for information on how file permissions
3755 and modes are used by @code{tar}.
3757 The @code{uid} and @code{gid} fields contain the numeric user and
3758 group IDs of the file owners. If the operating system does not
3759 support numeric user or group IDs, these fields should be ignored.
3762 The @code{size} field contains the size of the file in bytes; this
3763 field contains a zero if the header describes a link to a file.
3765 The @code{mtime} field contains the modification time of the file.
3766 This is the ASCII representation of the octal value of the last time
3767 the file was modified, represented as an integer number of seconds
3768 since January 1, 1970, 00:00 Coordinated Universal Time.
3769 @xref{File Writing Options}, for a description of how @code{tar} uses
3772 The @code{chksum} field contains the ASCII representation of the octal
3773 value of the simple sum of all bytes in the header record. To
3774 generate this sum, each 8-bit byte in the header is added to an
3775 unsigned integer, which has been initialized to zero. The precision
3776 of the integer is seventeen bits. When calculating the checksum, the
3777 @code{chksum} field itself is treated as blank.
3779 The @code{atime} and @code{ctime} fields are used when making
3780 incremental backups; they store, respectively, the file's access time
3781 and last inode-change time.
3783 The value in the @code{offset} field is used when making a
3784 multi-volume archive. The offset is number of bytes into the file
3785 that we need to go to pick up where we left off in the previous
3786 volume, i.e the location that a continued file is continued from.
3788 The @code{longnames} field supports a feature that is not yet
3789 implemented. This field should be empty.
3791 The @code{magic} field indicates that this archive was output in the
3792 P1003 archive format. If this field contains @code{TMAGIC}, the
3793 @code{uname} and @code{gname} fields will contain the ASCII
3794 representation of the owner and group of the file respectively. If
3795 found, the user and group IDs are used rather than the values in the
3796 @code{uid} and @code{gid} fields.
3798 The @code{sp} field is used to archive sparse files efficiently.
3799 @xref{Sparse File Handling}, for a description of this field, and
3800 other fields it may imply.
3802 The @code{typeflag} field specifies the file's type. If a particular
3803 implementation does not recognize or permit the specified type,
3804 @code{tar} extracts the file as if it were a regular file, and reports
3805 the discrepancy on the standard error. @xref{File Types}. @xref{GNU
3809 * File Types:: File Types
3810 * GNU File Types:: Additional File Types Supported by GNU
3813 @node File Types, GNU File Types, Header Fields, Header Fields
3814 @appendixsubsec File Types
3816 The following flags are used to describe file types:
3821 Indicates a regular file. In order to be compatible with older
3822 versions of @code{tar}, a @code{typeflag} value of @code{LF_OLDNORMAL}
3823 should be silently recognized as a regular file. New archives should
3824 be created using @code{LF_NORMAL} for regular files. For backward
3825 compatibility, @code{tar} treats a regular file whose name ends with a
3826 slash as a directory.
3829 Indicates a link to another file, of any type, which has been
3830 previously archived. @code{tar} identifies linked files in Unix by
3831 matching device and inode numbers. The linked-to name is specified in
3832 the @code{linkname} field with a trailing null.
3835 Indicates a symbolic link to another file. The linked-to
3836 name is specified in the @code{linkname} field with a trailing null.
3837 @xref{File Writing Options}, for information on archiving files
3838 referenced by a symbolic link.
3842 Indicate character special files and block special files,
3843 respectively. In this case the @code{devmajor} and @code{devminor}
3844 fields will contain the major and minor device numbers. Operating
3845 systems may map the device specifications to their own local
3846 specification, or may ignore the entry.
3849 Indicates a directory or sub-directory. The directory name in the
3850 @code{name} field should end with a slash. On systems where disk
3851 allocation is performed on a directory basis, the @code{size} field
3852 will contain the maximum number of bytes (which may be rounded to the
3853 nearest disk block allocation unit) that the directory can hold. A
3854 @code{size} field of zero indicates no size limitations. Systems that
3855 do not support size limiting in this manner should ignore the
3859 Indicates a FIFO special file. Note that archiving a FIFO file
3860 archives the existence of the file and not its contents.
3863 Indicates a contiguous file. Contiguous files are the same as normal
3864 files except that, in operating systems that support it, all the
3865 files' disk space is allocated contiguously. Operating systems which
3866 do not allow contiguous allocation should silently treat this type as
3871 These are reserved for custom implementations. Some of these are used
3872 in the GNU modified format, which is described below. @xref{GNU File
3876 Certain other flag values are reserved for specification in future
3877 revisions of the P1003 standard, and should not be used by any
3880 @node GNU File Types, , File Types, Header Fields
3881 @appendixsubsec Additional File Types Supported by GNU
3883 GNU @code{tar} uses additional file types to describe new types of
3884 files in an archive. These are listed below.
3889 Indicates a directory and a list of files created by the
3890 @samp{+incremental} option. The @code{size} field gives the total
3891 size of the associated list of files. Each file name is preceded by
3892 either a @code{'Y'} (the file should be in this archive) or an
3893 @code{'N'} (the file is a directory, or is not stored in the archive).
3894 Each file name is terminated by a null. There is an additional null
3895 after the last file name.
3899 Indicates a file continued from another volume of a multi-volume
3900 archive (@pxref{Multi-Volume Archives}). The original type of the file is not
3901 given here. The @code{size} field gives the maximum size of this
3902 piece of the file (assuming the volume does not end before the file is
3903 written out). The @code{offset} field gives the offset from the
3904 beginning of the file where this part of the file begins. Thus
3905 @code{size} plus @code{offset} should equal the original size of the
3910 Indicates a sparse file. @xref{Sparse Files}. @xref{Sparse File
3915 Marks an archive label that was created using the @samp{+label} option
3916 when the archive was created (@pxref{Archive Label}. The @code{name}
3917 field contains the argument to the option. The @code{size} field is
3918 zero. Only the first file in each volume of an archive should have
3922 @node Sparse File Handling, , Header Fields, Data Format Details
3923 @appendixsec Fields to Handle Sparse Files
3925 The following header information was added to deal with sparse files
3926 (@pxref{Sparse Files}):
3929 The @code{sp} field (fields? something else?) is an array of
3930 @code{struct sparse}. Each @code{struct sparse} contains two
3931 12-character strings, which represent the offset into the file and the
3932 number of bytes to be written at that offset. The offset is absolute,
3933 and not relative to the offset in preceding array elements.
3935 The header can contain four of these @code{struct sparse}; if more are
3936 needed, they are not stored in the header, instead, the flag
3937 @code{isextended} is set and the next record is an
3938 @code{extended_header}.
3939 @c @code{extended_header} or @dfn{extended_header} ??? the next
3940 @c record after the header, or in the middle of it.
3942 The @code{isextended} flag is only set for sparse files, and then only
3943 if extended header records are needed when archiving the file.
3945 Each extended header record can contain an array of 21 sparse
3946 structures, as well as another @code{isextended} flag. There is no
3947 limit (except that implied by the archive media) on the number of
3948 extended header records that can be used to describe a sparse file.
3950 @c so is @code{extended_header} the right way to write this?
3952 @node Concept Index, , Data Format Details, Top
3953 @unnumbered Concept Index