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