]> Dogcows Code - chaz/tar/blob - doc/tar.texi
*** empty log message ***
[chaz/tar] / doc / tar.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename tar.info
4 @settitle The Tar Manual: DRAFT
5 @setchapternewpage odd
6 @c %**end of header
7
8 @c Note: the edition number and date is listed in *two* places; please update.
9 @c subtitle and top node; search for !!set
10
11 @c Search for comments marked with !! or <<< (or >>>)
12
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).>>>
16
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".>>>
20
21 @c <<< @code{tar} is always lower case, in bold. >>>
22
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
27
28 @c <<< (don't forget to comment these out in final draft) -ringo
29
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
32 @c smallbook
33
34 @iftex
35 @c finalout
36 @end iftex
37
38 @ifinfo
39 This file documents @code{tar}, a utility used to store, backup, and
40 transport files.
41
42 Copyright (C) 1992 Free Software Foundation, Inc. DRAFT!
43 @c Need to put distribution information here when ready.
44 @end ifinfo
45
46 @c !!set edition number and date here
47 @titlepage
48 @title @code{tar}
49 @subtitle The GNU Tape Archiver
50 @subtitle Edition 0.01, for @code{tar} Version 1.10
51 @subtitle @today{}
52 @c remove preceding today line when ready
53 @sp 1
54 @subtitle DRAFT
55 @c subtitle insert month here when ready
56
57 @author Amy Gorin, Michael I. Bushnell, and Jay Fenlason
58 @c <<<best to have hack read this over and see if anything is left he
59 @c wrote. I don't think so. -ringo>>>>
60
61 @page
62 @vskip 0pt plus 1filll
63 Copyright @copyright{} 1992 Free Software Foundation, Inc.
64
65 @sp 2
66 This draft is not yet ready for distribution.
67 @end titlepage
68
69 @ifinfo
70 @node Top, Introduction, (dir), (dir)
71 @top @code{tar}
72
73 This file documents @code{tar}, a utility used to store, backup, and
74 transport files.
75
76 @c !!set edition number and date here
77 This is DRAFT Edition 0.01 of the @code{tar} documentation, @today{}, for @code{tar}
78 version 1.12.
79 @end ifinfo
80
81 @c <<< The menus need to be gone over, and node names fixed.
82 @menu
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
98 @end menu
99
100 @node Introduction, Invoking @code{tar}, Top, Top
101 @chapter @code{tar}: The GNU Tape Archiver
102
103 You can use @code{tar} to create an @dfn{archive}---a single file
104 which contains other files' contents as well as a listing of those
105 files' characteristics. You can also use @code{tar} to read, add to,
106 or manipulate already existing archives. Because an archive created
107 by @code{tar} is capable of preserving file information and directory
108 structure, @code{tar} is ideal for performing full and incremental
109 backups, as well as for transferring groups of files between disks and
110 over networks.
111
112 The name @code{tar} comes from the words ``Tape ARchiver'', but
113 @code{tar} can actually process archives wherever they are stored; on
114 tapes and disk files, for example. In addition, tar can read archives
115 from standard input or write them to standard output. (This is often
116 useful if redirected another program with a pipe.)
117
118 @c <<< this menu will conflict with menu above in info mode. -ringo
119 @menu
120 * Invoking @code{tar}:: How to invoke @code{tar} and specify arguments.
121 * Tutorial:: An introduction to @code{tar}.
122 * Operations:: What you can use @code{tar} to do.
123 * Options:: How to change the way @code{tar} behaves.
124 * Problems:: Common problems with @code{tar}.
125 @end menu
126
127 @node Tutorial, Wizardry, Invoking @code{tar}, Top
128 @chapter Getting Started With @code{tar}
129
130 This chapter guides you through some basic examples of @code{tar}
131 operations. If you already know how to use some other version of
132 @code{tar}, then you probably don't need to read this chapter. This
133 chapter omits complicated details about many of the ways @code{tar}
134 works. See later chapters for full information.
135
136 @menu
137 * Creating Archives:: Creating Archives
138 * Extracting Files:: Extracting Files from an Archive
139 * Listing Archive Contents:: Listing the Contents of an Archive
140 * Comparing Files:: Comparing Archives with the File System
141 * Adding to Archives:: Adding Files to Existing Archives
142 * Concatenate:: Concatenating Archives
143 * Deleting Files:: Deleting Files From an Archive
144 @end menu
145
146 @node Creating Archives, Listing Archive Contents, Tutorial, Tutorial
147 @section Creating Archives
148
149 To create a new archive, use @samp{tar --create}. You should generally
150 use the @samp{--file} option to specify the name the tar archive will
151 have. Then specify the names of the files you wish to place in the
152 archive. For example, to place the files @file{foo}, @file{bar}, and
153 @file{baz} into an archive named @file{my-archive}, use the following
154 command:
155
156 @example
157 tar --create --file=my-archive foo bar baz
158 @end example
159
160 The order of the arguments is not important. You could also say:
161
162 @example
163 tar foo --create --file=my-archive bar baz
164 @end example
165
166 This order is harder to understand however. In this manual, we will
167 list the arguments in a reasonable order to make the commands easier to
168 understand, but you can type them in any order you wish.
169
170 If you don't specify the @samp{--file} option, then @code{tar} will use
171 a default. Usually this default is some physical tape drive attached to
172 your machine. If there is no tape drive attached, or the default is not
173 meaningful, then tar will print an error message. This error message
174 might look roughly like one of the following:
175
176 @example
177 tar: can't open /dev/rmt8 : No such device or address
178 tar: can't open /dev/rsmt0 : I/O error
179 @end example
180
181 If you get an error like this, mentioning a file you didn't specify
182 (@file{/dev/rmt8} or @file{/dev/rsmt0} in the examples above), then @code{tar}
183 is using a default value for @samp{--file}. You should generally specify a
184 @samp{--file} argument whenever you use @code{tar}, rather than relying
185 on a default.
186
187 If you don't specify the names of any files to put in the archive, then
188 tar will create an empty archive. So, the following command will create
189 an archive with nothing in it:
190
191 @example
192 tar --create --file=my-empty-archive
193 @end example
194
195 Whenever you use @samp{tar --create}, @code{tar} will erase the current
196 contents of the file named by @samp{--file} if it exists. To add files
197 to an existing archive, you need to use a different option.
198 @xref{Adding to Archives} for information on how to do this.
199
200 The names of the members of an archive are called @dfn{member names}.
201 When @samp{tar --create} creates an archive, the member names of the
202 members of the archive are exactly the same as the file names as you
203 typed them in the @code{tar} command. So, the member names of
204 @file{my-archive} (as created by the first example above) are
205 @file{foo}, @file{bar}, and @file{baz}. However, suppose the archive
206 were created with this command instead:
207
208 @example
209 tar --create --file=my-new-archive ./foo bar ./baz
210 @end example
211
212 Then, the same three files would get placed in the archive (because
213 @file{./} is a synonym for the current directory), but their member
214 names would now be @file{./foo}, @file{bar}, and @file{./baz}.
215
216 If you want to see the progress of tar as it writes files into the
217 archive, you can use the @samp{--verbose} option.
218
219 If one of the files named to @samp{tar --create} is a directory, then
220 the operation of tar is more complicated. @xref{Tar and Directories},
221 the last section of this tutorial, for more information.
222
223 @section Listing Archives
224
225 Use @samp{tar --list} to print the names of members stored in an
226 archive. Use a @samp{--file} option just as with @samp{tar --create} to
227 specify the name of the archive. For example, the archive
228 @file{my-archive} created in the last section could be examined with the
229 command @samp{tar --list --file=my-archive}. The output of tar would
230 then be:
231
232 @example
233 foo
234 bar
235 baz
236 @end example
237
238 The archive @file{my-new-archive} would list as follows:
239
240 @example
241 ./foo
242 bar
243 ./baz
244 @end example
245
246 Note that, despite the identical contents of the two archives' members,
247 the member names are different. (Of course, @samp{tar --list
248 --file=my-empty-archive} would produce no output.)
249
250 If you use the @samp{--verbose} option with @samp{tar --list}, then tar
251 will print out a listing reminiscent of @samp{ls -l}, showing owner,
252 file size, and so forth.
253
254 You can also specify member names when using @samp{tar --list}. In this
255 case, tar will only list the names of members you identify. For
256 example, @samp{tar --list --file=my-archive foo} would only print
257 @samp{foo}. It is essential when specifying member names to tar that
258 you give the exact member names. For example, @samp{tar --list
259 --file=my-new-archive foo} would produce no output, because there is no
260 member named @file{foo}, only one named @file{./foo}. While the file
261 names @file{foo} and @file{./foo} name the same file, member names are
262 compared using a simplistic name comparison, in which an exact match is
263 necessary.
264
265 @section Extracting Files from an Archive
266
267 In order to extract files from an archive, use @samp{tar --extract}.
268 Specify the name of the archive with @samp{--file}. To extract specific
269 archive members, give their member names as arguments. It essential to
270 give their exact member name, as printed by @samp{tar --list}.
271
272 Keeping the example of the two archives created at the beginning of this
273 tutorial, @samp{tar --extract --file=my-archive foo} would create a file
274 @file{foo} in the current directory with the contents of the archive
275 member @file{foo}. It would remove any file named @file{foo} already
276 present in the directory, but it would not change the archive in any
277 way.
278
279 Remember that specifying the exact member name is important. @samp{tar
280 --extract --file=my-new-archive foo} will fail, because there is no
281 member named @file{foo}. To extract the member named @file{./foo} you
282 would need to specify @samp{tar --extract --file=my-new-archive ./foo}.
283 To find the exact member names of the members of an archive, use
284 @samp{tar --list}. @xref{Listing Archives}.
285
286 If you do not list any archive member names, then @samp{tar --extract}
287 will extract all the members of the archive.
288
289 If you give the @samp{--verbose} option, then @samp{tar --extract} will
290 print the names of the archive members as it extracts them.
291
292 @section Adding Files to Existing Archives
293
294 If you want to add files to an existing archive, then don't use
295 @samp{tar --create}. That will erase an archive and create a new one in
296 its place. Instead, use @samp{tar --add-file}. The command @samp{tar
297 --add-file --file=my-archive qux} would add the file @file{qux} to the
298 existing archive @file{my-archive}. It is essential that the archive
299 exist already in order to use @samp{tar --add-file}.
300
301 As with @samp{tar --create}, the member names of the newly added files
302 will be the exact same as their names given on the command line. The
303 @samp{--verbose} option will print out the names of the files as they
304 are written into the archive.
305
306 If you add a file to an archive using @samp{tar --add-file} with the
307 same name as an archive member already present in the archive, then the
308 old member is not deleted. What does happen, however, is somewhat
309 complex. @xref{Multiple Members with the Same Name}. If you want to
310 replace an archive member, use @samp{tar --delete} first, and then use
311 @samp{tar --add-file}.
312
313 @section Deleting Files from Archives
314
315 You can delete files from an archive using @samp{tar --delete}. Specify
316 the name of the archive with @samp{--file}. List the member names of
317 the files to be deleted. If you list no member names, then nothing will
318 be deleted. The @samp{--verbose} option will cause @code{tar} to print
319 the names of the members as they are deleted. As with @samp{tar
320 --extract}, it is important that you give the exact member names when
321 using @samp{tar --delete}. Use @samp{tar --list} to find out the exact
322 member names in an archive (@pxref{Listing Archives}).
323
324 The @samp{tar --delete} command only works with archives stored on disk.
325 Archives stored on a tape drive cannot be deleted from.
326
327 @section Directories
328
329 When the names of files or member names specify directories, the
330 operation of @code{tar} is more complex. Generally, when a directory is
331 named, @code{tar} also operates on all the contents of the directory,
332 recursively. Thus, to @code{tar}, the file name @file{/} names the
333 entire file system.
334
335 To archive the entire contents of a directory, use @samp{tar --create}
336 (or @samp{tar --add-file}) as usual, and specify the name of the
337 directory. For example, to archive all the contents of the current
338 directory, use @samp{tar --create --file=@var{archive-name} .}. Doing
339 this will give the archive members names starting with @samp{./}. To
340 archive the contents of a directory named @file{foodir}, use @samp{tar
341 --create --file=@var{archive-name} foodir}. In this case, the member
342 names will all start with @samp{foodir/}.
343
344 If you give @code{tar} a command such as @samp{tar --create --file=foo
345 .}, it will report @samp{tar: foo is the archive; not dumped}. This
346 happens because the archive @file{foo} is created before putting any
347 files into it. Then, when @code{tar} attempts to add all the files in
348 the directory @file{.} to the archive, it notices that the file
349 @file{foo} is the same as the archive, and skips it. (It makes no sense
350 to put an archive into itself.) GNU @code{tar} will continue in this
351 case, and create the archive as normal, except for the exclusion of that
352 one file. Other versions of @code{tar}, however, are not so clever, and
353 will enter an infinite loop when this happens, so you should not depend
354 on this behavior. In general, make sure that the archive is not inside
355 a directory being dumped.
356
357 When extracting files, you can also name directory archive members on
358 the command line. In this case, @code{tar} extracts all the archive
359 members whose names begin with the name of the directory. As usual,
360 @code{tar} is not particularly clever about interpreting member names.
361 The command @samp{tar --extract --file=@var{archive-name} .} will not
362 extract all the contents of the archive, but only those members whose
363 member names begin with @samp{./}.
364
365
366 @node Invoking @code{tar}, Tutorial, Introduction, Top
367 @chapter How To Invoke @code{tar}
368
369 The usual way to invoke tar is
370
371 @example
372 @code{tar} @var{options}... [@var{file-names}...]
373 @end example
374
375 All the options start with @samp{-}. The arguments which do not start
376 with @samp{-} are taken to be file-name arguments. (But
377 @xref{Argument Form}.) You can actually type in arguments in any
378 order. In this manual the options always precede the file-name
379 arguments, to make examples easier to understand.
380
381 @menu
382 * Option Form:: The Forms of Arguments
383 * Argument Functions:: The Functions of Arguments
384 * Old Syntax for Commands:: An Old, but Still Supported, Syntax
385 for @code{tar} Commands
386 @end menu
387
388 @node Option Form, Old Syntax for Commands, Argument Functions, Invoking @code{tar}
389 @section The Forms of Arguments
390
391 Most options of @code{tar} have a single letter form (a single letter
392 preceded by @samp{-}), and at least one mnemonic form (a word or
393 abbreviation preceded by @samp{--}). The forms are absolutely
394 identical in function. For example, you can use either @samp{tar -t}
395 or @samp{tar --list} to list the contents of an archive. In addition,
396 mnemonic names can be given unique abbreviations. For example,
397 @samp{--cre} can be used in place of @samp{--create} because there is
398 no other option which begins with @samp{cre}.
399
400 Some options require an additional argument. Single letter options
401 which require arguments use the immediately following argument. (This
402 is an exception to the rule that @code{tar} arguments which are not
403 options are file-name arguments.) Mnemonic options are separated from
404 their arguments by an @samp{=} sign. For example, to create an an
405 archive file named @file{george}, use either @samp{tar --create
406 --file=george} or @samp{tar --create -f george}. Both
407 @samp{--file=@var{archive-name}} and @samp{-f @var{archive-name}}
408 denote the option to give the archive a non-default name, which in the
409 example is @samp{george}.
410
411 You can mix single letter and mnemonic forms in the same command. You
412 could type the above example as @samp{tar -c --file=george} or
413 @samp{tar --create -f george}. However, @code{tar} operations and
414 options are case sensitive. You would not type the above example as
415 @samp{tar -C --file=george}, because @samp{-C} is an option that
416 causes @code{tar} to change directories, not an operation that creates
417 an archive. In fact, @samp{-C} requires a further argument (the name
418 of the directory which to change to). In this case, tar would think
419 it needs to change to a directory named @samp{--file=george}, and
420 wouldn't interpret @samp{--file-george} as an option at all!
421
422 @node Argument Functions, Argument Form, Invoking @code{tar}, Invoking @code{tar}
423 @section The Functions of Arguments
424
425 You must give exactly one option from the following list to tar. This
426 option specifies the basic operation for tar to perform.
427
428 @itemize
429 @item
430 Add files to an existing archive (@samp{--add-file}, @samp{--append} or
431 @samp{-r})
432
433 @item
434 Compare files in an archive with files in the file system
435 (@samp{--compare}, @samp{--diff} or @samp{-d})
436
437 @item
438 Add archives to another archive (@samp{--add-archive}, @samp{--catenate}
439 or @samp{-A})
440 @c was --concatenate. -ringo
441
442 @item
443 Create a new archive (@samp{--create} or @samp{-c})
444
445 @item
446 Delete files from an archive (@samp{--delete})
447
448 @item
449 Extract files from an archive (@samp{--extract}, @samp{--get} or @samp{-x})
450
451 @item
452 List the files in an archive (@samp{--list} or @samp{-t})
453
454 @item
455 Update an archive by appending newer versions of already stored files
456 (@samp{--update} or @samp{-u})
457 @end itemize
458
459 @xref{Reading and Writing}, for more information about these
460 operations.
461
462 The remaining options to @code{tar} change details of the operation,
463 such as archive format, archive name, or level of user interaction.
464 You can specify more than one option.
465
466 The remaining arguments are file-name arguments. For --add-file and
467 --create these arguments specify the names of files (which must
468 already exist) to place in the archive. For the remaining operation
469 types, the file-name arguments specify archive members to compare,
470 delete, extract, list, or update. When naming archive members, you
471 must give the exact name of the member in the archive. When naming
472 files, the normal file name rules apply.
473
474 If you don't use any file-name arguments, @samp{--add-file},
475 @samp{--update} and @samp{--delete} will do nothing. Naturally,
476 @samp{--create} will make an empty archive if given no file-name
477 arguments. The other operations of @code{tar} will act on defaults.
478
479 Anytime you use a file-name argument to specify a directory file,
480 @code{tar} acts recursively on all the files and directories beneath
481 that directory.
482
483 @node Old Syntax for Commands, , Argument Form, Invoking @code{tar}
484 @section An Old, but Still Supported, Syntax for @code{tar} Commands
485
486 For historical reasons, GNU @code{tar} also accepts a syntax for
487 commands which splits options that require additional arguments into
488 two parts. That syntax is of the form:
489
490 @example
491 @code{tar} @var{option-letters}... [@var{option-arguments}...] [@var{file-names}...]@refill
492 @end example
493
494 @noindent
495 where arguments to the options appear in the same order as the letters
496 to which they correspond, and the operation and all the option letters
497 appear as a single argument, without separating spaces.
498
499 This command syntax is useful because it lets you type the single
500 letter forms of the operation and options as a single argument to
501 @code{tar}, without writing preceding @samp{-}s or inserting spaces
502 between letters. @samp{tar cv} or @samp{tar -cv} are equivalent to
503 @samp{tar -c -v}.
504
505 On the other hand, this old style syntax makes it difficult to match
506 option letters with their corresponding arguments, and is often
507 confusing. In the command @samp{tar cvbf 20 /dev/rmt0}, for example,
508 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
509 argument for @samp{-f}, and @samp{-v} does not have a corresponding
510 argument. The modern syntax---@samp{tar -c -v -b 20 -f
511 /dev/rmt0}---is clearer.
512
513 @node Wizardry, Archive Structure, Tutorial, Top
514 @chapter Wizardry
515
516 <<<This section needs to be written -ringo
517
518 @strong{To come:} using Unix file linking capability to recreate directory
519 structures---linking files into one subdirectory and then tarring that
520 directory.
521
522 @strong{to come:} nice hairy example using absolute-paths, newer, etc.
523
524
525 Piping one @code{tar} to another is an easy way to copy a directory's
526 contents from one disk to another, while preserving the dates, modes, owners
527 and link-structure of all the files therein.
528
529 @example
530 cd sourcedirectory; tar cf - . | (cd targetdir; tar xf -)
531 @end example
532
533 @noindent
534 or
535
536 <<< the following using standard input/output correct??
537 @example
538 cd sourcedirectory; tar --create --file=- . | (cd targetdir; tar --extract --file=-)
539 @end example
540
541 @noindent
542
543 Archive files can be used for transporting a group of files from one system
544 to another: put all relevant files into an archive on one computer system,
545 transfer the archive to another, and extract the contents there. The basic
546 transfer medium might be magnetic tape, Internet FTP, or even electronic
547 mail (though you must encode the archive with @code{uuencode} in order to
548 transport it properly by mail). Both machines do not have to use the same
549 operating system, as long as they both support the @code{tar} program.
550 @findex uuencode
551 <<< mention uuencode on a paragraph of its own
552
553 <<<<<end construction>>>>>
554
555 @node Archive Structure, Reading and Writing, Wizardry, Top
556 @chapter The Structure of an Archive
557
558 While an archive may contain many files, the archive itself is a
559 single ordinary file. Like any other file, an archive file can be
560 written to a storage device such as a tape or disk, sent through a
561 pipe or over a network, saved on the active file system, or even
562 stored in another archive. An archive file is not easy to read or
563 manipulate without using the @code{tar} utility or Tar mode in Emacs.
564
565
566 Physically, an archive consists of a series of file entries terminated
567 by an end-of-archive entry, which consists of 512 zero bytes. A file
568 entry usually describes one of the files in the archive (an
569 @dfn{archive member}), and consists of a file header and the contents
570 of the file. File headers contain file names and statistics, checksum
571 information which @code{tar} uses to detect file corruption, and
572 information about file types.
573
574 More than archive member can have the same file name. One way this
575 situation can occur is if more than one version of a file has been
576 stored in the archive. For information about adding new versions of a
577 file to an archive, @pxref{Modifying}.
578
579 In addition to entries describing archive members, an archive may contain
580 entries which @code{tar} itself uses to store information.
581 @xref{Archive Label}, for an example of such an archive entry.
582
583 @menu
584 * Old Style File Information:: Old Style File Information
585 * Archive Label::
586 * Format Variations::
587 @end menu
588
589 @node Old Style File Information, Archive Label, Archive Structure, Archive Structure
590 @section Old Style File Information
591 @cindex Format, old style
592 @cindex Old style format
593 @cindex Old style archives
594
595 Archives record not only an archive member's contents, but also its
596 file name or names, its access permissions, user and group, size in
597 bytes, and last modification time. Some archives also record the file
598 names in each archived directory, as well as other file and directory
599 information.
600
601 Certain old versions of @code{tar} cannot handle additional
602 information recorded by newer @code{tar} programs. To create an
603 archive which can be read by these old versions, specify the
604 @samp{--old-archive} option in conjunction with the @samp{tar --create}
605 operation. When you specify this option, @code{tar} leaves out
606 information about directories, pipes, fifos, contiguous files, and
607 device files, and specifies file ownership by group and user ids
608 instead of names.
609
610 The @samp{--old-archive} option is needed only if the archive must be
611 readable by an older tape archive program which cannot handle the new format.
612 Most @code{tar} programs do not have this limitation, so this option
613 is seldom needed.
614
615 @table @samp
616 @item --old-archive
617 @itemx -o
618 @itemx --old
619 @itemx --portable
620 @c has portability been changed to portable?
621 Creates an archive that can be read by an old @code{tar} program.
622 Used in conjunction with the @samp{tar --create} operation.
623 @end table
624
625 @node Archive Label, Format Variations, Old Style File Information, Archive Structure
626 @section Including a Label in the Archive
627 @cindex Labeling an archive
628 @cindex Labels on the archive media
629
630 @c !! Should the arg to --label be a quoted string?? no - ringo
631 To avoid problems caused by misplaced paper labels on the archive
632 media, you can include a @dfn{label} entry---an archive member which
633 contains the name of the archive---in the archive itself. Use the
634 @samp{--label=@var{archive-label}} option in conjunction with the
635 @samp{--create} operation to include a label entry in the archive as it
636 is being created.
637
638 If you create an archive using both @samp{--label=@var{archive-label}}
639 and @samp{--multi-volume}, each volume of the archive will have an
640 archive label of the form @samp{@var{archive-label} Volume @var{n}},
641 where @var{n} is 1 for the first volume, 2 for the next, and so on.
642 @xref{Multi-Volume Archives}, for information on creating multiple
643 volume archives.
644
645 If you extract an archive using @samp{--label=@var{archive-label}},
646 @code{tar} will print an error if the archive label doesn't match the
647 @var{archive-label} specified, and will then not extract the archive.
648 You can include a regular expression in @var{archive-label}, in this
649 case only.
650 @c >>> why is a reg. exp. useful here? (to limit extraction to a
651 @c >>>specific group? ie for multi-volume??? -ringo
652
653 To find out an archive's label entry (or to find out if an archive has
654 a label at all), use @samp{tar --list --verbose}. @code{tar} will print the
655 label first, and then print archive member information, as in the
656 example below:
657
658 @example
659 % tar --verbose --list --file=iamanarchive
660 V--------- 0/0 0 Mar 7 12:01 1992 iamalabel--Volume Header--
661 -rw-rw-rw- ringo/user 40 May 21 13:30 1990 iamafilename
662 @end example
663
664 @table @samp
665 @item --label=@var{archive-label}
666 @itemx -V @var{archive-label}
667 Includes an @dfn{archive-label} at the beginning of the archive when
668 the archive is being created (when used in conjunction with the
669 @samp{tar --create} operation). Checks to make sure the archive label
670 matches the one specified (when used in conjunction with the @samp{tar
671 --extract} operation.
672 @end table
673 @c was --volume
674
675 @node Format Variations, , Archive Label, Archive Structure
676 @section Format Variations
677 @cindex Format Parameters
678 @cindex Format Options
679 @cindex Options to specify archive format.
680
681 Format parameters specify how an archive is written on the archive
682 media. The best choice of format parameters will vary depending on
683 the type and number of files being archived, and on the media used to
684 store the archive.
685
686 To specify format parameters when accessing or creating an archive,
687 you can use the options described in the following sections. If you
688 do not specify any format parameters, @code{tar} uses default
689 parameters. You cannot modify a compressed archive. If you create an
690 archive with the @samp{--block-size} option specified (@pxref{Blocking
691 Factor}), you must specify that block-size when operating on the
692 archive. @xref{Matching Format Parameters}, for other examples of
693 format parameter considerations.
694
695
696 @menu
697 * Multi-Volume Archives::
698 * Sparse Files::
699 * Blocking Factor::
700 * Compressed Archives::
701 @end menu
702
703 @node Multi-Volume Archives, Sparse Files, Format Variations, Format Variations
704 @subsection Archives Longer than One Tape or Disk
705 @cindex Multi-volume archives
706
707 To create an archive that is larger than will fit on a single unit of
708 the media, use the @samp{--multi-volume} option in conjunction with the
709 @samp{tar --create} operation (@pxref{Creating Archives}). A
710 @dfn{multi-volume} archive can be manipulated like any other archive
711 (provided the @samp{--multi-volume} option is specified), but is stored
712 on more than one tape or disk.
713
714 When you specify @samp{--multi-volume}, @code{tar} does not report an
715 error when it comes to the end of an archive volume (when reading), or
716 the end of the media (when writing). Instead, it prompts you to load
717 a new storage volume. If the archive is on a magnetic tape, you
718 should change tapes when you see the prompt; if the archive is on a
719 floppy disk, you should change disks; etc.
720
721 You can read each individual volume of a multi-volume archive as if it
722 were an archive by itself. For example, to list the contents of one
723 volume, use @samp{tar --list}, without @samp{--multi-volume} specified.
724 To extract an archive member from one volume (assuming it is described
725 that volume), use @samp{tar --extract}, again without
726 @samp{--multi-volume}.
727
728 If an archive member is split across volumes (ie. its entry begins on
729 one volume of the media and ends on another), you need to specify
730 @samp{--multi-volume} to extract it successfully. In this case, you
731 should load the volume where the archive member starts, and use
732 @samp{tar --extract --multi-volume}---@code{tar} will prompt for later
733 volumes as it needs them. @xref{Extracting From Archives} for more
734 information about extracting archives.
735
736 @samp{--info-script=@var{program-file}} is like @samp{--multi-volume},
737 except that @code{tar} does not prompt you directly to change media
738 volumes when a volume is full---instead, @code{tar} runs commands you
739 have stored in @var{program-file}. This option can be used to
740 broadcast messages such as @samp{someone please come change my tape}
741 when performing unattended backups. When @var{program-file} is done,
742 @code{tar} will assume that the media has been changed.
743
744
745 <<< There should be a sample program here, including an exit before
746 <<< end.
747
748 @table @samp
749 @item --multi-volume
750 @itemx -M
751 Creates a multi-volume archive, when used in conjunction with
752 @samp{tar --create}. To perform any other operation on a multi-volume
753 archive, specify @samp{--multi-volume} in conjunction with that
754 operation.
755
756 @item --info-script=@var{program-file}
757 @itemx -F @var{program-file}
758 Creates a multi-volume archive via a script. Used in conjunction with
759 @samp{tar --create}.
760 @end table
761
762 @node Sparse Files, Blocking Factor, Multi-Volume Archives, Format Variations
763 @subsection Archiving Sparse Files
764 @cindex Sparse Files
765
766 A file is sparse if it contains blocks of zeros whose existance is
767 recorded, but that have no space allocated on disk. When you specify
768 the @samp{--sparse} option in conjunction with the @samp{--create}
769 operation, @code{tar} tests all files for sparseness while archiving.
770 If @code{tar} finds a file to be sparse, it uses a sparse
771 representation of the file in the archive. @xref{Creating Archives},
772 for more information about creating archives.
773
774 @samp{--sparse} is useful when archiving files, such as dbm files,
775 likely to contain many nulls. This option dramatically
776 decreases the amount of space needed to store such an archive.
777
778 @quotation
779 @strong{Please Note:} Always use @samp{--sparse} when performing file
780 system backups, to avoid archiving the expanded forms of files stored
781 sparsely in the system.@refill
782
783 Even if your system has no no sparse files currently, some may be
784 created in the future. If you use @samp{--sparse} while making file
785 system backups as a matter of course, you can be assured the archive
786 will always take no more space on the media than the files take on
787 disk (otherwise, archiving a disk filled with sparse files might take
788 hundreds of tapes).@refill
789 <<< xref incremental when node name is set.
790 @end quotation
791
792 @code{tar} ignores the @samp{--sparse} option when reading an archive.
793
794 @table @samp
795 @item --sparse
796 @itemx -S
797 Files stored sparsely in the file system are represented sparsely in
798 the archive. Use in conjunction with write operations.
799 @end table
800
801 @node Blocking Factor, Compressed Archives, Sparse Files, Format Variations
802 @subsection The Blocking Factor of an Archive
803 @cindex Blocking Factor
804 @cindex Block Size
805 @cindex Number of records per block
806 @cindex Number of bytes per block
807 @cindex Bytes per block
808 @cindex Records per block
809
810 The data in an archive is grouped into records, which are 512 bytes.
811 Records are read and written in whole number multiples called
812 @dfn{blocks}. The number of records in a block (ie. the size of a
813 block in units of 512 bytes) is called the @dfn{blocking factor}. The
814 @samp{--block-size=@var{number}} option specifies the blocking factor
815 of an archive. The default blocking factor is typically 20 (ie.@:
816 10240 bytes), but can be specified at installation. To find out the
817 blocking factor of an existing archive, use @samp {tar --list
818 --file=@var{archive-name}}. This may not work on some devices.
819
820 Blocks are seperated by gaps, which waste space on the archive media.
821 If you are archiving on magnetic tape, using a larger blocking factor
822 (and therefore larger blocks) provides faster throughput and allows
823 you to fit more data on a tape (because there are fewer gaps). If you
824 are archiving on cartridge, a very large blocking factor (say 126 or
825 more) greatly increases performance. A
826 smaller blocking factor, on the other hand, may be usefull when
827 archiving small files, to avoid archiving lots of nulls as @code{tar}
828 fills out the archive to the end of the block. In general, the ideal block size
829 depends on the size of the inter-block gaps on the tape you are using,
830 and the average size of the files you are archiving. @xref{Creating
831 Archives}, for information on writing archives.
832
833 Archives with blocking factors larger than 20 cannot be read by very
834 old versions of @code{tar}, or by some newer versions of @code{tar}
835 running on old machines with small address spaces. With GNU
836 @code{tar}, the blocking factor of an archive is limited only by the
837 maximum block size of the device containing the archive, or by the
838 amount of available virtual memory.
839
840 If you use a non-default blocking factor when you create an archive,
841 you must specify the same blocking factor when you modify that
842 archive. Some archive devices will also require you to specify the
843 blocking factor when reading that archive, however this is not
844 typically the case. Usually, you can use @samp{tar --list} without
845 specifying a blocking factor---@code{tar} reports a non-default block
846 size and then lists the archive members as it would normally. To
847 extract files from an archive with a non-standard blocking factor
848 (particularly if you're not sure what the blocking factor is), you can
849 usually use the {--read-full-blocks} option while specifying a blocking
850 factor larger then the blocking factor of the archive (ie. @samp{tar
851 --extract --read-full-blocks --block-size=300}. @xref{Listing Contents}
852 for more information on the @samp{--list} operation.
853 @xref{read-full-blocks} for a more detailed explanation of that
854 option.
855
856 @table @samp
857 @item --block-size=@var{number}
858 @itemx -b @var{number}
859 Specifies the blocking factor of an archive. Can be used with any
860 operation, but is usually not necessary with @samp{tar --list}.
861 @end table
862
863 @node Compressed Archives, , Blocking Factor, Format Variations
864 @subsection Creating and Reading Compressed Archives
865 @cindex Compressed archives
866 @cindex Storing archives in compressed format
867
868 @samp{--compress} indicates an archive stored in compressed format.
869 The @samp{--compress} option is useful in saving time over networks and
870 space in pipes, and when storage space is at a premium.
871 @samp{--compress} causes @code{tar} to compress when writing the
872 archive, or to uncompress when reading the archive.
873
874 To perform compression and uncompression on the archive, @code{tar}
875 runs the @code{compress} utility. @code{tar} uses the default
876 compression parameters; if you need to override them, avoid the
877 @samp{--compress} option and run the @code{compress} utility
878 explicitly. It is useful to be able to call the @code{compress}
879 utility from within @code{tar} because the @code{compress} utility by
880 itself cannot access remote tape drives.
881
882 The @samp{--compress} option will not work in conjunction with the
883 @samp{--multi-volume} option or the @samp{--add-file}, @samp{--update},
884 @samp{--add-file} and @samp{--delete} operations. @xref{Modifying}, for
885 more information on these operations.
886
887 If there is no compress utility available, @code{tar} will report an
888 error.
889
890 @samp{--compress-block} is like @samp{--compress}, but when used in
891 conjunction with @samp{--create} also causes @code{tar} to pad the last
892 block of the archive out to the next block boundary as it is written.
893 This is useful with certain devices which require all write operations
894 be a multiple of a specific size.
895
896 @quotation
897 @strong{Please Note:} The @code{compress} program may be covered by a patent,
898 and therefore we recommend you stop using it. We hope to have a
899 different compress program in the future. We may change the name of
900 this option at that time.
901 @end quotation
902
903 @table @samp
904 @item --compress
905 @itemx --uncompress
906 @itemx -z
907 @itemx -Z
908 When this option is specified, @code{tar} will compress (when writing
909 an archive), or uncompress (when reading an archive). Used in
910 conjunction with the @samp{--create}, @samp{--extract}, @samp{--list} and
911 @samp{--compare} operations.
912
913 @item --compress-block
914 @itemx -z -z
915 Acts like @samp{--compress}, but pads the archive out to the next block
916 boundary as it is written when used in conjunction with the
917 @samp{--create} operation.
918 @end table
919
920 @c >>> MIB -- why not use -Z instead of -z -z ? -ringo
921
922 @node Reading and Writing, Insuring Accuracy, Archive Structure, Top
923 @chapter Reading and Writing Archives
924
925 The @samp{--create} operation writes a new archive, and the
926 @samp{--extract} operation reads files from an archive and writes them
927 into the file system. You can use other @code{tar} operations to
928 write new information into an existing archive (adding files to it,
929 adding another archive to it, or deleting files from it), and you can
930 read a list of the files in an archive without extracting it using the
931 @samp{--list} operation.
932
933 @menu
934 * Archive Name:: The name of an archive
935 * Creating in Detail:: Creating in detail
936 * Modifying:: Modifying archives
937 * Listing Contents:: Listing the contents of an archive
938 * Extracting From Archives:: Extracting files from an archive
939 @end menu
940
941 @node Archive Name, Creating in Detail, Reading and Writing, Reading and Writing
942 @section The Name of an Archive
943 @cindex Naming an archive
944 @cindex Archive Name
945 @cindex Directing output
946 @cindex Where is the archive?
947
948 An archive can be saved as a file in the file system, sent through a
949 pipe or over a network, or written to an I/O device such as a tape or
950 disk drive. To specify the name of the archive, use the
951 @samp{--file=@var{archive-name}} option.
952
953 An archive name can be the name of an ordinary file or the name of an
954 I/O device. @code{tar} always needs an archive name---if you do not
955 specify an archive name, the archive name comes from the environment
956 variable @code{TAPE} or, if that variable is not specified, a default
957 archive name, which is usually the name of tape unit zero (ie.
958 /dev/tu00).
959
960 If you use @file{-} as an @var{archive-name}, @code{tar} reads the
961 archive from standard input (when listing or extracting files), or
962 writes it to standard output (when creating an archive). If you use
963 @file{-} as an @var{archive-name} when modifying an archive,
964 @code{tar} reads the original archive from its standard input and
965 writes the entire new archive to its standard output.
966
967 @c >>> MIB--does standard input and output redirection work with all
968 @c >>> operations?
969 @c >>> need example for standard input and output (screen and keyboard?)
970
971 @cindex Standard input and output
972 @cindex tar to standard input and output
973
974 To specify an archive file on a device attached to a remote machine,
975 use the following:
976
977 @example
978 --file=@var{hostname}:/@var{dev}/@var{file name}
979 @end example
980
981 @noindent
982 @code{tar} will complete the remote connection, if possible, and
983 prompt you for a username and password. If you use
984 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @code{tar}
985 will complete the remote connection, if possible, using your username
986 as the username on the remote machine.
987
988 @c >>>MIB --- is this clear?
989
990 @table @samp
991 @item --file=@var{archive-name}
992 @itemx -f @var{archive-name}
993 Names the archive to create or operate on. Use in conjunction with
994 any operation.
995 @end table
996
997 @node Creating in Detail, Modifying, Archive Name, Reading and Writing
998 @section Creating in Detail
999 @c operations should probably have examples, not tables.
1000 @cindex Writing new archives
1001 @cindex Archive creation
1002
1003 To create an archive, use @samp{tar --create}. To name the archive,
1004 use @samp{--file=@var{archive-name}} in conjunction with the
1005 @samp{--create} operation (@pxref{Archive Name}). If you do not name
1006 the archive, @code{tar} uses the value of the environment variable
1007 @code{TAPE} as the file name for the archive, or, if that is not
1008 available, @code{tar} uses a default archive name, usually that for tape
1009 unit zero. @xref{Archive Name}, for more information about specifying
1010 an archive name.
1011
1012 The following example creates an archive named @file{stooges},
1013 containing the files @file{larry}, @file{moe} and @file{curley}:
1014
1015 @example
1016 tar --create --file=stooges larry moe curley
1017 @end example
1018
1019 If you specify a directory name as a file-name argument, @code{tar}
1020 will archive all the files in that directory. The following example
1021 creates an archive named @file{hail/hail/fredonia}, containing the
1022 contents of the directory @file{marx}:
1023
1024 @example
1025 tar --create --file=hail/hail/fredonia marx
1026 @end example
1027
1028 If you don't specify files to put in the archive, @code{tar} archives
1029 all the files in the working directory. The following example creates
1030 an archive named @file{home} containing all the files in the working
1031 directory:
1032
1033 @example
1034 tar --create --file=home
1035 @end example
1036
1037 @xref{File Name Lists}, for other ways to specify files to archive.
1038
1039 Note: In the example above, an archive containing all the files in the
1040 working directory is being written to the working directory. GNU
1041 @code{tar} stores files in the working directory in an archive which
1042 is itself in the working directory without falling into an infinite
1043 loop. Other versions of @code{tar} may fall into this trap.
1044
1045 @node Modifying, Listing Contents, Creating in Detail, Reading and Writing
1046 @section Modifying Archives
1047 @cindex Modifying archives
1048
1049 Once an archive is created, you can add new archive members to it, add
1050 the contents of another archive, add newer versions of members already
1051 stored, or delete archive members already stored.
1052
1053 To find out what files are already stored in an archive, use @samp{tar
1054 --list --file=@var{archive-name}}. @xref{Listing Contents}.
1055
1056 @menu
1057 * Adding Files::
1058 * Appending Archives::
1059 * Deleting Archive Files:: Deleting Files From an Archive
1060 * Matching Format Parameters::
1061 @end menu
1062
1063 @node Adding Files, Appending Archives, Modifying, Modifying
1064 @subsection Adding Files to an Archive
1065 @cindex Adding files to an archive
1066 @cindex Updating an archive
1067
1068 To add files to an archive, use @samp{tar --add-file}. The archive to
1069 be added to must already exist and be in proper archive format (which
1070 normally means it was created previously using @code{tar}). If the
1071 archive was created with a different block size than now specified,
1072 @code{tar} will report an error (@pxref{Blocking Factor}). If the
1073 archive is not a valid @code{tar} archive, the results will be
1074 unpredictable. You cannot add files to a compressed archive, however
1075 you can add files to the last volume of a multi-volume archive.
1076 @xref{Matching Format Parameters}.
1077
1078 The following example adds the file @file{shemp} to the archive
1079 @file{stooges} created above:
1080
1081 @example
1082 tar --add-file --file=stooges shemp
1083 @end example
1084
1085 You must specify the files to be added; there is no default.
1086
1087 @samp{tar --update} acts like @samp{tar --add-file}, but does not add
1088 files to the archive if there is already a file entry with that name
1089 in the archive that has the same modification time.
1090
1091 Both @samp{--update} and @samp{--add-file} work by adding to the end of
1092 the archive. When you extract a file from the archive, only the
1093 version stored last will wind up in the file system. Because
1094 @samp{tar --extract} extracts files from an archive in sequence, and
1095 overwrites files with the same name in the file system, if a file name
1096 appears more than once in an archive the last version of the file will
1097 overwrite the previous versions which have just been extracted. You
1098 should avoid storing older versions of a file later in the archive.
1099
1100 Note: @samp{--update} is not suitable for performing backups, because
1101 it doesn't change directory content entries, and because it lengthens
1102 the archive every time it is used.
1103 @c <<< xref to scripted backup, listed incremental, for info on backups.
1104
1105 @node Appending Archives, Deleting Archive Files, Adding Files, Modifying
1106 @subsection Appending One Archive's Contents to Another Archive
1107 @cindex Adding archives to an archive
1108 @cindex Concatenating Archives
1109
1110 To append copies of an archive or archives to the end of another
1111 archive, use @samp{tar --add-archive}. The source and target archives
1112 must already exist and have been created using compatable format
1113 parameters (@pxref{Matching Format Parameters}).
1114
1115 @code{tar} will stop reading an archive if it encounters an
1116 end-of-archive marker. The @code{cat} utility does not remove
1117 end-of-archive markers, and is therefore unsuitable for concatenating
1118 archives. @samp{tar --add-archive} removes the end-of-archive marker
1119 from the target archive before each new archive is appended.
1120 @c <<< xref ignore-zeros
1121
1122 You must specify the source archives using
1123 @samp{--file=@var{archive-name}} (@pxref{Archive Name}). If you do not
1124 specify the target archive , @code{tar} uses the value of the
1125 environment variable @code{TAPE}, or, if this has not been set, the
1126 default archive name.
1127
1128 The following example adds the contents of the archive
1129 @file{hail/hail/fredonia} to the archive @file{stooges} (both archives
1130 were created in examples above):
1131
1132 @example
1133 tar --add-archive --file=stooges hail/hail/fredonia
1134 @end example
1135
1136 If you need to retrieve files from an archive that was added to using
1137 the @code{cat} utility, use the @samp{--ignore-zeros} option
1138 (@pxref{Archive Reading Options}).
1139
1140 @node Deleting Archive Files, Matching Format Parameters, Appending Archives, Modifying
1141 @subsection Deleting Files From an Archive
1142 @cindex Deleting files from an archive
1143 @cindex Removing files from an archive
1144
1145 To delete archive members from an archive, use @samp{tar --delete}.
1146 You must specify the file names of the members to be deleted. All
1147 archive members with the specified file names will be removed from the
1148 archive.
1149
1150 The following example removes the file @file{curley} from the archive
1151 @file{stooges}:
1152
1153 @example
1154 tar --delete --file=stooges curley
1155 @end example
1156
1157 You can only use @samp{tar --delete} on an archive if the archive
1158 device allows you to write to any point on the media.
1159
1160 @quotation
1161 @strong{Warning:} Don't try to delete an archive member from a
1162 magnetic tape, lest you scramble the archive. There is no safe way
1163 (except by completely re-writing the archive) to delete files from
1164 most kinds of magnetic tape.
1165 @end quotation
1166
1167 @c <<< MIB -- how about automatic detection of archive media? give error
1168 @c <<< unless the archive device is either an ordinary file or different
1169 @c <<< input and output (--file=-).
1170
1171 @node Matching Format Parameters, , Deleting Archive Files, Modifying
1172 @subsection Matching the Format Parameters
1173
1174 Some format parameters must be taken into consideration when modifying
1175 an archive:
1176
1177 Compressed archives cannot be modified.
1178
1179 You have to specify the block size of the archive when modifying an
1180 archive with a non-default block size.
1181
1182 Multi-volume archives can be modified like any other archive. To add
1183 files to a multi-volume archive, you need to only mount the last
1184 volume of the archive media (and new volumes, if needed). For all
1185 other operations, you need to use the entire archive.
1186
1187 If a multi-volume archive was labeled using @samp{--label}
1188 (@pxref{Archive Label}) when it was created, @code{tar} will not
1189 automatically label volumes which are added later. To label
1190 subsequent volumes, specify @samp{--label=@var{archive-label}} again in
1191 conjunction with the @samp{--add-file}, @samp{--update} or
1192 @samp{--add-archive} operation.
1193 @cindex Labelling multi-volume archives
1194 @c <<< example
1195
1196 @c <<< xref somewhere, for more information about format parameters.
1197
1198 @node Listing Contents, Extracting From Archives, Modifying, Reading and Writing
1199 @section Listing the Contents of an Archive
1200 @cindex Names of the files in an archive
1201 @cindex Archive contents, list of
1202 @cindex Archive members, list of
1203
1204 @samp{tar --list} prints a list of the file names of the archive
1205 members on the standard output. If you specify @var{file-name}
1206 arguments on the command line (or using the @samp{--files-from} option,
1207 @pxref{File Name Lists}), only the files you specify will be listed,
1208 and only if they exist in the archive. Files not specified will be
1209 ignored, unless they are under a specific directory.
1210
1211 If you include the @samp{--verbose} option, @code{tar} prints an
1212 @samp{ls -l} type listing for the archive. @pxref{Additional
1213 Information}, for a description of the @samp{--verbose} option.
1214
1215 If the blocking factor of the archive differs from the default,
1216 @code{tar} reports this. @xref{Blocking Factor}.
1217
1218 @xref{Archive Reading Options} for a list of options which can be used
1219 to modify @samp{--list}'s operation.
1220
1221 This example prints a list of the archive members of the archive
1222 @file{stooges}:
1223
1224 @example
1225 tar --list --file=stooges
1226 @end example
1227
1228 @noindent
1229 @code{tar} responds:
1230
1231 @example
1232 larry
1233 moe
1234 shemp
1235 marx/julius
1236 marx/alexander
1237 marx/karl
1238 @end example
1239
1240 This example generates a verbose list of the archive members of the
1241 archive file @file{dwarves}, which has a blocking factor of two:
1242
1243 @example
1244 tar --list -v --file=blocks
1245 @end example
1246
1247 @noindent
1248 @code{tar} responds:
1249
1250 @example
1251 tar: Blocksize = 2 records
1252 -rw------- ringo/user 42 May 1 13:29 1990 .bashful
1253 -rw-rw-rw- ringo/user 42 Oct 4 13:29 1990 doc
1254 -rw-rw-rw- ringo/user 42 Jul 20 18:01 1969 dopey
1255 -rw-rw---- ringo/user 42 Nov 26 13:42 1963 grumpy
1256 -rw-rw-rw- ringo/user 42 May 5 13:29 1990 happy
1257 -rw-rw-rw- ringo/user 42 May 1 12:00 1868 sleepy
1258 -rw-rw-rw- ringo/user 42 Jul 4 17:29 1776 sneezy
1259 @end example
1260
1261 @node Extracting From Archives, , Listing Contents, Reading and Writing
1262 @section Extracting Files from an Archive
1263 @cindex Extraction
1264 @cindex Retrieving files from an archive
1265 @cindex Resurrecting files from an archive
1266
1267 To read archive members from the archive and write them into the file
1268 system, use @samp{tar --extract}. The archive itself is left
1269 unchanged.
1270
1271 If you do not specify the files to extract, @code{tar} extracts all
1272 the files in the archive. If you specify the name of a directory as a
1273 file-name argument, @code{tar} will extract all files which have been
1274 stored as part of that directory. If a file was stored with a
1275 directory name as part of its file name, and that directory does not
1276 exist under the working directory when the file is extracted,
1277 @code{tar} will create the directory. @xref{Selecting Archive
1278 Members}, for information on specifying files to extract.
1279
1280 The following example shows the extraction of the archive
1281 @file{stooges} into an empty directory:
1282
1283 @example
1284 tar --extract --file=stooges
1285 @end example
1286
1287 @noindent
1288 Generating a listing of the directory (@samp{ls}) produces:
1289
1290 @example
1291 larry
1292 moe
1293 shemp
1294 marx
1295 @end example
1296
1297 @noindent
1298 The subdirectory @file{marx} contains the files @file{julius},
1299 @file{alexander} and @file{karl}.
1300
1301 If you wanted to just extract the files in the subdirectory
1302 @file{marx}, you could specify that directory as a file-name argument
1303 in conjunction with the @samp{--extract} operation:
1304
1305 @example
1306 tar --extract --file=stooges marx
1307 @end example
1308
1309 @quotation
1310 @strong{Warning:} Extraction can overwrite files in the file system.
1311 To avoid losing files in the file system when extracting files from
1312 the archive with the same name, use the @samp{--keep-old-files} option
1313 (@pxref{File Writing Options}).
1314 @end quotation
1315
1316 If the archive was created using @samp{--block-size}, @samp{--compress}
1317 or @samp{--multi-volume}, you must specify those format options again
1318 when extracting files from the archive (@pxref{Format Variations}).
1319
1320 @menu
1321 * Archive Reading Options::
1322 * File Writing Options::
1323 * Scarce Disk Space:: Recovering From Scarce Disk Space
1324 @end menu
1325
1326 @node Archive Reading Options, File Writing Options, Extracting From Archives, Extracting From Archives
1327 @subsection Options to Help Read Archives
1328 @cindex Options when reading archives
1329 @cindex Reading incomplete blocks
1330 @cindex Blocks, incomplete
1331 @cindex End of archive markers, ignoring
1332 @cindex Ignoring end of archive markers
1333 @cindex Large lists of file names on small machines
1334 @cindex Small memory
1335 @cindex Running out of space
1336
1337 @c <<< each option wants its own node. summary after menu
1338
1339 Normally, @code{tar} will request data in full block increments from
1340 an archive storage device. If the device cannot return a full block,
1341 @code{tar} will report an error. However, some devices do not always
1342 return full blocks, or do not require the last block of an archive to
1343 be padded out to the next block boundary. To keep reading until you
1344 obtain a full block, or to accept an incomplete block if it contains
1345 an end-of-archive marker, specify the @samp{--read-full-blocks} option
1346 in conjunction with the @samp{--extract} or @samp{--list} operations.
1347 @xref{Listing Contents}.
1348
1349 The @samp{--read-full-blocks} option is turned on by default when
1350 @code{tar} reads an archive from standard input, or from a remote
1351 machine. This is because on BSD Unix systems, attempting to read a
1352 pipe returns however much happens to be in the pipe, even if it is
1353 less than was requested. If this option were not enabled, @code{tar}
1354 would fail as soon as it read an incomplete block from the pipe.
1355
1356 If you're not sure of the blocking factor of an archive, you can read
1357 the archive by specifying @samp{--read-full-blocks} and
1358 @samp{--block-size=@var{n}}, where @var{n} is a blocking factor larger
1359 than the blocking factor of the archive. This lets you avoid having
1360 to determine the blocking factor of an archive. @xref{Blocking
1361 Factor}.
1362
1363 @table @samp
1364 @item --read-full-blocks
1365 @item -B
1366 Use in conjunction with @samp{tar --extract} to read an archive which
1367 contains incomplete blocks, or one which has a blocking factor less
1368 than the one specified.
1369 @end table
1370
1371 Normally @code{tar} stops reading when it encounters a block of zeros
1372 between file entries (which usually indicates the end of the archive).
1373 @samp{--ignore-zeros} allows @code{tar} to completely read an archive
1374 which contains a block of zeros before the end (i.e.@: a damaged
1375 archive, or one which was created by @code{cat}-ing several archives
1376 together).
1377
1378 The @samp{--ignore-zeros} option is turned off by default because many
1379 versions of @code{tar} write garbage after the end of archive entry,
1380 since that part of the media is never supposed to be read. GNU
1381 @code{tar} does not write after the end of an archive, but seeks to
1382 maintain compatablity among archiving utilities.
1383
1384 @table @samp
1385 @item --ignore-zeros
1386 @itemx -i
1387 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
1388 encountered while reading an archive. Use in conjunction with
1389 @samp{tar --extract} or @samp{tar --list}.
1390 @end table
1391
1392 If you are using a machine with a small amount of memory, and you need
1393 to process large list of file-names, you can reduce the amount of
1394 space @code{tar} needs to process the list. To do so, specify the
1395 @samp{--same-order} option and provide an ordered list of file names.
1396 This option tells @code{tar} that the @file{file-name} arguments
1397 (provided on the command line, or read from a file using the
1398 @samp{--files-from} option) are listed in the same order as the files
1399 in the archive.
1400
1401 You can create a file containing an ordered list of files in the
1402 archive by storing the output produced by @samp{tar --list
1403 --file=@var{archive-name}}. @xref{Listing Contents}, for information
1404 on the @samp{--list} operation.
1405
1406 This option is probably never needed on modern computer systems.
1407
1408 @table @samp
1409 @item --same-order
1410 @itemx --preserve-order
1411 @itemx -s
1412 To process large lists of file-names on machines with small amounts of
1413 memory. Use in conjunction with @samp{tar --compare}, @samp{tar --list}
1414 or @samp{tar --extract}.
1415 @end table
1416
1417 @c we don't need/want --preserve to exist any more
1418
1419 @node File Writing Options, Scarce Disk Space, Archive Reading Options, Extracting From Archives
1420 @subsection Changing How @code{tar} Writes Files
1421 @c <<< find a better title
1422 @cindex Overwriting old files, prevention
1423 @cindex Protecting old files
1424 @cindex Modification times of extracted files
1425 @cindex Permissions of extracted files
1426 @cindex Modes of extracted files
1427 @cindex Writing extracted files to standard output
1428 @cindex Standard output, writing extracted files to
1429
1430 Normally, @code{tar} writes extracted files into the file system
1431 without regard to the files already on the system---files with the
1432 same name as archive members are overwritten. To prevent @code{tar}
1433 from extracting an archive member from an archive, if doing so will
1434 overwrite a file in the file system, use @samp{--keep-old-files} in
1435 conjunction with the @samp{--extract} operation. When this option is
1436 specified, @code{tar} reports an error stating the name of the files
1437 in conflict, instead of writing the file from the archive.
1438
1439 @table @samp
1440 @item --keep-old files
1441 @itemx -k
1442 Prevents @code{tar} from overwriting files in the file system during
1443 extraction.
1444 @end table
1445
1446 Normally, @code{tar} sets the modification times of extracted files to
1447 the modification times recorded for the files in the archive, but
1448 limits the permissions of extracted files by the current @code{umask}
1449 setting.
1450
1451 To set the modification times of extracted files to the time when
1452 the files were extracted, use the @samp{--modification-time} option in
1453 conjunction with @samp{tar --extract}.
1454
1455 @table @samp
1456 @item --modification-time
1457 @itemx -m
1458 Sets the modification time of extracted archive members to the time
1459 they were extracted, not the time recorded for them in the archive.
1460 Use in conjunction with @samp{--extract}.
1461 @end table
1462
1463 To set the modes (access permissions) of extracted files to those
1464 recorded for those files in the archive, use the
1465 @samp{--preserve-permissions} option in conjunction with the
1466 @samp{--extract} operation.
1467 @c <<<mib --- should be aliased to ignore-umask.
1468
1469 @table @samp
1470 @item --preserve-permission
1471 @itemx --same-permission
1472 @itemx --ignore-umask
1473 @itemx -p
1474 Set modes of extracted archive members to those recorded in the
1475 archive, instead of current umask settings. Use in conjunction with
1476 @samp{--extract}.
1477 @end table
1478
1479 @c <<< following paragraph needs to be rewritten:
1480 @c <<< why doesnt' this cat files together, why is this useful. is it
1481 @c <<< really useful with more than one file?
1482 To write the files extracted to the standard output, instead of
1483 creating the files on the file system, use @samp{--to-stdout} in
1484 conjunction with @samp{tar --extract}. This option is useful if you
1485 are extracting files to send them through a pipe, and do not need to
1486 preserve them in the file system.
1487
1488 @table @samp
1489 @item --to-stdout
1490 @itemx -O
1491 Writes files to the standard output. Used in conjunction with
1492 @samp{--extract}.
1493 @end table
1494
1495 @c <<< why would you want to do such a thing, how are files separated on
1496 @c <<< the standard output? is this useful with more that one file? are
1497 @c <<< pipes the real reason?
1498
1499 @node Scarce Disk Space, , File Writing Options, Extracting From Archives
1500 @subsection Recovering From Scarce Disk Space
1501 @cindex Middle of the archive, starting in the
1502 @cindex Running out of space during extraction
1503 @cindex Disk space, running out of
1504 @cindex Space on the disk, recovering from lack of
1505
1506 If a previous attempt to extract files failed due to lack of disk
1507 space, you can use @samp{--starting-file=@var{file-name}} to start
1508 extracting only after file @var{file-name} when extracting files from
1509 the archive. This assumes, of course, that there is now free space,
1510 or that you are now extracting into a different file system.
1511
1512 @table @samp
1513 @item --starting-file=@var{file-name}
1514 @itemx -K @var{file-name}
1515 Starts an operation in the middle of an archive. Use in conjunction
1516 with @samp{--extract} or @samp{--list}.
1517 @end table
1518
1519 If you notice you are running out of disk space during an extraction
1520 operation, you can also suspend @code{tar}, remove unnecessary files
1521 from the file system, and then restart the same @code{tar} operation.
1522 In this case, @samp{--starting-file} is not necessary.
1523
1524 @c <<< xref incremental, xref --interactive, xref --exclude
1525
1526 @node Insuring Accuracy, Selecting Archive Members, Reading and Writing, Top
1527 @chapter Insuring the Accuracy of an Archive
1528
1529 You can insure the accuracy of an archive by comparing files in the
1530 system with archive members. @code{tar} can compare an archive to the
1531 file system as the archive is being written, to verify a write
1532 operation, or can compare a previously written archive, to insure that
1533 it is up to date.
1534
1535 @menu
1536 * Write Verification::
1537 * Comparing::
1538 @end menu
1539
1540 @node Write Verification, Comparing, Insuring Accuracy, Insuring Accuracy
1541 @section Verifying Data as It is Stored
1542 @cindex Verifying a write operation
1543 @cindex Double-checking a write operation
1544
1545 To check for discrepancies in an archive immediately after it is
1546 written, use the @samp{--verify} option in conjunction with the
1547 @samp{tar --create} operation. When this option is specified,
1548 @code{tar} checks archive members against their counterparts in the file
1549 system, and reports discrepancies on the standard error. In
1550 multi-volume archives, each volume is verified after it is written,
1551 before the next volume is written.
1552
1553 To verify an archive, you must be able to read it from before the end
1554 of the last written entry. This option is useful for detecting data
1555 errors on some tapes. Archives written to pipes, some cartridge tape
1556 drives, and some other devices cannot be verified.
1557
1558 @table @samp
1559 @item --verify
1560 @itemx -W
1561 Checks for discrepancies in the archive immediately after it is
1562 written. Use in conjunction with @samp{tar --create}.
1563 @end table
1564
1565 @node Comparing, , Write Verification, Insuring Accuracy
1566 @section Comparing an Archive with the File System
1567 @cindex Verifying the currency of an archive
1568
1569 @samp{tar --compare} compares archive members in an existing archive
1570 with their counterparts in the file system, and reports differences in
1571 file size, mode, owner, modification date and contents. If a file is
1572 represented in the archive but does not exist in the file system,
1573 @code{tar} reports a difference.
1574
1575 If you use @var{file-name} arguments in conjunction with @samp{tar
1576 --compare}, @code{tar} compares the archived versions of the files
1577 specified with their counterparts in the file system. If you specify
1578 a file that is not in the archive, @code{tar} will report an error. If
1579 you don't specify any files, @code{tar} compares all the files in the
1580 archive.
1581
1582 Because @code{tar} only checks files in the archive against files in
1583 the file system, and not vice versa, it ignores files in the file
1584 system that do not exist in the archive.
1585
1586 The following example compares the archive members @file{larry},
1587 @file{moe} and @file{curly} in the archive @file{stooges} with files
1588 of the same name in the file system.
1589
1590 @example
1591 tar --compare --file=stooges larry moe curly
1592 @end example
1593
1594 @noindent
1595 If a file, for example @file{curly}, did not exist in the archive,
1596 @code{tar} would report an error, as follows:
1597
1598 @example
1599 curly: does not exist
1600 @end example
1601
1602 @node Selecting Archive Members, User Interaction, Insuring Accuracy, Top
1603 @chapter Selecting Archive Members
1604 @cindex Specifying files to act on
1605 @cindex Specifying archive members
1606
1607 @dfn{File-name arguments} specify which files in the file system
1608 @code{tar} operates on, when creating or adding to an archive, or
1609 which archive members @code{tar} operates on, when reading or
1610 deleting from an archive. (@pxref{Reading and Writing}.)
1611
1612 To specify file names, you can include them as the last arguments on
1613 the command line, as follows:
1614 @example
1615 tar @var{operation} [@var{option1} @var{option2} ..] [@var{file-name-1} @var{file-name-2} ...]
1616 @end example
1617
1618 If you specify a directory name as a file name argument, all the files
1619 in that directory are operated on by @code{tar}.
1620
1621 If you do not specify files when @code{tar} is invoked, @code{tar}
1622 operates on all the non-directory files in the working directory (if
1623 the operation is @samp{--create}), all the archive members in the
1624 archive (if a read operation is specified), or does nothing (if any
1625 other operation is specified).
1626
1627 @menu
1628 * File Name Lists:: Reading File Names from a File
1629 * File Name Interpretation:: this needs a better title
1630 * File Exclusion:: so does this
1631 @end menu
1632
1633 @node File Name Lists, File Name Interpretation, Selecting Archive Members, Selecting Archive Members
1634 @section Reading a List of File Names from a File
1635 @cindex Lists of file names
1636 @cindex File-name arguments, alternatives
1637
1638 To read file names from a file on the file system, instead of from the
1639 command line, use the @samp{--files-from=@var{file}} option. If you
1640 specify @samp{-} as @var{file}, the file names are read from standard
1641 input. Note that using both @samp{--files-from=-} and @samp{--file=-}
1642 in the same command will not work unless the operation is
1643 @samp{--create}. @xref{Archive Name}, for an explanation of the
1644 @samp{--file} option.
1645
1646 @table @samp
1647 @item --files-from=@var{file}
1648 @itemx -T @var{file}
1649 Reads file-name arguments from a file on the file system, instead of
1650 from the command line. Use in conjunction with any operation.
1651 @end table
1652
1653 @node File Name Interpretation, File Exclusion, File Name Lists, Selecting Archive Members
1654 @section File Name Interpretation
1655 @cindex File Names, interpreting
1656
1657 @c <<<<add some text -ringo
1658
1659 @menu
1660 * Absolute File Names::
1661 * Changing Working Directory::
1662 * Archiving with Symbolic Links:: Archiving Using Symbolic Links
1663 @end menu
1664
1665 @node Absolute File Names, Changing Working Directory, File Name Interpretation, File Name Interpretation
1666 @subsection Storing and Extracting Files Relative to Root
1667
1668 @c <<< is this what this does, or does it just preserve the slash?
1669 @c <<< is it still called --absolute-paths?
1670
1671 @c To archive or extract files relative to the root directory, specify
1672 @c the @samp{--absolute-paths} option.
1673
1674 @c Normally, @code{tar} acts on files relative to the working
1675 @c directory---ignoring superior directory names when archiving, and
1676 @c ignoring leading slashes when extracting.
1677
1678 @c When you specify @samp{--absolute-paths}, @code{tar} stores file names
1679 @c including all superior directory names, and preserves leading slashes.
1680 @c If you only invoked @code{tar} from the root directory you would never
1681 @c need the @samp{--absolute-paths} option, but using this option may be
1682 @c more convenient than switching to root.
1683
1684 @c >>> should be an example in the tutorial/wizardry section using this
1685 @c >>> to transfer files between systems.
1686
1687 @c >>> is write access an issue?
1688
1689 @table @samp
1690 @item --absolute-paths
1691 Preserves full file names (inclusing superior dirctory names) when
1692 archiving files. Preserves leading slash when extracting files.
1693 @end table
1694
1695 @node Changing Working Directory, Archiving with Symbolic Links, Absolute File Names, File Name Interpretation
1696 @subsection Changing the Working Directory Within a List of File-names
1697 @cindex Directory, changing in mid-stream
1698 @cindex Working directory, specifying
1699
1700 To change working directory in the middle of a list of file names,
1701 (either on the command line or in a file specified using
1702 @samp{--files-from}), use @samp{--directory=@var{directory}}. This will
1703 change the working directory to the directory @var{directory} after
1704 that point in the list. For example,
1705
1706 @example
1707 tar --create iggy ziggy --directory=baz melvin
1708 @end example
1709
1710 @noindent
1711 will place the files @file{iggy} and @file{ziggy} from the current
1712 directory into the archive, followed by the file @file{melvin} from
1713 the directory @file{baz}. This option is especially useful when you
1714 have several widely separated files that you want to store in the same
1715 directory in the archive.
1716
1717 Note that the file @file{melvin} is recorded in the archive under the
1718 precise name @file{melvin}, @emph{not} @file{baz/melvin}. Thus, the
1719 archive will contain three files that all appear to have come from the
1720 same directory; if the archive is extracted with plain @samp{tar
1721 --extract}, all three files will be written in the current directory.
1722
1723 Contrast this with the command
1724
1725 @example
1726 tar -c iggy ziggy bar/melvin
1727 @end example
1728
1729 @noindent
1730 which records the third file in the archive under the name
1731 @file{bar/melvin} so that, if the archive is extracted using @samp{tar
1732 --extract}, the third file will be written in a subdirectory named
1733 @file{bar}.
1734
1735 @table @samp
1736 @item --directory=@file{directory}
1737 @itemx -C @file{directory}
1738 Changes the working directory.
1739 @end table
1740
1741 @c <<<need to test how extract deals with this, and add an example -ringo
1742
1743 @node Archiving with Symbolic Links, , Changing Working Directory, File Name Interpretation
1744 @subsection Archiving Using Symbolic Links
1745 @cindex File names, using symbolic links
1746 @cindex Symbolic link as file name
1747
1748 @samp{--dereference} is used with @samp{tar --create}, and causes
1749 @code{tar} to archive files which are referenced by a symbolic link,
1750 using the name of the link as the file name.
1751
1752 <<<this needs to be checked by MIB and then re-written, with an example
1753 The name under which the file is stored in the file system is not
1754 recorded in the archive. To record both the symbolic link name and
1755 the file name in the system, archive the file under both names. If
1756 all links were recorded automatically by @code{tar}, an extracted file
1757 might be linked to a file name that no longer exists in the file
1758 system.
1759
1760 @c <<< is the following still true? - ringo
1761 If a linked-to file is encountered again by @code{tar} while creating
1762 the same archive, an entire second copy of it will be stored. This
1763 could be considered a bug.
1764
1765 @table @samp
1766 @item --dereference
1767 @itemx -h
1768 Stores files referenced by a symbolic link, using the name of the link
1769 as the file name. Use in conjunction with any write operation.
1770 @end table
1771
1772 @node File Exclusion, , File Name Interpretation, Selecting Archive Members
1773 @section Selecting Files by Characteristic
1774 @cindex File names, excluding files by
1775 @cindex Excluding files by name and pattern
1776 @cindex Excluding files by file system
1777 @cindex File system boundaries, not crossing
1778 @cindex Excluding file by age
1779 @cindex Modification time, excluding files by
1780 @cindex Age, excluding files by
1781
1782 To avoid crossing file system boundaries when archiving parts of a
1783 directory tree, use @samp{--one-file-system}. This option only affects
1784 files that are archived because they are in a directory that is being
1785 archived; files explicitly named on the command line are archived
1786 regardless of where they reside.
1787
1788 This option is useful for making full or incremental archival backups
1789 of a file system.
1790
1791 If this option is used in conjunction with @samp{--verbose}, files that
1792 are excluded are mentioned by name on the standard error.
1793
1794 @table @samp
1795 @item --one-file-system
1796 @itemx -l
1797 Prevents @code{tar} from crossing file system boundaries when
1798 archiving. Use in conjunction with any write operation.
1799 @end table
1800
1801 To avoid operating on files whose names match a particular pattern,
1802 use the @samp{--exclude=@var{pattern}} or
1803 @samp{--exclude-from=@var{file}} options.
1804
1805 When you specify the @samp{--exclude=@var{pattern}} option, @code{tar}
1806 ignores files which match the @var{pattern}, which can be a single
1807 file name or a more complex expression. Thus, if you invoke
1808 @code{tar} with @samp{tar --create --exclude=*.o}, no files whose names
1809 end in @file{.o} are included in the archive.
1810 @c <<< what other things can you use besides "*"?
1811
1812 @samp{--exclude-from=@var{file}} acts like @samp{--exclude}, but
1813 specifies a file @var{file} containing a list of patterns. @code{tar}
1814 ignores files with names that fit any of these patterns.
1815
1816 You can use either option more than once in a single command.
1817
1818 @table @samp
1819 @item --exclude=@var{pattern}
1820 Causes @code{tar} to ignore files that match the @var{pattern}.
1821
1822 @item --exclude-from=@var{file}
1823 Causes @code{tar} to ignore files that match the patterns listed in
1824 @var{file}.
1825 @end table
1826 @c --exclude-from used to be "--exclude", --exclude didn't used to exist.
1827
1828 To operate only on files with modification or status-change times
1829 after a particular date, use @samp{--after-date=@var{date}}. You can
1830 use this option with @samp{tar --create} or @samp{tar --add-file} to
1831 insure only new files are archived, or with @samp{tar --extract} to
1832 insure only recent files are resurrected. @refill
1833 @c --after-date @var{date} or --newer @var{date}
1834
1835 @samp{--newer-mtime=@var{date}} acts like @samp{--after-date=@var{date}},
1836 but tests just the modification times of the files, ignoring
1837 status-change times.
1838
1839 @c <<<need example of --newer-mtime with quoted argument
1840 Remember that the entire date argument should be quoted if it contains
1841 any spaces.
1842
1843
1844 @strong{Please Note:} @samp{--after-date} and @samp{--newer-mtime}
1845 should not be used for incremental backups. Some files (such as those
1846 in renamed directories) are not selected up properly by these options.
1847 @c xref to incremental backup chapter when node name is decided.
1848
1849 @table @samp
1850 @item --after-date=@var{date}
1851 @itemx --newer=@var{date}
1852 @itemx -N @var{date}
1853 Acts on files only if their modification or inode-changed times are
1854 later than @var{date}. Use in conjunction with any operation.
1855 @item --newer-mtime=@var{date}
1856 Acts like @samp{--after-date}, but only looks at modification times.
1857 @end table
1858
1859 @c <<< following is the getdate date format --- needs to be re-written,
1860 @c <<< made a sub-node:
1861
1862 Time/Date Formats Accepted by getdate
1863 (omitting obscure constructions)
1864
1865 The input consists of one or more of: time zone day date year
1866 in any order.
1867
1868 Those in turn consist of (`|' and `/' mean `or', `[]' means `optional'):
1869
1870 time: H am/pm | H:M [am/pm] | H:M:S [am/pm]
1871 zone: timezone-name | timezone-name dst
1872 day: day-name | day-name, | N day-name
1873 date: M/D | M/D/Y | month-name D | month-name D, Y | D month-name | D month-name Y
1874 year: Y
1875
1876 am can also be a.m., pm can also be p.m.
1877 case and spaces around punctuation are not significant.
1878 month and day names can be abbreviated. >>>
1879
1880 @node User Interaction, Backups and Restoration, Selecting Archive Members, Top
1881 @chapter User Interaction
1882 @cindex Getting more information during the operation
1883 @cindex Information during operation
1884 @cindex Feedback from @code{tar}
1885
1886 Once you have typed a @code{tar}command, it is usually performed
1887 without any further information required of the user, or provided by
1888 @code{tar}. The following options allow you to generate progress and
1889 status information during an operation, or to confirm operations on
1890 files as they are performed.
1891
1892 @menu
1893 * Additional Information::
1894 * Interactive Operation::
1895 @end menu
1896
1897 @node Additional Information, Interactive Operation, User Interaction, User Interaction
1898 @section Progress and Status Information
1899 @cindex Progress information
1900 @cindex Status information
1901 @cindex Information on progress and status of operations
1902 @cindex Verbose operation
1903 @cindex Record number where error occured
1904 @cindex Error message, record number of
1905 @cindex Version of the @code{tar} program
1906
1907 Typically, @code{tar} performs most operations without reporting any
1908 information to the user except error messages. If you have
1909 encountered a problem when operating on an archive, however, you may
1910 need more information than just an error message in order to solve the
1911 problem. The following options can be helpful diagnostic tools.
1912
1913 When used with most operations, @samp{--verbose} causes @code{tar} to
1914 print the file names of the files or archive members it is operating
1915 on. When used with @samp{tar --list}, the verbose option causes
1916 @code{tar} to print out an @samp{ls -l} type listing of the files in
1917 the archive.
1918
1919 Verbose output appears on the standard output except when an archive
1920 is being written to the standard output (as with @samp{tar --create
1921 --file=- --verbose}). In that case @code{tar} writes verbose output to
1922 the standard error stream.
1923
1924 @table @samp
1925 @item --verbose
1926 @itemx -v
1927 Prints the names of files or archive members as they are being
1928 operated on. Can be used in conjunction with any operation. When
1929 used with @samp{--list}, generates an @samp{ls -l} type listing.
1930 @end table
1931
1932 To find out where in an archive a message was triggered, use
1933 @samp{--record-number}. @samp{--record-number} causes @code{tar} to
1934 print, along with every message it produces, the record number within
1935 the archive where the message was triggered.
1936
1937 This option is especially useful when reading damaged archives, since
1938 it helps pinpoint the damaged sections. It can also be used with
1939 @samp{tar --list} when listing a file-system backup tape, allowing you
1940 to choose among several backup tapes when retrieving a file later, in
1941 favor of the tape where the file appears earliest (closest to the
1942 front of the tape).
1943 @c <<< xref when the node name is set and the backup section written
1944
1945 @table @samp
1946 @item --record-number
1947 @itemx -R
1948 Prints the record number whenever a message is generated by
1949 @code{tar}. Use in conjunction with any operation.
1950 @end table
1951
1952 @c rewrite below
1953 To print the version number of the @code{tar} program, use @samp{tar
1954 --version}. @code{tar} prints the version number to the standard
1955 error. For example:
1956
1957 @example
1958 tar --version
1959 @end example
1960
1961 @noindent
1962 might return:
1963
1964 @example
1965 GNU tar version 1.09
1966 @end example
1967 @c used to be an option. has been fixed.
1968
1969 @node Interactive Operation, , Additional Information, User Interaction
1970 @section Asking for Confirmation During Operations
1971 @cindex Interactive operation
1972
1973 Typically, @code{tar} carries out a command without stopping for
1974 further instructions. In some situations however, you
1975 may want to exclude some files and archive members from the operation
1976 (for instance if disk or storage space is tight). You can do this by
1977 excluding certain files automatically (@pxref{File Exclusion}), or by
1978 performing an operation interactively, using the @samp{--interactive}
1979 operation.
1980
1981 When the @samp{--interactive} option is specified, @code{tar} asks for
1982 confirmation before reading, writing, or deleting each file it
1983 encounters while carrying out an operation. To confirm the action you
1984 must type a line of input beginning with @samp{y}. If your input line
1985 begins with anything other than @samp{y}, @code{tar} skips that file.
1986
1987 Commands which might be useful to perform interactively include
1988 appending files to an archive, extracting files from an archive,
1989 deleting a file from an archive, and deleting a file from disk during
1990 an incremental restore.
1991
1992 If @code{tar} is reading the archive from the standard input,
1993 @code{tar} opens the file @file{/dev/tty} to support the interactive
1994 communications.
1995 <<< this aborts if you won't OK the working directory. this is a bug. -ringo
1996
1997 @table @samp
1998 @item --interactive
1999 @itemx --confirmation
2000 @itemx -w
2001 Asks for confirmation before reading, writing or deleting an archive
2002 member (when listing, comparing or writing an archive or deleting
2003 archive members), or before writing or deleting a file (when
2004 extracting an archive).
2005 @end table
2006
2007 @node Backups and Restoration, Media, User Interaction, Top
2008 @chapter Performing Backups and Restoring Files
2009
2010 To @dfn{back up} a file system means to create archives that contain
2011 all the files in that file system. Those archives can then be used to
2012 restore any or all of those files (for instance if a disk crashes or a
2013 file is accidently deleted). File system @dfn{backups} are also
2014 called @dfn{dumps}.
2015
2016 @menu
2017 * Backup Levels:: Levels of backups
2018 * Backup Scripts:: Using scripts to perform backups
2019 and restoration
2020 * incremental and listed-incremental:: The --incremental
2021 and --listed-incremental Options
2022 * Problems:: Some common problems and their solutions
2023 @end menu
2024
2025 @node Backup Levels, Backup Scripts, Backups and Restoration, Backups and Restoration
2026 @section Levels of Backups
2027
2028 An archive containing all the files in the file system is called a
2029 @dfn{full backup} or @dfn{full dump}. You could insure your data by
2030 creating a full dump every day. This strategy, however, would waste a
2031 substantial amount of archive media and user time, as unchanged files
2032 are daily re-archived.
2033
2034 It is more efficient to do a full dump only occasionally. To back up
2035 files between full dumps, you can a incremental dump. A @dfn{level
2036 one} dump archives all the files that have changed since the last full
2037 dump.
2038
2039 A typical dump strategy would be to perform a full dump once a week,
2040 and a level one dump once a day. This means some versions of files
2041 will in fact be archived more than once, but this dump strategy makes
2042 it possible to restore a file system to within one day of accuracy by
2043 only extracting two archives---the last weekly (full) dump and the
2044 last daily (level one) dump. The only information lost would be in
2045 files changed or created since the last daily backup. (Doing dumps
2046 more than once a day is usually not worth the trouble).
2047
2048 @node Backup Scripts, incremental and listed-incremental, Backup Levels, Backups and Restoration
2049 @section Using Scripts to Perform Backups and Restoration
2050
2051 GNU @code{tar} comes with scripts you can use to do full and level-one
2052 dumps. Using scripts (shell programs) to perform backups and
2053 restoration is a convenient and reliable alternative to typing out
2054 file name lists and @code{tar} commands by hand.
2055
2056 Before you use these scripts, you need to edit the file
2057 @file{backup-specs}, which specifies parameters used by the backup
2058 scripts and by the restore script. @xref{Script Syntax}.
2059 Once the backup parameters are set, you can perform backups or
2060 restoration by running the appropriate script.
2061
2062 The name of the restore script is @code{restore}. The names of the
2063 level one and full backup scripts are, respectively, @code{level-1} and
2064 @code{level-0}. The @code{level-0} script also exists under the name
2065 @code{weekly}, and the @code{level-1} under the name
2066 @code{daily}---these additional names can be changed according to your
2067 backup schedule. @xref{Scripted Restoration}, for more information
2068 on running the restoration script. @xref{Scripted Backups}, for more
2069 information on running the backup scripts.
2070
2071 @emph{Please Note:} The backup scripts and the restoration scripts are
2072 designed to be used together. While it is possible to restore files
2073 by hand from an archive which was created using a backup script, and
2074 to create an archive by hand which could then be extracted using the
2075 restore script, it is easier to use the scripts. @xref{incremental
2076 and listed-incremental}, before making such an attempt.
2077
2078 @c shorten node names
2079 @menu
2080 * Backup Parameters:: Setting parameters for backups and restoration
2081 * Scripted Backups:: Using the backup scripts
2082 * Scripted Restoration:: Using the restore script
2083 @end menu
2084
2085 @node Backup Parameters, Scripted Backups, Backup Scripts, Backup Scripts
2086 @subsection Setting Parameters for Backups and Restoration
2087
2088 The file @file{backup-specs} specifies backup parameters for the
2089 backup and restoration scripts provided with @code{tar}. You must
2090 edit @file{backup-specs} to fit your system configuration and schedule
2091 before using these scripts.
2092
2093 @c <<< This about backup scripts needs to be written:
2094 @c <<<BS is a shell script .... thus ... @file{backup-specs} is in shell
2095 @c script syntax. @xref{Script Syntax}, for an explanation of this
2096 @c syntax.
2097
2098 @c whats a parameter .... looked at by the backup scripts ... which will
2099 @c be expecting to find ... now syntax ... value is linked to lame ...
2100 @c @file{backup-specs} specifies the following parameters:
2101
2102
2103 @table @code
2104 @item ADMINISTRATOR
2105 The user name of the backup administrator.
2106
2107 @item BACKUP_HOUR
2108 The hour at which the backups are done. This can be a number from 0
2109 to 23, or the string @samp{now}.
2110
2111 @item TAPE_FILE
2112 The device @code{tar} writes the archive to. This device should be
2113 attached to the host on which the dump scripts are run.
2114 @c <<< examples for all ...
2115
2116 @item TAPE_STATUS
2117 The command to use to obtain the status of the archive device,
2118 including error count. On some tape drives there may not be such a
2119 command; in that case, simply use `TAPE_STATUS=false'.
2120
2121 @item BLOCKING
2122 The blocking factor @code{tar} will use when writing the dump archive.
2123 @xref{Blocking Factor}.
2124
2125 @item BACKUP_DIRS
2126 A list of file systems to be dumped. You can include any directory
2127 name in the list---subdirectories on that file system will be
2128 included, regardless of how they may look to other networked machines.
2129 Subdirectories on other file systems will be ignored.
2130
2131 The host name specifies which host to run @code{tar} on, and should
2132 normally be the host that actually contains the file system. However,
2133 the host machine must have GNU @code{tar} installed, and must be able
2134 to access the directory containing the backup scripts and their
2135 support files using the same file name that is used on the machine
2136 where the scripts are run (ie. what @code{pwd} will print when in that
2137 directory on that machine). If the host that contains the file system
2138 does not have this capability, you can specify another host as long as
2139 it can access the file system through NFS.
2140
2141 @item BACKUP_FILES
2142 A list of individual files to be dumped. These should be accessible
2143 from the machine on which the backup script is run.
2144 @c <<<same file name, be specific. through nfs ...
2145 @end table
2146
2147 @menu
2148 * backup-specs example:: An Example Text of @file{Backup-specs}
2149 * Script Syntax:: Syntax for @file{Backup-specs}
2150 @end menu
2151
2152 @node backup-specs example, Script Syntax, Backup Parameters, Backup Parameters
2153 @subsubsection An Example Text of @file{Backup-specs}
2154
2155 The following is the text of @file{backup-specs} as it appears at FSF:
2156
2157 @example
2158 # site-specific parameters for file system backup.
2159
2160 ADMINISTRATOR=friedman
2161 BACKUP_HOUR=1
2162 TAPE_FILE=/dev/nrsmt0
2163 TAPE_STATUS="mts -t $TAPE_FILE"
2164 BLOCKING=124
2165 BACKUP_DIRS="
2166 albert:/fs/fsf
2167 apple-gunkies:/gd
2168 albert:/fs/gd2
2169 albert:/fs/gp
2170 geech:/usr/jla
2171 churchy:/usr/roland
2172 albert:/
2173 albert:/usr
2174 apple-gunkies:/
2175 apple-gunkies:/usr
2176 gnu:/hack
2177 gnu:/u
2178 apple-gunkies:/com/mailer/gnu
2179 apple-gunkies:/com/archive/gnu"
2180
2181 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
2182
2183 @end example
2184
2185 @node Script Syntax, , backup-specs example, Backup Parameters
2186 @subsubsection Syntax for @file{Backup-specs}
2187
2188 @file{backup-specs} is in shell script syntax. The following
2189 conventions should be considered when editing the script:
2190 @c <<< "conventions?"
2191
2192 A quoted string is considered to be contiguous, even if it is on more
2193 than one line. Therefore, you cannot include commented-out lines
2194 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
2195 the two most likely parameters to be multi-line.
2196
2197 A quoted string typically cannot contain wildcards. In
2198 @file{backup-specs}, however, the parameters BACKUP_DIRS and
2199 BACKUP_FILES can contain wildcards.
2200
2201 @node Scripted Backups, Scripted Restoration, Backup Parameters, Backup Scripts
2202 @subsection Using the Backup Scripts
2203
2204 The syntax for running a backup script is:
2205
2206 @example
2207 @file{script-name} [@var{time-to-be-run}]
2208 @end example
2209
2210 where @var{time-to-be-run} can be a specific system time, or can be
2211 @kbd{now}. If you do not specify a time, the script runs at the time
2212 specified in @file{backup-specs} (@pxref{Script Syntax}).
2213
2214 You should start a script with a tape or disk mounted. Once you start
2215 a script, it prompts you for new tapes or disks as it needs them.
2216 Media volumes don't have to correspond to archive files---a
2217 multi-volume archive can be started in the middle of a tape that
2218 already contains the end of another multi-volume archive. The
2219 @code{restore} script prompts for media by its archive volume, so to
2220 avoid an error message you should keep track of which tape (or disk)
2221 contains which volume of the archive. @xref{Scripted Restoration}.
2222
2223 @c <<<have file names changed? -ringo
2224 The backup scripts write two files on the file system. The first is a
2225 record file in @file{/etc/tar-backup/}, which is used by the scripts
2226 to store and retrieve information about which files were dumped. This
2227 file is not meant to be read by humans, and should not be deleted by
2228 them. @xref{incremental and listed-incremental}, for a more
2229 detailed explanation of this file.
2230
2231 The second file is a log file containing the names of the file systems
2232 and files dumped, what time the backup was made, and any error
2233 messages that were generated, as well as how much space was left in
2234 the media volume after the last volume of the archive was written.
2235 You should check this log file after every backup. The file name is
2236 @file{log-@var{mmm-ddd-yyyy}-level-1} or
2237 @file{log-@var{mmm-ddd-yyyy}-full}.
2238
2239 The script also prints the name of each system being dumped to the
2240 standard output.
2241 @c <<<the section on restore scripts is commented out.
2242 @c <<< a section on non-scripted testore mya be a good idea
2243 @ignore
2244 @node Scripted Restoration, , Scripted Backups, Backup Scripts
2245 @subsection Using the Restore Script
2246 @c subject to change as things develop
2247
2248 To restore files that were archived using a scripted backup, use the
2249 @code{restore} script. The syntax for the script is:
2250
2251
2252 where ##### are the file systems to restore from, and
2253 ##### is a regular expression which specifies which files to
2254 restore. If you specify --all, the script restores all the files
2255 in the file system.
2256
2257 You should start the restore script with the media containing the
2258 first volume of the archive mounted. The script will prompt for other
2259 volumes as they are needed. If the archive is on tape, you don't need
2260 to rewind the tape to to its beginning---if the tape head is
2261 positioned past the beginning of the archive, the script will rewind
2262 the tape as needed. @xref{Media}, for a discussion of tape
2263 positioning.
2264
2265 If you specify @samp{--all} as the @var{files} argument, the
2266 @code{restore} script extracts all the files in the archived file
2267 system into the active file system.
2268
2269 @quotation
2270 @strong{Warning:}The script will delete files from the active file
2271 system if they were not in the file system when the archive was made.
2272 @end quotation
2273
2274 @xref{incremental and listed-incremental}, for an explanation of how
2275 the script makes that determination.
2276 @c this may be an option, not a given
2277 @end ignore
2278
2279 @node incremental and listed-incremental, Problems, Backup Scripts, Backups and Restoration
2280 @section The @code{--incremental} and @code{--listed-incremental} Options
2281
2282 @samp{--incremental} is used in conjunction with @samp{--create},
2283 @samp{--extract} or @samp{--list} when backing up and restoring file
2284 systems. An archive cannot be extracted or listed with the
2285 @samp{--incremental} option specified unless it was created with the
2286 option specified. This option should only be used by a script, not by
2287 the user, and is usually disregarded in favor of
2288 @samp{--listed-incremental}, which is described below.
2289
2290 @samp{--incremental} in conjunction with @samp{--create} causes
2291 @code{tar} to write, at the beginning of the archive, an entry for
2292 each of the directories that will be archived. The entry for a
2293 directory includes a list of all the files in the directory at the
2294 time the archive was created and a flag for each file indicating
2295 whether or not the file is going to be put in the archive.
2296
2297 Note that this option causes @code{tar} to create a non-standard
2298 archive that may not be readable by non-GNU versions of the @code{tar}
2299 program.
2300
2301 @samp{--incremental} in conjunction with @samp{--extract} causes
2302 @code{tar} to read the lists of directory contents previously stored
2303 in the archive, @emph{delete} files in the file system that did not
2304 exist in their directories when the archive was created, and then
2305 extract the files in the archive.
2306
2307 This behavior is convenient when restoring a damaged file system from
2308 a succession of incremental backups: it restores the entire state of
2309 the file system to that which obtained when the backup was made. If
2310 @samp{--incremental} isn't specified, the file system will probably
2311 fill up with files that shouldn't exist any more.
2312
2313 @samp{--incremental} in conjunction with @samp{--list}, causes
2314 @code{tar} to print, for each directory in the archive, the list of
2315 files in that directory at the time the archive was created. This
2316 information is put out in a format that is not easy for humans to
2317 read, but which is unambiguous for a program: each file name is
2318 preceded by either a @samp{Y} if the file is present in the archive,
2319 an @samp{N} if the file is not included in the archive, or a @samp{D}
2320 if the file is a directory (and is included in the archive). Each
2321 file name is terminated by a null character. The last file is followed
2322 by an additional null and a newline to indicate the end of the data.
2323
2324 @samp{--listed-incremental}=@var{file} acts like @samp{--incremental},
2325 but when used in conjunction with @samp{--create} will also cause
2326 @code{tar} to use the file @var{file}, which contains information
2327 about the state of the file system at the time of the last backup, to
2328 decide which files to include in the archive being created. That file
2329 will then be updated by @code{tar}. If the file @var{file} does not
2330 exist when this option is specified, @code{tar} will create it, and
2331 include all appropriate files in the archive.
2332
2333 The file @var{file}, which is archive independent, contains the date
2334 it was last modified and a list of devices, inode numbers and
2335 directory names. @code{tar} will archive files with newer mod dates
2336 or inode change times, and directories with an unchanged inode number
2337 and device but a changed directory name. The file is updated after
2338 the files to be archived are determined, but before the new archive is
2339 actually created.
2340
2341 @c <<< this section needs to be written
2342 @node Problems, , incremental and listed-incremental, Backups and Restoration
2343 @section Some Common Problems and their Solutions
2344
2345 errors from system:
2346 permission denied
2347 no such file or directory
2348 not owner
2349
2350 errors from tar:
2351 directory checksum error
2352 header format error
2353
2354 errors from media/system:
2355 i/o error
2356 device busy
2357
2358 @node Media, Quick Reference, Backups and Restoration, Top
2359 @chapter Tapes and Other Archive Media
2360
2361 Archives are usually written on dismountable media---tape cartridges,
2362 mag tapes, or floppy disks.
2363
2364 The amount of data a tape or disk holds depends not only on its size,
2365 but also on how it is formatted. A 2400 foot long reel of mag tape
2366 holds 40 megabytes of data when formated at 1600 bits per inch. The
2367 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
2368
2369 Magnetic media are re-usable---once the archive on a tape is no longer
2370 needed, the archive can be erased and the tape or disk used over.
2371 Media quality does deteriorate with use, however. Most tapes or disks
2372 should be disgarded when they begin to produce data errors. EXABYTE
2373 tape cartridges should be disgarded when they generate an @dfn{error
2374 count} (number of non-usable bits) of more than 10k.
2375
2376 Magnetic media are written and erased using magnetic fields, and
2377 should be protected from such fields to avoid damage to stored data.
2378 Sticking a floppy disk to a filing cabinet using a magnet is probably
2379 not a good idea.
2380
2381
2382 @menu
2383 * Write Protection:: Write Protection
2384 * Tape Positioning:: Tape Positions and Tape Marks
2385 @end menu
2386
2387 @node Write Protection, Tape Positioning, Media, Media
2388 @section Write Protection
2389
2390 All tapes and disks can be @dfn{write protected}, to protect data on
2391 them from being changed. Once an archive is written, you should write
2392 protect the media to prevent the archive from being accidently
2393 overwritten or deleted. (This will protect the archive from being
2394 changed with a tape or floppy drive---it will not protect it from
2395 magnet fields or other physical hazards).
2396
2397 The write protection device itself is usually an integral part of the
2398 physical media, and can be a two position (write enabled/write
2399 disabled) switch, a notch which can be popped out or covered, a ring
2400 which can be removed from the center of a tape reel, or some other
2401 changeable feature.
2402
2403 @node Tape Positioning, , Write Protection, Media
2404 @section Tape Positions and Tape Marks
2405
2406 Just as archives can store more than one file from the file system,
2407 tapes can store more than one archive file. To keep track of where
2408 archive files (or any other type of file stored on tape) begin and
2409 end, tape archive devices write magnetic @dfn{tape marks} on the
2410 archive media. Tape drives write one tape mark between files,
2411 two at the end of all the file entries.
2412
2413 If you think of data as a series of "0000"'s, and tape marks as "x"'s,
2414 a tape might look like the following:
2415
2416 @example
2417 0000x000000x00000x00x00000xx-------------------------
2418 @end example
2419
2420 Tape devices read and write tapes using a read/write @dfn{tape
2421 head}---a physical part of the device which can only access one point
2422 on the tape at a time. When you use @code{tar} to read or write
2423 archive data from a tape device, the device will begin reading or
2424 writing from wherever on the tape the tape head happens to be,
2425 regardless of which archive or what part of the archive the tape head
2426 is on. Before writing an archive, you should make sure that no data
2427 on the tape will be overwritten (unless it is no longer needed).
2428 Before reading an archive, you should make sure the tape head is at
2429 the beginning of the archive you want to read. (The @code{restore}
2430 script will find the archive automatically. @xref{Scripted
2431 Restoration}). @xref{mt}, for an explanation of the tape moving
2432 utility.
2433
2434 If you want to add new archive file entries to a tape, you should
2435 advance the tape to the end of the existing file entries, backspace
2436 over the last tape mark, and write the new archive file. If you were
2437 to add two archives to the example above, the tape might look like the
2438 following:
2439
2440 @example
2441 0000x000000x00000x00x00000x000x0000xx----------------
2442 @end example
2443
2444 @menu
2445 * mt:: The @code{mt} Utility
2446 @end menu
2447
2448 @node mt, , Tape Positioning, Tape Positioning
2449 @subsection The @code{mt} Utility
2450
2451 <<< is it true that this only works on non-block devices? should
2452 <<< explain the difference, xref to block-size (fixed or variable).
2453
2454 You can use the @code{mt} utility to advance or rewind a tape past a
2455 specified number of archive files on the tape. This will allow you to
2456 move to the beginning of an archive before extracting or reading it,
2457 or to the end of all the archives before writing a new one.
2458 @c why isn't there an "advance 'til you find two tape marks together"?
2459
2460 The syntax of the @code{mt} command is:
2461
2462 @example
2463 mt [-f @var{tapename}] @var{operation} [@var{number}]
2464 @end example
2465
2466 where @var{tapename} is the name of the tape device, @var{number} is
2467 the number of times an operation is performed (with a default of one),
2468 and @var{operation} is one of the following:
2469
2470 @table @code
2471 @item eof
2472 @itemx weof
2473 Writes @var{number} tape marks at the current position on the tape.
2474
2475
2476 @item fsf
2477 Moves tape position forward @var{number} files.
2478
2479
2480 @item bsf
2481 Moves tape position back @var{number} files.
2482
2483
2484 @item rewind
2485 Rewinds the tape. (Ignores @var{number}).
2486
2487
2488 @item offline
2489 @itemx rewoff1
2490 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
2491
2492
2493 @item status
2494 Prints status information about the tape unit.
2495 @end table
2496 <<< is there a better way to frob the spacing on the list? -ringo
2497
2498 If you don't specify a @var{tapename}, @code{mt} uses the environment
2499 variable TAPE; if TAPE does not exist, @code{mt} uses the device
2500 @file{/dev/rmt12}.
2501
2502 @code{mt} returns a 0 exit status when the operation(s) were
2503 successful, 1 if the command was unrecognized, and 2 if an operation
2504 failed.
2505
2506 @c <<< new node on how to find an archive? -ringo
2507 If you use @code{tar --extract} with the
2508 @samp{--label=@var{archive-name}} option specified, @code{tar} will
2509 read an archive label (the tape head has to be positioned on it) and
2510 print an error if the archive label doesn't match the
2511 @var{archive-name} specified. @var{archive-name} can be any regular
2512 expression. If the labels match, @code{tar} extracts the archive.
2513 @xref{Archive Label}. @xref{Matching Format Parameters}.
2514 <<< fix cross references
2515
2516 @code{tar --list --label} will cause @code{tar} to print the label.
2517
2518 @c <<< MIB -- program to list all the labels on a tape?
2519
2520 @node Quick Reference, Data Format Details, Media, Top
2521 @appendix A Quick Reference Guide to @code{tar} Operations and Options
2522 @c put in proper form for appendix. (unnumbered?)
2523
2524 @menu
2525 * Operations:: A Table of Operations
2526 * Options:: Table of Options
2527 @end menu
2528
2529 @node Operations, Options, Quick Reference, Quick Reference
2530 @appendixsec A Table of Operations
2531 @c add xrefs, note synonyms
2532
2533 The operation argument to @code{tar} specifies which action you want to
2534 take.
2535
2536 @table @samp
2537 @item -A
2538 Adds copies of an archive or archives to the end of another archive.
2539
2540 @item -c
2541 Creates a new archive.
2542
2543 @item -d
2544 Compares files in the archive with their counterparts in the file
2545 system, and reports differences in file size, mode, owner,
2546 modification date and contents.
2547
2548 @item -r
2549 Adds files to the end of the archive.
2550
2551 @item -t
2552 Prints a list of the contents of the archive.
2553
2554 @item -x
2555 Reads files from the archive and writes them into the active file
2556 system.
2557
2558 @item -u
2559 Adds files to the end of the archive, but only if they are newer than
2560 their counterparts already in the archive, or if they do not already
2561 exist in the archive.
2562
2563 @item --add-archive
2564 Adds copies of an archive or archives to the end of another archive.
2565
2566 @item --add-file
2567 Adds files to the end of the archive.
2568
2569 @item --append
2570 Adds files to the end of the archive.
2571
2572 @item --catenate
2573 Adds copies of an archive or archives to the end of another archive.
2574
2575 @item --compare
2576 Compares files in the archive with their counterparts in the file
2577 system, and reports differences in file size, mode, owner,
2578 modification date and contents.
2579
2580 @item --concatenate
2581 Adds copies of an archive or archives to the end of another archive.
2582
2583 @item --create
2584 Creates a new archive.
2585
2586 @item --delete
2587 Deletes files from the archive. All versions of the files are deleted.
2588
2589 @item --diff
2590 Compares files in the archive with their counterparts in the file
2591 system, and reports differences in file size, mode, owner,
2592 modification date and contents.
2593
2594 @item --extract
2595 Reads files from the archive and writes them into the active file
2596 system.
2597
2598 @item --get
2599 Reads files from the archive and writes them into the active file
2600 system.
2601
2602 @item --help
2603 Prints a list of @code{tar} operations and options.
2604
2605 @item --list
2606 Prints a list of the contents of the archive.
2607
2608 @item --update
2609 Adds files to the end of the archive, but only if they are newer than
2610 their counterparts already in the archive, or if they do not already
2611 exist in the archive.
2612
2613 @item --version
2614 Prints the version number of the @code{tar} program to the standard
2615 error.
2616 @end table
2617
2618 @node Options, , Operations, Quick Reference
2619 @appendixsec Table of Options
2620
2621 Options change the way @code{tar} performs an operation.
2622
2623 @table @samp
2624 @item --absolute-paths
2625 WILL BE INPUT WHEN QUESTION IS RESOLVED
2626
2627 @item --after-date=@var{date}
2628 Limit the operation to files changed after the given date.
2629 @xref{File Exclusion}.
2630
2631 @item --block-size=@var{number}
2632 Specify the blocking factor of an archive. @xref{Blocking Factor}.
2633
2634 @item --compress
2635 Specify a compressed archive. @xref{Compressed Archives}.
2636
2637 @item --compress-block.
2638 Create a whole block sized compressed archive. @xref{Compressed Archives}.
2639
2640 @item --confirmation
2641 Solicit confirmation for each file. @xref{Interactive Operation}
2642 <<< --selective should be a synonym.
2643
2644 @item --dereference
2645 Treat a symbolic link as an alternate name for the file the link
2646 points to. @xref{Symbolic Links}.
2647
2648 @item --directory=@file{directory}
2649 Change the working directory. @xref{Changing Working Directory}.
2650
2651 @item --exclude=@var{pattern}
2652 Exclude files which match the regular expression @var{pattern}.
2653 @xref{File Exclusion}.
2654
2655 @item --exclude-from=@file{file}
2656 Exclude files which match any of the regular expressions listed in
2657 the file @file{file}. @xref{File Exclusion}.
2658
2659 @item --file=@var{archive-name}
2660 Name the archive. @xref{Archive Name}).
2661
2662 @item --files-from=@file{file}
2663 Read file-name arguments from a file on the file system.
2664 @xref{File Name Lists}.
2665
2666 @item --ignore-umask
2667 Set modes of extracted files to those recorded in the archive.
2668 @xref{File Writing Options}.
2669
2670 @item --ignore-zeros
2671 Ignore end-of-archive entries. @xref{Archive Reading Options}.
2672 <<< this should be changed to --ignore-end
2673
2674 @item --listed-incremental=@var{file-name} (-g)
2675 Take a file name argument always. If the file doesn't exist, run a level
2676 zero dump, creating the file. If the file exists, uses that file to see
2677 what has changed.
2678
2679 @item --incremental (-G)
2680 @c <<<look it up>>>
2681
2682 @item --tape-length=@var{n} (-L)
2683 @c <<<alternate way of doing multi archive, will go to that length and
2684 @c prompts for new tape, automatically turns on multi-volume. >>>
2685 @c <<< this needs to be written into main body as well -ringo
2686
2687 @item --info-script=@var{program-file}
2688 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
2689
2690 @item --interactive
2691 Ask for confirmation before performing any operation on a file or
2692 archive member.
2693
2694 @item --keep-old-files
2695 Prevent overwriting during extraction. @xref{File Writing Options}.
2696
2697 @item --label=@var{archive-label}
2698 Include an archive-label in the archive being created. @xref{Archive
2699 Label}.
2700
2701 @item --modification-time
2702 Set the modification time of extracted files to the time they were
2703 extracted. @xref{File Writing Options}.
2704
2705 @item --multi-volume
2706 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
2707
2708 @item --newer=@var{date}
2709 Limit the operation to files changed after the given date.
2710 @xref{File Exclusion}.
2711
2712 @item --newer-mtime=@var{date}
2713 Limit the operation to files modified after the given date. @xref{File
2714 Exclusion}.
2715
2716 @item --old
2717 Create an old format archive. @xref{Old Style File Information}.
2718 @c <<< did we agree this should go away as a synonym?
2719
2720 @item --old-archive
2721 Create an old format archive. @xref{Old Style File Information}.
2722
2723 @item --one-file-system
2724 Prevent @code{tar} from crossing file system boundaries when
2725 archiving. @xref{File Exclusion}.
2726
2727 @item --portable
2728 Create an old format archive. @xref{Old Style File Information}.
2729 @c <<< was portability, may still need to be changed
2730
2731 @item --preserve-order
2732 Help process large lists of file-names on machines with small amounts of
2733 memory. @xref{Archive Reading Options}.
2734
2735 @item --preserve-permission
2736 Set modes of extracted files to those recorded in the archive.
2737 @xref{File Writing Options}.
2738
2739 @item --read-full-blocks
2740 Read an archive with a smaller than specified block size or which
2741 contains incomplete blocks. @xref{Archive Reading Options}).
2742 @c should be --partial-blocks (!!!)
2743
2744 @item --record-number
2745 Print the record number where a message is generated.
2746 @xref{Additional Information}.
2747
2748 @item --same-order
2749 Help process large lists of file-names on machines with small amounts of
2750 memory. @xref{Archive Reading Options}.
2751
2752 @item --same-permission
2753 Set the modes of extracted files to those recorded in the archive.
2754 @xref{File Writing Options}.
2755
2756 @item --sparse
2757 Archive sparse files sparsely. @xref{Sparse Files}.
2758
2759 @item --starting-file=@var{file-name}
2760 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
2761
2762 @item --to-stdout
2763 Write files to the standard output. @xref{File Writing Options}.
2764
2765 @item --uncompress
2766 Specifdo a compressed archive. @xref{Compressed Archives}.
2767
2768 @item -V @var{archive-label}
2769 Include an archive-label in the archive being created. @xref{Archive
2770 Label}.
2771 @c was --volume
2772
2773 @item --verbose
2774 Print the names of files or archive members as they are being
2775 operated on. @xref{Additional Information}.
2776
2777 @item --verify
2778 Check for discrepancies in the archive immediately after it is
2779 written. @xref{Write Verification}.
2780
2781 @item -B
2782 Read an archive with a smaller than specified block size or which
2783 contains incomplete blocks. @xref{Archive Reading Options}).
2784
2785 @item -K @var{file-name}
2786 Begin reading in the middle of an archive. @xref{Scarce Disk Space}.
2787
2788 @item -M
2789 Specify a multi-volume archive. @xref{Multi-Volume Archives}.
2790
2791 @item -N @var{date}
2792 Limit operation to files changed after the given date. @xref{File Exclusion}.
2793
2794 @item -O
2795 Write files to the standard output. @xref{File Writing Options}.
2796
2797 @c <<<<- P is absolute paths, add when resolved. -ringo>>>
2798
2799 @item -R
2800 Print the record number where a message is generated.
2801 @xref{Additional Information}.
2802
2803 @item -S
2804 Archive sparse files sparsely. @xref{Sparse Files}.
2805
2806 @item -T @var{file}
2807 Read file-name arguments from a file on the file system.
2808 @xref{File Name Lists}.
2809
2810 @item -W
2811 Check for discrepancies in the archive immediately after it is
2812 written. @xref{Write Verification}.
2813
2814 @item -Z
2815 Specify a compressed archive. @xref{Compressed Archives}.
2816
2817 @item -b @var{number}
2818 Specify the blocking factor of an archive. @xref{Blocking Factor}.
2819
2820 @item -f @var{archive-name}
2821 Name the archive. @xref{Archive Name}).
2822
2823 @item -h
2824 Treat a symbolic link as an alternate name for the file the link
2825 points to. @xref{Symbolic Links}.
2826
2827 @item -i
2828 Ignore end-of-archive entries. @xref{Archive Reading Options}.
2829
2830 @item -k
2831 Prevent overwriting during extraction. @xref{File Writing Options}.
2832
2833 @item -l
2834 Prevent @code{tar} from crossing file system boundaries when
2835 archiving. @xref{File Exclusion}.
2836
2837 @item -m
2838 Set the modification time of extracted files to the time they were
2839 extracted. @xref{File Writing Options}.
2840
2841 @item -o
2842 Create an old format archive. @xref{Old Style File Information}.
2843
2844 @item -p
2845 Set the modes of extracted files to those recorded in the archive.
2846 @xref{File Writing Options}.
2847
2848 @item -s
2849 Help process large lists of file-names on machines with small amounts of
2850 memory. @xref{Archive Reading Options}.
2851
2852 @item -v
2853 Print the names of files or archive members they are being operated
2854 on. @xref{Additional Information}.
2855
2856 @item -w
2857 @c <<<see --interactive. WILL BE INPUT WHEN QUESTIONS ARE RESOLVED.>>>
2858
2859 @item -z
2860 Specify a compressed archive. @xref{Compressed Archives}.
2861
2862 @item -z -z
2863 Create a whole block sized compressed archive. @xref{Compressed Archives}.
2864 @c I would rather this were -Z. it is the only double letter short
2865 @c form.
2866
2867 @item -C @file{directory}
2868 Change the working directory. @xref{Changing Working Directory}.
2869
2870 @item -F @var{program-file}
2871 Create a multi-volume archive via a script. @xref{Multi-Volume Archives}.
2872
2873 @item -X @file{file}
2874 Exclude files which match any of the regular expressions listed in
2875 the file @file{file}. @xref{File Exclusion}.
2876 @end table
2877
2878 @node Data Format Details, Concept Index, Quick Reference, Top
2879 @appendix Details of the Archive Data Format
2880
2881 This chapter is based heavily on John Gilmore's @i{tar}(5) manual page
2882 for the public domain @code{tar} that GNU @code{tar} is based on.
2883 @c it's been majorly edited since, we may be able to lose this.
2884
2885 The archive media contains a series of records, each of which contains
2886 512 bytes. Each archive member is represented by a header record,
2887 which describes the file, followed by zero or more records which
2888 represent the contents of the file. At the end of the archive file
2889 there may be a record consisting of a series of binary zeros, as an
2890 end-of-archive marker. GNU @code{tar} writes a record of zeros at the
2891 end of an archive, but does not assume that such a record exists when
2892 reading an archive.
2893
2894 Records may be grouped into @dfn{blocks} for I/O operations. A block
2895 of records is written with a single @code{write()} operation. The
2896 number of records in a block is specified using the @samp{--block-size}
2897 option. @xref{Blocking Factor}, for more information about specifying
2898 block size.
2899
2900 @menu
2901 * Header Data:: The Distribution of Data in the Header
2902 * Header Fields:: The Meaning of Header Fields
2903 * Sparse File Handling:: Fields to Handle Sparse Files
2904 @end menu
2905
2906 @node Header Data, Header Fields, Data Format Details, Data Format Details
2907 @appendixsec The Distribution of Data in the Header
2908
2909 The header record is defined in C as follows:
2910 @c I am taking the following code on faith.
2911
2912 @example
2913 @r{Standard Archive Format - Standard TAR - USTAR}
2914
2915 #define RECORDSIZE 512
2916 #define NAMSIZ 100
2917 #define TUNMLEN 32
2918 #define TGNMLEN 32
2919 #define SPARSE_EXT_HDR 21
2920 #define SPARSE_IN_HDR 4
2921
2922 struct sparse @{
2923 char offset[12];
2924 char numbytes[12];
2925 @};
2926
2927 union record @{
2928 char charptr[RECORDSIZE];
2929 struct header @{
2930 char name[NAMSIZ];
2931 char mode[8];
2932 char uid[8];
2933 char gid[8];
2934 char size[12];
2935 char mtime[12];
2936 char chksum[8];
2937 char linkflag;
2938 char linkname[NAMSIZ];
2939 char magic[8];
2940 char uname[TUNMLEN];
2941 char gname[TGNMLEN];
2942 char devmajor[8];
2943 char devminor[8];
2944
2945 @r{The following fields were added by gnu and are not used by other}
2946 @r{versions of @code{tar}}.
2947 char atime[12];
2948 char ctime[12];
2949 char offset[12];
2950 char longnames[4];
2951 @r{The next three fields were added by gnu to deal with shrinking down}
2952 @r{sparse files.}
2953 struct sparse sp[SPARSE_IN_HDR];
2954 char isextended;
2955 @r{This is the number of nulls at the end of the file, if any.}
2956 char ending_blanks[12];
2957
2958 @} header;
2959
2960 struct extended_header @{
2961 struct sparse sp[21];
2962 char isextended;
2963 @} ext_hdr;
2964
2965 @};
2966 @c <<< this whole thing needs to be put into better english
2967
2968 @r{The checksum field is filled with this while the checksum is computed.}
2969 #define CHKBLANKS " " @r{8 blanks, no null}
2970
2971 @r{Inclusion of this field marks an archive as being in standard}
2972 @r{Posix format (though GNU tar itself is not Posix conforming). GNU}
2973 @r{tar puts "ustar" in this field if uname and gname are valid.}
2974 #define TMAGIC "ustar " @r{7 chars and a null}
2975
2976 @r{The magic field is filled with this if this is a GNU format dump entry.}
2977 #define GNUMAGIC "GNUtar " @r{7 chars and a null}
2978
2979 @r{The linkflag defines the type of file.}
2980 #define LF_OLDNORMAL '\0' @r{Normal disk file, Unix compatible}
2981 #define LF_NORMAL '0' @r{Normal disk file}
2982 #define LF_LINK '1' @r{Link to previously dumped file}
2983 #define LF_SYMLINK '2' @r{Symbolic link}
2984 #define LF_CHR '3' @r{Character special file}
2985 #define LF_BLK '4' @r{Block special file}
2986 #define LF_DIR '5' @r{Directory}
2987 #define LF_FIFO '6' @r{FIFO special file}
2988 #define LF_CONTIG '7' @r{Contiguous file}
2989
2990 @r{hhe following are further link types which were defined later.}
2991
2992 @r{This is a dir entry that contains the names of files that were in}
2993 @r{the dir at the time the dump was made.}
2994 #define LF_DUMPDIR 'D'
2995
2996 @r{This is the continuation of a file that began on another volume}
2997 #define LF_MULTIVOL 'M'
2998
2999 @r{This is for sparse files}
3000 #define LF_SPARSE 'S'
3001
3002 @r{This file is a tape/volume header. Ignore it on extraction.}
3003 #define LF_VOLHDR 'V'
3004
3005 @r{These are bits used in the mode field - the values are in octal}
3006 #define TSUID 04000 @r{Set UID on execution}
3007 #define TSGID 02000 @r{Set GID on execution}
3008 #define TSVTX 01000 @r{Save text (sticky bit)}
3009
3010 @r{These are file permissions}
3011 #define TUREAD 00400 @r{read by owner}
3012 #define TUWRITE 00200 @r{write by owner}
3013 #define TUEXEC 00100 @r{execute/search by owner}
3014 #define TGREAD 00040 @r{read by group}
3015 #define TGWRITE 00020 @r{write by group}
3016 #define TGEXEC 00010 @r{execute/search by group}
3017 #define TOREAD 00004 @r{read by other}
3018 #define TOWRITE 00002 @r{write by other}
3019 #define TOEXEC 00001 @r{execute/search by other}
3020 @end example
3021
3022
3023 All characters in headers are 8-bit characters in the local variant of
3024 ASCII. Each field in the header is contiguous; that is, there is no
3025 padding in the header format.
3026
3027 Data representing the contents of files is not translated in any way
3028 and is not constrained to represent characters in any character set.
3029 @code{tar} does not distinguish between text files and binary files.
3030
3031 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
3032 @code{gname} fields contain null-terminated character strings. All
3033 other fields contain zero-filled octal numbers in ASCII. Each numeric
3034 field of width @var{w} contains @var{w} @minus{} 2 digits, a space, and a
3035 null, except @code{size} and @code{mtime}, which do not contain the
3036 trailing null.
3037
3038 @node Header Fields, Sparse File Handling, Header Data, Data Format Details
3039 @appendixsec The Meaning of Header Fields
3040
3041 The @code{name} field contains the name of the file.
3042 <<< how big a name before field overflows?
3043
3044 The @code{mode} field contains nine bits which specify file
3045 permissions, and three bits which specify the Set UID, Set GID, and
3046 Save Text (``stick'') modes. Values for these bits are defined above.
3047 @xref{File Writing Options}, for information on how file permissions
3048 and modes are used by @code{tar}.
3049
3050 The @code{uid} and @code{gid} fields contain the numeric user and
3051 group IDs of the file owners. If the operating system does not
3052 support numeric user or group IDs, these fields should be ignored.
3053 @c but are they?
3054
3055 The @code{size} field contains the size of the file in bytes; this
3056 field contains a zero if the header describes a link to a file.
3057
3058 The @code{mtime} field contains the modification time of the file.
3059 This is the ASCII representation of the octal value of the last time
3060 the file was modified, represented as an integer number of seconds
3061 since January 1, 1970, 00:00 Coordinated Universal Time.
3062 @xref{File Writing Options}, for a description of how @code{tar} uses
3063 this information.
3064
3065 The @code{chksum} field contains the ASCII representation of the octal
3066 value of the simple sum of all bytes in the header record. To
3067 generate this sum, each 8-bit byte in the header is added to an
3068 unsigned integer, which has been initialized to zero. The precision
3069 of the integer is seventeen bits. When calculating the checksum, the
3070 @code{chksum} field itself is treated as blank.
3071
3072 The @code{atime} and @code{ctime} fields are used when making
3073 incremental backups; they store, respectively, the file's access time
3074 and last inode-change time.
3075
3076 The value in the @code{offset} field is used when making a
3077 multi-volume archive. The offset is number of bytes into the file
3078 that we need to go to pick up where we left off in the previous
3079 volume, i.e the location that a continued file is continued from.
3080
3081 The @code{longnames} field supports a feature that is not yet
3082 implemented. This field should be empty.
3083
3084 The @code{magic} field indicates that this archive was output in the
3085 P1003 archive format. If this field contains @code{TMAGIC}, the
3086 @code{uname} and @code{gname} fields will contain the ASCII
3087 representation of the owner and group of the file respectively. If
3088 found, the user and group IDs are used rather than the values in the
3089 @code{uid} and @code{gid} fields.
3090
3091 The @code{sp} field is used to archive sparse files efficiently.
3092 @xref{Sparse File Handling}, for a description of this field, and
3093 other fields it may imply.
3094
3095 The @code{typeflag} field specifies the file's type. If a particular
3096 implementation does not recognize or permit the specified type,
3097 @code{tar} extracts the file as if it were a regular file, and reports
3098 the discrepancy on the standard error. @xref{File Types}. @xref{GNU
3099 File Types}.
3100
3101 @menu
3102 * File Types:: File Types
3103 * GNU File Types:: Additional File Types Supported by GNU
3104 @end menu
3105
3106 @node File Types, GNU File Types, Header Fields, Header Fields
3107 @appendixsubsec File Types
3108
3109 The following flags are used to describe file types:
3110
3111 @table @code
3112 @item LF_NORMAL
3113 @itemx LF_OLDNORMAL
3114 Indicates a regular file. In order to be compatible with older
3115 versions of @code{tar}, a @code{typeflag} value of @code{LF_OLDNORMAL}
3116 should be silently recognized as a regular file. New archives should
3117 be created using @code{LF_NORMAL} for regular files. For backward
3118 compatibility, @code{tar} treats a regular file whose name ends with a
3119 slash as a directory.
3120
3121 @item LF_LINK
3122 Indicates a link to another file, of any type, which has been
3123 previously archived. @code{tar} identifies linked files in Unix by
3124 matching device and inode numbers. The linked-to name is specified in
3125 the @code{linkname} field with a trailing null.
3126
3127 @item LF_SYMLINK
3128 Indicates a symbolic link to another file. The linked-to
3129 name is specified in the @code{linkname} field with a trailing null.
3130 @xref{File Writing Options}, for information on archiving files
3131 referenced by a symbolic link.
3132
3133 @item LF_CHR
3134 @itemx LF_BLK
3135 Indicate character special files and block special files,
3136 respectively. In this case the @code{devmajor} and @code{devminor}
3137 fields will contain the major and minor device numbers. Operating
3138 systems may map the device specifications to their own local
3139 specification, or may ignore the entry.
3140
3141 @item LF_DIR
3142 Indicates a directory or sub-directory. The directory name in the
3143 @code{name} field should end with a slash. On systems where disk
3144 allocation is performed on a directory basis, the @code{size} field
3145 will contain the maximum number of bytes (which may be rounded to the
3146 nearest disk block allocation unit) that the directory can hold. A
3147 @code{size} field of zero indicates no size limitations. Systems that
3148 do not support size limiting in this manner should ignore the
3149 @code{size} field.
3150
3151 @item LF_FIFO
3152 Indicates a FIFO special file. Note that archiving a FIFO file
3153 archives the existence of the file and not its contents.
3154
3155 @item LF_CONTIG
3156 Indicates a contiguous file. Contiguous files are the same as normal
3157 files except that, in operating systems that support it, all the
3158 files' disk space is allocated contiguously. Operating systems which
3159 do not allow contiguous allocation should silently treat this type as
3160 a normal file.
3161
3162 @item 'A' @dots{}
3163 @itemx 'Z'
3164 These are reserved for custom implementations. Some of these are used
3165 in the GNU modified format, which is described below. @xref{GNU File
3166 Types}.
3167 @end table
3168
3169 Certain other flag values are reserved for specification in future
3170 revisions of the P1003 standard, and should not be used by any
3171 @code{tar} program.
3172
3173 @node GNU File Types, , File Types, Header Fields
3174 @appendixsubsec Additional File Types Supported by GNU
3175
3176 GNU @code{tar} uses additional file types to describe new types of
3177 files in an archive. These are listed below.
3178
3179 @table @code
3180 @item LF_DUMPDIR
3181 @itemx 'D'
3182 Indicates a directory and a list of files created by the
3183 @samp{--incremental} option. The @code{size} field gives the total
3184 size of the associated list of files. Each file name is preceded by
3185 either a @code{'Y'} (the file should be in this archive) or an
3186 @code{'N'} (the file is a directory, or is not stored in the archive).
3187 Each file name is terminated by a null. There is an additional null
3188 after the last file name.
3189
3190 @item LF_MULTIVOL
3191 @itemx 'M'
3192 Indicates a file continued from another volume of a multi-volume
3193 archive (@pxref{Multi-Volume Archives}). The original type of the file is not
3194 given here. The @code{size} field gives the maximum size of this
3195 piece of the file (assuming the volume does not end before the file is
3196 written out). The @code{offset} field gives the offset from the
3197 beginning of the file where this part of the file begins. Thus
3198 @code{size} plus @code{offset} should equal the original size of the
3199 file.
3200
3201 @item LF_SPARSE
3202 @itemx 'S'
3203 Indicates a sparse file. @xref{Sparse Files}. @xref{Sparse File
3204 Handling}.
3205
3206 @item LF_VOLHDR
3207 @itemx 'V'
3208 Marks an archive label that was created using the @samp{--label} option
3209 when the archive was created (@pxref{Archive Label}. The @code{name}
3210 field contains the argument to the option. The @code{size} field is
3211 zero. Only the first file in each volume of an archive should have
3212 this type.
3213 @end table
3214
3215 @node Sparse File Handling, , Header Fields, Data Format Details
3216 @appendixsec Fields to Handle Sparse Files
3217
3218 The following header information was added to deal with sparse files
3219 (@pxref{Sparse Files}):
3220
3221 @c TALK TO MIB
3222 The @code{sp} field (fields? something else?) is an array of
3223 @code{struct sparse}. Each @code{struct sparse} contains two
3224 12-character strings, which represent the offset into the file and the
3225 number of bytes to be written at that offset. The offset is absolute,
3226 and not relative to the offset in preceding array elements.
3227
3228 The header can contain four of these @code{struct sparse}; if more are
3229 needed, they are not stored in the header, instead, the flag
3230 @code{isextended} is set and the next record is an
3231 @code{extended_header}.
3232 @c @code{extended_header} or @dfn{extended_header} ??? the next
3233 @c record after the header, or in the middle of it.
3234
3235 The @code{isextended} flag is only set for sparse files, and then only
3236 if extended header records are needed when archiving the file.
3237
3238 Each extended header record can contain an array of 21 sparse
3239 structures, as well as another @code{isextended} flag. There is no
3240 limit (except that implied by the archive media) on the number of
3241 extended header records that can be used to describe a sparse file.
3242
3243 @c so is @code{extended_header} the right way to write this?
3244
3245 @node Concept Index, , Data Format Details, Top
3246 @unnumbered Concept Index
3247
3248 @printindex cp
3249
3250 @summarycontents
3251 @contents
3252 @bye
3253
3254
This page took 0.184105 seconds and 5 git commands to generate.