tar.texi 151 KB

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