tar.texi 336 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c ======================================================================
  11. @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
  12. @c as decided by @set symbols. The PUBLISH rendition does not show
  13. @c notes or marks asking for revision. Most users will prefer having more
  14. @c information, even if this information is not fully revised for adequacy,
  15. @c so DISTRIB is the default for tar distributions. The PROOF rendition
  16. @c show all marks to the point of ugliness, but is nevertheless useful to
  17. @c those working on the manual itself.
  18. @c ======================================================================
  19. @ifclear PUBLISH
  20. @ifclear DISTRIB
  21. @ifclear PROOF
  22. @set DISTRIB
  23. @end ifclear
  24. @end ifclear
  25. @end ifclear
  26. @ifset PUBLISH
  27. @set RENDITION The book, version
  28. @end ifset
  29. @ifset DISTRIB
  30. @set RENDITION FTP release, version
  31. @end ifset
  32. @ifset PROOF
  33. @set RENDITION Proof reading version
  34. @end ifset
  35. @c ---------------------------------------------------------------------
  36. @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
  37. @c plan. These annotations are somewhat precious to him; he asks that I
  38. @c do not alter them inconsiderately. Much work is needed for GNU tar
  39. @c internals (the sources, the programs themselves). Revising the
  40. @c adequacy of the manual while revising the sources, and cleaning them
  41. @c both at the same time, seems to him like a good way to proceed.
  42. @c ---------------------------------------------------------------------
  43. @c Output marks for nodes needing revision, but not in PUBLISH rendition.
  44. @macro UNREVISED
  45. @ifclear PUBLISH
  46. @quotation
  47. @emph{(This message will disappear, once this node revised.)}
  48. @end quotation
  49. @end ifclear
  50. @end macro
  51. @c Output various FIXME information only in PROOF rendition.
  52. @macro FIXME{string}
  53. @allow-recursion
  54. @quote-arg
  55. @ifset PROOF
  56. @strong{<FIXME>} \string\ @strong{</>}
  57. @end ifset
  58. @end macro
  59. @macro FIXME-ref{string}
  60. @quote-arg
  61. @ifset PROOF
  62. @strong{<REF>} \string\ @strong{</>}
  63. @end ifset
  64. @end macro
  65. @macro FIXME-pxref{string}
  66. @quote-arg
  67. @ifset PROOF
  68. @strong{<PXREF>} \string\ @strong{</>}
  69. @end ifset
  70. @end macro
  71. @macro FIXME-xref{string}
  72. @quote-arg
  73. @ifset PROOF
  74. @strong{<XREF>} \string\ @strong{</>}
  75. @end ifset
  76. @end macro
  77. @c @macro option{entry}
  78. @c @quote-arg
  79. @c @opindex{--\entry\}
  80. @c @value{\entry\}
  81. @c @end macro
  82. @macro GNUTAR
  83. @acronym{GNU} @command{tar}
  84. @end macro
  85. @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
  86. @set ref-absolute-names @ref{absolute}
  87. @set xref-absolute-names @xref{absolute}
  88. @set pxref-absolute-names @pxref{absolute}
  89. @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
  90. @set ref-after-date @ref{after}
  91. @set xref-after-date @xref{after}
  92. @set pxref-after-date @pxref{after}
  93. @set op-append @kbd{--append} (@kbd{-r})
  94. @set ref-append @ref{add}
  95. @set xref-append @xref{add}
  96. @set pxref-append @pxref{add}
  97. @set op-atime-preserve @kbd{--atime-preserve}
  98. @set ref-atime-preserve @ref{Attributes}
  99. @set xref-atime-preserve @xref{Attributes}
  100. @set pxref-atime-preserve @pxref{Attributes}
  101. @set op-backup @kbd{--backup}
  102. @set ref-backup @ref{Backup options}
  103. @set xref-backup @xref{Backup options}
  104. @set pxref-backup @pxref{Backup options}
  105. @set op-block-number @kbd{--block-number} (@kbd{-R})
  106. @set ref-block-number @ref{verbose}
  107. @set xref-block-number @xref{verbose}
  108. @set pxref-block-number @pxref{verbose}
  109. @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
  110. @set ref-blocking-factor @ref{Blocking Factor}
  111. @set xref-blocking-factor @xref{Blocking Factor}
  112. @set pxref-blocking-factor @pxref{Blocking Factor}
  113. @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
  114. @set ref-bzip2 @ref{gzip}
  115. @set xref-bzip2 @xref{gzip}
  116. @set pxref-bzip2 @pxref{gzip}
  117. @set op-check-links @kbd{--check-links} (@kbd{-l})
  118. @set ref-check-links @ref{--check-links}
  119. @set xref-check-links @xref{--check-links}
  120. @set pxref-check-links @pxref{--check-links}
  121. @set op-checkpoint @kbd{--checkpoint}
  122. @set ref-checkpoint @ref{verbose}
  123. @set xref-checkpoint @xref{verbose}
  124. @set pxref-checkpoint @pxref{verbose}
  125. @set op-check-links @kbd{--check-links}
  126. @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
  127. @set ref-compare @ref{compare}
  128. @set xref-compare @xref{compare}
  129. @set pxref-compare @pxref{compare}
  130. @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
  131. @set ref-compress @ref{gzip}
  132. @set xref-compress @xref{gzip}
  133. @set pxref-compress @pxref{gzip}
  134. @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
  135. @set ref-concatenate @ref{concatenate}
  136. @set xref-concatenate @xref{concatenate}
  137. @set pxref-concatenate @pxref{concatenate}
  138. @set op-create @kbd{--create} (@kbd{-c})
  139. @set ref-create @ref{create}
  140. @set xref-create @xref{create}
  141. @set pxref-create @pxref{create}
  142. @set op-delete @kbd{--delete}
  143. @set ref-delete @ref{delete}
  144. @set xref-delete @xref{delete}
  145. @set pxref-delete @pxref{delete}
  146. @set op-dereference @kbd{--dereference} (@kbd{-h})
  147. @set ref-dereference @ref{dereference}
  148. @set xref-dereference @xref{dereference}
  149. @set pxref-dereference @pxref{dereference}
  150. @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
  151. @set ref-directory @ref{directory}
  152. @set xref-directory @xref{directory}
  153. @set pxref-directory @pxref{directory}
  154. @set op-exclude @kbd{--exclude=@var{pattern}}
  155. @set ref-exclude @ref{exclude}
  156. @set xref-exclude @xref{exclude}
  157. @set pxref-exclude @pxref{exclude}
  158. @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
  159. @set ref-exclude-from @ref{exclude}
  160. @set xref-exclude-from @xref{exclude}
  161. @set pxref-exclude-from @pxref{exclude}
  162. @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
  163. @set ref-extract @ref{extract}
  164. @set xref-extract @xref{extract}
  165. @set pxref-extract @pxref{extract}
  166. @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
  167. @set ref-file @ref{file}
  168. @set xref-file @xref{file}
  169. @set pxref-file @pxref{file}
  170. @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
  171. @set ref-files-from @ref{files}
  172. @set xref-files-from @xref{files}
  173. @set pxref-files-from @pxref{files}
  174. @set op-force-local @kbd{--force-local}
  175. @set ref-force-local @ref{file}
  176. @set xref-force-local @xref{file}
  177. @set pxref-force-local @pxref{file}
  178. @set op-group @kbd{--group=@var{group}}
  179. @set ref-group @ref{Option Summary}
  180. @set xref-group @xref{Option Summary}
  181. @set pxref-group @pxref{Option Summary}
  182. @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
  183. @set ref-gzip @ref{gzip}
  184. @set xref-gzip @xref{gzip}
  185. @set pxref-gzip @pxref{gzip}
  186. @set op-help @kbd{--help}
  187. @set ref-help @ref{help}
  188. @set xref-help @xref{help}
  189. @set pxref-help @pxref{help}
  190. @set op-ignore-failed-read @kbd{--ignore-failed-read}
  191. @set ref-ignore-failed-read @ref{create options}
  192. @set xref-ignore-failed-read @xref{create options}
  193. @set pxref-ignore-failed-read @pxref{create options}
  194. @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
  195. @set ref-ignore-zeros @ref{Reading}
  196. @set xref-ignore-zeros @xref{Reading}
  197. @set pxref-ignore-zeros @pxref{Reading}
  198. @set op-incremental @kbd{--incremental} (@kbd{-G})
  199. @set ref-incremental @ref{Inc Dumps}
  200. @set xref-incremental @xref{Inc Dumps}
  201. @set pxref-incremental @pxref{Inc Dumps}
  202. @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
  203. @set ref-info-script @ref{Multi-Volume Archives}
  204. @set xref-info-script @xref{Multi-Volume Archives}
  205. @set pxref-info-script @pxref{Multi-Volume Archives}
  206. @set op-interactive @kbd{--interactive} (@kbd{-w})
  207. @set ref-interactive @ref{interactive}
  208. @set xref-interactive @xref{interactive}
  209. @set pxref-interactive @pxref{interactive}
  210. @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
  211. @set ref-keep-old-files @ref{Writing}
  212. @set xref-keep-old-files @xref{Writing}
  213. @set pxref-keep-old-files @pxref{Writing}
  214. @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
  215. @set ref-label @ref{label}
  216. @set xref-label @xref{label}
  217. @set pxref-label @pxref{label}
  218. @set op-list @kbd{--list} (@kbd{-t})
  219. @set ref-list @ref{list}
  220. @set xref-list @xref{list}
  221. @set pxref-list @pxref{list}
  222. @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
  223. @set ref-listed-incremental @ref{Inc Dumps}
  224. @set xref-listed-incremental @xref{Inc Dumps}
  225. @set pxref-listed-incremental @pxref{Inc Dumps}
  226. @set op-mode @kbd{--mode=@var{permissions}}
  227. @set ref-mode @ref{Option Summary}
  228. @set xref-mode @xref{Option Summary}
  229. @set pxref-mode @pxref{Option Summary}
  230. @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
  231. @set ref-multi-volume @ref{Multi-Volume Archives}
  232. @set xref-multi-volume @xref{Multi-Volume Archives}
  233. @set pxref-multi-volume @pxref{Multi-Volume Archives}
  234. @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
  235. @set ref-newer-mtime @ref{after}
  236. @set xref-newer-mtime @xref{after}
  237. @set pxref-newer-mtime @pxref{after}
  238. @set op-no-recursion @kbd{--no-recursion}
  239. @set ref-no-recursion @ref{recurse}
  240. @set xref-no-recursion @xref{recurse}
  241. @set pxref-no-recursion @pxref{recurse}
  242. @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
  243. @set ref-no-same-owner @ref{Attributes}
  244. @set xref-no-same-owner @xref{Attributes}
  245. @set pxref-no-same-owner @pxref{Attributes}
  246. @set op-no-same-permissions @kbd{--no-same-permissions}
  247. @set ref-no-same-permissions @ref{Attributes}
  248. @set xref-no-same-permissions @xref{Attributes}
  249. @set pxref-no-same-permissions @pxref{Attributes}
  250. @set op-null @kbd{--null}
  251. @set ref-null @ref{files}
  252. @set xref-null @xref{files}
  253. @set pxref-null @pxref{files}
  254. @set op-numeric-owner @kbd{--numeric-owner}
  255. @set ref-numeric-owner @ref{Attributes}
  256. @set xref-numeric-owner @xref{Attributes}
  257. @set pxref-numeric-owner @pxref{Attributes}
  258. @set op-occurrence @kbd{--occurrence}
  259. @set ref-occurrence @ref{--occurrence}
  260. @set xref-occurrence @xref{--occurrence}
  261. @set pxref-occurrence @pxref{--occurrence}
  262. @set op-old-archive @kbd{--old-archive} (@kbd{-o})
  263. @set ref-old-archive @ref{old}
  264. @set xref-old-archive @xref{old}
  265. @set pxref-old-archive @pxref{old}
  266. @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
  267. @set ref-one-file-system @ref{one}
  268. @set xref-one-file-system @xref{one}
  269. @set pxref-one-file-system @pxref{one}
  270. @set op-overwrite @kbd{--overwrite}
  271. @set ref-overwrite @ref{Overwrite Old Files}
  272. @set xref-overwrite @xref{Overwrite Old Files}
  273. @set pxref-overwrite @pxref{Overwrite Old Files}
  274. @set op-owner @kbd{--owner=@var{user}}
  275. @set ref-owner @ref{Option Summary}
  276. @set xref-owner @xref{Option Summary}
  277. @set pxref-owner @pxref{Option Summary}
  278. @set op-format @kbd{--format}
  279. @set ref-format @ref{format}
  280. @set xref-format @xref{format}
  281. @set pxref-format @pxref{format}
  282. @set op-format-v7 @kbd{--format=v7}
  283. @set op-format-gnu @kbd{--format=gnu}
  284. @set op-format-oldgnu @kbd{--format=oldgnu}
  285. @set op-format-posix @kbd{--format=posix}
  286. @set op-format-ustar @kbd{--format=ustar}
  287. @set op-posix @kbd{--posix}
  288. @set ref-posix @ref{posix}
  289. @set xref-posix @xref{posix}
  290. @set pxref-posix @pxref{posix}
  291. @set op-preserve @kbd{--preserve}
  292. @set ref-preserve @ref{Attributes}
  293. @set xref-preserve @xref{Attributes}
  294. @set pxref-preserve @pxref{Attributes}
  295. @set op-record-size @kbd{--record-size=@var{size}}
  296. @set ref-record-size @ref{Blocking}
  297. @set xref-record-size @xref{Blocking}
  298. @set pxref-record-size @pxref{Blocking}
  299. @set op-recursive-unlink @kbd{--recursive-unlink}
  300. @set ref-recursive-unlink @ref{Writing}
  301. @set xref-recursive-unlink @xref{Writing}
  302. @set pxref-recursive-unlink @pxref{Writing}
  303. @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
  304. @set ref-read-full-records @ref{Blocking}
  305. @set xref-read-full-records @xref{Blocking}
  306. @set pxref-read-full-records @pxref{Blocking}
  307. @c FIXME: or should it be Reading, or Blocking Factor
  308. @set op-remove-files @kbd{--remove-files}
  309. @set ref-remove-files @ref{Writing}
  310. @set xref-remove-files @xref{Writing}
  311. @set pxref-remove-files @pxref{Writing}
  312. @set op-rsh-command @kbd{rsh-command=@var{command}}
  313. @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
  314. @set ref-same-order @ref{Scarce}
  315. @set xref-same-order @xref{Scarce}
  316. @set pxref-same-order @pxref{Scarce}
  317. @c FIXME: or should it be Reading, or Attributes?
  318. @set op-same-owner @kbd{--same-owner}
  319. @set ref-same-owner @ref{Attributes}
  320. @set xref-same-owner @xref{Attributes}
  321. @set pxref-same-owner @pxref{Attributes}
  322. @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
  323. @set ref-same-permissions @ref{Attributes}
  324. @set xref-same-permissions @xref{Attributes}
  325. @set pxref-same-permissions @pxref{Attributes}
  326. @c FIXME: or should it be Writing?
  327. @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
  328. @set ref-show-omitted-dirs @ref{verbose}
  329. @set xref-show-omitted-dirs @xref{verbose}
  330. @set pxref-show-omitted-dirs @pxref{verbose}
  331. @set op-sparse @kbd{--sparse} (@kbd{-S})
  332. @set ref-sparse @ref{sparse}
  333. @set xref-sparse @xref{sparse}
  334. @set pxref-sparse @pxref{sparse}
  335. @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
  336. @set ref-starting-file @ref{Scarce}
  337. @set xref-starting-file @xref{Scarce}
  338. @set pxref-starting-file @pxref{Scarce}
  339. @set op-strip-path @kbd{--strip-path}
  340. @set ref-strip-path @ref{--strip-path}
  341. @set xref-strip-path @xref{--strip-path}
  342. @set pxref-strip-path @pxref{--strip-path}
  343. @set op-suffix @kbd{--suffix=@var{suffix}}
  344. @set ref-suffix @ref{Backup options}
  345. @set xref-suffix @xref{Backup options}
  346. @set pxref-suffix @pxref{Backup options}
  347. @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
  348. @set ref-tape-length @ref{Using Multiple Tapes}
  349. @set xref-tape-length @xref{Using Multiple Tapes}
  350. @set pxref-tape-length @pxref{Using Multiple Tapes}
  351. @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
  352. @set ref-to-stdout @ref{Writing}
  353. @set xref-to-stdout @xref{Writing}
  354. @set pxref-to-stdout @pxref{Writing}
  355. @set op-totals @kbd{--totals}
  356. @set ref-totals @ref{verbose}
  357. @set xref-totals @xref{verbose}
  358. @set pxref-totals @pxref{verbose}
  359. @set op-touch @kbd{--touch} (@kbd{-m})
  360. @set ref-touch @ref{Writing}
  361. @set xref-touch @xref{Writing}
  362. @set pxref-touch @pxref{Writing}
  363. @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
  364. @set ref-unlink-first @ref{Writing}
  365. @set xref-unlink-first @xref{Writing}
  366. @set pxref-unlink-first @pxref{Writing}
  367. @set op-update @kbd{--update} (@kbd{-u})
  368. @set ref-update @ref{update}
  369. @set xref-update @xref{update}
  370. @set pxref-update @pxref{update}
  371. @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
  372. @set ref-use-compress-prog @ref{gzip}
  373. @set xref-use-compress-prog @xref{gzip}
  374. @set pxref-use-compress-prog @pxref{gzip}
  375. @set op-verbose @kbd{--verbose} (@kbd{-v})
  376. @set ref-verbose @ref{verbose}
  377. @set xref-verbose @xref{verbose}
  378. @set pxref-verbose @pxref{verbose}
  379. @set op-verify @kbd{--verify} (@kbd{-W})
  380. @set ref-verify @ref{verify}
  381. @set xref-verify @xref{verify}
  382. @set pxref-verify @pxref{verify}
  383. @set op-version @kbd{--version}
  384. @set ref-version @ref{help}
  385. @set xref-version @xref{help}
  386. @set pxref-version @pxref{help}
  387. @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
  388. @set ref-volno-file @ref{Using Multiple Tapes}
  389. @set xref-volno-file @xref{Using Multiple Tapes}
  390. @set pxref-volno-file @pxref{Using Multiple Tapes}
  391. @c Put everything in one index (arbitrarily chosen to be the concept index).
  392. @syncodeindex fn cp
  393. @syncodeindex ky cp
  394. @syncodeindex pg cp
  395. @syncodeindex vr cp
  396. @defindex op
  397. @syncodeindex op cp
  398. @copying
  399. This manual is for @acronym{GNU} @command{tar} (version
  400. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  401. from archives.
  402. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  403. 2003, 2004 Free Software Foundation, Inc.
  404. @quotation
  405. Permission is granted to copy, distribute and/or modify this document
  406. under the terms of the GNU Free Documentation License, Version 1.1 or
  407. any later version published by the Free Software Foundation; with the
  408. Invariant Sections being "GNU General Public License", with the
  409. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  410. as in (a) below. A copy of the license is included in the section
  411. entitled "GNU Free Documentation License".
  412. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  413. this GNU Manual. Buying copies from GNU Press supports the FSF in
  414. developing GNU and promoting software freedom.''
  415. @end quotation
  416. @end copying
  417. @dircategory Archiving
  418. @direntry
  419. * Tar: (tar). Making tape (or disk) archives.
  420. @end direntry
  421. @dircategory Individual utilities
  422. @direntry
  423. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  424. @end direntry
  425. @shorttitlepage @acronym{GNU} @command{tar}
  426. @titlepage
  427. @title @acronym{GNU} tar: an archiver tool
  428. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  429. @author Melissa Weisshaus, Jay Fenlason,
  430. @author Thomas Bushnell, n/BSG, Amy Gorin
  431. @c he said to remove it: Fran@,{c}ois Pinard
  432. @c i'm thinking about how the author page *should* look. -mew 2may96
  433. @page
  434. @vskip 0pt plus 1filll
  435. @insertcopying
  436. @end titlepage
  437. @ifnottex
  438. @node Top
  439. @top @acronym{GNU} tar: an archiver tool
  440. @insertcopying
  441. @cindex file archival
  442. @cindex archiving files
  443. The first part of this master menu lists the major nodes in this Info
  444. document. The rest of the menu lists all the lower level nodes.
  445. @end ifnottex
  446. @c The master menu, created with texinfo-master-menu, goes here.
  447. @c (However, getdate.texi's menu is interpolated by hand.)
  448. @menu
  449. * Introduction::
  450. * Tutorial::
  451. * tar invocation::
  452. * operations::
  453. * Backups::
  454. * Choosing::
  455. * Date input formats::
  456. * Formats::
  457. * Media::
  458. * Free Software Needs Free Documentation::
  459. * Copying This Manual::
  460. * Index::
  461. @detailmenu
  462. --- The Detailed Node Listing ---
  463. Introduction
  464. * Book Contents:: What this Book Contains
  465. * Definitions:: Some Definitions
  466. * What tar Does:: What @command{tar} Does
  467. * Naming tar Archives:: How @command{tar} Archives are Named
  468. * Current status:: Current development status of @GNUTAR{}
  469. * Authors:: @GNUTAR{} Authors
  470. * Reports:: Reporting bugs or suggestions
  471. Tutorial Introduction to @command{tar}
  472. * assumptions::
  473. * stylistic conventions::
  474. * basic tar options:: Basic @command{tar} Operations and Options
  475. * frequent operations::
  476. * Two Frequent Options::
  477. * create:: How to Create Archives
  478. * list:: How to List Archives
  479. * extract:: How to Extract Members from an Archive
  480. * going further::
  481. Two Frequently Used Options
  482. * file tutorial::
  483. * verbose tutorial::
  484. * help tutorial::
  485. How to Create Archives
  486. * prepare for examples::
  487. * Creating the archive::
  488. * create verbose::
  489. * short create::
  490. * create dir::
  491. How to List Archives
  492. * list dir::
  493. How to Extract Members from an Archive
  494. * extracting archives::
  495. * extracting files::
  496. * extract dir::
  497. * failing commands::
  498. Invoking @GNUTAR{}
  499. * Synopsis::
  500. * using tar options::
  501. * Styles::
  502. * All Options::
  503. * help::
  504. * verbose::
  505. * interactive::
  506. The Three Option Styles
  507. * Mnemonic Options:: Mnemonic Option Style
  508. * Short Options:: Short Option Style
  509. * Old Options:: Old Option Style
  510. * Mixing:: Mixing Option Styles
  511. All @command{tar} Options
  512. * Operation Summary::
  513. * Option Summary::
  514. * Short Option Summary::
  515. @GNUTAR{} Operations
  516. * Basic tar::
  517. * Advanced tar::
  518. * create options::
  519. * extract options::
  520. * backup::
  521. * Applications::
  522. * looking ahead::
  523. Advanced @GNUTAR{} Operations
  524. * Operations::
  525. * append::
  526. * update::
  527. * concatenate::
  528. * delete::
  529. * compare::
  530. How to Add Files to Existing Archives: @code{--append}
  531. * appending files:: Appending Files to an Archive
  532. * multiple::
  533. Updating an Archive
  534. * how to update::
  535. Options Used by @code{--create}
  536. * Ignore Failed Read::
  537. Options Used by @code{--extract}
  538. * Reading:: Options to Help Read Archives
  539. * Writing:: Changing How @command{tar} Writes Files
  540. * Scarce:: Coping with Scarce Resources
  541. Options to Help Read Archives
  542. * read full records::
  543. * Ignore Zeros::
  544. Changing How @command{tar} Writes Files
  545. * Dealing with Old Files::
  546. * Overwrite Old Files::
  547. * Keep Old Files::
  548. * Unlink First::
  549. * Recursive Unlink::
  550. * Modification Times::
  551. * Setting Access Permissions::
  552. * Writing to Standard Output::
  553. * remove files::
  554. Coping with Scarce Resources
  555. * Starting File::
  556. * Same Order::
  557. Performing Backups and Restoring Files
  558. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  559. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  560. * incremental and listed-incremental:: The Incremental Options
  561. * Backup Levels:: Levels of Backups
  562. * Backup Parameters:: Setting Parameters for Backups and Restoration
  563. * Scripted Backups:: Using the Backup Scripts
  564. * Scripted Restoration:: Using the Restore Script
  565. Setting Parameters for Backups and Restoration
  566. * backup-specs example:: An Example Text of @file{Backup-specs}
  567. * Script Syntax:: Syntax for @file{Backup-specs}
  568. Choosing Files and Names for @command{tar}
  569. * file:: Choosing the Archive's Name
  570. * Selecting Archive Members::
  571. * files:: Reading Names from a File
  572. * exclude:: Excluding Some Files
  573. * Wildcards::
  574. * after:: Operating Only on New Files
  575. * recurse:: Descending into Directories
  576. * one:: Crossing Filesystem Boundaries
  577. Reading Names from a File
  578. * nul::
  579. Excluding Some Files
  580. * controlling pattern-patching with exclude::
  581. * problems with exclude::
  582. Crossing Filesystem Boundaries
  583. * directory:: Changing Directory
  584. * absolute:: Absolute File Names
  585. Date input formats
  586. * General date syntax:: Common rules.
  587. * Calendar date items:: 19 Dec 1994.
  588. * Time of day items:: 9:20pm.
  589. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  590. * Day of week items:: Monday and others.
  591. * Relative items in date strings:: next tuesday, 2 years ago.
  592. * Pure numbers in date strings:: 19931219, 1440.
  593. * Seconds since the Epoch:: @@1078100502.
  594. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  595. Controlling the Archive Format
  596. * Portability:: Making @command{tar} Archives More Portable
  597. * Compression:: Using Less Space through Compression
  598. * Attributes:: Handling File Attributes
  599. * Standard:: The Standard Format
  600. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  601. * cpio:: Comparison of @command{tar} and @command{cpio}
  602. Making @command{tar} Archives More Portable
  603. * Portable Names:: Portable Names
  604. * dereference:: Symbolic Links
  605. * old:: Old V7 Archives
  606. * posix:: @sc{posix} archives
  607. * Checksumming:: Checksumming Problems
  608. * Large or Negative Values:: Large files, negative time stamps, etc.
  609. Using Less Space through Compression
  610. * gzip:: Creating and Reading Compressed Archives
  611. * sparse:: Archiving Sparse Files
  612. Tapes and Other Archive Media
  613. * Device:: Device selection and switching
  614. * Remote Tape Server::
  615. * Common Problems and Solutions::
  616. * Blocking:: Blocking
  617. * Many:: Many archives on one tape
  618. * Using Multiple Tapes:: Using Multiple Tapes
  619. * label:: Including a Label in the Archive
  620. * verify::
  621. * Write Protection::
  622. Blocking
  623. * Format Variations:: Format Variations
  624. * Blocking Factor:: The Blocking Factor of an Archive
  625. Many Archives on One Tape
  626. * Tape Positioning:: Tape Positions and Tape Marks
  627. * mt:: The @command{mt} Utility
  628. Using Multiple Tapes
  629. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  630. * Tape Files:: Tape Files
  631. Copying This Manual
  632. * GNU Free Documentation License:: License for copying this manual
  633. @end detailmenu
  634. @end menu
  635. @node Introduction
  636. @chapter Introduction
  637. @GNUTAR{} creates
  638. and manipulates (@dfn{archives}) which are actually collections of
  639. many other files; the program provides users with an organized and
  640. systematic method for controlling a large amount of data.
  641. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  642. archives need not (and these days, typically do not) reside on tapes.
  643. @menu
  644. * Book Contents:: What this Book Contains
  645. * Definitions:: Some Definitions
  646. * What tar Does:: What @command{tar} Does
  647. * Naming tar Archives:: How @command{tar} Archives are Named
  648. * Current status:: Current development status of @GNUTAR{}
  649. * Authors:: @GNUTAR{} Authors
  650. * Reports:: Reporting bugs or suggestions
  651. @end menu
  652. @node Book Contents
  653. @section What this Book Contains
  654. The first part of this chapter introduces you to various terms that will
  655. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  656. and its documentation, and where you should send bug reports
  657. or comments.
  658. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  659. gentle introduction for people who are new to using @command{tar}. It is
  660. meant to be self contained, not requiring any reading from subsequent
  661. chapters to make sense. It moves from topic to topic in a logical,
  662. progressive order, building on information already explained.
  663. Although the tutorial is paced and structured to allow beginners to
  664. learn how to use @command{tar}, it is not intended solely for beginners.
  665. The tutorial explains how to use the three most frequently used
  666. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  667. two frequently used options (@samp{file} and @samp{verbose}). The other
  668. chapters do not refer to the tutorial frequently; however, if a section
  669. discusses something which is a complex variant of a basic concept, there
  670. may be a cross reference to that basic concept. (The entire book,
  671. including the tutorial, assumes that the reader understands some basic
  672. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  673. The third chapter presents the remaining five operations, and
  674. information about using @command{tar} options and option syntax.
  675. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  676. than the reality. should think about whether this makes sense to say
  677. here, or not.} The other chapters are meant to be used as a
  678. reference. Each chapter presents everything that needs to be said
  679. about a specific topic.
  680. One of the chapters (@pxref{Date input formats}) exists in its
  681. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  682. In addition, one section of this manual (@pxref{Standard}) contains a
  683. big quote which is taken directly from @command{tar} sources.
  684. In general, we give both the long and short (abbreviated) option names
  685. at least once in each section where the relevant option is covered, so
  686. that novice readers will become familiar with both styles. (A few
  687. options have no short versions, and the relevant sections will
  688. indicate this.)
  689. @node Definitions
  690. @section Some Definitions
  691. @cindex archive
  692. @cindex tar archive
  693. The @command{tar} program is used to create and manipulate @command{tar}
  694. archives. An @dfn{archive} is a single file which contains the contents
  695. of many files, while still identifying the names of the files, their
  696. owner(s), and so forth. (In addition, archives record access
  697. permissions, user and group, size in bytes, and last modification time.
  698. Some archives also record the file names in each archived directory, as
  699. well as other file and directory information.) You can use @command{tar}
  700. to @dfn{create} a new archive in a specified directory.
  701. @cindex member
  702. @cindex archive member
  703. @cindex file name
  704. @cindex member name
  705. The files inside an archive are called @dfn{members}. Within this
  706. manual, we use the term @dfn{file} to refer only to files accessible in
  707. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  708. @dfn{member} to refer only to the members of an archive. Similarly, a
  709. @dfn{file name} is the name of a file, as it resides in the filesystem,
  710. and a @dfn{member name} is the name of an archive member within the
  711. archive.
  712. @cindex extraction
  713. @cindex unpacking
  714. The term @dfn{extraction} refers to the process of copying an archive
  715. member (or multiple members) into a file in the filesystem. Extracting
  716. all the members of an archive is often called @dfn{extracting the
  717. archive}. The term @dfn{unpack} can also be used to refer to the
  718. extraction of many or all the members of an archive. Extracting an
  719. archive does not destroy the archive's structure, just as creating an
  720. archive does not destroy the copies of the files that exist outside of
  721. the archive. You may also @dfn{list} the members in a given archive
  722. (this is often thought of as ``printing'' them to the standard output,
  723. or the command line), or @dfn{append} members to a pre-existing archive.
  724. All of these operations can be performed using @command{tar}.
  725. @node What tar Does
  726. @section What @command{tar} Does
  727. @cindex tar
  728. The @command{tar} program provides the ability to create @command{tar}
  729. archives, as well as various other kinds of manipulation. For example,
  730. you can use @command{tar} on previously created archives to extract files,
  731. to store additional files, or to update or list files which were already
  732. stored.
  733. Initially, @command{tar} archives were used to store files conveniently on
  734. magnetic tape. The name @command{tar} comes from this use; it stands for
  735. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  736. direct its output to available devices, files, or other programs (using
  737. pipes). @command{tar} may even access remote devices or files (as archives).
  738. @FIXME{the following table entries need a bit of work..}
  739. You can use @command{tar} archives in many ways. We want to stress a few
  740. of them: storage, backup, and transportation.
  741. @table @asis
  742. @item Storage
  743. Often, @command{tar} archives are used to store related files for
  744. convenient file transfer over a network. For example, the
  745. @acronym{GNU} Project distributes its software bundled into
  746. @command{tar} archives, so that all the files relating to a particular
  747. program (or set of related programs) can be transferred as a single
  748. unit.
  749. A magnetic tape can store several files in sequence. However, the tape
  750. has no names for these files; it only knows their relative position on
  751. the tape. One way to store several files on one tape and retain their
  752. names is by creating a @command{tar} archive. Even when the basic transfer
  753. mechanism can keep track of names, as FTP can, the nuisance of handling
  754. multiple files, directories, and multiple links makes @command{tar}
  755. archives useful.
  756. Archive files are also used for long-term storage. You can think of
  757. this as transportation from the present into the future. (It is a
  758. science-fiction idiom that you can move through time as well as in
  759. space; the idea here is that @command{tar} can be used to move archives in
  760. all dimensions, even time!)
  761. @item Backup
  762. Because the archive created by @command{tar} is capable of preserving
  763. file information and directory structure, @command{tar} is commonly
  764. used for performing full and incremental backups of disks. A backup
  765. puts a collection of files (possibly pertaining to many users and
  766. projects) together on a disk or a tape. This guards against
  767. accidental destruction of the information in those files.
  768. @GNUTAR{} has special features that allow it to be
  769. used to make incremental and full dumps of all the files in a
  770. filesystem.
  771. @item Transportation
  772. You can create an archive on one system, transfer it to another system,
  773. and extract the contents there. This allows you to transport a group of
  774. files from one system to another.
  775. @end table
  776. @node Naming tar Archives
  777. @section How @command{tar} Archives are Named
  778. Conventionally, @command{tar} archives are given names ending with
  779. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  780. but this manual follows that convention in order to accustom readers to
  781. it and to make examples more clear.
  782. @cindex tar file
  783. @cindex entry
  784. @cindex tar entry
  785. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  786. archive members as ``files'' or ``entries''. For people familiar with
  787. the operation of @command{tar}, this causes no difficulty. However, in
  788. this manual, we consistently refer to ``archives'' and ``archive
  789. members'' to make learning to use @command{tar} easier for novice users.
  790. @node Current status
  791. @section Current development status of @GNUTAR{}
  792. @GNUTAR{} is currently in the process of active development, whose
  793. primary aims are:
  794. @itemize @bullet
  795. @item Improve compatibility between @GNUTAR{} and other @command{tar}
  796. implementations.
  797. @item Switch to using @acronym{POSIX} archives.
  798. @item Revise sparse file handling.
  799. @item Revise multiple volume processing.
  800. @end itemize
  801. The following issues need mentioning:
  802. @table @asis
  803. @item Use of short option @option{-o}.
  804. Earlier versions of @GNUTAR{} understood @option{-o} command line
  805. option as a synonym for @option{--old-archive}.
  806. @GNUTAR{} starting from version 1.13.90 understands this option as
  807. a synonym for @option{--no-same-owner}. This is compatible with
  808. UNIX98 @command{tar} implementations.
  809. However, to facilitate transition, @option{-o} option retains its
  810. old semantics when it is used with one of archive-creation commands.
  811. Users are encouraged to use @value{op-format-oldgnu} instead.
  812. Future versions of @GNUTAR{} will understand @option{-o} only as a
  813. synonym for @option{--no-same-owner}.
  814. @item Use of short option @option{-l}
  815. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  816. synonym for @samp{--one-file-system}. Such usage is deprecated.
  817. For compatibility with other implementations future versions of
  818. @GNUTAR{} will understand this option as a synonym for
  819. @option{--check-links}.
  820. @item Use of options @option{--portability} and @option{--old-archive}
  821. These options are deprecated. Please use @option{--format=v7} instead.
  822. @item Use of option @option{--posix}
  823. This option is deprecated. Please use @option{--format=posix} instead.
  824. @end table
  825. @node Authors
  826. @section @GNUTAR{} Authors
  827. @GNUTAR{} was originally written by John Gilmore,
  828. and modified by many people. The @acronym{GNU} enhancements were
  829. written by Jay Fenlason, then Joy Kendall, and the whole package has
  830. been further maintained by Thomas Bushnell, n/BSG, and finally
  831. Fran@,{c}ois Pinard, with the help of numerous and kind users.
  832. We wish to stress that @command{tar} is a collective work, and owes much to
  833. all those people who reported problems, offered solutions and other
  834. insights, or shared their thoughts and suggestions. An impressive, yet
  835. partial list of those contributors can be found in the @file{THANKS}
  836. file from the @GNUTAR{} distribution.
  837. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  838. sure i want to spell out the history in this detail, at least not for
  839. the printed book. i'm just not sure it needs to be said this way.
  840. i'll think about it.}
  841. @FIXME{History is more important, and surely more interesting, than
  842. actual names. Quoting names without history would be meaningless. FP}
  843. Jay Fenlason put together a draft of a @GNUTAR{}
  844. manual, borrowing notes from the original man page from John Gilmore.
  845. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  846. Gorin worked on a tutorial and manual for @GNUTAR{}.
  847. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  848. taking information from all these sources and merging them. Melissa
  849. Weisshaus finally edited and redesigned the book to create version
  850. 1.12. @FIXME{update version number as necessary; i'm being
  851. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  852. maybe melissa? maybe julie sussman?] needs to properly index the
  853. thing.}
  854. For version 1.12, Daniel Hagerty contributed a great deal of technical
  855. consulting. In particular, he is the primary author of @ref{Backups}.
  856. In July, 2003 @GNUTAR{} was put on CVS at @url{savannah.gnu.org}, and
  857. an active development and maintenance work has started
  858. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  859. Poznyakoff and Jeff Bailey.
  860. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  861. @node Reports
  862. @section Reporting bugs or suggestions
  863. @cindex bug reports
  864. @cindex reporting bugs
  865. If you find problems or have suggestions about this program or manual,
  866. please report them to @file{bug-tar@@gnu.org}.
  867. @node Tutorial
  868. @chapter Tutorial Introduction to @command{tar}
  869. This chapter guides you through some basic examples of three @command{tar}
  870. operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
  871. you already know how to use some other version of @command{tar}, then you
  872. may not need to read this chapter. This chapter omits most complicated
  873. details about how @command{tar} works.
  874. @menu
  875. * assumptions::
  876. * stylistic conventions::
  877. * basic tar options:: Basic @command{tar} Operations and Options
  878. * frequent operations::
  879. * Two Frequent Options::
  880. * create:: How to Create Archives
  881. * list:: How to List Archives
  882. * extract:: How to Extract Members from an Archive
  883. * going further::
  884. @end menu
  885. @node assumptions
  886. @section Assumptions this Tutorial Makes
  887. This chapter is paced to allow beginners to learn about @command{tar}
  888. slowly. At the same time, we will try to cover all the basic aspects of
  889. these three operations. In order to accomplish both of these tasks, we
  890. have made certain assumptions about your knowledge before reading this
  891. manual, and the hardware you will be using:
  892. @itemize @bullet
  893. @item
  894. Before you start to work through this tutorial, you should understand
  895. what the terms ``archive'' and ``archive member'' mean
  896. (@pxref{Definitions}). In addition, you should understand something
  897. about how Unix-type operating systems work, and you should know how to
  898. use some basic utilities. For example, you should know how to create,
  899. list, copy, rename, edit, and delete files and directories; how to
  900. change between directories; and how to figure out where you are in the
  901. filesystem. You should have some basic understanding of directory
  902. structure and how files are named according to which directory they are
  903. in. You should understand concepts such as standard output and standard
  904. input, what various definitions of the term ``argument'' mean, and the
  905. differences between relative and absolute path names. @FIXME{and what
  906. else?}
  907. @item
  908. This manual assumes that you are working from your own home directory
  909. (unless we state otherwise). In this tutorial, you will create a
  910. directory to practice @command{tar} commands in. When we show path names,
  911. we will assume that those paths are relative to your home directory.
  912. For example, my home directory path is @file{/home/fsf/melissa}. All of
  913. my examples are in a subdirectory of the directory named by that path
  914. name; the subdirectory is called @file{practice}.
  915. @item
  916. In general, we show examples of archives which exist on (or can be
  917. written to, or worked with from) a directory on a hard disk. In most
  918. cases, you could write those archives to, or work with them on any other
  919. device, such as a tape drive. However, some of the later examples in
  920. the tutorial and next chapter will not work on tape drives.
  921. Additionally, working with tapes is much more complicated than working
  922. with hard disks. For these reasons, the tutorial does not cover working
  923. with tape drives. @xref{Media}, for complete information on using
  924. @command{tar} archives with tape drives.
  925. @FIXME{this is a cop out. need to add some simple tape drive info.}
  926. @end itemize
  927. @node stylistic conventions
  928. @section Stylistic Conventions
  929. In the examples, @samp{$} represents a typical shell prompt. It
  930. precedes lines you should type; to make this more clear, those lines are
  931. shown in @kbd{this font}, as opposed to lines which represent the
  932. computer's response; those lines are shown in @code{this font}, or
  933. sometimes @samp{like this}. When we have lines which are too long to be
  934. displayed in any other way, we will show them like this:
  935. @smallexample
  936. This is an example of a line which would otherwise not fit in this space.
  937. @end smallexample
  938. @FIXME{how often do we use smallexample?}
  939. @node basic tar options
  940. @section Basic @command{tar} Operations and Options
  941. @command{tar} can take a wide variety of arguments which specify and define
  942. the actions it will have on the particular set of files or the archive.
  943. The main types of arguments to @command{tar} fall into one of two classes:
  944. operations, and options.
  945. Some arguments fall into a class called @dfn{operations}; exactly one of
  946. these is both allowed and required for any instance of using @command{tar};
  947. you may @emph{not} specify more than one. People sometimes speak of
  948. @dfn{operating modes}. You are in a particular operating mode when you
  949. have specified the operation which specifies it; there are eight
  950. operations in total, and thus there are eight operating modes.
  951. The other arguments fall into the class known as @dfn{options}. You are
  952. not required to specify any options, and you are allowed to specify more
  953. than one at a time (depending on the way you are using @command{tar} at
  954. that time). Some options are used so frequently, and are so useful for
  955. helping you type commands more carefully that they are effectively
  956. ``required''. We will discuss them in this chapter.
  957. You can write most of the @command{tar} operations and options in any
  958. of three forms: long (mnemonic) form, short form, and old style. Some
  959. of the operations and options have no short or ``old'' forms; however,
  960. the operations and options which we will cover in this tutorial have
  961. corresponding abbreviations. @FIXME{make sure this is still the case,
  962. at the end}We will indicate those abbreviations appropriately to get
  963. you used to seeing them. (Note that the ``old style'' option forms
  964. exist in @GNUTAR{} for compatibility with Unix
  965. @command{tar}. We present a full discussion of this way of writing
  966. options and operations appears in @ref{Old Options}, and we discuss
  967. the other two styles of writing options in @ref{Mnemonic Options} and
  968. @ref{Short Options}.)
  969. In the examples and in the text of this tutorial, we usually use the
  970. long forms of operations and options; but the ``short'' forms produce
  971. the same result and can make typing long @command{tar} commands easier.
  972. For example, instead of typing
  973. @smallexample
  974. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  975. @end smallexample
  976. @noindent
  977. you can type
  978. @smallexample
  979. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  980. @end smallexample
  981. @noindent
  982. or even
  983. @smallexample
  984. @kbd{tar -cvf afiles.tar apple angst aspic}
  985. @end smallexample
  986. @noindent
  987. For more information on option syntax, see @ref{Advanced tar}. In
  988. discussions in the text, when we name an option by its long form, we
  989. also give the corresponding short option in parentheses.
  990. The term, ``option'', can be confusing at times, since ``operations''
  991. are often lumped in with the actual, @emph{optional} ``options'' in certain
  992. general class statements. For example, we just talked about ``short and
  993. long forms of options and operations''. However, experienced @command{tar}
  994. users often refer to these by shorthand terms such as, ``short and long
  995. options''. This term assumes that the ``operations'' are included, also.
  996. Context will help you determine which definition of ``options'' to use.
  997. Similarly, the term ``command'' can be confusing, as it is often used in
  998. two different ways. People sometimes refer to @command{tar} ``commands''.
  999. A @command{tar} @dfn{command} is the entire command line of user input
  1000. which tells @command{tar} what to do --- including the operation, options,
  1001. and any arguments (file names, pipes, other commands, etc). However,
  1002. you will also sometimes hear the term ``the @command{tar} command''. When
  1003. the word ``command'' is used specifically like this, a person is usually
  1004. referring to the @command{tar} @emph{operation}, not the whole line.
  1005. Again, use context to figure out which of the meanings the speaker
  1006. intends.
  1007. @node frequent operations
  1008. @section The Three Most Frequently Used Operations
  1009. Here are the three most frequently used operations (both short and long
  1010. forms), as well as a brief description of their meanings. The rest of
  1011. this chapter will cover how to use these operations in detail. We will
  1012. present the rest of the operations in the next chapter.
  1013. @table @kbd
  1014. @item --create
  1015. @itemx -c
  1016. Create a new @command{tar} archive.
  1017. @item --list
  1018. @itemx -t
  1019. List the contents of an archive.
  1020. @item --extract
  1021. @itemx -x
  1022. Extract one or more members from an archive.
  1023. @end table
  1024. @node Two Frequent Options
  1025. @section Two Frequently Used Options
  1026. To understand how to run @command{tar} in the three operating modes listed
  1027. previously, you also need to understand how to use two of the options to
  1028. @command{tar}: @samp{--file} (which takes an archive file as an argument)
  1029. and @samp{--verbose}. (You are usually not @emph{required} to specify
  1030. either of these options when you run @command{tar}, but they can be very
  1031. useful in making things more clear and helping you avoid errors.)
  1032. @menu
  1033. * file tutorial::
  1034. * verbose tutorial::
  1035. * help tutorial::
  1036. @end menu
  1037. @node file tutorial
  1038. @unnumberedsubsec The @samp{--file} Option
  1039. @table @kbd
  1040. @item --file=@var{archive-name}
  1041. @itemx -f @var{archive-name}
  1042. Specify the name of an archive file.
  1043. @end table
  1044. You can specify an argument for the @value{op-file} option whenever you
  1045. use @command{tar}; this option determines the name of the archive file
  1046. that @command{tar} will work on.
  1047. If you don't specify this argument, then @command{tar} will use a
  1048. default, usually some physical tape drive attached to your machine.
  1049. If there is no tape drive attached, or the default is not meaningful,
  1050. then @command{tar} will print an error message. The error message might
  1051. look roughly like one of the following:
  1052. @smallexample
  1053. tar: can't open /dev/rmt8 : No such device or address
  1054. tar: can't open /dev/rsmt0 : I/O error
  1055. @end smallexample
  1056. @noindent
  1057. To avoid confusion, we recommend that you always specify an archive file
  1058. name by using @value{op-file} when writing your @command{tar} commands.
  1059. For more information on using the @value{op-file} option, see
  1060. @ref{file}.
  1061. @node verbose tutorial
  1062. @unnumberedsubsec The @samp{--verbose} Option
  1063. @table @kbd
  1064. @item --verbose
  1065. @itemx -v
  1066. Show the files being worked on as @command{tar} is running.
  1067. @end table
  1068. @value{op-verbose} shows details about the results of running
  1069. @command{tar}. This can be especially useful when the results might not be
  1070. obvious. For example, if you want to see the progress of @command{tar} as
  1071. it writes files into the archive, you can use the @samp{--verbose}
  1072. option. In the beginning, you may find it useful to use
  1073. @samp{--verbose} at all times; when you are more accustomed to
  1074. @command{tar}, you will likely want to use it at certain times but not at
  1075. others. We will use @samp{--verbose} at times to help make something
  1076. clear, and we will give many examples both using and not using
  1077. @samp{--verbose} to show the differences.
  1078. Sometimes, a single instance of @samp{--verbose} on the command line
  1079. will show a full, @samp{ls} style listing of an archive or files,
  1080. @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
  1081. giving sizes, owners, and similar information. Other times,
  1082. @samp{--verbose} will only show files or members that the particular
  1083. operation is operating on at the time. In the latter case, you can
  1084. use @samp{--verbose} twice in a command to get a listing such as that
  1085. in the former case. For example, instead of saying
  1086. @smallexample
  1087. @kbd{tar -cvf afiles.tar apple angst aspic}
  1088. @end smallexample
  1089. @noindent
  1090. above, you might say
  1091. @smallexample
  1092. @kbd{tar -cvvf afiles.tar apple angst aspic}
  1093. @end smallexample
  1094. @noindent
  1095. This works equally well using short or long forms of options. Using
  1096. long forms, you would simply write out the mnemonic form of the option
  1097. twice, like this:
  1098. @smallexample
  1099. $ @kbd{tar --create --verbose --verbose @dots{}}
  1100. @end smallexample
  1101. @noindent
  1102. Note that you must double the hyphens properly each time.
  1103. Later in the tutorial, we will give examples using @w{@samp{--verbose
  1104. --verbose}}.
  1105. @node help tutorial
  1106. @unnumberedsubsec Getting Help: Using the @code{--help} Option
  1107. @table @kbd
  1108. @item --help
  1109. The @samp{--help} option to @command{tar} prints out a very brief list of
  1110. all operations and option available for the current version of
  1111. @command{tar} available on your system.
  1112. @end table
  1113. @node create
  1114. @section How to Create Archives
  1115. @UNREVISED
  1116. One of the basic operations of @command{tar} is @value{op-create}, which
  1117. you use to create a @command{tar} archive. We will explain
  1118. @samp{--create} first because, in order to learn about the other
  1119. operations, you will find it useful to have an archive available to
  1120. practice on.
  1121. To make this easier, in this section you will first create a directory
  1122. containing three files. Then, we will show you how to create an
  1123. @emph{archive} (inside the new directory). Both the directory, and
  1124. the archive are specifically for you to practice on. The rest of this
  1125. chapter and the next chapter will show many examples using this
  1126. directory and the files you will create: some of those files may be
  1127. other directories and other archives.
  1128. The three files you will archive in this example are called
  1129. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  1130. @file{collection.tar}.
  1131. This section will proceed slowly, detailing how to use @samp{--create}
  1132. in @code{verbose} mode, and showing examples using both short and long
  1133. forms. In the rest of the tutorial, and in the examples in the next
  1134. chapter, we will proceed at a slightly quicker pace. This section
  1135. moves more slowly to allow beginning users to understand how
  1136. @command{tar} works.
  1137. @menu
  1138. * prepare for examples::
  1139. * Creating the archive::
  1140. * create verbose::
  1141. * short create::
  1142. * create dir::
  1143. @end menu
  1144. @node prepare for examples
  1145. @subsection Preparing a Practice Directory for Examples
  1146. To follow along with this and future examples, create a new directory
  1147. called @file{practice} containing files called @file{blues}, @file{folk}
  1148. and @file{jazz}. The files can contain any information you like:
  1149. ideally, they should contain information which relates to their names,
  1150. and be of different lengths. Our examples assume that @file{practice}
  1151. is a subdirectory of your home directory.
  1152. Now @command{cd} to the directory named @file{practice}; @file{practice}
  1153. is now your @dfn{working directory}. (@emph{Please note}: Although
  1154. the full path name of this directory is
  1155. @file{/@var{homedir}/practice}, in our examples we will refer to
  1156. this directory as @file{practice}; the @var{homedir} is presumed.
  1157. In general, you should check that the files to be archived exist where
  1158. you think they do (in the working directory) by running @command{ls}.
  1159. Because you just created the directory and the files and have changed to
  1160. that directory, you probably don't need to do that this time.
  1161. It is very important to make sure there isn't already a file in the
  1162. working directory with the archive name you intend to use (in this case,
  1163. @samp{collection.tar}), or that you don't care about its contents.
  1164. Whenever you use @samp{create}, @command{tar} will erase the current
  1165. contents of the file named by @value{op-file} if it exists. @command{tar}
  1166. will not tell you if you are about to overwrite an archive unless you
  1167. specify an option which does this. @FIXME{xref to the node for
  1168. --backup!}To add files to an existing archive, you need to use a
  1169. different option, such as @value{op-append}; see @ref{append} for
  1170. information on how to do this.
  1171. @node Creating the archive
  1172. @subsection Creating the Archive
  1173. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  1174. archive named @file{collection.tar}, use the following command:
  1175. @smallexample
  1176. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  1177. @end smallexample
  1178. The order of the arguments is not very important, @emph{when using long
  1179. option forms}. You could also say:
  1180. @smallexample
  1181. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1182. @end smallexample
  1183. @noindent
  1184. However, you can see that this order is harder to understand; this is
  1185. why we will list the arguments in the order that makes the commands
  1186. easiest to understand (and we encourage you to do the same when you use
  1187. @command{tar}, to avoid errors).
  1188. Note that the part of the command which says,
  1189. @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
  1190. If you substituted any other string of characters for
  1191. @kbd{collection.tar}, then that string would become the name of the
  1192. archive file you create.
  1193. The order of the options becomes more important when you begin to use
  1194. short forms. With short forms, if you type commands in the wrong order
  1195. (even if you type them correctly in all other ways), you may end up with
  1196. results you don't expect. For this reason, it is a good idea to get
  1197. into the habit of typing options in the order that makes inherent sense.
  1198. @xref{short create}, for more information on this.
  1199. In this example, you type the command as shown above: @samp{--create}
  1200. is the operation which creates the new archive
  1201. (@file{collection.tar}), and @samp{--file} is the option which lets
  1202. you give it the name you chose. The files, @file{blues}, @file{folk},
  1203. and @file{jazz}, are now members of the archive, @file{collection.tar}
  1204. (they are @dfn{file name arguments} to the @samp{--create} operation).
  1205. @FIXME{xref here to the discussion of file name args?}Now that they are
  1206. in the archive, they are called @emph{archive members}, not files.
  1207. @FIXME{xref to definitions?}
  1208. When you create an archive, you @emph{must} specify which files you
  1209. want placed in the archive. If you do not specify any archive
  1210. members, @GNUTAR{} will complain.
  1211. If you now list the contents of the working directory (@kbd{ls}), you will
  1212. find the archive file listed as well as the files you saw previously:
  1213. @smallexample
  1214. blues folk jazz collection.tar
  1215. @end smallexample
  1216. @noindent
  1217. Creating the archive @samp{collection.tar} did not destroy the copies of
  1218. the files in the directory.
  1219. Keep in mind that if you don't indicate an operation, @command{tar} will not
  1220. run and will prompt you for one. If you don't name any files, @command{tar}
  1221. will complain. You must have write access to the working directory,
  1222. or else you will not be able to create an archive in that directory.
  1223. @emph{Caution}: Do not attempt to use @value{op-create} to add files to
  1224. an existing archive; it will delete the archive and write a new one.
  1225. Use @value{op-append} instead. @xref{append}.
  1226. @node create verbose
  1227. @subsection Running @samp{--create} with @samp{--verbose}
  1228. If you include the @value{op-verbose} option on the command line,
  1229. @command{tar} will list the files it is acting on as it is working. In
  1230. verbose mode, the @code{create} example above would appear as:
  1231. @smallexample
  1232. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  1233. blues
  1234. folk
  1235. jazz
  1236. @end smallexample
  1237. This example is just like the example we showed which did not use
  1238. @samp{--verbose}, except that @command{tar} generated the remaining lines
  1239. @iftex
  1240. (note the different font styles).
  1241. @end iftex
  1242. @ifinfo
  1243. .
  1244. @end ifinfo
  1245. In the rest of the examples in this chapter, we will frequently use
  1246. @code{verbose} mode so we can show actions or @command{tar} responses that
  1247. you would otherwise not see, and which are important for you to
  1248. understand.
  1249. @node short create
  1250. @subsection Short Forms with @samp{create}
  1251. As we said before, the @value{op-create} operation is one of the most
  1252. basic uses of @command{tar}, and you will use it countless times.
  1253. Eventually, you will probably want to use abbreviated (or ``short'')
  1254. forms of options. A full discussion of the three different forms that
  1255. options can take appears in @ref{Styles}; for now, here is what the
  1256. previous example (including the @value{op-verbose} option) looks like
  1257. using short option forms:
  1258. @smallexample
  1259. $ @kbd{tar -cvf collection.tar blues folk jazz}
  1260. blues
  1261. folk
  1262. jazz
  1263. @end smallexample
  1264. @noindent
  1265. As you can see, the system responds the same no matter whether you use
  1266. long or short option forms.
  1267. @FIXME{i don't like how this is worded:} One difference between using
  1268. short and long option forms is that, although the exact placement of
  1269. arguments following options is no more specific when using short forms,
  1270. it is easier to become confused and make a mistake when using short
  1271. forms. For example, suppose you attempted the above example in the
  1272. following way:
  1273. @smallexample
  1274. $ @kbd{tar -cfv collection.tar blues folk jazz}
  1275. @end smallexample
  1276. @noindent
  1277. In this case, @command{tar} will make an archive file called @file{v},
  1278. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  1279. the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
  1280. is thus taken to be the chosen archive file name. @command{tar} will try
  1281. to add a file called @file{collection.tar} to the @file{v} archive file;
  1282. if the file @file{collection.tar} did not already exist, @command{tar} will
  1283. report an error indicating that this file does not exist. If the file
  1284. @file{collection.tar} does already exist (e.g., from a previous command
  1285. you may have run), then @command{tar} will add this file to the archive.
  1286. Because the @samp{-v} option did not get registered, @command{tar} will not
  1287. run under @samp{verbose} mode, and will not report its progress.
  1288. The end result is that you may be quite confused about what happened,
  1289. and possibly overwrite a file. To illustrate this further, we will show
  1290. you how an example we showed previously would look using short forms.
  1291. This example,
  1292. @smallexample
  1293. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1294. @end smallexample
  1295. @noindent
  1296. is confusing as it is. When shown using short forms, however, it
  1297. becomes much more so:
  1298. @smallexample
  1299. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1300. @end smallexample
  1301. @noindent
  1302. It would be very easy to put the wrong string of characters
  1303. immediately following the @samp{-f}, but doing that could sacrifice
  1304. valuable data.
  1305. For this reason, we recommend that you pay very careful attention to
  1306. the order of options and placement of file and archive names,
  1307. especially when using short option forms. Not having the option name
  1308. written out mnemonically can affect how well you remember which option
  1309. does what, and therefore where different names have to be placed.
  1310. (Placing options in an unusual order can also cause @command{tar} to
  1311. report an error if you have set the shell environment variable
  1312. @env{POSIXLY_CORRECT}.)
  1313. @node create dir
  1314. @subsection Archiving Directories
  1315. @cindex Archiving Directories
  1316. @cindex Directories, Archiving
  1317. You can archive a directory by specifying its directory name as a
  1318. file name argument to @command{tar}. The files in the directory will be
  1319. archived relative to the working directory, and the directory will be
  1320. re-created along with its contents when the archive is extracted.
  1321. To archive a directory, first move to its superior directory. If you
  1322. have followed the previous instructions in this tutorial, you should
  1323. type:
  1324. @smallexample
  1325. $ @kbd{cd ..}
  1326. $
  1327. @end smallexample
  1328. @noindent
  1329. This will put you into the directory which contains @file{practice},
  1330. i.e. your home directory. Once in the superior directory, you can
  1331. specify the subdirectory, @file{practice}, as a file name argument. To
  1332. store @file{practice} in the new archive file @file{music.tar}, type:
  1333. @smallexample
  1334. $ @kbd{tar --create --verbose --file=music.tar practice}
  1335. @end smallexample
  1336. @noindent
  1337. @command{tar} should output:
  1338. @smallexample
  1339. practice/
  1340. practice/blues
  1341. practice/folk
  1342. practice/jazz
  1343. practice/collection.tar
  1344. @end smallexample
  1345. Note that the archive thus created is not in the subdirectory
  1346. @file{practice}, but rather in the current working directory---the
  1347. directory from which @command{tar} was invoked. Before trying to archive a
  1348. directory from its superior directory, you should make sure you have
  1349. write access to the superior directory itself, not only the directory
  1350. you are trying archive with @command{tar}. For example, you will probably
  1351. not be able to store your home directory in an archive by invoking
  1352. @command{tar} from the root directory; @value{xref-absolute-names}. (Note
  1353. also that @file{collection.tar}, the original archive file, has itself
  1354. been archived. @command{tar} will accept any file as a file to be
  1355. archived, regardless of its content. When @file{music.tar} is
  1356. extracted, the archive file @file{collection.tar} will be re-written
  1357. into the file system).
  1358. If you give @command{tar} a command such as
  1359. @smallexample
  1360. $ @kbd{tar --create --file=foo.tar .}
  1361. @end smallexample
  1362. @noindent
  1363. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1364. dumped}. This happens because @command{tar} creates the archive
  1365. @file{foo.tar} in the current directory before putting any files into
  1366. it. Then, when @command{tar} attempts to add all the files in the
  1367. directory @file{.} to the archive, it notices that the file
  1368. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1369. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1370. will continue in this case, and create the archive
  1371. normally, except for the exclusion of that one file. (@emph{Please
  1372. note:} Other versions of @command{tar} are not so clever; they will
  1373. enter an infinite loop when this happens, so you should not depend on
  1374. this behavior unless you are certain you are running @GNUTAR{}.)
  1375. @FIXME{bob doesn't like this sentence, since he does
  1376. it all the time, and we've been doing it in the editing passes for
  1377. this manual: In general, make sure that the archive is not inside a
  1378. directory being dumped.}
  1379. @node list
  1380. @section How to List Archives
  1381. Frequently, you will find yourself wanting to determine exactly what a
  1382. particular archive contains. You can use the @value{op-list} operation
  1383. to get the member names as they currently appear in the archive, as well
  1384. as various attributes of the files at the time they were archived. For
  1385. example, you can examine the archive @file{collection.tar} that you
  1386. created in the last section with the command,
  1387. @smallexample
  1388. $ @kbd{tar --list --file=collection.tar}
  1389. @end smallexample
  1390. @noindent
  1391. The output of @command{tar} would then be:
  1392. @smallexample
  1393. blues
  1394. folk
  1395. jazz
  1396. @end smallexample
  1397. @FIXME{we hope this will change. if it doesn't, need to show the
  1398. creation of bfiles somewhere above!!! : }
  1399. @noindent
  1400. The archive @file{bfiles.tar} would list as follows:
  1401. @smallexample
  1402. ./birds
  1403. baboon
  1404. ./box
  1405. @end smallexample
  1406. @noindent
  1407. Be sure to use a @value{op-file} option just as with @value{op-create}
  1408. to specify the name of the archive.
  1409. If you use the @value{op-verbose} option with @samp{--list}, then
  1410. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1411. showing owner, file size, and so forth.
  1412. If you had used @value{op-verbose} mode, the example above would look
  1413. like:
  1414. @smallexample
  1415. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1416. -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
  1417. @end smallexample
  1418. @cindex File name arguments, using @code{--list} with
  1419. @cindex @code{--list} with file name arguments
  1420. You can specify one or more individual member names as arguments when
  1421. using @samp{list}. In this case, @command{tar} will only list the
  1422. names of members you identify. For example, @w{@kbd{tar --list
  1423. --file=afiles.tar apple}} would only print @file{apple}.
  1424. @FIXME{we hope the relevant aspects of this will change:}Because
  1425. @command{tar} preserves paths, file names must be specified as they appear
  1426. in the archive (ie., relative to the directory from which the archive
  1427. was created). Therefore, it is essential when specifying member names
  1428. to @command{tar} that you give the exact member names. For example,
  1429. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1430. something like @samp{tar: birds: Not found in archive}, because there is
  1431. no member named @file{birds}, only one named @file{./birds}. While the
  1432. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1433. names are compared using a simplistic name comparison, in which an exact
  1434. match is necessary. @xref{absolute}.
  1435. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1436. with @file{folk}, because @file{folk} is in the archive file
  1437. @file{collection.tar}. If you are not sure of the exact file name, try
  1438. listing all the files in the archive and searching for the one you
  1439. expect to find; remember that if you use @samp{--list} with no file
  1440. names as arguments, @command{tar} will print the names of all the members
  1441. stored in the specified archive.
  1442. @menu
  1443. * list dir::
  1444. @end menu
  1445. @node list dir
  1446. @unnumberedsubsec Listing the Contents of a Stored Directory
  1447. @UNREVISED
  1448. @FIXME{i changed the order of these nodes around and haven't had a
  1449. chance to play around with this node's example, yet. i have to play
  1450. with it and see what it actually does for my own satisfaction, even if
  1451. what it says *is* correct..}
  1452. To get information about the contents of an archived directory,
  1453. use the directory name as a file name argument in conjunction with
  1454. @value{op-list}. To find out file attributes, include the
  1455. @value{op-verbose} option.
  1456. For example, to find out about files in the directory @file{practice}, in
  1457. the archive file @file{music.tar}, type:
  1458. @smallexample
  1459. $ @kbd{tar --list --verbose --file=music.tar practice}
  1460. @end smallexample
  1461. @command{tar} responds:
  1462. @smallexample
  1463. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1464. -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
  1465. -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
  1466. -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
  1467. -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1468. @end smallexample
  1469. When you use a directory name as a file name argument, @command{tar} acts on
  1470. all the files (including sub-directories) in that directory.
  1471. @node extract
  1472. @section How to Extract Members from an Archive
  1473. @UNREVISED
  1474. @cindex Extraction
  1475. @cindex Retrieving files from an archive
  1476. @cindex Resurrecting files from an archive
  1477. Creating an archive is only half the job---there is no point in storing
  1478. files in an archive if you can't retrieve them. The act of retrieving
  1479. members from an archive so they can be used and manipulated as
  1480. unarchived files again is called @dfn{extraction}. To extract files
  1481. from an archive, use the @value{op-extract} operation. As with
  1482. @value{op-create}, specify the name of the archive with @value{op-file}.
  1483. Extracting an archive does not modify the archive in any way; you can
  1484. extract it multiple times if you want or need to.
  1485. Using @samp{--extract}, you can extract an entire archive, or specific
  1486. files. The files can be directories containing other files, or not. As
  1487. with @value{op-create} and @value{op-list}, you may use the short or the
  1488. long form of the operation without affecting the performance.
  1489. @menu
  1490. * extracting archives::
  1491. * extracting files::
  1492. * extract dir::
  1493. * extracting untrusted archives::
  1494. * failing commands::
  1495. @end menu
  1496. @node extracting archives
  1497. @subsection Extracting an Entire Archive
  1498. To extract an entire archive, specify the archive file name only, with
  1499. no individual file names as arguments. For example,
  1500. @smallexample
  1501. $ @kbd{tar -xvf collection.tar}
  1502. @end smallexample
  1503. @noindent
  1504. produces this:
  1505. @smallexample
  1506. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  1507. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  1508. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  1509. @end smallexample
  1510. @node extracting files
  1511. @subsection Extracting Specific Files
  1512. To extract specific archive members, give their exact member names as
  1513. arguments, as printed by @value{op-list}. If you had mistakenly deleted
  1514. one of the files you had placed in the archive @file{collection.tar}
  1515. earlier (say, @file{blues}), you can extract it from the archive without
  1516. changing the archive's structure. It will be identical to the original
  1517. file @file{blues} that you deleted. @FIXME{check this; will the times,
  1518. permissions, owner, etc be the same, also?}
  1519. First, make sure you are in the @file{practice} directory, and list the
  1520. files in the directory. Now, delete the file, @samp{blues}, and list
  1521. the files in the directory again.
  1522. You can now extract the member @file{blues} from the archive file
  1523. @file{collection.tar} like this:
  1524. @smallexample
  1525. $ @kbd{tar --extract --file=collection.tar blues}
  1526. @end smallexample
  1527. @noindent
  1528. If you list the files in the directory again, you will see that the file
  1529. @file{blues} has been restored, with its original permissions, creation
  1530. times, and owner.@FIXME{This is only accidentally true, but not in
  1531. general. In most cases, one has to be root for restoring the owner, and
  1532. use a special option for restoring permissions. Here, it just happens
  1533. that the restoring user is also the owner of the archived members, and
  1534. that the current @code{umask} is compatible with original permissions.}
  1535. (These parameters will be identical to those which
  1536. the file had when you originally placed it in the archive; any changes
  1537. you may have made before deleting the file from the file system,
  1538. however, will @emph{not} have been made to the archive member.) The
  1539. archive file, @samp{collection.tar}, is the same as it was before you
  1540. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1541. @value{op-list}.
  1542. @FIXME{we hope this will change:}Remember that as with other operations,
  1543. specifying the exact member name is important. @w{@kbd{tar --extract
  1544. --file=bfiles.tar birds}} will fail, because there is no member named
  1545. @file{birds}. To extract the member named @file{./birds}, you must
  1546. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1547. exact member names of the members of an archive, use @value{op-list}
  1548. (@pxref{list}).
  1549. You can extract a file to standard output by combining the above options
  1550. with the @option{--to-stdout} option (@pxref{Writing to Standard
  1551. Output}).
  1552. If you give the @value{op-verbose} option, then @value{op-extract} will
  1553. print the names of the archive members as it extracts them.
  1554. @node extract dir
  1555. @subsection Extracting Files that are Directories
  1556. Extracting directories which are members of an archive is similar to
  1557. extracting other files. The main difference to be aware of is that if
  1558. the extracted directory has the same name as any directory already in
  1559. the working directory, then files in the extracted directory will be
  1560. placed into the directory of the same name. Likewise, if there are
  1561. files in the pre-existing directory with the same names as the members
  1562. which you extract, the files from the extracted archive will replace
  1563. the files already in the working directory (and possible
  1564. subdirectories). This will happen regardless of whether or not the
  1565. files in the working directory were more recent than those extracted.
  1566. However, if a file was stored with a directory name as part of its file
  1567. name, and that directory does not exist under the working directory when
  1568. the file is extracted, @command{tar} will create the directory.
  1569. We can demonstrate how to use @samp{--extract} to extract a directory
  1570. file with an example. Change to the @file{practice} directory if you
  1571. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1572. go back to the parent directory and extract the archive
  1573. @file{music.tar}. You may either extract the entire archive, or you may
  1574. extract only the files you just deleted. To extract the entire archive,
  1575. don't give any file names as arguments after the archive name
  1576. @file{music.tar}. To extract only the files you deleted, use the
  1577. following command:
  1578. @smallexample
  1579. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1580. @end smallexample
  1581. @FIXME{need to show tar's response; used verbose above. also, here's a
  1582. good place to demonstrate the -v -v thing. have to write that up
  1583. (should be trivial, but i'm too tired!).}
  1584. @noindent
  1585. Because you created the directory with @file{practice} as part of the
  1586. file names of each of the files by archiving the @file{practice}
  1587. directory as @file{practice}, you must give @file{practice} as part
  1588. of the file names when you extract those files from the archive.
  1589. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1590. will be.}
  1591. @node extracting untrusted archives
  1592. @subsection Extracting Archives from Untrusted Sources
  1593. Extracting files from archives can overwrite files that already exist.
  1594. If you receive an archive from an untrusted source, you should make a
  1595. new directory and extract into that directory, so that you don't have
  1596. to worry about the extraction overwriting one of your existing files.
  1597. For example, if @file{untrusted.tar} came from somewhere else on the
  1598. Internet, and you don't necessarily trust its contents, you can
  1599. extract it as follows:
  1600. @smallexample
  1601. $ @kbd{mkdir newdir}
  1602. $ @kbd{cd newdir}
  1603. $ @kbd{tar -xvf ../untrusted.tar}
  1604. @end smallexample
  1605. @node failing commands
  1606. @subsection Commands That Will Fail
  1607. Here are some sample commands you might try which will not work, and why
  1608. they won't work.
  1609. If you try to use this command,
  1610. @smallexample
  1611. $ @kbd{tar -xvf music.tar folk jazz}
  1612. @end smallexample
  1613. @noindent
  1614. you will get the following response:
  1615. @smallexample
  1616. tar: folk: Not found in archive
  1617. tar: jazz: Not found in archive
  1618. $
  1619. @end smallexample
  1620. @noindent
  1621. This is because these files were not originally @emph{in} the parent
  1622. directory @file{..}, where the archive is located; they were in the
  1623. @file{practice} directory, and their file names reflect this:
  1624. @smallexample
  1625. $ @kbd{tar -tvf music.tar}
  1626. practice/folk
  1627. practice/jazz
  1628. practice/rock
  1629. @end smallexample
  1630. @FIXME{make sure the above works when going through the examples in
  1631. order...}
  1632. @noindent
  1633. Likewise, if you try to use this command,
  1634. @smallexample
  1635. $ @kbd{tar -tvf music.tar folk jazz}
  1636. @end smallexample
  1637. @noindent
  1638. you would get a similar response. Members with those names are not in the
  1639. archive. You must use the correct member names in order to extract the
  1640. files from the archive.
  1641. If you have forgotten the correct names of the files in the archive,
  1642. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1643. @FIXME{more examples, here? hag thinks it's a good idea.}
  1644. @node going further
  1645. @section Going Further Ahead in this Manual
  1646. @FIXME{need to write up a node here about the things that are going to
  1647. be in the rest of the manual.}
  1648. @node tar invocation
  1649. @chapter Invoking @GNUTAR{}
  1650. @UNREVISED
  1651. This chapter is about how one invokes the @GNUTAR{}
  1652. command, from the command synopsis (@pxref{Synopsis}). There are
  1653. numerous options, and many styles for writing them. One mandatory
  1654. option specifies the operation @command{tar} should perform
  1655. (@pxref{Operation Summary}), other options are meant to detail how
  1656. this operation should be performed (@pxref{Option Summary}).
  1657. Non-option arguments are not always interpreted the same way,
  1658. depending on what the operation is.
  1659. You will find in this chapter everything about option styles and rules for
  1660. writing them (@pxref{Styles}). On the other hand, operations and options
  1661. are fully described elsewhere, in other chapters. Here, you will find
  1662. only synthetic descriptions for operations and options, together with
  1663. pointers to other parts of the @command{tar} manual.
  1664. Some options are so special they are fully described right in this
  1665. chapter. They have the effect of inhibiting the normal operation of
  1666. @command{tar} or else, they globally alter the amount of feedback the user
  1667. receives about what is going on. These are the @value{op-help} and
  1668. @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
  1669. and @value{op-interactive} options (@pxref{interactive}).
  1670. @menu
  1671. * Synopsis::
  1672. * using tar options::
  1673. * Styles::
  1674. * All Options::
  1675. * help::
  1676. * verbose::
  1677. * interactive::
  1678. @end menu
  1679. @node Synopsis
  1680. @section General Synopsis of @command{tar}
  1681. The @GNUTAR{} program is invoked as either one of:
  1682. @smallexample
  1683. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1684. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1685. @end smallexample
  1686. The second form is for when old options are being used.
  1687. You can use @command{tar} to store files in an archive, to extract them from
  1688. an archive, and to do other types of archive manipulation. The primary
  1689. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1690. which action to take. The other arguments to @command{tar} are either
  1691. @dfn{options}, which change the way @command{tar} performs an operation,
  1692. or file names or archive members, which specify the files or members
  1693. @command{tar} is to act on.
  1694. You can actually type in arguments in any order, even if in this manual
  1695. the options always precede the other arguments, to make examples easier
  1696. to understand. Further, the option stating the main operation mode
  1697. (the @command{tar} main command) is usually given first.
  1698. Each @var{name} in the synopsis above is interpreted as an archive member
  1699. name when the main command is one of @value{op-compare}, @value{op-delete},
  1700. @value{op-extract}, @value{op-list} or @value{op-update}. When naming
  1701. archive members, you must give the exact name of the member in the
  1702. archive, as it is printed by @value{op-list}. For @value{op-append}
  1703. and @value{op-create}, these @var{name} arguments specify the names
  1704. of either files or directory hierarchies to place in the archive.
  1705. These files or hierarchies should already exist in the file system,
  1706. prior to the execution of the @command{tar} command.
  1707. @command{tar} interprets relative file names as being relative to the
  1708. working directory. @command{tar} will make all file names relative
  1709. (by removing leading slashes when archiving or restoring files),
  1710. unless you specify otherwise (using the @value{op-absolute-names}
  1711. option). @value{xref-absolute-names}, for more information about
  1712. @value{op-absolute-names}.
  1713. If you give the name of a directory as either a file name or a member
  1714. name, then @command{tar} acts recursively on all the files and directories
  1715. beneath that directory. For example, the name @file{/} identifies all
  1716. the files in the filesystem to @command{tar}.
  1717. The distinction between file names and archive member names is especially
  1718. important when shell globbing is used, and sometimes a source of confusion
  1719. for newcomers. @xref{Wildcards}, for more information about globbing.
  1720. The problem is that shells may only glob using existing files in the
  1721. file system. Only @command{tar} itself may glob on archive members, so when
  1722. needed, you must ensure that wildcard characters reach @command{tar} without
  1723. being interpreted by the shell first. Using a backslash before @samp{*}
  1724. or @samp{?}, or putting the whole argument between quotes, is usually
  1725. sufficient for this.
  1726. Even if @var{name}s are often specified on the command line, they
  1727. can also be read from a text file in the file system, using the
  1728. @value{op-files-from} option.
  1729. If you don't use any file name arguments, @value{op-append},
  1730. @value{op-delete} and @value{op-concatenate} will do nothing, while
  1731. @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
  1732. execution. The other operations of @command{tar} (@value{op-list},
  1733. @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
  1734. on the entire contents of the archive.
  1735. @cindex exit status
  1736. @cindex return status
  1737. Besides successful exits, @GNUTAR{} may fail for
  1738. many reasons. Some reasons correspond to bad usage, that is, when the
  1739. @command{tar} command is improperly written. Errors may be
  1740. encountered later, while encountering an error processing the archive
  1741. or the files. Some errors are recoverable, in which case the failure
  1742. is delayed until @command{tar} has completed all its work. Some
  1743. errors are such that it would not meaningful, or at least risky, to
  1744. continue processing: @command{tar} then aborts processing immediately.
  1745. All abnormal exits, whether immediate or delayed, should always be
  1746. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1747. the error.
  1748. @GNUTAR{} returns only a few exit statuses. I'm really
  1749. aiming simplicity in that area, for now. If you are not using the
  1750. @value{op-compare} option, zero means that everything went well, besides
  1751. maybe innocuous warnings. Nonzero means that something went wrong.
  1752. Right now, as of today, ``nonzero'' is almost always 2, except for
  1753. remote operations, where it may be 128.
  1754. @node using tar options
  1755. @section Using @command{tar} Options
  1756. @GNUTAR{} has a total of eight operating modes which
  1757. allow you to perform a variety of tasks. You are required to choose
  1758. one operating mode each time you employ the @command{tar} program by
  1759. specifying one, and only one operation as an argument to the
  1760. @command{tar} command (two lists of four operations each may be found
  1761. at @ref{frequent operations} and @ref{Operations}). Depending on
  1762. circumstances, you may also wish to customize how the chosen operating
  1763. mode behaves. For example, you may wish to change the way the output
  1764. looks, or the format of the files that you wish to archive may require
  1765. you to do something special in order to make the archive look right.
  1766. You can customize and control @command{tar}'s performance by running
  1767. @command{tar} with one or more options (such as @value{op-verbose}, which
  1768. we used in the tutorial). As we said in the tutorial, @dfn{options} are
  1769. arguments to @command{tar} which are (as their name suggests) optional.
  1770. Depending on the operating mode, you may specify one or more options.
  1771. Different options will have different effects, but in general they all
  1772. change details of the operation, such as archive format, archive name,
  1773. or level of user interaction. Some options make sense with all
  1774. operating modes, while others are meaningful only with particular modes.
  1775. You will likely use some options frequently, while you will only use
  1776. others infrequently, or not at all. (A full list of options is
  1777. available in @pxref{All Options}.)
  1778. The @env{TAR_OPTIONS} environment variable specifies default options to
  1779. be placed in front of any explicit options. For example, if
  1780. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1781. if the two options @option{-v} and @option{--unlink-first} had been
  1782. specified before any explicit options. Option specifications are
  1783. separated by whitespace. A backslash escapes the next character, so it
  1784. can be used to specify an option containing whitespace or a backslash.
  1785. Note that @command{tar} options are case sensitive. For example, the
  1786. options @samp{-T} and @samp{-t} are different; the first requires an
  1787. argument for stating the name of a file providing a list of @var{name}s,
  1788. while the second does not require an argument and is another way to
  1789. write @value{op-list}.
  1790. In addition to the eight operations, there are many options to
  1791. @command{tar}, and three different styles for writing both: long (mnemonic)
  1792. form, short form, and old style. These styles are discussed below.
  1793. Both the options and the operations can be written in any of these three
  1794. styles.
  1795. @FIXME{menu at end of this node. need to think of an actual outline
  1796. for this chapter; probably do that after stuff from chap. 4 is
  1797. incorporated.}
  1798. @node Styles
  1799. @section The Three Option Styles
  1800. There are three styles for writing operations and options to the command
  1801. line invoking @command{tar}. The different styles were developed at
  1802. different times during the history of @command{tar}. These styles will be
  1803. presented below, from the most recent to the oldest.
  1804. Some options must take an argument. (For example, @value{op-file} takes
  1805. the name of an archive file as an argument. If you do not supply an
  1806. archive file name, @command{tar} will use a default, but this can be
  1807. confusing; thus, we recommend that you always supply a specific archive
  1808. file name.) Where you @emph{place} the arguments generally depends on
  1809. which style of options you choose. We will detail specific information
  1810. relevant to each option style in the sections on the different option
  1811. styles, below. The differences are subtle, yet can often be very
  1812. important; incorrect option placement can cause you to overwrite a
  1813. number of important files. We urge you to note these differences, and
  1814. only use the option style(s) which makes the most sense to you until you
  1815. feel comfortable with the others.
  1816. @FIXME{hag to write a brief paragraph on the option(s) which can
  1817. optionally take an argument}
  1818. @menu
  1819. * Mnemonic Options:: Mnemonic Option Style
  1820. * Short Options:: Short Option Style
  1821. * Old Options:: Old Option Style
  1822. * Mixing:: Mixing Option Styles
  1823. @end menu
  1824. @node Mnemonic Options
  1825. @subsection Mnemonic Option Style
  1826. @FIXME{have to decide whether or not to replace other occurrences of
  1827. "mnemonic" with "long", or *ugh* vice versa.}
  1828. Each option has at least one long (or mnemonic) name starting with two
  1829. dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
  1830. their corresponding short or old names. It sometimes happens that a
  1831. single mnemonic option has many different different names which are
  1832. synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
  1833. long option names can be given unique abbreviations. For example,
  1834. @samp{--cre} can be used in place of @samp{--create} because there is no
  1835. other mnemonic option which begins with @samp{cre}. (One way to find
  1836. this out is by trying it and seeing what happens; if a particular
  1837. abbreviation could represent more than one option, @command{tar} will tell
  1838. you that that abbreviation is ambiguous and you'll know that that
  1839. abbreviation won't work. You may also choose to run @samp{tar --help}
  1840. to see a list of options. Be aware that if you run @command{tar} with a
  1841. unique abbreviation for the long name of an option you didn't want to
  1842. use, you are stuck; @command{tar} will perform the command as ordered.)
  1843. Mnemonic options are meant to be obvious and easy to remember, and their
  1844. meanings are generally easier to discern than those of their
  1845. corresponding short options (see below). For example:
  1846. @smallexample
  1847. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1848. @end smallexample
  1849. @noindent
  1850. gives a fairly good set of hints about what the command does, even
  1851. for those not fully acquainted with @command{tar}.
  1852. Mnemonic options which require arguments take those arguments
  1853. immediately following the option name; they are introduced by an equal
  1854. sign. For example, the @samp{--file} option (which tells the name
  1855. of the @command{tar} archive) is given a file such as @file{archive.tar}
  1856. as argument by using the notation @samp{--file=archive.tar} for the
  1857. mnemonic option.
  1858. @node Short Options
  1859. @subsection Short Option Style
  1860. Most options also have a short option name. Short options start with
  1861. a single dash, and are followed by a single character, e.g.@: @samp{-t}
  1862. (which is equivalent to @samp{--list}). The forms are absolutely
  1863. identical in function; they are interchangeable.
  1864. The short option names are faster to type than long option names.
  1865. Short options which require arguments take their arguments immediately
  1866. following the option, usually separated by white space. It is also
  1867. possible to stick the argument right after the short option name, using
  1868. no intervening space. For example, you might write @w{@samp{-f
  1869. archive.tar}} or @samp{-farchive.tar} instead of using
  1870. @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
  1871. @w{@samp{-f @var{archive-name}}} denote the option which indicates a
  1872. specific archive, here named @file{archive.tar}.
  1873. Short options' letters may be clumped together, but you are not
  1874. required to do this (as compared to old options; see below). When
  1875. short options are clumped as a set, use one (single) dash for them
  1876. all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
  1877. such a set is allowed to have an argument@footnote{Clustering many
  1878. options, the last of which has an argument, is a rather opaque way to
  1879. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1880. even be made helpful enough for considering such usages as invalid.}.
  1881. When the options are separated, the argument for each option which requires
  1882. an argument directly follows that option, as is usual for Unix programs.
  1883. For example:
  1884. @smallexample
  1885. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1886. @end smallexample
  1887. If you reorder short options' locations, be sure to move any arguments
  1888. that belong to them. If you do not move the arguments properly, you may
  1889. end up overwriting files.
  1890. @node Old Options
  1891. @subsection Old Option Style
  1892. @UNREVISED
  1893. Like short options, old options are single letters. However, old options
  1894. must be written together as a single clumped set, without spaces separating
  1895. them or dashes preceding them@footnote{Beware that if you precede options
  1896. with a dash, you are announcing the short option style instead of the
  1897. old option style; short options are decoded differently.}. This set
  1898. of letters must be the first to appear on the command line, after the
  1899. @command{tar} program name and some white space; old options cannot appear
  1900. anywhere else. The letter of an old option is exactly the same letter as
  1901. the corresponding short option. For example, the old option @samp{t} is
  1902. the same as the short option @samp{-t}, and consequently, the same as the
  1903. mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
  1904. cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
  1905. @FIXME{bob suggests having an uglier example. :-) }
  1906. When options that need arguments are given together with the command,
  1907. all the associated arguments follow, in the same order as the options.
  1908. Thus, the example given previously could also be written in the old
  1909. style as follows:
  1910. @smallexample
  1911. $ @kbd{tar cvbf 20 /dev/rmt0}
  1912. @end smallexample
  1913. @noindent
  1914. Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
  1915. the argument of @samp{-f}.
  1916. On the other hand, this old style syntax makes it difficult to match
  1917. option letters with their corresponding arguments, and is often
  1918. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1919. @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
  1920. argument for @samp{-f}, and @samp{-v} does not have a corresponding
  1921. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1922. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1923. pertain to.
  1924. If you want to reorder the letters in the old option argument, be
  1925. sure to reorder any corresponding argument appropriately.
  1926. This old way of writing @command{tar} options can surprise even experienced
  1927. users. For example, the two commands:
  1928. @smallexample
  1929. @kbd{tar cfz archive.tar.gz file}
  1930. @kbd{tar -cfz archive.tar.gz file}
  1931. @end smallexample
  1932. @noindent
  1933. are quite different. The first example uses @file{archive.tar.gz} as
  1934. the value for option @samp{f} and recognizes the option @samp{z}. The
  1935. second example, however, uses @file{z} as the value for option
  1936. @samp{f}---probably not what was intended.
  1937. Old options are kept for compatibility with old versions of @command{tar}.
  1938. This second example could be corrected in many ways, among which the
  1939. following are equivalent:
  1940. @smallexample
  1941. @kbd{tar -czf archive.tar.gz file}
  1942. @kbd{tar -cf archive.tar.gz -z file}
  1943. @kbd{tar cf archive.tar.gz -z file}
  1944. @end smallexample
  1945. @FIXME{still could explain this better; it's redundant:}
  1946. @cindex option syntax, traditional
  1947. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1948. non-@acronym{GNU}, support old options. @GNUTAR{}
  1949. supports them not only for historical reasons, but also because many
  1950. people are used to them. For compatibility with Unix @command{tar},
  1951. the first argument is always treated as containing command and option
  1952. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1953. equivalent to @w{@samp{tar -c}:} both of them specify the
  1954. @value{op-create} command to create an archive.
  1955. @node Mixing
  1956. @subsection Mixing Option Styles
  1957. All three styles may be intermixed in a single @command{tar} command,
  1958. so long as the rules for each style are fully
  1959. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1960. a bug prevented intermixing old style options with mnemonic options in
  1961. some cases.}. Old style options and either of the modern styles of
  1962. options may be mixed within a single @command{tar} command. However,
  1963. old style options must be introduced as the first arguments only,
  1964. following the rule for old options (old options must appear directly
  1965. after the @command{tar} command and some white space). Modern options
  1966. may be given only after all arguments to the old options have been
  1967. collected. If this rule is not respected, a modern option might be
  1968. falsely interpreted as the value of the argument to one of the old
  1969. style options.
  1970. For example, all the following commands are wholly equivalent, and
  1971. illustrate the many combinations and orderings of option styles.
  1972. @smallexample
  1973. @kbd{tar --create --file=archive.tar}
  1974. @kbd{tar --create -f archive.tar}
  1975. @kbd{tar --create -farchive.tar}
  1976. @kbd{tar --file=archive.tar --create}
  1977. @kbd{tar --file=archive.tar -c}
  1978. @kbd{tar -c --file=archive.tar}
  1979. @kbd{tar -c -f archive.tar}
  1980. @kbd{tar -c -farchive.tar}
  1981. @kbd{tar -cf archive.tar}
  1982. @kbd{tar -cfarchive.tar}
  1983. @kbd{tar -f archive.tar --create}
  1984. @kbd{tar -f archive.tar -c}
  1985. @kbd{tar -farchive.tar --create}
  1986. @kbd{tar -farchive.tar -c}
  1987. @kbd{tar c --file=archive.tar}
  1988. @kbd{tar c -f archive.tar}
  1989. @kbd{tar c -farchive.tar}
  1990. @kbd{tar cf archive.tar}
  1991. @kbd{tar f archive.tar --create}
  1992. @kbd{tar f archive.tar -c}
  1993. @kbd{tar fc archive.tar}
  1994. @end smallexample
  1995. On the other hand, the following commands are @emph{not} equivalent to
  1996. the previous set:
  1997. @smallexample
  1998. @kbd{tar -f -c archive.tar}
  1999. @kbd{tar -fc archive.tar}
  2000. @kbd{tar -fcarchive.tar}
  2001. @kbd{tar -farchive.tarc}
  2002. @kbd{tar cfarchive.tar}
  2003. @end smallexample
  2004. @noindent
  2005. These last examples mean something completely different from what the
  2006. user intended (judging based on the example in the previous set which
  2007. uses long options, whose intent is therefore very clear). The first
  2008. four specify that the @command{tar} archive would be a file named
  2009. @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  2010. respectively. The first two examples also specify a single non-option,
  2011. @var{name} argument having the value @samp{archive.tar}. The last
  2012. example contains only old style option letters (repeating option
  2013. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  2014. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  2015. the first sentence of this paragraph..}
  2016. @node All Options
  2017. @section All @command{tar} Options
  2018. The coming manual sections contain an alphabetical listing of all
  2019. @command{tar} operations and options, with brief descriptions and cross
  2020. references to more in-depth explanations in the body of the manual.
  2021. They also contain an alphabetically arranged table of the short option
  2022. forms with their corresponding long option. You can use this table as
  2023. a reference for deciphering @command{tar} commands in scripts.
  2024. @menu
  2025. * Operation Summary::
  2026. * Option Summary::
  2027. * Short Option Summary::
  2028. @end menu
  2029. @node Operation Summary
  2030. @subsection Operations
  2031. @table @kbd
  2032. @item --append
  2033. @itemx -r
  2034. Appends files to the end of the archive. @xref{append}.
  2035. @item --catenate
  2036. @itemx -A
  2037. Same as @samp{--concatenate}. @xref{concatenate}.
  2038. @item --compare
  2039. @itemx -d
  2040. Compares archive members with their counterparts in the file
  2041. system, and reports differences in file size, mode, owner,
  2042. modification date and contents. @xref{compare}.
  2043. @item --concatenate
  2044. @itemx -A
  2045. Appends other @command{tar} archives to the end of the archive.
  2046. @xref{concatenate}.
  2047. @item --create
  2048. @itemx -c
  2049. Creates a new @command{tar} archive. @xref{create}.
  2050. @item --delete
  2051. Deletes members from the archive. Don't try this on a archive on a
  2052. tape! @xref{delete}.
  2053. @item --diff
  2054. @itemx -d
  2055. Same @samp{--compare}. @xref{compare}.
  2056. @item --extract
  2057. @itemx -x
  2058. Extracts members from the archive into the file system. @xref{extract}.
  2059. @item --get
  2060. @itemx -x
  2061. Same as @samp{--extract}. @xref{extract}.
  2062. @item --list
  2063. @itemx -t
  2064. Lists the members in an archive. @xref{list}.
  2065. @item --update
  2066. @itemx -u
  2067. @FIXME{It was: A combination of the @samp{--compare} and
  2068. @samp{--append} operations. This is not true and rather misleading,
  2069. as @value{op-compare} does a lot more than @value{op-update} for
  2070. ensuring files are identical.} Adds files to the end of the archive,
  2071. but only if they are newer than their counterparts already in the
  2072. archive, or if they do not already exist in the archive.
  2073. @xref{update}.
  2074. @end table
  2075. @node Option Summary
  2076. @subsection @command{tar} Options
  2077. @table @kbd
  2078. @item --absolute-names
  2079. @itemx -P
  2080. Normally when creating an archive, @command{tar} strips an initial
  2081. @samp{/} from member names. This option disables that behavior.
  2082. @FIXME-xref{}
  2083. @item --after-date
  2084. (See @samp{--newer}.) @FIXME-pxref{}
  2085. @item --anchored
  2086. An exclude pattern must match an initial subsequence of the name's components.
  2087. @FIXME-xref{}
  2088. @item --atime-preserve
  2089. Tells @command{tar} to preserve the access time field in a file's inode when
  2090. reading it. Due to limitations in the @code{utimes} system call, the
  2091. modification time field is also preserved, which may cause problems if
  2092. the file is simultaneously being modified by another program.
  2093. This option is incompatible with incremental backups, because
  2094. preserving the access time involves updating the last-changed time.
  2095. Also, this option does not work on files that you do not own,
  2096. unless you're root.
  2097. @FIXME-xref{}
  2098. @item --backup=@var{backup-type}
  2099. Rather than deleting files from the file system, @command{tar} will
  2100. back them up using simple or numbered backups, depending upon
  2101. @var{backup-type}. @FIXME-xref{}
  2102. @item --block-number
  2103. @itemx -R
  2104. With this option present, @command{tar} prints error messages for read errors
  2105. with the block number in the archive file. @FIXME-xref{}
  2106. @item --blocking-factor=@var{blocking}
  2107. @itemx -b @var{blocking}
  2108. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  2109. record. @FIXME-xref{}
  2110. @item --bzip2
  2111. @itemx -j
  2112. This option tells @command{tar} to read or write archives through
  2113. @code{bzip2}. @FIXME-xref{}
  2114. @item --checkpoint
  2115. This option directs @command{tar} to print periodic checkpoint messages as it
  2116. reads through the archive. Its intended for when you want a visual
  2117. indication that @command{tar} is still running, but don't want to see
  2118. @samp{--verbose} output. @FIXME-xref{}
  2119. @item --check-links
  2120. @itemx -l
  2121. If this option was given, @command{tar} will check the number of links
  2122. dumped for each processed file. If this number does not match the
  2123. total number of hard links for the file, a warning message will be
  2124. output.
  2125. Future versions will take @option{-l} as a short version of
  2126. @option{--check-links}. However, current release still retains the old
  2127. semantics for @option{-l}.
  2128. @xref{Current status}, for more information.
  2129. @item --compress
  2130. @itemx --uncompress
  2131. @itemx -Z
  2132. @command{tar} will use the @command{compress} program when reading or
  2133. writing the archive. This allows you to directly act on archives
  2134. while saving space. @FIXME-xref{}
  2135. @item --confirmation
  2136. (See @samp{--interactive}.) @FIXME-pxref{}
  2137. @item --dereference
  2138. @itemx -h
  2139. When creating a @command{tar} archive, @command{tar} will archive the
  2140. file that a symbolic link points to, rather than archiving the
  2141. symlink. @FIXME-xref{}
  2142. @item --directory=@var{dir}
  2143. @itemx -C @var{dir}
  2144. When this option is specified, @command{tar} will change its current directory
  2145. to @var{dir} before performing any operations. When this option is used
  2146. during archive creation, it is order sensitive. @FIXME-xref{}
  2147. @item --exclude=@var{pattern}
  2148. When performing operations, @command{tar} will skip files that match
  2149. @var{pattern}. @FIXME-xref{}
  2150. @item --exclude-from=@var{file}
  2151. @itemx -X @var{file}
  2152. Similar to @samp{--exclude}, except @command{tar} will use the list of
  2153. patterns in the file @var{file}. @FIXME-xref{}
  2154. @item --file=@var{archive}
  2155. @itemx -f @var{archive}
  2156. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2157. performs operations on, rather than @command{tar}'s compilation dependent
  2158. default. @FIXME-xref{}
  2159. @item --files-from=@var{file}
  2160. @itemx -T @var{file}
  2161. @command{tar} will use the contents of @var{file} as a list of archive members
  2162. or files to operate on, in addition to those specified on the
  2163. command-line. @FIXME-xref{}
  2164. @item --force-local
  2165. Forces @command{tar} to interpret the filename given to @samp{--file}
  2166. as a local file, even if it looks like a remote tape drive name.
  2167. @FIXME-xref{}
  2168. @item --format=@var{format}
  2169. Selects output archive format. @var{Format} may be one of the
  2170. following:
  2171. @table @samp
  2172. @item v7
  2173. Creates an archive that is compatible with Unix V7 @command{tar}.
  2174. @item oldgnu
  2175. Creates an archive that is compatible with GNU @command{tar} version
  2176. 1.12 or earlier.
  2177. @item gnu
  2178. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2179. @samp{oldgnu} with the only difference in the way it handles long
  2180. numeric fields.
  2181. @item ustar
  2182. Creates a POSIX.1-1988 compatible archive.
  2183. @item posix
  2184. Creates a POSIX.1-2001 archive.
  2185. @end table
  2186. @item --group=@var{group}
  2187. Files added to the @command{tar} archive will have a group id of @var{group},
  2188. rather than the group from the source file. @var{group} is first decoded
  2189. as a group symbolic name, but if this interpretation fails, it has to be
  2190. a decimal numeric group ID. @FIXME-xref{}
  2191. Also see the comments for the @value{op-owner} option.
  2192. @item --gzip
  2193. @itemx --gunzip
  2194. @itemx --ungzip
  2195. @itemx -z
  2196. This option tells @command{tar} to read or write archives through
  2197. @command{gzip}, allowing @command{tar} to directly operate on several
  2198. kinds of compressed archives transparently. @FIXME-xref{}
  2199. @item --help
  2200. @command{tar} will print out a short message summarizing the operations and
  2201. options to @command{tar} and exit. @FIXME-xref{}
  2202. @item --ignore-case
  2203. Ignore case when excluding files.
  2204. @FIXME-xref{}
  2205. @item --ignore-failed-read
  2206. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2207. @xref{Reading}.
  2208. @item --ignore-zeros
  2209. @itemx -i
  2210. With this option, @command{tar} will ignore zeroed blocks in the
  2211. archive, which normally signals EOF. @xref{Reading}.
  2212. @item --incremental
  2213. @itemx -G
  2214. Used to inform @command{tar} that it is working with an old
  2215. @acronym{GNU}-format incremental backup archive. It is intended
  2216. primarily for backwards compatibility only. @FIXME-xref{}
  2217. @item --index-file=@var{file}
  2218. Send verbose output to @var{file} instead of to standard output.
  2219. @item --info-script=@var{script-file}
  2220. @itemx --new-volume-script=@var{script-file}
  2221. @itemx -F @var{script-file}
  2222. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2223. at the end of each tape. If @var{script-file} exits with nonzero status,
  2224. @command{tar} fails immediately. @FIXME-xref{}
  2225. @item --interactive
  2226. @itemx --confirmation
  2227. @itemx -w
  2228. Specifies that @command{tar} should ask the user for confirmation before
  2229. performing potentially destructive options, such as overwriting files.
  2230. @FIXME-xref{}
  2231. @item --keep-old-files
  2232. @itemx -k
  2233. Do not overwrite existing files when extracting files from an archive.
  2234. @xref{Writing}.
  2235. @item --label=@var{name}
  2236. @itemx -V @var{name}
  2237. When creating an archive, instructs @command{tar} to write @var{name}
  2238. as a name record in the archive. When extracting or listing archives,
  2239. @command{tar} will only operate on archives that have a label matching
  2240. the pattern specified in @var{name}. @FIXME-xref{}
  2241. @item --listed-incremental=@var{snapshot-file}
  2242. @itemx -g @var{snapshot-file}
  2243. During a @samp{--create} operation, specifies that the archive that
  2244. @command{tar} creates is a new @acronym{GNU}-format incremental
  2245. backup, using @var{snapshot-file} to determine which files to backup.
  2246. With other operations, informs @command{tar} that the archive is in
  2247. incremental format. @FIXME-xref{}
  2248. @item --mode=@var{permissions}
  2249. When adding files to an archive, @command{tar} will use
  2250. @var{permissions} for the archive members, rather than the permissions
  2251. from the files. The program @command{chmod} and this @command{tar}
  2252. option share the same syntax for what @var{permissions} might be.
  2253. @xref{File permissions, Permissions, File permissions, fileutils,
  2254. @acronym{GNU} file utilities}. This reference also has useful
  2255. information for those not being overly familiar with the Unix
  2256. permission system.
  2257. Of course, @var{permissions} might be plainly specified as an octal number.
  2258. However, by using generic symbolic modifications to mode bits, this allows
  2259. more flexibility. For example, the value @samp{a+rw} adds read and write
  2260. permissions for everybody, while retaining executable bits on directories
  2261. or on any other file already marked as executable.
  2262. @item --multi-volume
  2263. @itemx -M
  2264. Informs @command{tar} that it should create or otherwise operate on a
  2265. multi-volume @command{tar} archive. @FIXME-xref{}
  2266. @item --new-volume-script
  2267. (see --info-script)
  2268. @item --newer=@var{date}
  2269. @itemx --after-date=@var{date}
  2270. @itemx -N
  2271. When creating an archive, @command{tar} will only add files that have changed
  2272. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2273. is taken to be the name of a file whose last-modified time specifies
  2274. the date. @FIXME-xref{}
  2275. @item --newer-mtime=@var{date}
  2276. Like @samp{--newer}, but add only files whose
  2277. contents have changed (as opposed to just @samp{--newer}, which will
  2278. also back up files for which any status information has changed).
  2279. @item --no-anchored
  2280. An exclude pattern can match any subsequence of the name's components.
  2281. @FIXME-xref{}
  2282. @item --no-ignore-case
  2283. Use case-sensitive matching when excluding files.
  2284. @FIXME-xref{}
  2285. @item --no-recursion
  2286. With this option, @command{tar} will not recurse into directories.
  2287. @FIXME-xref{}
  2288. @item --no-same-owner
  2289. @itemx -o
  2290. When extracting an archive, do not attempt to preserve the owner
  2291. specified in the @command{tar} archive. This the default behavior
  2292. for ordinary users; this option has an effect only for the superuser.
  2293. @item --no-same-permissions
  2294. When extracting an archive, subtract the user's umask from files from
  2295. the permissions specified in the archive. This is the default behavior
  2296. for ordinary users; this option has an effect only for the superuser.
  2297. @item --no-wildcards
  2298. Do not use wildcards when excluding files.
  2299. @FIXME-xref{}
  2300. @item --no-wildcards-match-slash
  2301. Wildcards do not match @samp{/} when excluding files.
  2302. @FIXME-xref{}
  2303. @item --null
  2304. When @command{tar} is using the @samp{--files-from} option, this option
  2305. instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
  2306. @command{tar} can correctly work with file names that contain newlines.
  2307. @FIXME-xref{}
  2308. @item --numeric-owner
  2309. This option will notify @command{tar} that it should use numeric user
  2310. and group IDs when creating a @command{tar} file, rather than names.
  2311. @FIXME-xref{}
  2312. @item -o
  2313. When extracting files, this option is a synonym for
  2314. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2315. restoring ownership of files being extracted.
  2316. When creating an archive, @option{-o} is a synonym for
  2317. @option{--old-archive}. This behavior is for compatibility
  2318. with previous versions of @GNUTAR{}, and will be
  2319. removed in the future releases.
  2320. @xref{Current status}, for more information.
  2321. @item --occurrence[=@var{number}]
  2322. This option can be used in conjunction with one of the subcommands
  2323. @option{--delete}, @option{--diff}, @option{--extract} or
  2324. @option{--list} when a list of files is given either on the command
  2325. line or via @option{-T} option.
  2326. This option instructs @command{tar} to process only the @var{number}th
  2327. occurrence of each named file. @var{Number} defaults to 1, so
  2328. @smallexample
  2329. tar -x -f archive.tar --occurrence filename
  2330. @end smallexample
  2331. @noindent
  2332. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2333. and will terminate without scanning to the end of the archive.
  2334. @item --old-archive
  2335. Synonym for @option{--format=v7}.
  2336. @item --one-file-system
  2337. @itemx -l
  2338. Used when creating an archive. Prevents @command{tar} from recursing into
  2339. directories that are on different file systems from the current
  2340. directory.
  2341. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2342. synonym for @option{--one-file-system}. Although such usage is still
  2343. allowed in the present version, it is @emph{strongly discouraged}.
  2344. The future versions of @GNUTAR{} will use @option{-l} as
  2345. a synonym for @option{--check-links}.
  2346. @xref{Current status}, for more information.
  2347. @item --overwrite
  2348. Overwrite existing files and directory metadata when extracting files
  2349. from an archive. @xref{Overwrite Old Files}.
  2350. @item --overwrite-dir
  2351. Overwrite the metadata of existing directories when extracting files
  2352. from an archive. @xref{Overwrite Old Files}.
  2353. @item --owner=@var{user}
  2354. Specifies that @command{tar} should use @var{user} as the owner of members
  2355. when creating archives, instead of the user associated with the source
  2356. file. @var{user} is first decoded as a user symbolic name, but if
  2357. this interpretation fails, it has to be a decimal numeric user ID.
  2358. @FIXME-xref{}
  2359. There is no value indicating a missing number, and @samp{0} usually means
  2360. @code{root}. Some people like to force @samp{0} as the value to offer in
  2361. their distributions for the owner of files, because the @code{root} user is
  2362. anonymous anyway, so that might as well be the owner of anonymous archives.
  2363. This option does not affect extraction from archives.
  2364. @item --pax-option=@var{keyword-list}
  2365. This option is meaningful only with POSIX.1-2001 archives
  2366. (@FIXME-xref{}). It modifies the way @command{tar} handles the
  2367. extended header keywords. @var{Keyword-list} is a comma-separated
  2368. list of keyword options, each keyword option taking one of
  2369. the following forms:
  2370. @table @asis
  2371. @item delete=@var{pattern}
  2372. When used with one of archive-creation command (@FIXME-xref{}),
  2373. this option instructs @command{tar} to omit from extended header records
  2374. that it produces any keywords matching the string @var{pattern}.
  2375. When used in extract or list mode, this option instructs tar
  2376. to ignore any keywords matching the given @var{pattern} in the extended
  2377. header records. In both cases, matching is performed using the pattern
  2378. matching notation described in POSIX 1003.2, 3.13 (@FIXME-xref{}, see
  2379. man 7 glob). For example:
  2380. @smallexample
  2381. --pax-option delete=security.*
  2382. @end smallexample
  2383. would suppress security-related information.
  2384. @item exthdr.name=@var{string}
  2385. This keyword allows user control over the name that is written into the
  2386. ustar header blocks for the extended headers. The name is obtained
  2387. from @var{string} after substituting the following meta-characters:
  2388. @multitable @columnfractions .30 .70
  2389. @item Meta-character @tab Replaced By
  2390. @item %d @tab The directory name of the file, equivalent to the
  2391. result of the @command{dirname} utility on the translated pathname.
  2392. @item %f @tab The filename of the file, equivalent to the result
  2393. of the @command{basename} utility on the translated pathname.
  2394. @item %p @tab The process ID of the @command{tar} process.
  2395. @item %% @tab A @samp{%} character.
  2396. @end multitable
  2397. Any other @samp{%} characters in @var{string} produce undefined
  2398. results.
  2399. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2400. will use the following default value:
  2401. @smallexample
  2402. %d/PaxHeaders.%p/%f
  2403. @end smallexample
  2404. @item globexthdr.name=@var{string}
  2405. This keyword allows user control over the name that is written into
  2406. the ustar header blocks for global extended header records. The name
  2407. shall will be obtained from the contents of @var{string}, after the
  2408. following character substitutions have been made:
  2409. @multitable @columnfractions .30 .70
  2410. @item Meta-character @tab Replaced By
  2411. @item %n @tab An integer that represents the
  2412. sequence number of the global extended header record in the archive,
  2413. starting at 1.
  2414. @item %p @tab The process ID of the @command{tar} process.
  2415. @item %% @tab A @samp{%} character.
  2416. @end multitable
  2417. Any other @samp{%} characters in string produce undefined results.
  2418. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2419. will use the following default value:
  2420. @smallexample
  2421. $TMPDIR/GlobalHead.%p.%n
  2422. @end smallexample
  2423. @noindent
  2424. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2425. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2426. uses @samp{/tmp}.
  2427. @item @var{keyword}=@var{value}
  2428. When used with one of archive-creation commands, these keyword/value pairs
  2429. will be included at the beginning of the archive in a global extended
  2430. header record. When used with one of archive-reading commands,
  2431. @command{tar} will behave as if it has encountered these keyword/value
  2432. pairs at the beginning of the archive in a global extended header
  2433. record.
  2434. @item @var{keyword}:=@var{value}
  2435. When used with one of archive-creation commands, these keyword/value pairs
  2436. will be included as records at the beginning of an extended header for
  2437. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2438. form except that it creates no global extended header records.
  2439. When used with one of archive-reading commands, @command{tar} will
  2440. behave as if these keyword/value pairs were included as records at the
  2441. end of each extended header; thus, they will override any global or
  2442. file-specific extended header record keywords of the same names.
  2443. For example, in the command:
  2444. @smallexample
  2445. tar --format=posix --create \
  2446. --file archive --pax-option gname:=user .
  2447. @end smallexample
  2448. the group name will be forced to a new value for all files
  2449. stored in the archive.
  2450. @end table
  2451. @item --portability
  2452. @itemx --old-archive
  2453. Synonym for @option{--format=v7}.
  2454. @item --posix
  2455. Same as @option{--format=posix}.
  2456. @item --preserve
  2457. Synonymous with specifying both @samp{--preserve-permissions} and
  2458. @samp{--same-order}. @FIXME-xref{}
  2459. @item --preserve-order
  2460. (See @samp{--same-order}; @pxref{Reading}.)
  2461. @item --preserve-permissions
  2462. @itemx --same-permissions
  2463. @itemx -p
  2464. When @command{tar} is extracting an archive, it normally subtracts the
  2465. users' umask from the permissions specified in the archive and uses
  2466. that number as the permissions to create the destination file.
  2467. Specifying this option instructs @command{tar} that it should use the
  2468. permissions directly from the archive. @xref{Writing}.
  2469. @item --read-full-records
  2470. @itemx -B
  2471. Specifies that @command{tar} should reblock its input, for reading
  2472. from pipes on systems with buggy implementations. @xref{Reading}.
  2473. @item --record-size=@var{size}
  2474. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2475. archive. @FIXME-xref{}
  2476. @item --recursion
  2477. With this option, @command{tar} recurses into directories.
  2478. @FIXME-xref{}
  2479. @item --recursive-unlink
  2480. Remove existing
  2481. directory hierarchies before extracting directories of the same name
  2482. from the archive. @xref{Writing}.
  2483. @item --remove-files
  2484. Directs @command{tar} to remove the source file from the file system after
  2485. appending it to an archive. @FIXME-xref{}
  2486. @item --rsh-command=@var{cmd}
  2487. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2488. devices. @FIXME-xref{}
  2489. @item --same-order
  2490. @itemx --preserve-order
  2491. @itemx -s
  2492. This option is an optimization for @command{tar} when running on machines with
  2493. small amounts of memory. It informs @command{tar} that the list of file
  2494. arguments has already been sorted to match the order of files in the
  2495. archive. @xref{Reading}.
  2496. @item --same-owner
  2497. When extracting an archive, @command{tar} will attempt to preserve the owner
  2498. specified in the @command{tar} archive with this option present.
  2499. This is the default behavior for the superuser; this option has an
  2500. effect only for ordinary users. @FIXME-xref{}
  2501. @item --same-permissions
  2502. (See @samp{--preserve-permissions}; @pxref{Writing}.)
  2503. @item --show-omitted-dirs
  2504. Instructs @command{tar} to mention directories its skipping over when
  2505. operating on a @command{tar} archive. @FIXME-xref{}
  2506. @item --sparse
  2507. @itemx -S
  2508. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2509. sparse files efficiently. @FIXME-xref{}
  2510. @item --starting-file=@var{name}
  2511. @itemx -K @var{name}
  2512. This option affects extraction only; @command{tar} will skip extracting
  2513. files in the archive until it finds one that matches @var{name}.
  2514. @xref{Scarce}.
  2515. @item --strip-path=@var{number}
  2516. Strip given @var{number} of leading components from file names before
  2517. extraction. For example, if archive @file{archive.tar} contained
  2518. @file{/some/file/name}, then running
  2519. @smallexample
  2520. tar --extract --file archive.tar --strip-path=2
  2521. @end smallexample
  2522. @noindent
  2523. would extracted this file to file @file{name}.
  2524. @item --suffix=@var{suffix}
  2525. Alters the suffix @command{tar} uses when backing up files from the default
  2526. @samp{~}. @FIXME-xref{}
  2527. @item --tape-length=@var{num}
  2528. @itemx -L @var{num}
  2529. Specifies the length of tapes that @command{tar} is writing as being
  2530. @w{@var{num} x 1024} bytes long. @FIXME-xref{}
  2531. @item --to-stdout
  2532. @itemx -O
  2533. During extraction, @command{tar} will extract files to stdout rather
  2534. than to the file system. @xref{Writing}.
  2535. @item --totals
  2536. Displays the total number of bytes written after creating an archive.
  2537. @FIXME-xref{}
  2538. @item --touch
  2539. @itemx -m
  2540. Sets the modification time of extracted files to the extraction time,
  2541. rather than the modification time stored in the archive.
  2542. @xref{Writing}.
  2543. @item --uncompress
  2544. (See @samp{--compress}.) @FIXME-pxref{}
  2545. @item --ungzip
  2546. (See @samp{--gzip}.) @FIXME-pxref{}
  2547. @item --unlink-first
  2548. @itemx -U
  2549. Directs @command{tar} to remove the corresponding file from the file
  2550. system before extracting it from the archive. @xref{Writing}.
  2551. @item --use-compress-program=@var{prog}
  2552. Instructs @command{tar} to access the archive through @var{prog}, which is
  2553. presumed to be a compression program of some sort. @FIXME-xref{}
  2554. @item --verbose
  2555. @itemx -v
  2556. Specifies that @command{tar} should be more verbose about the operations its
  2557. performing. This option can be specified multiple times for some
  2558. operations to increase the amount of information displayed. @FIXME-xref{}
  2559. @item --verify
  2560. @itemx -W
  2561. Verifies that the archive was correctly written when creating an
  2562. archive. @FIXME-xref{}
  2563. @item --version
  2564. @command{tar} will print an informational message about what version
  2565. it is and a copyright message, some credits, and then exit.
  2566. @FIXME-xref{}
  2567. @item --volno-file=@var{file}
  2568. Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
  2569. of which volume of a multi-volume archive its working in @var{file}.
  2570. @FIXME-xref{}
  2571. @item --wildcards
  2572. Use wildcards when excluding files.
  2573. @FIXME-xref{}
  2574. @item --wildcards-match-slash
  2575. Wildcards match @samp{/} when excluding files.
  2576. @FIXME-xref{}
  2577. @end table
  2578. @node Short Option Summary
  2579. @subsection Short Options Cross Reference
  2580. Here is an alphabetized list of all of the short option forms, matching
  2581. them with the equivalent long option.
  2582. @table @kbd
  2583. @item -A
  2584. @samp{--concatenate}
  2585. @item -B
  2586. @samp{--read-full-records}
  2587. @item -C
  2588. @samp{--directory}
  2589. @item -F
  2590. @samp{--info-script}
  2591. @item -G
  2592. @samp{--incremental}
  2593. @item -K
  2594. @samp{--starting-file}
  2595. @item -L
  2596. @samp{--tape-length}
  2597. @item -M
  2598. @samp{--multi-volume}
  2599. @item -N
  2600. @samp{--newer}
  2601. @item -O
  2602. @samp{--to-stdout}
  2603. @item -P
  2604. @samp{--absolute-names}
  2605. @item -R
  2606. @samp{--block-number}
  2607. @item -S
  2608. @samp{--sparse}
  2609. @item -T
  2610. @samp{--files-from}
  2611. @item -U
  2612. @samp{--unlink-first}
  2613. @item -V
  2614. @samp{--label}
  2615. @item -W
  2616. @samp{--verify}
  2617. @item -X
  2618. @samp{--exclude-from}
  2619. @item -Z
  2620. @samp{--compress}
  2621. @item -b
  2622. @samp{--blocking-factor}
  2623. @item -c
  2624. @samp{--create}
  2625. @item -d
  2626. @samp{--compare}
  2627. @item -f
  2628. @samp{--file}
  2629. @item -g
  2630. @samp{--listed-incremental}
  2631. @item -h
  2632. @samp{--dereference}
  2633. @item -i
  2634. @samp{--ignore-zeros}
  2635. @item -j
  2636. @samp{--bzip2}
  2637. @item -k
  2638. @samp{--keep-old-files}
  2639. @item -l
  2640. @samp{--one-file-system}. Use of this short option is deprecated. It
  2641. is retained for compatibility with the earlier versions of GNU
  2642. @command{tar}, and will be changed in future releases.
  2643. @xref{Current status}, for more information.
  2644. @item -m
  2645. @samp{--touch}
  2646. @item -o
  2647. When creating --- @samp{--no-same-owner}, when extracting ---
  2648. @samp{--portability}.
  2649. The later usage is deprecated. It is retained for compatibility with
  2650. the earlier versions of @GNUTAR{}. In the future releases
  2651. @option{-o} will be equivalent to @samp{--no-same-owner} only.
  2652. @item -p
  2653. @samp{--preserve-permissions}
  2654. @item -r
  2655. @samp{--append}
  2656. @item -s
  2657. @samp{--same-order}
  2658. @item -t
  2659. @samp{--list}
  2660. @item -u
  2661. @samp{--update}
  2662. @item -v
  2663. @samp{--verbose}
  2664. @item -w
  2665. @samp{--interactive}
  2666. @item -x
  2667. @samp{--extract}
  2668. @item -z
  2669. @samp{--gzip}
  2670. @end table
  2671. @node help
  2672. @section @GNUTAR{} documentation
  2673. Being careful, the first thing is really checking that you are using
  2674. @GNUTAR{}, indeed. The @value{op-version} option
  2675. will generate a message giving confirmation that you are using
  2676. @GNUTAR{}, with the precise version of @GNUTAR{}
  2677. you are using. @command{tar} identifies itself and
  2678. prints the version number to the standard output, then immediately
  2679. exits successfully, without doing anything else, ignoring all other
  2680. options. For example, @w{@samp{tar --version}} might return:
  2681. @smallexample
  2682. tar (@acronym{GNU} tar) @value{VERSION}
  2683. @end smallexample
  2684. @noindent
  2685. The first occurrence of @samp{tar} in the result above is the program
  2686. name in the package (for example, @command{rmt} is another program),
  2687. while the second occurrence of @samp{tar} is the name of the package
  2688. itself, containing possibly many programs. The package is currently
  2689. named @samp{tar}, after the name of the main program it
  2690. contains@footnote{There are plans to merge the @command{cpio} and
  2691. @command{tar} packages into a single one which would be called
  2692. @code{paxutils}. So, who knows if, one of this days, the
  2693. @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
  2694. paxutils) 3.2}}}.
  2695. Another thing you might want to do is checking the spelling or meaning
  2696. of some particular @command{tar} option, without resorting to this
  2697. manual, for once you have carefully read it. @GNUTAR{}
  2698. has a short help feature, triggerable through the
  2699. @value{op-help} option. By using this option, @command{tar} will
  2700. print a usage message listing all available options on standard
  2701. output, then exit successfully, without doing anything else and
  2702. ignoring all other options. Even if this is only a brief summary, it
  2703. may be several screens long. So, if you are not using some kind of
  2704. scrollable window, you might prefer to use something like:
  2705. @smallexample
  2706. $ @kbd{tar --help | less}
  2707. @end smallexample
  2708. @noindent
  2709. presuming, here, that you like using @command{less} for a pager. Other
  2710. popular pagers are @command{more} and @command{pg}. If you know about some
  2711. @var{keyword} which interests you and do not want to read all the
  2712. @value{op-help} output, another common idiom is doing:
  2713. @smallexample
  2714. tar --help | grep @var{keyword}
  2715. @end smallexample
  2716. @noindent
  2717. for getting only the pertinent lines.
  2718. The perceptive reader would have noticed some contradiction in the
  2719. previous paragraphs. It is written that both @value{op-version} and
  2720. @value{op-help} print something, and have all other options ignored. In
  2721. fact, they cannot ignore each other, and one of them has to win. We do
  2722. not specify which is stronger, here; experiment if you really wonder!
  2723. The short help output is quite succinct, and you might have to get
  2724. back to the full documentation for precise points. If you are reading
  2725. this paragraph, you already have the @command{tar} manual in some
  2726. form. This manual is available in printed form, as a kind of small
  2727. book. It may printed out of the @GNUTAR{}
  2728. distribution, provided you have @TeX{} already installed somewhere,
  2729. and a laser printer around. Just configure the distribution, execute
  2730. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2731. usual way (contact your local guru to know how). If @GNUTAR{}
  2732. has been conveniently installed at your place, this
  2733. manual is also available in interactive, hypertextual form as an Info
  2734. file. Just call @w{@samp{info tar}} or, if you do not have the
  2735. @command{info} program handy, use the Info reader provided within
  2736. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2737. There is currently no @code{man} page for @GNUTAR{}.
  2738. If you observe such a @code{man} page on the system you are running,
  2739. either it does not long to @GNUTAR{}, or it has not
  2740. been produced by @acronym{GNU}. Currently, @GNUTAR{}
  2741. documentation is provided in Texinfo format only, if we
  2742. except, of course, the short result of @kbd{tar --help}.
  2743. @node verbose
  2744. @section Checking @command{tar} progress
  2745. @cindex Progress information
  2746. @cindex Status information
  2747. @cindex Information on progress and status of operations
  2748. @cindex Verbose operation
  2749. @cindex Block number where error occurred
  2750. @cindex Error message, block number of
  2751. @cindex Version of the @command{tar} program
  2752. @cindex Getting more information during the operation
  2753. @cindex Information during operation
  2754. @cindex Feedback from @command{tar}
  2755. Typically, @command{tar} performs most operations without reporting any
  2756. information to the user except error messages. When using @command{tar}
  2757. with many options, particularly ones with complicated or
  2758. difficult-to-predict behavior, it is possible to make serious mistakes.
  2759. @command{tar} provides several options that make observing @command{tar}
  2760. easier. These options cause @command{tar} to print information as it
  2761. progresses in its job, and you might want to use them just for being
  2762. more careful about what is going on, or merely for entertaining
  2763. yourself. If you have encountered a problem when operating on an
  2764. archive, however, you may need more information than just an error
  2765. message in order to solve the problem. The following options can be
  2766. helpful diagnostic tools.
  2767. Normally, the @value{op-list} command to list an archive prints just
  2768. the file names (one per line) and the other commands are silent.
  2769. When used with most operations, the @value{op-verbose} option causes
  2770. @command{tar} to print the name of each file or archive member as it
  2771. is processed. This and the other options which make @command{tar} print
  2772. status information can be useful in monitoring @command{tar}.
  2773. With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
  2774. just prints the names of the files or members as they are processed.
  2775. Using it twice causes @command{tar} to print a longer listing (reminiscent
  2776. of @samp{ls -l}) for each member. Since @value{op-list} already prints
  2777. the names of the members, @value{op-verbose} used once with @value{op-list}
  2778. causes @command{tar} to print an @samp{ls -l} type listing of the files
  2779. in the archive. The following examples both extract members with
  2780. long list output:
  2781. @smallexample
  2782. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2783. $ @kbd{tar xvvf archive.tar}
  2784. @end smallexample
  2785. Verbose output appears on the standard output except when an archive is
  2786. being written to the standard output, as with @samp{tar --create
  2787. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2788. installer let standard output be the default archive). In that case
  2789. @command{tar} writes verbose output to the standard error stream.
  2790. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2791. verbose output to @var{file} rather than to standard output or standard
  2792. error.
  2793. The @value{op-totals} option---which is only meaningful when used with
  2794. @value{op-create}---causes @command{tar} to print the total
  2795. amount written to the archive, after it has been fully created.
  2796. The @value{op-checkpoint} option prints an occasional message
  2797. as @command{tar} reads or writes the archive. In fact, it print
  2798. directory names while reading the archive. It is designed for
  2799. those who don't need the more detailed (and voluminous) output of
  2800. @value{op-block-number}, but do want visual confirmation that @command{tar}
  2801. is actually making forward progress.
  2802. @FIXME{There is some confusion here. It seems that -R once wrote a
  2803. message at @samp{every} record read or written.}
  2804. The @value{op-show-omitted-dirs} option, when reading an archive---with
  2805. @value{op-list} or @value{op-extract}, for example---causes a message
  2806. to be printed for each directory in the archive which is skipped.
  2807. This happens regardless of the reason for skipping: the directory might
  2808. not have been named on the command line (implicitly or explicitly),
  2809. it might be excluded by the use of the @value{op-exclude} option, or
  2810. some other reason.
  2811. If @value{op-block-number} is used, @command{tar} prints, along with
  2812. every message it would normally produce, the block number within the
  2813. archive where the message was triggered. Also, supplementary messages
  2814. are triggered when reading blocks full of NULs, or when hitting end of
  2815. file on the archive. As of now, if the archive if properly terminated
  2816. with a NUL block, the reading of the file may stop before end of file
  2817. is met, so the position of end of file will not usually show when
  2818. @value{op-block-number} is used. Note that @GNUTAR{}
  2819. drains the archive before exiting when reading the
  2820. archive from a pipe.
  2821. This option is especially useful when reading damaged archives, since
  2822. it helps pinpoint the damaged sections. It can also be used with
  2823. @value{op-list} when listing a file-system backup tape, allowing you to
  2824. choose among several backup tapes when retrieving a file later, in
  2825. favor of the tape where the file appears earliest (closest to the
  2826. front of the tape). @FIXME-xref{when the node name is set and the
  2827. backup section written.}
  2828. @node interactive
  2829. @section Asking for Confirmation During Operations
  2830. @cindex Interactive operation
  2831. Typically, @command{tar} carries out a command without stopping for
  2832. further instructions. In some situations however, you may want to
  2833. exclude some files and archive members from the operation (for instance
  2834. if disk or storage space is tight). You can do this by excluding
  2835. certain files automatically (@pxref{Choosing}), or by performing
  2836. an operation interactively, using the @value{op-interactive} option.
  2837. @command{tar} also accepts @samp{--confirmation} for this option.
  2838. When the @value{op-interactive} option is specified, before
  2839. reading, writing, or deleting files, @command{tar} first prints a message
  2840. for each such file, telling what operation it intends to take, then asks
  2841. for confirmation on the terminal. The actions which require
  2842. confirmation include adding a file to the archive, extracting a file
  2843. from the archive, deleting a file from the archive, and deleting a file
  2844. from disk. To confirm the action, you must type a line of input
  2845. beginning with @samp{y}. If your input line begins with anything other
  2846. than @samp{y}, @command{tar} skips that file.
  2847. If @command{tar} is reading the archive from the standard input,
  2848. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2849. communications.
  2850. Verbose output is normally sent to standard output, separate from
  2851. other error messages. However, if the archive is produced directly
  2852. on standard output, then verbose output is mixed with errors on
  2853. @code{stderr}. Producing the archive on standard output may be used
  2854. as a way to avoid using disk space, when the archive is soon to be
  2855. consumed by another process reading it, say. Some people felt the need
  2856. of producing an archive on stdout, still willing to segregate between
  2857. verbose output and error output. A possible approach would be using a
  2858. named pipe to receive the archive, and having the consumer process to
  2859. read from that named pipe. This has the advantage of letting standard
  2860. output free to receive verbose output, all separate from errors.
  2861. @node operations
  2862. @chapter @GNUTAR{} Operations
  2863. @menu
  2864. * Basic tar::
  2865. * Advanced tar::
  2866. * create options::
  2867. * extract options::
  2868. * backup::
  2869. * Applications::
  2870. * looking ahead::
  2871. @end menu
  2872. @node Basic tar
  2873. @section Basic @GNUTAR{} Operations
  2874. The basic @command{tar} operations, @value{op-create}, @value{op-list} and
  2875. @value{op-extract}, are currently presented and described in the tutorial
  2876. chapter of this manual. This section provides some complementary notes
  2877. for these operations.
  2878. @table @asis
  2879. @item @value{op-create}
  2880. Creating an empty archive would have some kind of elegance. One can
  2881. initialize an empty archive and later use @value{op-append} for adding
  2882. all members. Some applications would not welcome making an exception
  2883. in the way of adding the first archive member. On the other hand,
  2884. many people reported that it is dangerously too easy for @command{tar}
  2885. to destroy a magnetic tape with an empty archive@footnote{This is well
  2886. described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
  2887. Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
  2888. common errors are:
  2889. @enumerate
  2890. @item
  2891. Mistakingly using @code{create} instead of @code{extract}, when the
  2892. intent was to extract the full contents of an archive. This error
  2893. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2894. the QWERTY keyboard. Instead of being unpacked, the archive then
  2895. gets wholly destroyed. When users speak about @dfn{exploding} an
  2896. archive, they usually mean something else :-).
  2897. @item
  2898. Forgetting the argument to @code{file}, when the intent was to create
  2899. an archive with a single file in it. This error is likely because a
  2900. tired user can easily add the @kbd{f} key to the cluster of option
  2901. letters, by the mere force of habit, without realizing the full
  2902. consequence of doing so. The usual consequence is that the single
  2903. file, which was meant to be saved, is rather destroyed.
  2904. @end enumerate
  2905. So, recognizing the likelihood and the catastrophical nature of these
  2906. errors, @GNUTAR{} now takes some distance from elegance, and
  2907. cowardly refuses to create an archive when @value{op-create} option is
  2908. given, there are no arguments besides options, and @value{op-files-from}
  2909. option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
  2910. and nevertheless create an archive with nothing in it,
  2911. one may still use, as the value for the @value{op-files-from} option,
  2912. a file with no names in it, as shown in the following commands:
  2913. @smallexample
  2914. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2915. @kbd{tar cfT empty-archive.tar /dev/null}
  2916. @end smallexample
  2917. @item @value{op-extract}
  2918. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2919. @item @value{op-list}
  2920. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2921. while it used to show them as @samp{Aug 30 1996}. (One can revert to
  2922. the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
  2923. before reinstalling.) But preferably, people should get used to ISO
  2924. 8601 dates. Local American dates should be made available again with
  2925. full date localization support, once ready. In the meantime, programs
  2926. not being localizable for dates should prefer international dates,
  2927. that's really the way to go.
  2928. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2929. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2930. @end table
  2931. @node Advanced tar
  2932. @section Advanced @GNUTAR{} Operations
  2933. Now that you have learned the basics of using @GNUTAR{}, you may want
  2934. to learn about further ways in which @command{tar} can help you.
  2935. This chapter presents five, more advanced operations which you probably
  2936. won't use on a daily basis, but which serve more specialized functions.
  2937. We also explain the different styles of options and why you might want
  2938. to use one or another, or a combination of them in your @command{tar}
  2939. commands. Additionally, this chapter includes options which allow you to
  2940. define the output from @command{tar} more carefully, and provide help and
  2941. error correction in special circumstances.
  2942. @FIXME{check this after the chapter is actually revised to make sure
  2943. it still introduces the info in the chapter correctly : ).}
  2944. @menu
  2945. * Operations::
  2946. * append::
  2947. * update::
  2948. * concatenate::
  2949. * delete::
  2950. * compare::
  2951. @end menu
  2952. @node Operations
  2953. @subsection The Five Advanced @command{tar} Operations
  2954. @UNREVISED
  2955. In the last chapter, you learned about the first three operations to
  2956. @command{tar}. This chapter presents the remaining five operations to
  2957. @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
  2958. @samp{--delete}, and @samp{--compare}.
  2959. You are not likely to use these operations as frequently as those
  2960. covered in the last chapter; however, since they perform specialized
  2961. functions, they are quite useful when you do need to use them. We
  2962. will give examples using the same directory and files that you created
  2963. in the last chapter. As you may recall, the directory is called
  2964. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2965. @samp{rock}, and the two archive files you created are
  2966. @samp{collection.tar} and @samp{music.tar}.
  2967. We will also use the archive files @samp{afiles.tar} and
  2968. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2969. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2970. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2971. Unless we state otherwise, all practicing you do and examples you follow
  2972. in this chapter will take place in the @file{practice} directory that
  2973. you created in the previous chapter; see @ref{prepare for examples}.
  2974. (Below in this section, we will remind you of the state of the examples
  2975. where the last chapter left them.)
  2976. The five operations that we will cover in this chapter are:
  2977. @table @kbd
  2978. @item --append
  2979. @itemx -r
  2980. Add new entries to an archive that already exists.
  2981. @item --update
  2982. @itemx -r
  2983. Add more recent copies of archive members to the end of an archive, if
  2984. they exist.
  2985. @item --concatenate
  2986. @itemx --catenate
  2987. @itemx -A
  2988. Add one or more pre-existing archives to the end of another archive.
  2989. @item --delete
  2990. Delete items from an archive (does not work on tapes).
  2991. @item --compare
  2992. @itemx --diff
  2993. @itemx -d
  2994. Compare archive members to their counterparts in the file system.
  2995. @end table
  2996. @node append
  2997. @subsection How to Add Files to Existing Archives: @code{--append}
  2998. @UNREVISED
  2999. If you want to add files to an existing archive, you don't need to
  3000. create a new archive; you can use @value{op-append}. The archive must
  3001. already exist in order to use @samp{--append}. (A related operation
  3002. is the @samp{--update} operation; you can use this to add newer
  3003. versions of archive members to an existing archive. To learn how to
  3004. do this with @samp{--update}, @pxref{update}.)
  3005. @FIXME{Explain in second paragraph whether you can get to the previous
  3006. version -- explain whole situation somewhat more clearly.}
  3007. If you use @value{op-append} to add a file that has the same name as an
  3008. archive member to an archive containing that archive member, then the
  3009. old member is not deleted. What does happen, however, is somewhat
  3010. complex. @command{tar} @emph{allows} you to have infinite numbers of files
  3011. with the same name. Some operations treat these same-named members no
  3012. differently than any other set of archive members: for example, if you
  3013. view an archive with @value{op-list}, you will see all of those members
  3014. listed, with their modification times, owners, etc.
  3015. Other operations don't deal with these members as perfectly as you might
  3016. prefer; if you were to use @value{op-extract} to extract the archive,
  3017. only the most recently added copy of a member with the same name as four
  3018. other members would end up in the working directory. This is because
  3019. @samp{--extract} extracts an archive in the order the members appeared
  3020. in the archive; the most recently archived members will be extracted
  3021. last. Additionally, an extracted member will @emph{replace} a file of
  3022. the same name which existed in the directory already, and @command{tar}
  3023. will not prompt you about this. Thus, only the most recently archived
  3024. member will end up being extracted, as it will replace the one
  3025. extracted before it, and so on.
  3026. @FIXME{ hag -- you might want to incorporate some of the above into the
  3027. MMwtSN node; not sure. i didn't know how to make it simpler...}
  3028. There are a few ways to get around this. @FIXME-xref{Multiple Members
  3029. with the Same Name.}
  3030. @cindex Members, replacing with other members
  3031. @cindex Replacing members with other members
  3032. If you want to replace an archive member, use @value{op-delete} to
  3033. delete the member you want to remove from the archive, , and then use
  3034. @samp{--append} to add the member you want to be in the archive. Note
  3035. that you can not change the order of the archive; the most recently
  3036. added member will still appear last. In this sense, you cannot truly
  3037. ``replace'' one member with another. (Replacing one member with another
  3038. will not work on certain types of media, such as tapes; see @ref{delete}
  3039. and @ref{Media}, for more information.)
  3040. @menu
  3041. * appending files:: Appending Files to an Archive
  3042. * multiple::
  3043. @end menu
  3044. @node appending files
  3045. @subsubsection Appending Files to an Archive
  3046. @UNREVISED
  3047. @cindex Adding files to an Archive
  3048. @cindex Appending files to an Archive
  3049. @cindex Archives, Appending files to
  3050. The simplest way to add a file to an already existing archive is the
  3051. @value{op-append} operation, which writes specified files into the
  3052. archive whether or not they are already among the archived files.
  3053. When you use @samp{--append}, you @emph{must} specify file name
  3054. arguments, as there is no default. If you specify a file that already
  3055. exists in the archive, another copy of the file will be added to the
  3056. end of the archive. As with other operations, the member names of the
  3057. newly added files will be exactly the same as their names given on the
  3058. command line. The @value{op-verbose} option will print out the names
  3059. of the files as they are written into the archive.
  3060. @samp{--append} cannot be performed on some tape drives, unfortunately,
  3061. due to deficiencies in the formats those tape drives use. The archive
  3062. must be a valid @command{tar} archive, or else the results of using this
  3063. operation will be unpredictable. @xref{Media}.
  3064. To demonstrate using @samp{--append} to add a file to an archive,
  3065. create a file called @file{rock} in the @file{practice} directory.
  3066. Make sure you are in the @file{practice} directory. Then, run the
  3067. following @command{tar} command to add @file{rock} to
  3068. @file{collection.tar}:
  3069. @smallexample
  3070. $ @kbd{tar --append --file=collection.tar rock}
  3071. @end smallexample
  3072. @noindent
  3073. If you now use the @value{op-list} operation, you will see that
  3074. @file{rock} has been added to the archive:
  3075. @smallexample
  3076. $ @kbd{tar --list --file=collection.tar}
  3077. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3078. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3079. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3080. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3081. @end smallexample
  3082. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3083. title claims it will become...}
  3084. @node multiple
  3085. @subsubsection Multiple Files with the Same Name
  3086. You can use @value{op-append} to add copies of files which have been
  3087. updated since the archive was created. (However, we do not recommend
  3088. doing this since there is another @command{tar} option called
  3089. @samp{--update}; @pxref{update} for more information. We describe this
  3090. use of @samp{--append} here for the sake of completeness.) @FIXME{is
  3091. this really a good idea, to give this whole description for something
  3092. which i believe is basically a Stupid way of doing something? certain
  3093. aspects of it show ways in which tar is more broken than i'd personally
  3094. like to admit to, specifically the last sentence. On the other hand, i
  3095. don't think it's a good idea to be saying that re explicitly don't
  3096. recommend using something, but i can't see any better way to deal with
  3097. the situation.}When you extract the archive, the older version will be
  3098. effectively lost. This works because files are extracted from an
  3099. archive in the order in which they were archived. Thus, when the
  3100. archive is extracted, a file archived later in time will replace a
  3101. file of the same name which was archived earlier, even though the older
  3102. version of the file will remain in the archive unless you delete all
  3103. versions of the file.
  3104. Supposing you change the file @file{blues} and then append the changed
  3105. version to @file{collection.tar}. As you saw above, the original
  3106. @file{blues} is in the archive @file{collection.tar}. If you change the
  3107. file and append the new version of the file to the archive, there will
  3108. be two copies in the archive. When you extract the archive, the older
  3109. version of the file will be extracted first, and then replaced by the
  3110. newer version when it is extracted.
  3111. You can append the new, changed copy of the file @file{blues} to the
  3112. archive in this way:
  3113. @smallexample
  3114. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3115. blues
  3116. @end smallexample
  3117. @noindent
  3118. Because you specified the @samp{--verbose} option, @command{tar} has
  3119. printed the name of the file being appended as it was acted on. Now
  3120. list the contents of the archive:
  3121. @smallexample
  3122. $ @kbd{tar --list --verbose --file=collection.tar}
  3123. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3124. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3125. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3126. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3127. -rw-rw-rw- me user 58 1996-10-24 18:30 blues
  3128. @end smallexample
  3129. @noindent
  3130. The newest version of @file{blues} is now at the end of the archive
  3131. (note the different creation dates and file sizes). If you extract
  3132. the archive, the older version of the file @file{blues} will be
  3133. replaced by the newer version. You can confirm this by extracting
  3134. the archive and running @samp{ls} on the directory. @xref{Writing},
  3135. for more information. (@emph{Please note:} This is the case unless
  3136. you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
  3137. with the Same Name}.)
  3138. @node update
  3139. @subsection Updating an Archive
  3140. @UNREVISED
  3141. @cindex Updating an archive
  3142. In the previous section, you learned how to use @value{op-append} to add
  3143. a file to an existing archive. A related operation is
  3144. @value{op-update}. The @samp{--update} operation updates a @command{tar}
  3145. archive by comparing the date of the specified archive members against
  3146. the date of the file with the same name. If the file has been modified
  3147. more recently than the archive member, then the newer version of the
  3148. file is added to the archive (as with @value{op-append}).
  3149. Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
  3150. The operation will fail.
  3151. @FIXME{other examples of media on which --update will fail? need to ask
  3152. charles and/or mib/thomas/dave shevett..}
  3153. Both @samp{--update} and @samp{--append} work by adding to the end
  3154. of the archive. When you extract a file from the archive, only the
  3155. version stored last will wind up in the file system, unless you use
  3156. the @value{op-backup} option. @FIXME-ref{Multiple Members with the
  3157. Same Name}
  3158. @menu
  3159. * how to update::
  3160. @end menu
  3161. @node how to update
  3162. @subsubsection How to Update an Archive Using @code{--update}
  3163. You must use file name arguments with the @value{op-update} operation.
  3164. If you don't specify any files, @command{tar} won't act on any files and
  3165. won't tell you that it didn't do anything (which may end up confusing
  3166. you).
  3167. @FIXME{note: the above parenthetical added because in fact, this
  3168. behavior just confused the author. :-) }
  3169. To see the @samp{--update} option at work, create a new file,
  3170. @file{classical}, in your practice directory, and some extra text to the
  3171. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3172. the @samp{update} operation and the @value{op-verbose} option specified,
  3173. using the names of all the files in the practice directory as file name
  3174. arguments:
  3175. @smallexample
  3176. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3177. blues
  3178. classical
  3179. $
  3180. @end smallexample
  3181. @noindent
  3182. Because we have specified verbose mode, @command{tar} prints out the names
  3183. of the files it is working on, which in this case are the names of the
  3184. files that needed to be updated. If you run @samp{tar --list} and look
  3185. at the archive, you will see @file{blues} and @file{classical} at its
  3186. end. There will be a total of two versions of the member @samp{blues};
  3187. the one at the end will be newer and larger, since you added text before
  3188. updating it.
  3189. (The reason @command{tar} does not overwrite the older file when updating
  3190. it is because writing to the middle of a section of tape is a difficult
  3191. process. Tapes are not designed to go backward. @xref{Media}, for more
  3192. information about tapes.
  3193. @value{op-update} is not suitable for performing backups for two
  3194. reasons: it does not change directory content entries, and it
  3195. lengthens the archive every time it is used. The @GNUTAR{}
  3196. options intended specifically for backups are more
  3197. efficient. If you need to run backups, please consult @ref{Backups}.
  3198. @node concatenate
  3199. @subsection Combining Archives with @code{--concatenate}
  3200. @cindex Adding archives to an archive
  3201. @cindex Concatenating Archives
  3202. Sometimes it may be convenient to add a second archive onto the end of
  3203. an archive rather than adding individual files to the archive. To add
  3204. one or more archives to the end of another archive, you should use the
  3205. @value{op-concatenate} operation.
  3206. To use @samp{--concatenate}, name the archives to be concatenated on the
  3207. command line. (Nothing happens if you don't list any.) The members,
  3208. and their member names, will be copied verbatim from those archives. If
  3209. this causes multiple members to have the same name, it does not delete
  3210. any members; all the members with the same name coexist. @FIXME-ref{For
  3211. information on how this affects reading the archive, Multiple
  3212. Members with the Same Name.}
  3213. To demonstrate how @samp{--concatenate} works, create two small archives
  3214. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3215. files from @file{practice}:
  3216. @smallexample
  3217. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3218. blues
  3219. classical
  3220. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3221. folk
  3222. jazz
  3223. @end smallexample
  3224. @noindent
  3225. If you like, You can run @samp{tar --list} to make sure the archives
  3226. contain what they are supposed to:
  3227. @smallexample
  3228. $ @kbd{tar -tvf bluesrock.tar}
  3229. -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
  3230. -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
  3231. $ @kbd{tar -tvf folkjazz.tar}
  3232. -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
  3233. -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
  3234. @end smallexample
  3235. We can concatenate these two archives with @command{tar}:
  3236. @smallexample
  3237. $ @kbd{cd ..}
  3238. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3239. @end smallexample
  3240. If you now list the contents of the @file{bluesclass.tar}, you will see
  3241. that now it also contains the archive members of @file{jazzfolk.tar}:
  3242. @smallexample
  3243. $ @kbd{tar --list --file=bluesrock.tar}
  3244. blues
  3245. rock
  3246. jazz
  3247. folk
  3248. @end smallexample
  3249. When you use @samp{--concatenate}, the source and target archives must
  3250. already exist and must have been created using compatible format
  3251. parameters. @FIXME-pxref{Matching Format Parameters}The new,
  3252. concatenated archive will be called by the same name as the first
  3253. archive listed on the command line. @FIXME{is there a way to specify a
  3254. new name?}
  3255. Like @value{op-append}, this operation cannot be performed on some
  3256. tape drives, due to deficiencies in the formats those tape drives use.
  3257. @cindex @code{concatenate} vs @command{cat}
  3258. @cindex @command{cat} vs @code{concatenate}
  3259. It may seem more intuitive to you to want or try to use @command{cat} to
  3260. concatenate two archives instead of using the @samp{--concatenate}
  3261. operation; after all, @command{cat} is the utility for combining files.
  3262. However, @command{tar} archives incorporate an end-of-file marker which
  3263. must be removed if the concatenated archives are to be read properly as
  3264. one archive. @samp{--concatenate} removes the end-of-archive marker
  3265. from the target archive before each new archive is appended. If you use
  3266. @command{cat} to combine the archives, the result will not be a valid
  3267. @command{tar} format archive. If you need to retrieve files from an
  3268. archive that was added to using the @command{cat} utility, use the
  3269. @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
  3270. information on dealing with archives improperly combined using the
  3271. @command{cat} shell utility.
  3272. @FIXME{this shouldn't go here. where should it go?} You must specify
  3273. the source archives using @value{op-file} (@value{pxref-file}). If you
  3274. do not specify the target archive, @command{tar} uses the value of the
  3275. environment variable @env{TAPE}, or, if this has not been set, the
  3276. default archive name.
  3277. @node delete
  3278. @subsection Removing Archive Members Using @samp{--delete}
  3279. @UNREVISED
  3280. @cindex Deleting files from an archive
  3281. @cindex Removing files from an archive
  3282. You can remove members from an archive by using the @value{op-delete}
  3283. option. Specify the name of the archive with @value{op-file} and then
  3284. specify the names of the members to be deleted; if you list no member
  3285. names, nothing will be deleted. The @value{op-verbose} option will
  3286. cause @command{tar} to print the names of the members as they are deleted.
  3287. As with @value{op-extract}, you must give the exact member names when
  3288. using @samp{tar --delete}. @samp{--delete} will remove all versions of
  3289. the named file from the archive. The @samp{--delete} operation can run
  3290. very slowly.
  3291. Unlike other operations, @samp{--delete} has no short form.
  3292. @cindex Tapes, using @code{--delete} and
  3293. @cindex Deleting from tape archives
  3294. This operation will rewrite the archive. You can only use
  3295. @samp{--delete} on an archive if the archive device allows you to
  3296. write to any point on the media, such as a disk; because of this, it
  3297. does not work on magnetic tapes. Do not try to delete an archive member
  3298. from a magnetic tape; the action will not succeed, and you will be
  3299. likely to scramble the archive and damage your tape. There is no safe
  3300. way (except by completely re-writing the archive) to delete files from
  3301. most kinds of magnetic tape. @xref{Media}.
  3302. To delete all versions of the file @file{blues} from the archive
  3303. @file{collection.tar} in the @file{practice} directory, make sure you
  3304. are in that directory, and then,
  3305. @smallexample
  3306. $ @kbd{tar --list --file=collection.tar}
  3307. blues
  3308. folk
  3309. jazz
  3310. rock
  3311. practice/blues
  3312. practice/folk
  3313. practice/jazz
  3314. practice/rock
  3315. practice/blues
  3316. $ @kbd{tar --delete --file=collection.tar blues}
  3317. $ @kbd{tar --list --file=collection.tar}
  3318. folk
  3319. jazz
  3320. rock
  3321. $
  3322. @end smallexample
  3323. @FIXME{I changed the order of these nodes around and haven't had a chance
  3324. to fix the above example's results, yet. I have to play with this and
  3325. follow it and see what it actually does!}
  3326. The @value{op-delete} option has been reported to work properly when
  3327. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3328. @node compare
  3329. @subsection Comparing Archive Members with the File System
  3330. @cindex Verifying the currency of an archive
  3331. @UNREVISED
  3332. The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
  3333. specified archive members against files with the same names, and then
  3334. reports differences in file size, mode, owner, modification date and
  3335. contents. You should @emph{only} specify archive member names, not file
  3336. names. If you do not name any members, then @command{tar} will compare the
  3337. entire archive. If a file is represented in the archive but does not
  3338. exist in the file system, @command{tar} reports a difference.
  3339. You have to specify the record size of the archive when modifying an
  3340. archive with a non-default record size.
  3341. @command{tar} ignores files in the file system that do not have
  3342. corresponding members in the archive.
  3343. The following example compares the archive members @file{rock},
  3344. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3345. files of the same name in the file system. (Note that there is no file,
  3346. @file{funk}; @command{tar} will report an error message.)
  3347. @smallexample
  3348. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3349. rock
  3350. blues
  3351. tar: funk not found in archive
  3352. @end smallexample
  3353. @noindent
  3354. @FIXME{what does this actually depend on? i'm making a guess,
  3355. here.}Depending on the system where you are running @command{tar} and the
  3356. version you are running, @command{tar} may have a different error message,
  3357. such as:
  3358. @smallexample
  3359. funk: does not exist
  3360. @end smallexample
  3361. @FIXME-xref{somewhere, for more information about format parameters.
  3362. Melissa says: such as "format variations"? But why? Clearly I don't
  3363. get it yet; I'll deal when I get to that section.}
  3364. The spirit behind the @value{op-compare} option is to check whether the
  3365. archive represents the current state of files on disk, more than validating
  3366. the integrity of the archive media. For this later goal, @xref{verify}.
  3367. @node create options
  3368. @section Options Used by @code{--create}
  3369. The previous chapter described the basics of how to use
  3370. @value{op-create} to create an archive from a set of files.
  3371. @xref{create}. This section described advanced options to be used with
  3372. @samp{--create}.
  3373. @menu
  3374. * Ignore Failed Read::
  3375. @end menu
  3376. @node Ignore Failed Read
  3377. @subsection Ignore Fail Read
  3378. @table @kbd
  3379. @item --ignore-failed-read
  3380. Do not exit with nonzero on unreadable files or directories.
  3381. @end table
  3382. @node extract options
  3383. @section Options Used by @code{--extract}
  3384. @UNREVISED
  3385. @FIXME{i need to get dan to go over these options with me and see if
  3386. there's a better way of organizing them.}
  3387. The previous chapter showed how to use @value{op-extract} to extract
  3388. an archive into the filesystem. Various options cause @command{tar} to
  3389. extract more information than just file contents, such as the owner,
  3390. the permissions, the modification date, and so forth. This section
  3391. presents options to be used with @samp{--extract} when certain special
  3392. considerations arise. You may review the information presented in
  3393. @ref{extract} for more basic information about the
  3394. @samp{--extract} operation.
  3395. @menu
  3396. * Reading:: Options to Help Read Archives
  3397. * Writing:: Changing How @command{tar} Writes Files
  3398. * Scarce:: Coping with Scarce Resources
  3399. @end menu
  3400. @node Reading
  3401. @subsection Options to Help Read Archives
  3402. @cindex Options when reading archives
  3403. @cindex Reading incomplete records
  3404. @cindex Records, incomplete
  3405. @cindex End-of-archive entries, ignoring
  3406. @cindex Ignoring end-of-archive entries
  3407. @cindex Large lists of file names on small machines
  3408. @cindex Small memory
  3409. @cindex Running out of space
  3410. @UNREVISED
  3411. Normally, @command{tar} will request data in full record increments from
  3412. an archive storage device. If the device cannot return a full record,
  3413. @command{tar} will report an error. However, some devices do not always
  3414. return full records, or do not require the last record of an archive to
  3415. be padded out to the next record boundary. To keep reading until you
  3416. obtain a full record, or to accept an incomplete record if it contains
  3417. an end-of-archive marker, specify the @value{op-read-full-records} option
  3418. in conjunction with the @value{op-extract} or @value{op-list} operations.
  3419. @value{xref-read-full-records}.
  3420. The @value{op-read-full-records} option is turned on by default when
  3421. @command{tar} reads an archive from standard input, or from a remote
  3422. machine. This is because on BSD Unix systems, attempting to read a
  3423. pipe returns however much happens to be in the pipe, even if it is
  3424. less than was requested. If this option were not enabled, @command{tar}
  3425. would fail as soon as it read an incomplete record from the pipe.
  3426. If you're not sure of the blocking factor of an archive, you can
  3427. read the archive by specifying @value{op-read-full-records} and
  3428. @value{op-blocking-factor}, using a blocking factor larger than what the
  3429. archive uses. This lets you avoid having to determine the blocking factor
  3430. of an archive. @value{xref-blocking-factor}.
  3431. @menu
  3432. * read full records::
  3433. * Ignore Zeros::
  3434. @end menu
  3435. @node read full records
  3436. @unnumberedsubsubsec Reading Full Records
  3437. @FIXME{need sentence or so of intro here}
  3438. @table @kbd
  3439. @item --read-full-records
  3440. @item -B
  3441. Use in conjunction with @value{op-extract} to read an archive which
  3442. contains incomplete records, or one which has a blocking factor less
  3443. than the one specified.
  3444. @end table
  3445. @node Ignore Zeros
  3446. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3447. Normally, @command{tar} stops reading when it encounters a block of zeros
  3448. between file entries (which usually indicates the end of the archive).
  3449. @value{op-ignore-zeros} allows @command{tar} to completely read an archive
  3450. which contains a block of zeros before the end (i.e.@: a damaged
  3451. archive, or one which was created by concatenating several archives
  3452. together).
  3453. The @value{op-ignore-zeros} option is turned off by default because many
  3454. versions of @command{tar} write garbage after the end-of-archive entry,
  3455. since that part of the media is never supposed to be read. @GNUTAR{}
  3456. does not write after the end of an archive, but seeks to
  3457. maintain compatiblity among archiving utilities.
  3458. @table @kbd
  3459. @item --ignore-zeros
  3460. @itemx -i
  3461. To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
  3462. encountered while reading an archive. Use in conjunction with
  3463. @value{op-extract} or @value{op-list}.
  3464. @end table
  3465. @node Writing
  3466. @subsection Changing How @command{tar} Writes Files
  3467. @cindex Overwriting old files, prevention
  3468. @cindex Protecting old files
  3469. @cindex Modification times of extracted files
  3470. @cindex Permissions of extracted files
  3471. @cindex Modes of extracted files
  3472. @cindex Writing extracted files to standard output
  3473. @cindex Standard output, writing extracted files to
  3474. @UNREVISED
  3475. @FIXME{need to mention the brand new option, --backup}
  3476. @menu
  3477. * Dealing with Old Files::
  3478. * Overwrite Old Files::
  3479. * Keep Old Files::
  3480. * Unlink First::
  3481. * Recursive Unlink::
  3482. * Modification Times::
  3483. * Setting Access Permissions::
  3484. * Writing to Standard Output::
  3485. * remove files::
  3486. @end menu
  3487. @node Dealing with Old Files
  3488. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3489. When extracting files, if @command{tar} discovers that the extracted
  3490. file already exists, it normally replaces the file by removing it before
  3491. extracting it, to prevent confusion in the presence of hard or symbolic
  3492. links. (If the existing file is a symbolic link, it is removed, not
  3493. followed.) However, if a directory cannot be removed because it is
  3494. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3495. permission, etc.). The @option{--overwrite-dir} option enables this
  3496. default behavior. To be more cautious and preserve the metadata of
  3497. such a directory, use the @option{--no-overwrite-dir} option.
  3498. To be even more cautious and prevent existing files from being replaced, use
  3499. the @value{op-keep-old-files} option. It causes @command{tar} to refuse
  3500. to replace or update a file that already exists, i.e., a file with the
  3501. same name as an archive member prevents extraction of that archive
  3502. member. Instead, it reports an error.
  3503. To be more aggressive about altering existing files, use the
  3504. @value{op-overwrite} option. It causes @command{tar} to overwrite
  3505. existing files and to follow existing symbolic links when extracting.
  3506. Some people argue that @GNUTAR{} should not hesitate
  3507. to overwrite files with other files when extracting. When extracting
  3508. a @command{tar} archive, they expect to see a faithful copy of the
  3509. state of the filesystem when the archive was created. It is debatable
  3510. that this would always be a proper behavior. For example, suppose one
  3511. has an archive in which @file{usr/local} is a link to
  3512. @file{usr/local2}. Since then, maybe the site removed the link and
  3513. renamed the whole hierarchy from @file{/usr/local2} to
  3514. @file{/usr/local}. Such things happen all the time. I guess it would
  3515. not be welcome at all that @GNUTAR{} removes the
  3516. whole hierarchy just to make room for the link to be reinstated
  3517. (unless it @emph{also} simultaneously restores the full
  3518. @file{/usr/local2}, of course! @GNUTAR{} is indeed
  3519. able to remove a whole hierarchy to reestablish a symbolic link, for
  3520. example, but @emph{only if} @value{op-recursive-unlink} is specified
  3521. to allow this behavior. In any case, single files are silently
  3522. removed.
  3523. Finally, the @value{op-unlink-first} option can improve performance in
  3524. some cases by causing @command{tar} to remove files unconditionally
  3525. before extracting them.
  3526. @node Overwrite Old Files
  3527. @unnumberedsubsubsec Overwrite Old Files
  3528. @table @kbd
  3529. @item --overwrite
  3530. Overwrite existing files and directory metadata when extracting files
  3531. from an archive.
  3532. This
  3533. causes @command{tar} to write extracted files into the file system without
  3534. regard to the files already on the system; i.e., files with the same
  3535. names as archive members are overwritten when the archive is extracted.
  3536. It also causes @command{tar} to extract the ownership, permissions,
  3537. and time stamps onto any preexisting files or directories.
  3538. If the name of a corresponding file name is a symbolic link, the file
  3539. pointed to by the symbolic link will be overwritten instead of the
  3540. symbolic link itself (if this is possible). Moreover, special devices,
  3541. empty directories and even symbolic links are automatically removed if
  3542. they are in the way of extraction.
  3543. Be careful when using the @value{op-overwrite} option, particularly when
  3544. combined with the @value{op-absolute-names} option, as this combination
  3545. can change the contents, ownership or permissions of any file on your
  3546. system. Also, many systems do not take kindly to overwriting files that
  3547. are currently being executed.
  3548. @item --overwrite-dir
  3549. Overwrite the metadata of directories when extracting files from an
  3550. archive, but remove other files before extracting.
  3551. @end table
  3552. @node Keep Old Files
  3553. @unnumberedsubsubsec Keep Old Files
  3554. @table @kbd
  3555. @item --keep-old-files
  3556. @itemx -k
  3557. Do not replace existing files from archive. The
  3558. @value{op-keep-old-files} option prevents @command{tar} from replacing
  3559. existing files with files with the same name from the archive.
  3560. The @value{op-keep-old-files} option is meaningless with @value{op-list}.
  3561. Prevents @command{tar} from replacing files in the file system during
  3562. extraction.
  3563. @end table
  3564. @node Unlink First
  3565. @unnumberedsubsubsec Unlink First
  3566. @table @kbd
  3567. @item --unlink-first
  3568. @itemx -U
  3569. Remove files before extracting over them.
  3570. This can make @command{tar} run a bit faster if you know in advance
  3571. that the extracted files all need to be removed. Normally this option
  3572. slows @command{tar} down slightly, so it is disabled by default.
  3573. @end table
  3574. @node Recursive Unlink
  3575. @unnumberedsubsubsec Recursive Unlink
  3576. @table @kbd
  3577. @item --recursive-unlink
  3578. When this option is specified, try removing files and directory hierarchies
  3579. before extracting over them. @emph{This is a dangerous option!}
  3580. @end table
  3581. If you specify the @value{op-recursive-unlink} option,
  3582. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3583. as far as current permissions will allow it. This could include removal
  3584. of the contents of a full directory hierarchy.
  3585. @node Modification Times
  3586. @unnumberedsubsubsec Setting Modification Times
  3587. Normally, @command{tar} sets the modification times of extracted files to
  3588. the modification times recorded for the files in the archive, but
  3589. limits the permissions of extracted files by the current @code{umask}
  3590. setting.
  3591. To set the modification times of extracted files to the time when
  3592. the files were extracted, use the @value{op-touch} option in
  3593. conjunction with @value{op-extract}.
  3594. @table @kbd
  3595. @item --touch
  3596. @itemx -m
  3597. Sets the modification time of extracted archive members to the time
  3598. they were extracted, not the time recorded for them in the archive.
  3599. Use in conjunction with @value{op-extract}.
  3600. @end table
  3601. @node Setting Access Permissions
  3602. @unnumberedsubsubsec Setting Access Permissions
  3603. To set the modes (access permissions) of extracted files to those
  3604. recorded for those files in the archive, use @samp{--same-permissions}
  3605. in conjunction with the @value{op-extract} operation. @FIXME{Should be
  3606. aliased to ignore-umask.}
  3607. @table @kbd
  3608. @item --preserve-permission
  3609. @itemx --same-permission
  3610. @itemx --ignore-umask
  3611. @itemx -p
  3612. Set modes of extracted archive members to those recorded in the
  3613. archive, instead of current umask settings. Use in conjunction with
  3614. @value{op-extract}.
  3615. @end table
  3616. @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
  3617. files together, why is this useful. is it really useful with
  3618. more than one file?}
  3619. @node Writing to Standard Output
  3620. @unnumberedsubsubsec Writing to Standard Output
  3621. To write the extracted files to the standard output, instead of
  3622. creating the files on the file system, use @value{op-to-stdout} in
  3623. conjunction with @value{op-extract}. This option is useful if you are
  3624. extracting files to send them through a pipe, and do not need to
  3625. preserve them in the file system. If you extract multiple members,
  3626. they appear on standard output concatenated, in the order they are
  3627. found in the archive.
  3628. @table @kbd
  3629. @item --to-stdout
  3630. @itemx -O
  3631. Writes files to the standard output. Used in conjunction with
  3632. @value{op-extract}. Extract files to standard output. When this option
  3633. is used, instead of creating the files specified, @command{tar} writes
  3634. the contents of the files extracted to its standard output. This may
  3635. be useful if you are only extracting the files in order to send them
  3636. through a pipe. This option is meaningless with @value{op-list}.
  3637. @end table
  3638. This can be useful, for example, if you have a tar archive containing
  3639. a big file and don't want to store the file on disk before processing
  3640. it. You can use a command like this:
  3641. @smallexample
  3642. tar -xOzf foo.tgz bigfile | process
  3643. @end smallexample
  3644. or even like this if you want to process the concatenation of the files:
  3645. @smallexample
  3646. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3647. @end smallexample
  3648. @node remove files
  3649. @unnumberedsubsubsec Removing Files
  3650. @FIXME{the various macros in the front of the manual think that this
  3651. option goes in this section. i have no idea; i only know it's nowhere
  3652. else in the book...}
  3653. @table @kbd
  3654. @item --remove-files
  3655. Remove files after adding them to the archive.
  3656. @end table
  3657. @node Scarce
  3658. @subsection Coping with Scarce Resources
  3659. @cindex Middle of the archive, starting in the
  3660. @cindex Running out of space during extraction
  3661. @cindex Disk space, running out of
  3662. @cindex Space on the disk, recovering from lack of
  3663. @UNREVISED
  3664. @menu
  3665. * Starting File::
  3666. * Same Order::
  3667. @end menu
  3668. @node Starting File
  3669. @unnumberedsubsubsec Starting File
  3670. @table @kbd
  3671. @item --starting-file=@var{name}
  3672. @itemx -K @var{name}
  3673. Starts an operation in the middle of an archive. Use in conjunction
  3674. with @value{op-extract} or @value{op-list}.
  3675. @end table
  3676. If a previous attempt to extract files failed due to lack of disk
  3677. space, you can use @value{op-starting-file} to start extracting only
  3678. after member @var{name} of the archive. This assumes, of course, that
  3679. there is now free space, or that you are now extracting into a
  3680. different file system. (You could also choose to suspend @command{tar},
  3681. remove unnecessary files from the file system, and then restart the
  3682. same @command{tar} operation. In this case, @value{op-starting-file} is
  3683. not necessary. @value{xref-incremental}, @value{xref-interactive},
  3684. and @value{ref-exclude}.)
  3685. @node Same Order
  3686. @unnumberedsubsubsec Same Order
  3687. @table @kbd
  3688. @item --same-order
  3689. @itemx --preserve-order
  3690. @itemx -s
  3691. To process large lists of file names on machines with small amounts of
  3692. memory. Use in conjunction with @value{op-compare},
  3693. @value{op-list}
  3694. or @value{op-extract}.
  3695. @end table
  3696. @FIXME{we don't need/want --preserve to exist any more (from melissa:
  3697. ie, don't want that *version* of the option to exist, or don't want
  3698. the option to exist in either version?}
  3699. @FIXME{i think this explanation is lacking.}
  3700. The @value{op-same-order} option tells @command{tar} that the list of file
  3701. names to be listed or extracted is sorted in the same order as the
  3702. files in the archive. This allows a large list of names to be used,
  3703. even on a small machine that would not otherwise be able to hold all
  3704. the names in memory at the same time. Such a sorted list can easily be
  3705. created by running @samp{tar -t} on the archive and editing its output.
  3706. This option is probably never needed on modern computer systems.
  3707. @node backup
  3708. @section Backup options
  3709. @cindex backup options
  3710. @GNUTAR{} offers options for making backups of files
  3711. before writing new versions. These options control the details of
  3712. these backups. They may apply to the archive itself before it is
  3713. created or rewritten, as well as individual extracted members. Other
  3714. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3715. and @command{mv}, for example) offer similar options.
  3716. Backup options may prove unexpectedly useful when extracting archives
  3717. containing many members having identical name, or when extracting archives
  3718. on systems having file name limitations, making different members appear
  3719. has having similar names through the side-effect of name truncation.
  3720. (This is true only if we have a good scheme for truncated backup names,
  3721. which I'm not sure at all: I suspect work is needed in this area.)
  3722. When any existing file is backed up before being overwritten by extraction,
  3723. then clashing files are automatically be renamed to be unique, and the
  3724. true name is kept for only the last file of a series of clashing files.
  3725. By using verbose mode, users may track exactly what happens.
  3726. At the detail level, some decisions are still experimental, and may
  3727. change in the future, we are waiting comments from our users. So, please
  3728. do not learn to depend blindly on the details of the backup features.
  3729. For example, currently, directories themselves are never renamed through
  3730. using these options, so, extracting a file over a directory still has
  3731. good chances to fail. Also, backup options apply to created archives,
  3732. not only to extracted members. For created archives, backups will not
  3733. be attempted when the archive is a block or character device, or when it
  3734. refers to a remote file.
  3735. For the sake of simplicity and efficiency, backups are made by renaming old
  3736. files prior to creation or extraction, and not by copying. The original
  3737. name is restored if the file creation fails. If a failure occurs after a
  3738. partial extraction of a file, both the backup and the partially extracted
  3739. file are kept.
  3740. @table @samp
  3741. @item --backup[=@var{method}]
  3742. @opindex --backup
  3743. @vindex VERSION_CONTROL
  3744. @cindex backups
  3745. Back up files that are about to be overwritten or removed.
  3746. Without this option, the original versions are destroyed.
  3747. Use @var{method} to determine the type of backups made.
  3748. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3749. environment variable. And if @env{VERSION_CONTROL} is not set,
  3750. use the @samp{existing} method.
  3751. @vindex version-control @r{Emacs variable}
  3752. This option corresponds to the Emacs variable @samp{version-control};
  3753. the same values for @var{method} are accepted as in Emacs. This option
  3754. also allows more descriptive names. The valid @var{method}s are:
  3755. @table @samp
  3756. @item t
  3757. @itemx numbered
  3758. @opindex numbered @r{backup method}
  3759. Always make numbered backups.
  3760. @item nil
  3761. @itemx existing
  3762. @opindex existing @r{backup method}
  3763. Make numbered backups of files that already have them, simple backups
  3764. of the others.
  3765. @item never
  3766. @itemx simple
  3767. @opindex simple @r{backup method}
  3768. Always make simple backups.
  3769. @end table
  3770. @item --suffix=@var{suffix}
  3771. @opindex --suffix
  3772. @cindex backup suffix
  3773. @vindex SIMPLE_BACKUP_SUFFIX
  3774. Append @var{suffix} to each backup file made with @samp{--backup}. If this
  3775. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3776. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3777. set, the default is @samp{~}, just as in Emacs.
  3778. @end table
  3779. Some people express the desire to @emph{always} use the @value{op-backup}
  3780. option, by defining some kind of alias or script. This is not as easy
  3781. as one may think, due to the fact that old style options should appear first
  3782. and consume arguments a bit unpredictably for an alias or script. But,
  3783. if you are ready to give up using old style options, you may resort to
  3784. using something like (a Bourne shell function here):
  3785. @smallexample
  3786. tar () @{ /usr/local/bin/tar --backup $*; @}
  3787. @end smallexample
  3788. @node Applications
  3789. @section Notable @command{tar} Usages
  3790. @UNREVISED
  3791. @FIXME{Using Unix file linking capability to recreate directory
  3792. structures---linking files into one subdirectory and then
  3793. @command{tar}ring that directory.}
  3794. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3795. @findex uuencode
  3796. You can easily use archive files to transport a group of files from
  3797. one system to another: put all relevant files into an archive on one
  3798. computer system, transfer the archive to another system, and extract
  3799. the contents there. The basic transfer medium might be magnetic tape,
  3800. Internet FTP, or even electronic mail (though you must encode the
  3801. archive with @command{uuencode} in order to transport it properly by
  3802. mail). Both machines do not have to use the same operating system, as
  3803. long as they both support the @command{tar} program.
  3804. For example, here is how you might copy a directory's contents from
  3805. one disk to another, while preserving the dates, modes, owners and
  3806. link-structure of all the files therein. In this case, the transfer
  3807. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3808. @smallexample
  3809. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3810. @end smallexample
  3811. @noindent
  3812. The command also works using short option forms:
  3813. @FIXME{The following using standard input/output correct??}
  3814. @smallexample
  3815. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3816. @end smallexample
  3817. @noindent
  3818. This is one of the easiest methods to transfer a @command{tar} archive.
  3819. @node looking ahead
  3820. @section Looking Ahead: The Rest of this Manual
  3821. You have now seen how to use all eight of the operations available to
  3822. @command{tar}, and a number of the possible options. The next chapter
  3823. explains how to choose and change file and archive names, how to use
  3824. files to store names of other files which you can then call as
  3825. arguments to @command{tar} (this can help you save time if you expect to
  3826. archive the same list of files a number of times), and so forth.
  3827. @FIXME{in case it's not obvious, i'm making this up in some sense
  3828. based on my limited memory of what the next chapter *really* does. i
  3829. just wanted to flesh out this final section a little bit so i'd
  3830. remember to stick it in here. :-)}
  3831. If there are too many files to conveniently list on the command line,
  3832. you can list the names in a file, and @command{tar} will read that file.
  3833. @value{xref-files-from}.
  3834. There are various ways of causing @command{tar} to skip over some files,
  3835. and not archive them. @xref{Choosing}.
  3836. @node Backups
  3837. @chapter Performing Backups and Restoring Files
  3838. @UNREVISED
  3839. @GNUTAR{} is distributed along with the scripts
  3840. which the Free Software Foundation uses for performing backups. There
  3841. is no corresponding scripts available yet for doing restoration of
  3842. files. Even if there is a good chance those scripts may be satisfying
  3843. to you, they are not the only scripts or methods available for doing
  3844. backups and restore. You may well create your own, or use more
  3845. sophisticated packages dedicated to that purpose.
  3846. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3847. Automatic Network Disk Archiver), a backup system developed by James
  3848. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3849. This is free software, and it is available at these places:
  3850. @smallexample
  3851. http://www.cs.umd.edu/projects/amanda/amanda.html
  3852. ftp://ftp.cs.umd.edu/pub/amanda
  3853. @end smallexample
  3854. @ifclear PUBLISH
  3855. Here is a possible plan for a future documentation about the backuping
  3856. scripts which are provided within the @GNUTAR{}
  3857. distribution.
  3858. @smallexample
  3859. .* dumps
  3860. . + what are dumps
  3861. . + different levels of dumps
  3862. . - full dump = dump everything
  3863. . - level 1, level 2 dumps etc, -
  3864. A level n dump dumps everything changed since the last level
  3865. n-1 dump (?)
  3866. . + how to use scripts for dumps (ie, the concept)
  3867. . - scripts to run after editing backup specs (details)
  3868. . + Backup Specs, what is it.
  3869. . - how to customize
  3870. . - actual text of script [/sp/dump/backup-specs]
  3871. . + Problems
  3872. . - rsh doesn't work
  3873. . - rtape isn't installed
  3874. . - (others?)
  3875. . + the --incremental option of tar
  3876. . + tapes
  3877. . - write protection
  3878. . - types of media
  3879. . : different sizes and types, useful for different things
  3880. . - files and tape marks
  3881. one tape mark between files, two at end.
  3882. . - positioning the tape
  3883. MT writes two at end of write,
  3884. backspaces over one when writing again.
  3885. @end smallexample
  3886. @end ifclear
  3887. This chapter documents both the provided FSF scripts and @command{tar}
  3888. options which are more specific to usage as a backup tool.
  3889. To @dfn{back up} a file system means to create archives that contain
  3890. all the files in that file system. Those archives can then be used to
  3891. restore any or all of those files (for instance if a disk crashes or a
  3892. file is accidentally deleted). File system @dfn{backups} are also
  3893. called @dfn{dumps}.
  3894. @menu
  3895. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3896. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  3897. * incremental and listed-incremental:: The Incremental Options
  3898. * Backup Levels:: Levels of Backups
  3899. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3900. * Scripted Backups:: Using the Backup Scripts
  3901. * Scripted Restoration:: Using the Restore Script
  3902. @end menu
  3903. @node Full Dumps
  3904. @section Using @command{tar} to Perform Full Dumps
  3905. @UNREVISED
  3906. @cindex full dumps
  3907. @cindex dumps, full
  3908. @cindex corrupted archives
  3909. Full dumps should only be made when no other people or programs
  3910. are modifying files in the filesystem. If files are modified while
  3911. @command{tar} is making the backup, they may not be stored properly in
  3912. the archive, in which case you won't be able to restore them if you
  3913. have to. (Files not being modified are written with no trouble, and do
  3914. not corrupt the entire archive.)
  3915. You will want to use the @value{op-label} option to give the archive a
  3916. volume label, so you can tell what this archive is even if the label
  3917. falls off the tape, or anything like that.
  3918. Unless the filesystem you are dumping is guaranteed to fit on
  3919. one volume, you will need to use the @value{op-multi-volume} option.
  3920. Make sure you have enough tapes on hand to complete the backup.
  3921. If you want to dump each filesystem separately you will need to use
  3922. the @value{op-one-file-system} option to prevent @command{tar} from crossing
  3923. filesystem boundaries when storing (sub)directories.
  3924. The @value{op-incremental} option is not needed, since this is a complete
  3925. copy of everything in the filesystem, and a full restore from this
  3926. backup would only be done onto a completely empty disk.
  3927. Unless you are in a hurry, and trust the @command{tar} program (and your
  3928. tapes), it is a good idea to use the @value{op-verify} option, to make
  3929. sure your files really made it onto the dump properly. This will
  3930. also detect cases where the file was modified while (or just after)
  3931. it was being archived. Not all media (notably cartridge tapes) are
  3932. capable of being verified, unfortunately.
  3933. @value{op-listed-incremental} take a file name argument always. If the
  3934. file doesn't exist, run a level zero dump, creating the file. If the
  3935. file exists, uses that file to see what has changed.
  3936. @value{op-incremental} @FIXME{look it up}
  3937. @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
  3938. This option should only be used when creating an incremental backup of
  3939. a filesystem. When the @value{op-incremental} option is used, @command{tar}
  3940. writes, at the beginning of the archive, an entry for each of the
  3941. directories that will be operated on. The entry for a directory
  3942. includes a list of all the files in the directory at the time the
  3943. dump was done, and a flag for each file indicating whether the file
  3944. is going to be put in the archive. This information is used when
  3945. doing a complete incremental restore.
  3946. Note that this option causes @command{tar} to create a non-standard
  3947. archive that may not be readable by non-@acronym{GNU} versions of the
  3948. @command{tar} program.
  3949. The @value{op-incremental} option means the archive is an incremental
  3950. backup. Its meaning depends on the command that it modifies.
  3951. If the @value{op-incremental} option is used with @value{op-list},
  3952. @command{tar} will list, for each directory in the archive, the list
  3953. of files in that directory at the time the archive was created. This
  3954. information is put out in a format that is not easy for humans to
  3955. read, but which is unambiguous for a program: each file name is
  3956. preceded by either a @samp{Y} if the file is present in the archive,
  3957. an @samp{N} if the file is not included in the archive, or a @samp{D}
  3958. if the file is a directory (and is included in the archive). Each
  3959. file name is terminated by a null character. The last file is
  3960. followed by an additional null and a newline to indicate the end of
  3961. the data.
  3962. If the @value{op-incremental} option is used with @value{op-extract}, then
  3963. when the entry for a directory is found, all files that currently
  3964. exist in that directory but are not listed in the archive @emph{are
  3965. deleted from the directory}.
  3966. This behavior is convenient when you are restoring a damaged file
  3967. system from a succession of incremental backups: it restores the
  3968. entire state of the file system to that which obtained when the backup
  3969. was made. If you don't use @value{op-incremental}, the file system will
  3970. probably fill up with files that shouldn't exist any more.
  3971. @value{op-listed-incremental} handle new @acronym{GNU}-format
  3972. incremental backup. This option handles new @acronym{GNU}-format
  3973. incremental backup. It has much the same effect as
  3974. @value{op-incremental}, but also the time when the dump is done and
  3975. the list of directories dumped is written to the given
  3976. @var{file}. When restoring, only files newer than the saved time are
  3977. restored, and the directory list is used to speed up operations.
  3978. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  3979. used in conjunction with @value{op-create} will also cause @command{tar} to
  3980. use the file @var{file}, which contains information about the state
  3981. of the filesystem at the time of the last backup, to decide which
  3982. files to include in the archive being created. That file will then
  3983. be updated by @command{tar}. If the file @var{file} does not exist when
  3984. this option is specified, @command{tar} will create it, and include all
  3985. appropriate files in the archive.
  3986. The file, which is archive independent, contains the date it was last
  3987. modified and a list of devices, inode numbers and directory names.
  3988. @command{tar} will archive files with newer mod dates or inode change
  3989. times, and directories with an unchanged inode number and device but
  3990. a changed directory name. The file is updated after the files to
  3991. be archived are determined, but before the new archive is actually
  3992. created.
  3993. @node Inc Dumps
  3994. @section Using @command{tar} to Perform Incremental Dumps
  3995. @UNREVISED
  3996. @cindex incremental dumps
  3997. @cindex dumps, incremental
  3998. Performing incremental dumps is similar to performing full dumps,
  3999. although a few more options will usually be needed.
  4000. A standard scheme is to do a @emph{monthly} (full) dump once a month,
  4001. a @emph{weekly} dump once a week of everything since the last monthly
  4002. and a @emph{daily} every day of everything since the last (weekly or
  4003. monthly) dump.
  4004. Here is a sample script to dump the directory hierarchies @samp{/usr}
  4005. and @samp{/var}.
  4006. @smallexample
  4007. #! /bin/sh
  4008. tar --create \
  4009. --blocking-factor=126 \
  4010. --file=/dev/rmt/0 \
  4011. --label="`hostname` /usr /var `date +%Y-%m-%d`" \
  4012. --listed-incremental=/var/log/usr-var.snar \
  4013. --verbose \
  4014. /usr /var
  4015. @end smallexample
  4016. This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
  4017. store information about the previous tar dump.
  4018. The blocking factor 126 is an attempt to make the tape drive stream.
  4019. Some tape devices cannot handle 64 kB blocks or larger, and require the
  4020. block size to be a multiple of 1 kB; for these devices, 126 is the
  4021. largest blocking factor that can be used.
  4022. @node incremental and listed-incremental
  4023. @section The Incremental Options
  4024. @UNREVISED
  4025. @value{op-incremental} is used in conjunction with @value{op-create},
  4026. @value{op-extract} or @value{op-list} when backing up and restoring file
  4027. systems. An archive cannot be extracted or listed with the
  4028. @value{op-incremental} option specified unless it was created with the
  4029. option specified. This option should only be used by a script, not by
  4030. the user, and is usually disregarded in favor of
  4031. @value{op-listed-incremental}, which is described below.
  4032. @value{op-incremental} in conjunction with @value{op-create} causes
  4033. @command{tar} to write, at the beginning of the archive, an entry for
  4034. each of the directories that will be archived. The entry for a
  4035. directory includes a list of all the files in the directory at the
  4036. time the archive was created and a flag for each file indicating
  4037. whether or not the file is going to be put in the archive.
  4038. Note that this option causes @command{tar} to create a non-standard
  4039. archive that may not be readable by non-@acronym{GNU} versions of the
  4040. @command{tar} program.
  4041. @value{op-incremental} in conjunction with @value{op-extract} causes
  4042. @command{tar} to read the lists of directory contents previously stored
  4043. in the archive, @emph{delete} files in the file system that did not
  4044. exist in their directories when the archive was created, and then
  4045. extract the files in the archive.
  4046. This behavior is convenient when restoring a damaged file system from
  4047. a succession of incremental backups: it restores the entire state of
  4048. the file system to that which obtained when the backup was made. If
  4049. @value{op-incremental} isn't specified, the file system will probably
  4050. fill up with files that shouldn't exist any more.
  4051. @value{op-incremental} in conjunction with @value{op-list} causes
  4052. @command{tar} to print, for each directory in the archive, the list of
  4053. files in that directory at the time the archive was created. This
  4054. information is put out in a format that is not easy for humans to
  4055. read, but which is unambiguous for a program: each file name is
  4056. preceded by either a @samp{Y} if the file is present in the archive,
  4057. an @samp{N} if the file is not included in the archive, or a @samp{D}
  4058. if the file is a directory (and is included in the archive). Each
  4059. file name is terminated by a null character. The last file is followed
  4060. by an additional null and a newline to indicate the end of the data.
  4061. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4062. used in conjunction with @value{op-create} will also cause @command{tar}
  4063. to use the file @var{snapshot-file}, which contains information about
  4064. the state of the file system at the time of the last backup, to decide
  4065. which files to include in the archive being created. That file will
  4066. then be updated by @command{tar}. If the file @var{file} does not exist
  4067. when this option is specified, @command{tar} will create it, and include
  4068. all appropriate files in the archive.
  4069. The file @var{file}, which is archive independent, contains the date
  4070. it was last modified and a list of devices, inode numbers and
  4071. directory names. @command{tar} will archive files with newer mod dates
  4072. or inode change times, and directories with an unchanged inode number
  4073. and device but a changed directory name. The file is updated after
  4074. the files to be archived are determined, but before the new archive is
  4075. actually created.
  4076. Incremental dumps depend crucially on time stamps, so the results are
  4077. unreliable if you modify a file's time stamps during dumping (e.g.@:
  4078. with the @samp{--atime-preserve} option), or if you set the clock
  4079. backwards.
  4080. Despite it should be obvious that a device has a non-volatile value, NFS
  4081. devices have non-dependable values when an automounter gets in the picture.
  4082. This led to a great deal of spurious redumping in incremental dumps,
  4083. so it is somewhat useless to compare two NFS devices numbers over time.
  4084. So @command{tar} now considers all NFS devices as being equal when it comes
  4085. to comparing directories; this is fairly gross, but there does not seem
  4086. to be a better way to go.
  4087. @command{tar} doesn't access @var{snapshot-file} when
  4088. @value{op-create} or @value{op-list} are specified, but the
  4089. @value{op-listed-incremental} option must still be given. A
  4090. placeholder @var{snapshot-file} can be specified, e.g.,
  4091. @file{/dev/null}.
  4092. @FIXME{this section needs to be written}
  4093. @node Backup Levels
  4094. @section Levels of Backups
  4095. @UNREVISED
  4096. An archive containing all the files in the file system is called a
  4097. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4098. creating a full dump every day. This strategy, however, would waste a
  4099. substantial amount of archive media and user time, as unchanged files
  4100. are daily re-archived.
  4101. It is more efficient to do a full dump only occasionally. To back up
  4102. files between full dumps, you can a incremental dump. A @dfn{level
  4103. one} dump archives all the files that have changed since the last full
  4104. dump.
  4105. A typical dump strategy would be to perform a full dump once a week,
  4106. and a level one dump once a day. This means some versions of files
  4107. will in fact be archived more than once, but this dump strategy makes
  4108. it possible to restore a file system to within one day of accuracy by
  4109. only extracting two archives---the last weekly (full) dump and the
  4110. last daily (level one) dump. The only information lost would be in
  4111. files changed or created since the last daily backup. (Doing dumps
  4112. more than once a day is usually not worth the trouble).
  4113. @GNUTAR{} comes with scripts you can use to do full
  4114. and level-one dumps. Using scripts (shell programs) to perform
  4115. backups and restoration is a convenient and reliable alternative to
  4116. typing out file name lists and @command{tar} commands by hand.
  4117. Before you use these scripts, you need to edit the file
  4118. @file{backup-specs}, which specifies parameters used by the backup
  4119. scripts and by the restore script. @FIXME{There is no such restore
  4120. script!}@FIXME-xref{Script Syntax}Once the backup parameters
  4121. are set, you can perform backups or restoration by running the
  4122. appropriate script.
  4123. The name of the restore script is @code{restore}. @FIXME{There is
  4124. no such restore script!}The names of the level one and full backup
  4125. scripts are, respectively, @code{level-1} and @code{level-0}.
  4126. The @code{level-0} script also exists under the name @code{weekly}, and
  4127. the @code{level-1} under the name @code{daily}---these additional names
  4128. can be changed according to your backup schedule. @FIXME-xref{Scripted
  4129. Restoration, for more information on running the restoration script.}
  4130. @FIXME-xref{Scripted Backups, for more information on running the
  4131. backup scripts.}
  4132. @emph{Please Note:} The backup scripts and the restoration scripts are
  4133. designed to be used together. While it is possible to restore files by
  4134. hand from an archive which was created using a backup script, and to create
  4135. an archive by hand which could then be extracted using the restore script,
  4136. it is easier to use the scripts.@FIXME{There is no such restore script!}
  4137. @value{xref-incremental}, and @value{xref-listed-incremental},
  4138. before making such an attempt.
  4139. @FIXME{shorten node names}
  4140. @node Backup Parameters
  4141. @section Setting Parameters for Backups and Restoration
  4142. @UNREVISED
  4143. The file @file{backup-specs} specifies backup parameters for the
  4144. backup and restoration scripts provided with @command{tar}. You must
  4145. edit @file{backup-specs} to fit your system configuration and schedule
  4146. before using these scripts.
  4147. @FIXME{This about backup scripts needs to be written: BS is a shell
  4148. script .... thus ... @file{backup-specs} is in shell script syntax.}
  4149. @FIXME-xref{Script Syntax, for an explanation of this syntax.}
  4150. @FIXME{Whats a parameter .... looked at by the backup scripts
  4151. ... which will be expecting to find ... now syntax ... value is linked
  4152. to lame ... @file{backup-specs} specifies the following parameters:}
  4153. @table @samp
  4154. @item ADMINISTRATOR
  4155. The user name of the backup administrator.
  4156. @item BACKUP_HOUR
  4157. The hour at which the backups are done. This can be a number from 0
  4158. to 23, or the string @samp{now}.
  4159. @item TAPE_FILE
  4160. The device @command{tar} writes the archive to. This device should be
  4161. attached to the host on which the dump scripts are run.
  4162. @FIXME{examples for all ...}
  4163. @item TAPE_STATUS
  4164. The command to use to obtain the status of the archive device,
  4165. including error count. On some tape drives there may not be such a
  4166. command; in that case, simply use @samp{TAPE_STATUS=false}.
  4167. @item BLOCKING
  4168. The blocking factor @command{tar} will use when writing the dump archive.
  4169. @value{xref-blocking-factor}.
  4170. @item BACKUP_DIRS
  4171. A list of file systems to be dumped. You can include any directory
  4172. name in the list---subdirectories on that file system will be
  4173. included, regardless of how they may look to other networked machines.
  4174. Subdirectories on other file systems will be ignored.
  4175. The host name specifies which host to run @command{tar} on, and should
  4176. normally be the host that actually contains the file system. However,
  4177. the host machine must have @GNUTAR{} installed, and
  4178. must be able to access the directory containing the backup scripts and
  4179. their support files using the same file name that is used on the
  4180. machine where the scripts are run (ie. what @command{pwd} will print
  4181. when in that directory on that machine). If the host that contains
  4182. the file system does not have this capability, you can specify another
  4183. host as long as it can access the file system through NFS.
  4184. @item BACKUP_FILES
  4185. A list of individual files to be dumped. These should be accessible
  4186. from the machine on which the backup script is run.
  4187. @FIXME{Same file name, be specific. Through NFS ...}
  4188. @end table
  4189. @menu
  4190. * backup-specs example:: An Example Text of @file{Backup-specs}
  4191. * Script Syntax:: Syntax for @file{Backup-specs}
  4192. @end menu
  4193. @node backup-specs example
  4194. @subsection An Example Text of @file{Backup-specs}
  4195. @UNREVISED
  4196. The following is the text of @file{backup-specs} as it appears at FSF:
  4197. @smallexample
  4198. # site-specific parameters for file system backup.
  4199. ADMINISTRATOR=friedman
  4200. BACKUP_HOUR=1
  4201. TAPE_FILE=/dev/nrsmt0
  4202. TAPE_STATUS="mts -t $TAPE_FILE"
  4203. BLOCKING=124
  4204. BACKUP_DIRS="
  4205. albert:/fs/fsf
  4206. apple-gunkies:/gd
  4207. albert:/fs/gd2
  4208. albert:/fs/gp
  4209. geech:/usr/jla
  4210. churchy:/usr/roland
  4211. albert:/
  4212. albert:/usr
  4213. apple-gunkies:/
  4214. apple-gunkies:/usr
  4215. gnu:/hack
  4216. gnu:/u
  4217. apple-gunkies:/com/mailer/gnu
  4218. apple-gunkies:/com/archive/gnu"
  4219. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4220. @end smallexample
  4221. @node Script Syntax
  4222. @subsection Syntax for @file{Backup-specs}
  4223. @UNREVISED
  4224. @file{backup-specs} is in shell script syntax. The following
  4225. conventions should be considered when editing the script:
  4226. @FIXME{"conventions?"}
  4227. A quoted string is considered to be contiguous, even if it is on more
  4228. than one line. Therefore, you cannot include commented-out lines
  4229. within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
  4230. the two most likely parameters to be multi-line.
  4231. A quoted string typically cannot contain wildcards. In
  4232. @file{backup-specs}, however, the parameters BACKUP_DIRS and
  4233. BACKUP_FILES can contain wildcards.
  4234. @node Scripted Backups
  4235. @section Using the Backup Scripts
  4236. @UNREVISED
  4237. The syntax for running a backup script is:
  4238. @smallexample
  4239. @file{script-name} [@var{time-to-be-run}]
  4240. @end smallexample
  4241. where @var{time-to-be-run} can be a specific system time, or can be
  4242. @kbd{now}. If you do not specify a time, the script runs at the time
  4243. specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
  4244. You should start a script with a tape or disk mounted. Once you
  4245. start a script, it prompts you for new tapes or disks as it
  4246. needs them. Media volumes don't have to correspond to archive
  4247. files---a multi-volume archive can be started in the middle of a
  4248. tape that already contains the end of another multi-volume archive.
  4249. The @code{restore} script prompts for media by its archive volume,
  4250. so to avoid an error message you should keep track of which tape
  4251. (or disk) contains which volume of the archive. @FIXME{There is
  4252. no such restore script!} @FIXME-xref{Scripted Restoration}
  4253. @FIXME{Have file names changed?}
  4254. The backup scripts write two files on the file system. The first is a
  4255. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4256. to store and retrieve information about which files were dumped. This
  4257. file is not meant to be read by humans, and should not be deleted by
  4258. them. @FIXME-xref{incremental and listed-incremental, for a more
  4259. detailed explanation of this file.}
  4260. The second file is a log file containing the names of the file systems
  4261. and files dumped, what time the backup was made, and any error
  4262. messages that were generated, as well as how much space was left in
  4263. the media volume after the last volume of the archive was written.
  4264. You should check this log file after every backup. The file name is
  4265. @file{log-@var{mmm-ddd-yyyy}-level-1} or
  4266. @file{log-@var{mmm-ddd-yyyy}-full}.
  4267. The script also prints the name of each system being dumped to the
  4268. standard output.
  4269. @node Scripted Restoration
  4270. @section Using the Restore Script
  4271. @UNREVISED
  4272. @ifset PUBLISH
  4273. The @command{tar} distribution does not provide restoring scripts.
  4274. @end ifset
  4275. @ifclear PUBLISH
  4276. @quotation
  4277. @strong{Warning:} The @GNUTAR{} distribution does @emph{not}
  4278. provide any such @code{restore} script yet. This section is only
  4279. listed here for documentation maintenance purposes. In any case,
  4280. all contents is subject to change as things develop.
  4281. @end quotation
  4282. @FIXME{A section on non-scripted restore may be a good idea.}
  4283. To restore files that were archived using a scripted backup, use the
  4284. @code{restore} script. The syntax for the script is:
  4285. where ***** are the file systems to restore from, and
  4286. ***** is a regular expression which specifies which files to
  4287. restore. If you specify --all, the script restores all the files
  4288. in the file system.
  4289. You should start the restore script with the media containing the
  4290. first volume of the archive mounted. The script will prompt for other
  4291. volumes as they are needed. If the archive is on tape, you don't need
  4292. to rewind the tape to to its beginning---if the tape head is
  4293. positioned past the beginning of the archive, the script will rewind
  4294. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4295. positioning.}
  4296. If you specify @samp{--all} as the @var{files} argument, the
  4297. @code{restore} script extracts all the files in the archived file
  4298. system into the active file system.
  4299. @quotation
  4300. @strong{Warning:} The script will delete files from the active file
  4301. system if they were not in the file system when the archive was made.
  4302. @end quotation
  4303. @value{xref-incremental}, and @value{ref-listed-incremental},
  4304. for an explanation of how the script makes that determination.
  4305. @FIXME{this may be an option, not a given}
  4306. @end ifclear
  4307. @node Choosing
  4308. @chapter Choosing Files and Names for @command{tar}
  4309. @UNREVISED
  4310. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4311. Certain options to @command{tar} enable you to specify a name for your
  4312. archive. Other options let you decide which files to include or exclude
  4313. from the archive, based on when or whether files were modified, whether
  4314. the file names do or don't match specified patterns, or whether files
  4315. are in specified directories.
  4316. @menu
  4317. * file:: Choosing the Archive's Name
  4318. * Selecting Archive Members::
  4319. * files:: Reading Names from a File
  4320. * exclude:: Excluding Some Files
  4321. * Wildcards::
  4322. * after:: Operating Only on New Files
  4323. * recurse:: Descending into Directories
  4324. * one:: Crossing Filesystem Boundaries
  4325. @end menu
  4326. @node file
  4327. @section Choosing and Naming Archive Files
  4328. @cindex Naming an archive
  4329. @cindex Archive Name
  4330. @cindex Directing output
  4331. @cindex Choosing an archive file
  4332. @cindex Where is the archive?
  4333. @UNREVISED
  4334. @FIXME{should the title of this section actually be, "naming an
  4335. archive"?}
  4336. By default, @command{tar} uses an archive file name that was compiled when
  4337. it was built on the system; usually this name refers to some physical
  4338. tape drive on the machine. However, the person who installed @command{tar}
  4339. on the system may not set the default to a meaningful value as far as
  4340. most users are concerned. As a result, you will usually want to tell
  4341. @command{tar} where to find (or create) the archive. The @value{op-file}
  4342. option allows you to either specify or name a file to use as the archive
  4343. instead of the default archive file location.
  4344. @table @kbd
  4345. @item --file=@var{archive-name}
  4346. @itemx -f @var{archive-name}
  4347. Name the archive to create or operate on. Use in conjunction with
  4348. any operation.
  4349. @end table
  4350. For example, in this @command{tar} command,
  4351. @smallexample
  4352. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4353. @end smallexample
  4354. @noindent
  4355. @file{collection.tar} is the name of the archive. It must directly
  4356. follow the @samp{-f} option, since whatever directly follows @samp{-f}
  4357. @emph{will} end up naming the archive. If you neglect to specify an
  4358. archive name, you may end up overwriting a file in the working directory
  4359. with the archive you create since @command{tar} will use this file's name
  4360. for the archive name.
  4361. An archive can be saved as a file in the file system, sent through a
  4362. pipe or over a network, or written to an I/O device such as a tape,
  4363. floppy disk, or CD write drive.
  4364. @cindex Writing new archives
  4365. @cindex Archive creation
  4366. If you do not name the archive, @command{tar} uses the value of the
  4367. environment variable @env{TAPE} as the file name for the archive. If
  4368. that is not available, @command{tar} uses a default, compiled-in archive
  4369. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4370. @command{tar} always needs an archive name.
  4371. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4372. archive from standard input (when listing or extracting files), or
  4373. writes it to standard output (when creating an archive). If you use
  4374. @file{-} as an @var{archive-name} when modifying an archive,
  4375. @command{tar} reads the original archive from its standard input and
  4376. writes the entire new archive to its standard output.
  4377. @FIXME{might want a different example here; this is already used in
  4378. "notable tar usages".}
  4379. @smallexample
  4380. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4381. @end smallexample
  4382. @FIXME{help!}
  4383. @cindex Standard input and output
  4384. @cindex tar to standard input and output
  4385. To specify an archive file on a device attached to a remote machine,
  4386. use the following:
  4387. @smallexample
  4388. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4389. @end smallexample
  4390. @noindent
  4391. @command{tar} will complete the remote connection, if possible, and
  4392. prompt you for a username and password. If you use
  4393. @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4394. will complete the remote connection, if possible, using your username
  4395. as the username on the remote machine.
  4396. If the archive file name includes a colon (@samp{:}), then it is assumed
  4397. to be a file on another machine. If the archive file is
  4398. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4399. host @var{host}. The remote host is accessed using the @command{rsh}
  4400. program, with a username of @var{user}. If the username is omitted
  4401. (along with the @samp{@@} sign), then your user name will be used.
  4402. (This is the normal @command{rsh} behavior.) It is necessary for the
  4403. remote machine, in addition to permitting your @command{rsh} access, to
  4404. have the @file{/usr/ucb/rmt} program installed. If you need to use a
  4405. file whose name includes a colon, then the remote tape drive behavior
  4406. can be inhibited by using the @value{op-force-local} option.
  4407. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4408. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4409. into what came before it well enough <<i moved it now, is it better
  4410. here?>>. bob also comments that if Amanda isn't free software, we
  4411. shouldn't mention it..}
  4412. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4413. tries to minimize input and output operations. The
  4414. Amanda backup system, when used with @GNUTAR{}, has
  4415. an initial sizing pass which uses this feature.
  4416. @node Selecting Archive Members
  4417. @section Selecting Archive Members
  4418. @cindex Specifying files to act on
  4419. @cindex Specifying archive members
  4420. @dfn{File Name arguments} specify which files in the file system
  4421. @command{tar} operates on, when creating or adding to an archive, or which
  4422. archive members @command{tar} operates on, when reading or deleting from
  4423. an archive. @xref{Operations}.
  4424. To specify file names, you can include them as the last arguments on
  4425. the command line, as follows:
  4426. @smallexample
  4427. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4428. @end smallexample
  4429. If you specify a directory name as a file name argument, all the files
  4430. in that directory are operated on by @command{tar}.
  4431. If you do not specify files when @command{tar} is invoked with
  4432. @value{op-create}, @command{tar} operates on all the non-directory files in
  4433. the working directory. If you specify either @value{op-list} or
  4434. @value{op-extract}, @command{tar} operates on all the archive members in the
  4435. archive. If you specify any operation other than one of these three,
  4436. @command{tar} does nothing.
  4437. By default, @command{tar} takes file names from the command line. However,
  4438. there are other ways to specify file or member names, or to modify the
  4439. manner in which @command{tar} selects the files or members upon which to
  4440. operate. @FIXME{add xref here}In general, these methods work both for
  4441. specifying the names of files and archive members.
  4442. @node files
  4443. @section Reading Names from a File
  4444. @UNREVISED
  4445. @cindex Reading file names from a file
  4446. @cindex Lists of file names
  4447. @cindex File Name arguments, alternatives
  4448. Instead of giving the names of files or archive members on the command
  4449. line, you can put the names into a file, and then use the
  4450. @value{op-files-from} option to @command{tar}. Give the name of the file
  4451. which contains the list of files to include as the argument to
  4452. @samp{--files-from}. In the list, the file names should be separated by
  4453. newlines. You will frequently use this option when you have generated
  4454. the list of files to archive with the @command{find} utility.
  4455. @table @kbd
  4456. @item --files-from=@var{file name}
  4457. @itemx -T @var{file name}
  4458. Get names to extract or create from file @var{file name}.
  4459. @end table
  4460. If you give a single dash as a file name for @samp{--files-from}, (i.e.,
  4461. you specify either @samp{--files-from=-} or @samp{-T -}), then the file
  4462. names are read from standard input.
  4463. Unless you are running @command{tar} with @samp{--create}, you can not use
  4464. both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
  4465. command.
  4466. @FIXME{add bob's example, from his message on 2-10-97}
  4467. The following example shows how to use @command{find} to generate a list of
  4468. files smaller than 400K in length and put that list into a file
  4469. called @file{small-files}. You can then use the @samp{-T} option to
  4470. @command{tar} to specify the files from that file, @file{small-files}, to
  4471. create the archive @file{little.tgz}. (The @samp{-z} option to
  4472. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4473. more information.)
  4474. @smallexample
  4475. $ @kbd{find . -size -400 -print > small-files}
  4476. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4477. @end smallexample
  4478. @noindent
  4479. @FIXME{say more here to conclude the example/section?}
  4480. @menu
  4481. * nul::
  4482. @end menu
  4483. @node nul
  4484. @subsection @kbd{NUL} Terminated File Names
  4485. @cindex File names, terminated by @kbd{NUL}
  4486. @cindex @kbd{NUL} terminated file names
  4487. The @value{op-null} option causes @value{op-files-from} to read file
  4488. names terminated by a @code{NUL} instead of a newline, so files whose
  4489. names contain newlines can be archived using @samp{--files-from}.
  4490. @table @kbd
  4491. @item --null
  4492. Only consider @kbd{NUL} terminated file names, instead of files that
  4493. terminate in a newline.
  4494. @end table
  4495. The @samp{--null} option is just like the one in @acronym{GNU}
  4496. @command{xargs} and @command{cpio}, and is useful with the
  4497. @samp{-print0} predicate of @acronym{GNU} @command{find}. In
  4498. @command{tar}, @samp{--null} also causes @value{op-directory} options
  4499. to be treated as file names to archive, in case there are any files
  4500. out there called @file{-C}.
  4501. This example shows how to use @command{find} to generate a list of files
  4502. larger than 800K in length and put that list into a file called
  4503. @file{long-files}. The @samp{-print0} option to @command{find} just just
  4504. like @samp{-print}, except that it separates files with a @kbd{NUL}
  4505. rather than with a newline. You can then run @command{tar} with both the
  4506. @samp{--null} and @samp{-T} options to specify that @command{tar} get the
  4507. files from that file, @file{long-files}, to create the archive
  4508. @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
  4509. @command{tar} to recognize the @kbd{NUL} separator between files.
  4510. @smallexample
  4511. $ @kbd{find . -size +800 -print0 > long-files}
  4512. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4513. @end smallexample
  4514. @FIXME{say anything else here to conclude the section?}
  4515. @node exclude
  4516. @section Excluding Some Files
  4517. @cindex File names, excluding files by
  4518. @cindex Excluding files by name and pattern
  4519. @cindex Excluding files by file system
  4520. @UNREVISED
  4521. To avoid operating on files whose names match a particular pattern,
  4522. use the @value{op-exclude} or @value{op-exclude-from} options.
  4523. @table @kbd
  4524. @item --exclude=@var{pattern}
  4525. Causes @command{tar} to ignore files that match the @var{pattern}.
  4526. @end table
  4527. @findex exclude
  4528. The @value{op-exclude} option prevents any file or member whose name
  4529. matches the shell wildcard (@var{pattern}) from being operated on.
  4530. For example, to create an archive with all the contents of the directory
  4531. @file{src} except for files whose names end in @file{.o}, use the
  4532. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4533. You may give multiple @samp{--exclude} options.
  4534. @table @kbd
  4535. @item --exclude-from=@var{file}
  4536. @itemx -X @var{file}
  4537. Causes @command{tar} to ignore files that match the patterns listed in
  4538. @var{file}.
  4539. @end table
  4540. @findex exclude-from
  4541. Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
  4542. list of patterns, one per line, from @var{file}; @command{tar} will
  4543. ignore files matching those patterns. Thus if @command{tar} is
  4544. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4545. single line @file{*.o}, no files whose names end in @file{.o} will be
  4546. added to the archive.
  4547. @FIXME{do the exclude options files need to have stuff separated by
  4548. newlines the same as the files-from option does?}
  4549. @menu
  4550. * controlling pattern-patching with exclude::
  4551. * problems with exclude::
  4552. @end menu
  4553. @node controlling pattern-patching with exclude
  4554. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4555. Normally, a pattern matches a name if an initial subsequence of the
  4556. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4557. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4558. and wildcards can match @samp{/}.
  4559. Other than optionally stripping leading @samp{/} from names
  4560. (@pxref{absolute}), patterns and names are used as-is. For
  4561. example, trailing @samp{/} is not trimmed from a user-specified name
  4562. before deciding whether to exclude it.
  4563. However, this matching procedure can be altered by the options listed
  4564. below. These options accumulate. For example:
  4565. @smallexample
  4566. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4567. @end smallexample
  4568. ignores case when excluding @samp{makefile}, but not when excluding
  4569. @samp{readme}.
  4570. @table @option
  4571. @item --anchored
  4572. @itemx --no-anchored
  4573. If anchored (the default), a pattern must match an initial subsequence
  4574. of the name's components. Otherwise, the pattern can match any subsequence.
  4575. @item --ignore-case
  4576. @itemx --no-ignore-case
  4577. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4578. When not ignoring case (the default), matching is case-sensitive.
  4579. @item --wildcards
  4580. @itemx --no-wildcards
  4581. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4582. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4583. Otherwise, none of these characters are special, and patterns must match
  4584. names literally.
  4585. @item --wildcards-match-slash
  4586. @itemx --no-wildcards-match-slash
  4587. When wildcards match slash (the default), a wildcard like @samp{*} in
  4588. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4589. matched only by @samp{/}.
  4590. @end table
  4591. The @option{--recursion} and @option{--no-recursion} options
  4592. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4593. recursion is in effect, a pattern excludes a name if it matches any of
  4594. the name's parent directories.
  4595. @node problems with exclude
  4596. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4597. Some users find @samp{exclude} options confusing. Here are some common
  4598. pitfalls:
  4599. @itemize @bullet
  4600. @item
  4601. The main operating mode of @command{tar} does not act on a path name
  4602. explicitly listed on the command line if one of its file name
  4603. components is excluded. In the example above, if
  4604. you create an archive and exclude files that end with @samp{*.o}, but
  4605. explicitly name the file @samp{dir.o/foo} after all the options have been
  4606. listed, @samp{dir.o/foo} will be excluded from the archive.
  4607. @item
  4608. You can sometimes confuse the meanings of @value{op-exclude} and
  4609. @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
  4610. to be excluded are given as a pattern on the command line. Use
  4611. @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
  4612. file which contains a list of patterns, one per line; each of these
  4613. patterns can exclude zero, one, or many files.
  4614. @item
  4615. When you use @value{op-exclude}, be sure to quote the @var{pattern}
  4616. parameter, so @GNUTAR{} sees wildcard characters
  4617. like @samp{*}. If you do not do this, the shell might expand the
  4618. @samp{*} itself using files at hand, so @command{tar} might receive a
  4619. list of files instead of one pattern, or none at all, making the
  4620. command somewhat illegal. This might not correspond to what you want.
  4621. For example, write:
  4622. @smallexample
  4623. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4624. @end smallexample
  4625. @noindent
  4626. rather than:
  4627. @smallexample
  4628. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4629. @end smallexample
  4630. @item
  4631. You must use use shell syntax, or globbing, rather than @code{regexp}
  4632. syntax, when using exclude options in @command{tar}. If you try to use
  4633. @code{regexp} syntax to describe files to be excluded, your command
  4634. might fail.
  4635. @item
  4636. In earlier versions of @command{tar}, what is now the
  4637. @samp{--exclude-from=@var{file-of-patterns}} option was called
  4638. @samp{--exclude=@var{pattern}} instead. Now,
  4639. @samp{--exclude=@var{pattern}} applies to patterns listed on the command
  4640. line and @samp{--exclude-from=@var{file-of-patterns}} applies to
  4641. patterns listed in a file.
  4642. @end itemize
  4643. @node Wildcards
  4644. @section Wildcards Patterns and Matching
  4645. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  4646. @samp{*} or @samp{?} for example, are replaced and expanded into all
  4647. existing files matching the given pattern. However, @command{tar} often
  4648. uses wildcard patterns for matching (or globbing) archive members instead
  4649. of actual files in the filesystem. Wildcard patterns are also used for
  4650. verifying volume labels of @command{tar} archives. This section has the
  4651. purpose of explaining wildcard syntax for @command{tar}.
  4652. @FIXME{the next few paragraphs need work.}
  4653. A @var{pattern} should be written according to shell syntax, using wildcard
  4654. characters to effect globbing. Most characters in the pattern stand
  4655. for themselves in the matched string, and case is significant: @samp{a}
  4656. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  4657. pattern matches any single character in the matched string. The character
  4658. @samp{*} in the pattern matches zero, one, or more single characters in
  4659. the matched string. The character @samp{\} says to take the following
  4660. character of the pattern @emph{literally}; it is useful when one needs to
  4661. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  4662. The character @samp{[}, up to the matching @samp{]}, introduces a character
  4663. class. A @dfn{character class} is a list of acceptable characters
  4664. for the next single character of the matched string. For example,
  4665. @samp{[abcde]} would match any of the first five letters of the alphabet.
  4666. Note that within a character class, all of the ``special characters''
  4667. listed above other than @samp{\} lose their special meaning; for example,
  4668. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  4669. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  4670. the characters @samp{-} and @samp{]} must either come @emph{first} or
  4671. @emph{last} in a character class.)
  4672. @cindex Excluding characters from a character class
  4673. @cindex Character class, excluding characters from
  4674. If the first character of the class after the opening @samp{[}
  4675. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  4676. Rather than listing character to match, it lists those characters which
  4677. are @emph{forbidden} as the next single character of the matched string.
  4678. Other characters of the class stand for themselves. The special
  4679. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  4680. letters, is meant to represent all characters between @var{a} and
  4681. @var{e}, inclusive.
  4682. @FIXME{need to add a sentence or so here to make this clear for those
  4683. who don't have dan around.}
  4684. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  4685. special for wildcard matches. However, if a pattern completely matches
  4686. a directory prefix of a matched string, then it matches the full matched
  4687. string: excluding a directory also excludes all the files beneath it.
  4688. @node after
  4689. @section Operating Only on New Files
  4690. @cindex Excluding file by age
  4691. @cindex Modification time, excluding files by
  4692. @cindex Age, excluding files by
  4693. @UNREVISED
  4694. The @value{op-after-date} option causes @command{tar} to only work on files
  4695. whose modification or inode-changed times are newer than the @var{date}
  4696. given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
  4697. be a file name; the last-modified time of that file is used as the date.
  4698. If you use this option when creating or appending to an archive,
  4699. the archive will only include new files. If you use @samp{--after-date}
  4700. when extracting an archive, @command{tar} will only extract files newer
  4701. than the @var{date} you specify.
  4702. If you only want @command{tar} to make the date comparison based on
  4703. modification of the actual contents of the file (rather than inode
  4704. changes), then use the @value{op-newer-mtime} option.
  4705. You may use these options with any operation. Note that these options
  4706. differ from the @value{op-update} operation in that they allow you to
  4707. specify a particular date against which @command{tar} can compare when
  4708. deciding whether or not to archive the files.
  4709. @table @kbd
  4710. @item --after-date=@var{date}
  4711. @itemx --newer=@var{date}
  4712. @itemx -N @var{date}
  4713. Only store files newer than @var{date}.
  4714. Acts on files only if their modification or inode-changed times are
  4715. later than @var{date}. Use in conjunction with any operation.
  4716. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  4717. name; the last-modified time of that file is used as the date.
  4718. @item --newer-mtime=@var{date}
  4719. Acts like @value{op-after-date}, but only looks at modification times.
  4720. @end table
  4721. These options limit @command{tar} to only operating on files which have
  4722. been modified after the date specified. A file is considered to have
  4723. changed if the contents have been modified, or if the owner,
  4724. permissions, and so forth, have been changed. (For more information on
  4725. how to specify a date, see @ref{Date input formats}; remember that the
  4726. entire date argument must be quoted if it contains any spaces.)
  4727. Gurus would say that @value{op-after-date} tests both the @code{mtime}
  4728. (time the contents of the file were last modified) and @code{ctime}
  4729. (time the file's status was last changed: owner, permissions, etc)
  4730. fields, while @value{op-newer-mtime} tests only @code{mtime} field.
  4731. To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
  4732. @code{ctime} and processes the file if either one is more recent than
  4733. @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
  4734. disregards @code{ctime}. Neither uses @code{atime} (the last time the
  4735. contents of the file were looked at).
  4736. Date specifiers can have embedded spaces. Because of this, you may need
  4737. to quote date arguments to keep the shell from parsing them as separate
  4738. arguments.
  4739. @FIXME{Need example of --newer-mtime with quoted argument.}
  4740. @quotation
  4741. @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
  4742. should not be used for incremental backups. Some files (such as those
  4743. in renamed directories) are not selected properly by these options.
  4744. @xref{incremental and listed-incremental}.
  4745. @end quotation
  4746. @noindent
  4747. @FIXME{which tells -- need to fill this in!}
  4748. @node recurse
  4749. @section Descending into Directories
  4750. @cindex Avoiding recursion in directories
  4751. @cindex Descending directories, avoiding
  4752. @cindex Directories, avoiding recursion
  4753. @cindex Recursion in directories, avoiding
  4754. @UNREVISED
  4755. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  4756. @FIXME{show dan bob's comments, from 2-10-97}
  4757. Usually, @command{tar} will recursively explore all directories (either
  4758. those given on the command line or through the @value{op-files-from}
  4759. option) for the various files they contain. However, you may not always
  4760. want @command{tar} to act this way.
  4761. The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
  4762. into specified directories. If you specify @samp{--no-recursion}, you can
  4763. use the @command{find} utility for hunting through levels of directories to
  4764. construct a list of file names which you could then pass to @command{tar}.
  4765. @command{find} allows you to be more selective when choosing which files to
  4766. archive; see @ref{files} for more information on using @command{find} with
  4767. @command{tar}, or look.
  4768. @table @kbd
  4769. @item --no-recursion
  4770. Prevents @command{tar} from recursively descending directories.
  4771. @item --recursion
  4772. Requires @command{tar} to recursively descend directories.
  4773. This is the default.
  4774. @end table
  4775. When you use @samp{--no-recursion}, @GNUTAR{} grabs
  4776. directory entries themselves, but does not descend on them
  4777. recursively. Many people use @command{find} for locating files they
  4778. want to back up, and since @command{tar} @emph{usually} recursively
  4779. descends on directories, they have to use the @samp{@w{! -d}} option
  4780. to @command{find} @FIXME{needs more explanation or a cite to another
  4781. info file}as they usually do not want all the files in a directory.
  4782. They then use the @value{op-files-from} option to archive the files
  4783. located via @command{find}.
  4784. The problem when restoring files archived in this manner is that the
  4785. directories themselves are not in the archive; so the
  4786. @value{op-same-permissions} option does not affect them---while users
  4787. might really like it to. Specifying @value{op-no-recursion} is a way to
  4788. tell @command{tar} to grab only the directory entries given to it, adding
  4789. no new files on its own.
  4790. The @value{op-no-recursion} option also applies when extracting: it
  4791. causes @command{tar} to extract only the matched directory entries, not
  4792. the files under those directories.
  4793. The @value{op-no-recursion} option also affects how exclude patterns
  4794. are interpreted (@pxref{controlling pattern-patching with exclude}).
  4795. The @option{--no-recursion} and @option{--recursion} options apply to
  4796. later options and operands, and can be overridden by later occurrences
  4797. of @option{--no-recursion} and @option{--recursion}. For example:
  4798. @smallexample
  4799. $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
  4800. @end smallexample
  4801. @noindent
  4802. creates an archive with one entry for @file{grape}, and the recursive
  4803. contents of @file{grape/concord}, but no entries under @file{grape}
  4804. other than @file{grape/concord}.
  4805. @node one
  4806. @section Crossing Filesystem Boundaries
  4807. @cindex File system boundaries, not crossing
  4808. @UNREVISED
  4809. @command{tar} will normally automatically cross file system boundaries in
  4810. order to archive files which are part of a directory tree. You can
  4811. change this behavior by running @command{tar} and specifying
  4812. @value{op-one-file-system}. This option only affects files that are
  4813. archived because they are in a directory that is being archived;
  4814. @command{tar} will still archive files explicitly named on the command line
  4815. or through @value{op-files-from}, regardless of where they reside.
  4816. @table @kbd
  4817. @item --one-file-system
  4818. @itemx -l
  4819. Prevents @command{tar} from crossing file system boundaries when
  4820. archiving. Use in conjunction with any write operation.
  4821. @end table
  4822. The @samp{--one-file-system} option causes @command{tar} to modify its
  4823. normal behavior in archiving the contents of directories. If a file in
  4824. a directory is not on the same filesystem as the directory itself, then
  4825. @command{tar} will not archive that file. If the file is a directory
  4826. itself, @command{tar} will not archive anything beneath it; in other words,
  4827. @command{tar} will not cross mount points.
  4828. It is reported that using this option, the mount point is is archived,
  4829. but nothing under it.
  4830. This option is useful for making full or incremental archival backups of
  4831. a file system. If this option is used in conjunction with
  4832. @value{op-verbose}, files that are excluded are mentioned by name on the
  4833. standard error.
  4834. @menu
  4835. * directory:: Changing Directory
  4836. * absolute:: Absolute File Names
  4837. @end menu
  4838. @node directory
  4839. @subsection Changing the Working Directory
  4840. @FIXME{need to read over this node now for continuity; i've switched
  4841. things around some.}
  4842. @cindex Changing directory mid-stream
  4843. @cindex Directory, changing mid-stream
  4844. @cindex Working directory, specifying
  4845. @UNREVISED
  4846. To change the working directory in the middle of a list of file names,
  4847. either on the command line or in a file specified using
  4848. @value{op-files-from}, use @value{op-directory}. This will change the
  4849. working directory to the directory @var{directory} after that point in
  4850. the list.
  4851. @table @kbd
  4852. @item --directory=@var{directory}
  4853. @itemx -C @var{directory}
  4854. Changes the working directory in the middle of a command line.
  4855. @end table
  4856. For example,
  4857. @smallexample
  4858. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  4859. @end smallexample
  4860. @noindent
  4861. will place the files @file{grape} and @file{prune} from the current
  4862. directory into the archive @file{jams.tar}, followed by the file
  4863. @file{cherry} from the directory @file{food}. This option is especially
  4864. useful when you have several widely separated files that you want to
  4865. store in the same archive.
  4866. Note that the file @file{cherry} is recorded in the archive under the
  4867. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  4868. archive will contain three files that all appear to have come from the
  4869. same directory; if the archive is extracted with plain @samp{tar
  4870. --extract}, all three files will be written in the current directory.
  4871. Contrast this with the command,
  4872. @smallexample
  4873. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  4874. @end smallexample
  4875. @noindent
  4876. which records the third file in the archive under the name
  4877. @file{red/cherry} so that, if the archive is extracted using
  4878. @samp{tar --extract}, the third file will be written in a subdirectory
  4879. named @file{orange-colored}.
  4880. You can use the @samp{--directory} option to make the archive
  4881. independent of the original name of the directory holding the files.
  4882. The following command places the files @file{/etc/passwd},
  4883. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  4884. @file{foo.tar}:
  4885. @smallexample
  4886. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  4887. @end smallexample
  4888. @noindent
  4889. However, the names of the archive members will be exactly what they were
  4890. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  4891. They will not appear to be related by file name to the original
  4892. directories where those files were located.
  4893. Note that @samp{--directory} options are interpreted consecutively. If
  4894. @samp{--directory} specifies a relative file name, it is interpreted
  4895. relative to the then current directory, which might not be the same as
  4896. the original current working directory of @command{tar}, due to a previous
  4897. @samp{--directory} option.
  4898. @FIXME{dan: does this mean that you *can* use the short option form, but
  4899. you can *not* use the long option form with --files-from? or is this
  4900. totally screwed?}
  4901. When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
  4902. options in the file list. Unfortunately, you cannot put
  4903. @samp{--directory} options in the file list. (This interpretation can
  4904. be disabled by using the @value{op-null} option.)
  4905. @node absolute
  4906. @subsection Absolute File Names
  4907. @UNREVISED
  4908. @table @kbd
  4909. @item -P
  4910. @itemx --absolute-names
  4911. Do not strip leading slashes from file names, and permit file names
  4912. containing a @file{..} file name component.
  4913. @end table
  4914. By default, @GNUTAR{} drops a leading @samp{/} on
  4915. input or output, and complains about file names containing a @file{..}
  4916. component. This option turns off this behavior.
  4917. When @command{tar} extracts archive members from an archive, it strips any
  4918. leading slashes (@samp{/}) from the member name. This causes absolute
  4919. member names in the archive to be treated as relative file names. This
  4920. allows you to have such members extracted wherever you want, instead of
  4921. being restricted to extracting the member in the exact directory named
  4922. in the archive. For example, if the archive member has the name
  4923. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  4924. really @file{etc/passwd}.
  4925. File names containing @file{..} can cause problems when extracting, so
  4926. @command{tar} normally warns you about such files when creating an
  4927. archive, and rejects attempts to extracts such files.
  4928. Other @command{tar} programs do not do this. As a result, if you
  4929. create an archive whose member names start with a slash, they will be
  4930. difficult for other people with a non-@GNUTAR{}
  4931. program to use. Therefore, @GNUTAR{} also strips
  4932. leading slashes from member names when putting members into the
  4933. archive. For example, if you ask @command{tar} to add the file
  4934. @file{/bin/ls} to an archive, it will do so, but the member name will
  4935. be @file{bin/ls}.
  4936. If you use the @value{op-absolute-names} option, @command{tar} will do
  4937. none of these transformations.
  4938. To archive or extract files relative to the root directory, specify
  4939. the @value{op-absolute-names} option.
  4940. Normally, @command{tar} acts on files relative to the working
  4941. directory---ignoring superior directory names when archiving, and
  4942. ignoring leading slashes when extracting.
  4943. When you specify @value{op-absolute-names}, @command{tar} stores file names
  4944. including all superior directory names, and preserves leading slashes.
  4945. If you only invoked @command{tar} from the root directory you would never
  4946. need the @value{op-absolute-names} option, but using this option may be
  4947. more convenient than switching to root.
  4948. @FIXME{Should be an example in the tutorial/wizardry section using this
  4949. to transfer files between systems.}
  4950. @FIXME{Is write access an issue?}
  4951. @table @kbd
  4952. @item --absolute-names
  4953. Preserves full file names (including superior directory names) when
  4954. archiving files. Preserves leading slash when extracting files.
  4955. @end table
  4956. @FIXME{this is still horrible; need to talk with dan on monday.}
  4957. @command{tar} prints out a message about removing the @samp{/} from
  4958. file names. This message appears once per @GNUTAR{}
  4959. invocation. It represents something which ought to be told; ignoring
  4960. what it means can cause very serious surprises, later.
  4961. Some people, nevertheless, do not want to see this message. Wanting to
  4962. play really dangerously, one may of course redirect @command{tar} standard
  4963. error to the sink. For example, under @command{sh}:
  4964. @smallexample
  4965. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  4966. @end smallexample
  4967. @noindent
  4968. Another solution, both nicer and simpler, would be to change to
  4969. the @file{/} directory first, and then avoid absolute notation.
  4970. For example:
  4971. @smallexample
  4972. $ @kbd{(cd / && tar -c -f archive.tar home)}
  4973. $ @kbd{tar -c -f archive.tar -C / home}
  4974. @end smallexample
  4975. @include getdate.texi
  4976. @node Formats
  4977. @chapter Controlling the Archive Format
  4978. Due to historical reasons, there are several formats of tar archives.
  4979. All of them are based on the same principles, but have some subtle
  4980. differences that often make them incompatible with each other.
  4981. GNU tar is able to create and handle archives in a variety of formats.
  4982. The most frequently used formats are (in alphabetical order):
  4983. @table @asis
  4984. @item gnu
  4985. Format used by @GNUTAR{}.
  4986. @item v7
  4987. Archive format, compatible with the V7 implementation of tar.
  4988. @item oldgnu
  4989. Format used by @GNUTAR{} of versions prior to 1.12.
  4990. @item posix
  4991. Archive format defined by POSIX.1-2001 specification.
  4992. @item star
  4993. Format used by J@"org Schilling @command{star} implementation.
  4994. @end table
  4995. @GNUTAR{} is able to create archives in any of these formats,
  4996. except @samp{star}. It is able to read archives in any of these
  4997. formats.
  4998. The default format for @GNUTAR{} is defined at compilation
  4999. time. You may check it by running @command{tar --help}, and examining
  5000. the last lines of its output. Usually, @GNUTAR{} is configured
  5001. to create archives in @samp{gnu} format, however, future version will
  5002. switch to @samp{posix}.
  5003. @menu
  5004. * Portability:: Making @command{tar} Archives More Portable
  5005. * Compression:: Using Less Space through Compression
  5006. * Attributes:: Handling File Attributes
  5007. * Standard:: The Standard Format
  5008. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5009. * cpio:: Comparison of @command{tar} and @command{cpio}
  5010. @end menu
  5011. @node Portability
  5012. @section Making @command{tar} Archives More Portable
  5013. Creating a @command{tar} archive on a particular system that is meant to be
  5014. useful later on many other machines and with other versions of @command{tar}
  5015. is more challenging than you might think. @command{tar} archive formats
  5016. have been evolving since the first versions of Unix. Many such formats
  5017. are around, and are not always compatible with each other. This section
  5018. discusses a few problems, and gives some advice about making @command{tar}
  5019. archives more portable.
  5020. One golden rule is simplicity. For example, limit your @command{tar}
  5021. archives to contain only regular files and directories, avoiding
  5022. other kind of special files. Do not attempt to save sparse files or
  5023. contiguous files as such. Let's discuss a few more problems, in turn.
  5024. @menu
  5025. * Portable Names:: Portable Names
  5026. * dereference:: Symbolic Links
  5027. * old:: Old V7 Archives
  5028. * gnu:: GNU and old GNU format archives.
  5029. * posix:: @sc{posix} archives
  5030. * Checksumming:: Checksumming Problems
  5031. * Large or Negative Values:: Large files, negative time stamps, etc.
  5032. @end menu
  5033. @node Portable Names
  5034. @subsection Portable Names
  5035. Use portable file and member names. A name is portable if it contains
  5036. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5037. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5038. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5039. old Unix hosts, limit your file name components to 14 characters or
  5040. less.
  5041. If you intend to have your @command{tar} archives to be read under
  5042. MSDOS, you should not rely on case distinction for file names, and you
  5043. might use the @acronym{GNU} @command{doschk} program for helping you
  5044. further diagnosing illegal MSDOS names, which are even more limited
  5045. than System V's.
  5046. @node dereference
  5047. @subsection Symbolic Links
  5048. @cindex File names, using symbolic links
  5049. @cindex Symbolic link as file name
  5050. Normally, when @command{tar} archives a symbolic link, it writes a
  5051. block to the archive naming the target of the link. In that way, the
  5052. @command{tar} archive is a faithful record of the filesystem contents.
  5053. @value{op-dereference} is used with @value{op-create}, and causes
  5054. @command{tar} to archive the files symbolic links point to, instead of
  5055. the links themselves. When this option is used, when @command{tar}
  5056. encounters a symbolic link, it will archive the linked-to file,
  5057. instead of simply recording the presence of a symbolic link.
  5058. The name under which the file is stored in the file system is not
  5059. recorded in the archive. To record both the symbolic link name and
  5060. the file name in the system, archive the file under both names. If
  5061. all links were recorded automatically by @command{tar}, an extracted file
  5062. might be linked to a file name that no longer exists in the file
  5063. system.
  5064. If a linked-to file is encountered again by @command{tar} while creating
  5065. the same archive, an entire second copy of it will be stored. (This
  5066. @emph{might} be considered a bug.)
  5067. So, for portable archives, do not archive symbolic links as such,
  5068. and use @value{op-dereference}: many systems do not support
  5069. symbolic links, and moreover, your distribution might be unusable if
  5070. it contains unresolved symbolic links.
  5071. @node old
  5072. @subsection Old V7 Archives
  5073. @cindex Format, old style
  5074. @cindex Old style format
  5075. @cindex Old style archives
  5076. Certain old versions of @command{tar} cannot handle additional
  5077. information recorded by newer @command{tar} programs. To create an
  5078. archive in V7 format (not ANSI), which can be read by these old
  5079. versions, specify the @value{op-format-v7} option in
  5080. conjunction with the @value{op-create} (@command{tar} also
  5081. accepts @samp{--portability} or @samp{op-old-archive} for this
  5082. option). When you specify it,
  5083. @command{tar} leaves out information about directories, pipes, fifos,
  5084. contiguous files, and device files, and specifies file ownership by
  5085. group and user IDs instead of group and user names.
  5086. When updating an archive, do not use @value{op-format-v7}
  5087. unless the archive was created with using this option.
  5088. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5089. @command{tar} program without serious trouble, so this option should
  5090. seldom be needed. On the other hand, most modern @command{tar}s are
  5091. able to read old format archives, so it might be safer for you to
  5092. always use @value{op-format-v7} for your distributions.
  5093. @node gnu
  5094. @subsection @acronym{GNU} and old @GNUTAR{} format
  5095. @GNUTAR{} was based on an early draft of the
  5096. @sc{posix} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5097. @command{tar}, such as the support for file names longer than 100
  5098. characters, use portions of the @command{tar} header record which were
  5099. specified in that @sc{posix} draft as unused. Subsequent changes in
  5100. @sc{posix} have allocated the same parts of the header record for
  5101. other purposes. As a result, @GNUTAR{} format is
  5102. incompatible with the current @sc{posix} specification, and with
  5103. @command{tar} programs that follow it.
  5104. In the majority of cases, @command{tar} will be configured to create
  5105. this format by default. This may change in the future, since we plan
  5106. to make @samp{posix} format the default.
  5107. To force creation a @GNUTAR{} archive, use option
  5108. @value{op-format-gnu}.
  5109. Some @command{tar} options are currently basing on @GNUTAR{}
  5110. format, and can therefore be used only with @samp{gnu}
  5111. or @samp{oldgnu} archive formats. The list of such options follows:
  5112. @itemize @bullet
  5113. @item @value{op-label}, when used with @value{op-create}.
  5114. @item @value{op-incremental}
  5115. @item @value{op-multi-volume}
  5116. @item @value{op-sparse}
  5117. @end itemize
  5118. These options will be re-implemented for the @samp{posix} archive
  5119. format in the future.
  5120. @node posix
  5121. @subsection @GNUTAR{} and @sc{posix} @command{tar}
  5122. The version @value{VERSION} of @GNUTAR{} is able
  5123. to read and create archives conforming to @sc{posix.1-2001} standard.
  5124. A @sc{posix} conformant archive will be created if @command{tar}
  5125. was given @value{op-format-posix} option.
  5126. Notice, that currently @acronym{GNU} extensions are not
  5127. allowed with this format. Following is the list of options that
  5128. cannot be used with @value{op-format-posix}:
  5129. @itemize @bullet
  5130. @item @value{op-label}, when used with @value{op-create}.
  5131. @item @value{op-incremental}
  5132. @item @value{op-multi-volume}
  5133. @item @value{op-sparse}
  5134. @end itemize
  5135. This restriction will disappear in the future versions.
  5136. @node Checksumming
  5137. @subsection Checksumming Problems
  5138. SunOS and HP-UX @command{tar} fail to accept archives created using
  5139. @GNUTAR{} and containing non-ASCII file names, that
  5140. is, file names having characters with the eight bit set, because they
  5141. use signed checksums, while @GNUTAR{} uses unsigned
  5142. checksums while creating archives, as per @sc{posix} standards. On
  5143. reading, @GNUTAR{} computes both checksums and
  5144. accept any. It is somewhat worrying that a lot of people may go
  5145. around doing backup of their files using faulty (or at least
  5146. non-standard) software, not learning about it until it's time to
  5147. restore their missing files with an incompatible file extractor, or
  5148. vice versa.
  5149. @GNUTAR{} compute checksums both ways, and accept
  5150. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5151. wrong checksums. @GNUTAR{} produces the standard
  5152. checksum, however, raising incompatibilities with Sun. That is to
  5153. say, @GNUTAR{} has not been modified to
  5154. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5155. I've been told that more recent Sun @command{tar} now read standard
  5156. archives, so maybe Sun did a similar patch, after all?
  5157. The story seems to be that when Sun first imported @command{tar}
  5158. sources on their system, they recompiled it without realizing that
  5159. the checksums were computed differently, because of a change in
  5160. the default signing of @code{char}'s in their compiler. So they
  5161. started computing checksums wrongly. When they later realized their
  5162. mistake, they merely decided to stay compatible with it, and with
  5163. themselves afterwards. Presumably, but I do not really know, HP-UX
  5164. has chosen that their @command{tar} archives to be compatible with Sun's.
  5165. The current standards do not favor Sun @command{tar} format. In any
  5166. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5167. a @command{tar} able to read the good archives they receive.
  5168. @node Large or Negative Values
  5169. @subsection Large or Negative Values
  5170. @cindex large values
  5171. @cindex future time stamps
  5172. @cindex negative time stamps
  5173. @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
  5174. to represent numeric values. User and group IDs and device major and
  5175. minor numbers have unsigned 21-bit representations, and file sizes and
  5176. times have unsigned 33-bit representations. @GNUTAR{}
  5177. generates @sc{posix} representations when possible, but for values
  5178. outside the @sc{posix} range it generates two's-complement base-256
  5179. strings: uids, gids, and device numbers have signed 57-bit
  5180. representations, and file sizes and times have signed 89-bit
  5181. representations. These representations are an extension to @sc{posix}
  5182. @command{tar} format, so they are not universally portable.
  5183. The most common portability problems with out-of-range numeric values
  5184. are large files and future or negative time stamps.
  5185. Portable archives should avoid members of 8 GB or larger, as @sc{posix}
  5186. @command{tar} format cannot represent them.
  5187. Portable archives should avoid time stamps from the future. @sc{posix}
  5188. @command{tar} format can represent time stamps in the range 1970-01-01
  5189. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5190. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5191. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5192. portable archives must avoid these time stamps for many years to come.
  5193. Portable archives should also avoid time stamps before 1970. These time
  5194. stamps are a common @sc{posix} extension but their @code{time_t}
  5195. representations are negative. Many traditional @command{tar}
  5196. implementations generate a two's complement representation for negative
  5197. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5198. generate archives that are not portable to hosts with differing
  5199. @code{time_t} representations. @GNUTAR{} recognizes this
  5200. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5201. it issues a warning, as these time stamps are nonstandard and unportable.
  5202. @node Compression
  5203. @section Using Less Space through Compression
  5204. @menu
  5205. * gzip:: Creating and Reading Compressed Archives
  5206. * sparse:: Archiving Sparse Files
  5207. @end menu
  5208. @node gzip
  5209. @subsection Creating and Reading Compressed Archives
  5210. @cindex Compressed archives
  5211. @cindex Storing archives in compressed format
  5212. @UNREVISED
  5213. @table @kbd
  5214. @item -z
  5215. @itemx --gzip
  5216. @itemx --ungzip
  5217. Filter the archive through @command{gzip}.
  5218. @end table
  5219. @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
  5220. format parameters must be taken into consideration when modifying an
  5221. archive.@FIXME{???} Compressed archives cannot be modified.
  5222. You can use @samp{--gzip} and @samp{--gunzip} on physical devices
  5223. (tape drives, etc.) and remote files as well as on normal files; data
  5224. to or from such devices or remote files is reblocked by another copy
  5225. of the @command{tar} program to enforce the specified (or default) record
  5226. size. The default compression parameters are used; if you need to
  5227. override them, avoid the @value{op-gzip} option and run @command{gzip}
  5228. explicitly. (Or set the @env{GZIP} environment variable.)
  5229. The @value{op-gzip} option does not work with the @value{op-multi-volume}
  5230. option, or with the @value{op-update}, @value{op-append},
  5231. @value{op-concatenate}, or @value{op-delete} operations.
  5232. It is not exact to say that @GNUTAR{} is to work in concert
  5233. with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
  5234. possible that @command{tar} and @command{gzip} be done with a single call,
  5235. like in:
  5236. @smallexample
  5237. $ @kbd{tar cfz archive.tar.gz subdir}
  5238. @end smallexample
  5239. @noindent
  5240. to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
  5241. can do:
  5242. @smallexample
  5243. $ @kbd{tar xfz archive.tar.gz}
  5244. @end smallexample
  5245. @noindent
  5246. to explode and unpack.
  5247. The difference is that the whole archive is compressed. With
  5248. @command{zip}, archive members are archived individually. @command{tar}'s
  5249. method yields better compression. On the other hand, one can view the
  5250. contents of a @command{zip} archive without having to decompress it. As
  5251. for the @command{tar} and @command{gzip} tandem, you need to decompress the
  5252. archive to see its contents. However, this may be done without needing
  5253. disk space, by using pipes internally:
  5254. @smallexample
  5255. $ @kbd{tar tfz archive.tar.gz}
  5256. @end smallexample
  5257. @cindex corrupted archives
  5258. About corrupted compressed archives: @command{gzip}'ed files have no
  5259. redundancy, for maximum compression. The adaptive nature of the
  5260. compression scheme means that the compression tables are implicitly
  5261. spread all over the archive. If you lose a few blocks, the dynamic
  5262. construction of the compression tables becomes unsynchronized, and there
  5263. is little chance that you could recover later in the archive.
  5264. There are pending suggestions for having a per-volume or per-file
  5265. compression in @GNUTAR{}. This would allow for viewing the
  5266. contents without decompression, and for resynchronizing decompression at
  5267. every volume or file, in case of corrupted archives. Doing so, we might
  5268. lose some compressibility. But this would have make recovering easier.
  5269. So, there are pros and cons. We'll see!
  5270. @table @kbd
  5271. @item -j
  5272. @itemx --bzip2
  5273. Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
  5274. @item -Z
  5275. @itemx --compress
  5276. @itemx --uncompress
  5277. Filter the archive through @command{compress}. Otherwise like
  5278. @value{op-gzip}.
  5279. @item --use-compress-program=@var{prog}
  5280. Filter through @var{prog} (must accept @samp{-d}).
  5281. @end table
  5282. @value{op-compress} stores an archive in compressed format. This
  5283. option is useful in saving time over networks and space in pipes, and
  5284. when storage space is at a premium. @value{op-compress} causes
  5285. @command{tar} to compress when writing the archive, or to uncompress when
  5286. reading the archive.
  5287. To perform compression and uncompression on the archive, @command{tar}
  5288. runs the @command{compress} utility. @command{tar} uses the default
  5289. compression parameters; if you need to override them, avoid the
  5290. @value{op-compress} option and run the @command{compress} utility
  5291. explicitly. It is useful to be able to call the @command{compress}
  5292. utility from within @command{tar} because the @command{compress} utility by
  5293. itself cannot access remote tape drives.
  5294. The @value{op-compress} option will not work in conjunction with the
  5295. @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
  5296. and @value{op-delete} operations. @xref{Operations}, for
  5297. more information on these operations.
  5298. If there is no compress utility available, @command{tar} will report an error.
  5299. @strong{Please note} that the @command{compress} program may be covered by
  5300. a patent, and therefore we recommend you stop using it.
  5301. @value{op-bzip2} acts like @value{op-compress}, except that it uses
  5302. the @code{bzip2} utility.
  5303. @table @kbd
  5304. @item --compress
  5305. @itemx --uncompress
  5306. @itemx -z
  5307. @itemx -Z
  5308. When this option is specified, @command{tar} will compress (when
  5309. writing an archive), or uncompress (when reading an archive). Used in
  5310. conjunction with the @value{op-create}, @value{op-extract},
  5311. @value{op-list} and @value{op-compare} operations.
  5312. @end table
  5313. You can have archives be compressed by using the @value{op-gzip} option.
  5314. This will arrange for @command{tar} to use the @command{gzip} program to be
  5315. used to compress or uncompress the archive wren writing or reading it.
  5316. To use the older, obsolete, @command{compress} program, use the
  5317. @value{op-compress} option. The @acronym{GNU} Project recommends you not use
  5318. @command{compress}, because there is a patent covering the algorithm it
  5319. uses. You could be sued for patent infringement merely by running
  5320. @command{compress}.
  5321. I have one question, or maybe it's a suggestion if there isn't a way
  5322. to do it now. I would like to use @value{op-gzip}, but I'd also like
  5323. the output to be fed through a program like @acronym{GNU}
  5324. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5325. to use :-)), basically adding ECC protection on top of compression.
  5326. It seems as if this should be quite easy to do, but I can't work out
  5327. exactly how to go about it. Of course, I can pipe the standard output
  5328. of @command{tar} through @command{ecc}, but then I lose (though I
  5329. haven't started using it yet, I confess) the ability to have
  5330. @command{tar} use @command{rmt} for it's I/O (I think).
  5331. I think the most straightforward thing would be to let me specify a
  5332. general set of filters outboard of compression (preferably ordered,
  5333. so the order can be automatically reversed on input operations, and
  5334. with the options they require specifiable), but beggars shouldn't be
  5335. choosers and anything you decide on would be fine with me.
  5336. By the way, I like @command{ecc} but if (as the comments say) it can't
  5337. deal with loss of block sync, I'm tempted to throw some time at adding
  5338. that capability. Supposing I were to actually do such a thing and
  5339. get it (apparently) working, do you accept contributed changes to
  5340. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5341. Isn't that exactly the role of the @value{op-use-compress-prog} option?
  5342. I never tried it myself, but I suspect you may want to write a
  5343. @var{prog} script or program able to filter stdin to stdout to
  5344. way you want. It should recognize the @samp{-d} option, for when
  5345. extraction is needed rather than creation.
  5346. It has been reported that if one writes compressed data (through the
  5347. @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
  5348. the DLT compression mode, the data will actually get bigger and one will
  5349. end up with less space on the tape.
  5350. @node sparse
  5351. @subsection Archiving Sparse Files
  5352. @cindex Sparse Files
  5353. @UNREVISED
  5354. @table @kbd
  5355. @item -S
  5356. @itemx --sparse
  5357. Handle sparse files efficiently.
  5358. @end table
  5359. This option causes all files to be put in the archive to be tested for
  5360. sparseness, and handled specially if they are. The @value{op-sparse}
  5361. option is useful when many @code{dbm} files, for example, are being
  5362. backed up. Using this option dramatically decreases the amount of
  5363. space needed to store such a file.
  5364. In later versions, this option may be removed, and the testing and
  5365. treatment of sparse files may be done automatically with any special
  5366. @acronym{GNU} options. For now, it is an option needing to be specified on
  5367. the command line with the creation or updating of an archive.
  5368. Files in the filesystem occasionally have ``holes.'' A hole in a file
  5369. is a section of the file's contents which was never written. The
  5370. contents of a hole read as all zeros. On many operating systems,
  5371. actual disk storage is not allocated for holes, but they are counted
  5372. in the length of the file. If you archive such a file, @command{tar}
  5373. could create an archive longer than the original. To have @command{tar}
  5374. attempt to recognize the holes in a file, use @value{op-sparse}. When
  5375. you use the @value{op-sparse} option, then, for any file using less
  5376. disk space than would be expected from its length, @command{tar} searches
  5377. the file for consecutive stretches of zeros. It then records in the
  5378. archive for the file where the consecutive stretches of zeros are, and
  5379. only archives the ``real contents'' of the file. On extraction (using
  5380. @value{op-sparse} is not needed on extraction) any such files have
  5381. holes created wherever the continuous stretches of zeros were found.
  5382. Thus, if you use @value{op-sparse}, @command{tar} archives won't take
  5383. more space than the original.
  5384. A file is sparse if it contains blocks of zeros whose existence is
  5385. recorded, but that have no space allocated on disk. When you specify
  5386. the @value{op-sparse} option in conjunction with the @value{op-create}
  5387. operation, @command{tar} tests all files for sparseness while archiving.
  5388. If @command{tar} finds a file to be sparse, it uses a sparse representation of
  5389. the file in the archive. @value{xref-create}, for more information
  5390. about creating archives.
  5391. @value{op-sparse} is useful when archiving files, such as dbm files,
  5392. likely to contain many nulls. This option dramatically
  5393. decreases the amount of space needed to store such an archive.
  5394. @quotation
  5395. @strong{Please Note:} Always use @value{op-sparse} when performing file
  5396. system backups, to avoid archiving the expanded forms of files stored
  5397. sparsely in the system.
  5398. Even if your system has no sparse files currently, some may be
  5399. created in the future. If you use @value{op-sparse} while making file
  5400. system backups as a matter of course, you can be assured the archive
  5401. will never take more space on the media than the files take on disk
  5402. (otherwise, archiving a disk filled with sparse files might take
  5403. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5404. @end quotation
  5405. @command{tar} ignores the @value{op-sparse} option when reading an archive.
  5406. @table @kbd
  5407. @item --sparse
  5408. @itemx -S
  5409. Files stored sparsely in the file system are represented sparsely in
  5410. the archive. Use in conjunction with write operations.
  5411. @end table
  5412. However, users should be well aware that at archive creation time,
  5413. @GNUTAR{} still has to read whole disk file to
  5414. locate the @dfn{holes}, and so, even if sparse files use little space
  5415. on disk and in the archive, they may sometimes require inordinate
  5416. amount of time for reading and examining all-zero blocks of a file.
  5417. Although it works, it's painfully slow for a large (sparse) file, even
  5418. though the resulting tar archive may be small. (One user reports that
  5419. dumping a @file{core} file of over 400 megabytes, but with only about
  5420. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5421. ELC, with full CPU utilization.)
  5422. This reading is required in all cases and is not related to the fact
  5423. the @value{op-sparse} option is used or not, so by merely @emph{not}
  5424. using the option, you are not saving time@footnote{Well! We should say
  5425. the whole truth, here. When @value{op-sparse} is selected while creating
  5426. an archive, the current @command{tar} algorithm requires sparse files to be
  5427. read twice, not once. We hope to develop a new archive format for saving
  5428. sparse files in which one pass will be sufficient.}.
  5429. Programs like @command{dump} do not have to read the entire file; by
  5430. examining the file system directly, they can determine in advance
  5431. exactly where the holes are and thus avoid reading through them. The
  5432. only data it need read are the actual allocated data blocks.
  5433. @GNUTAR{} uses a more portable and straightforward
  5434. archiving approach, it would be fairly difficult that it does
  5435. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5436. 1990-12-10:
  5437. @quotation
  5438. What I did say is that you cannot tell the difference between a hole and an
  5439. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5440. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5441. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5442. to name one that does?), they may also care where the holes are (I have
  5443. no examples of this one either, but it's equally imaginable).
  5444. I conclude from this that good archivers are not portable. One can
  5445. arguably conclude that if you want a portable program, you can in good
  5446. conscience restore files with as many holes as possible, since you can't
  5447. get it right.
  5448. @end quotation
  5449. @node Attributes
  5450. @section Handling File Attributes
  5451. @UNREVISED
  5452. When @command{tar} reads files, this causes them to have the access
  5453. times updated. To have @command{tar} attempt to set the access times
  5454. back to what they were before they were read, use the
  5455. @value{op-atime-preserve} option.
  5456. Handling of file attributes
  5457. @table @kbd
  5458. @item --atime-preserve
  5459. Preserve access times on files that are read.
  5460. This doesn't work for files that
  5461. you don't own, unless you're root, and it doesn't interact with
  5462. incremental dumps nicely (@pxref{Backups}), and it can set access or
  5463. modification times incorrectly if other programs access the file while
  5464. @command{tar} is running; but it is good enough for some purposes.
  5465. @item -m
  5466. @itemx --touch
  5467. Do not extract file modified time.
  5468. When this option is used, @command{tar} leaves the modification times
  5469. of the files it extracts as the time when the files were extracted,
  5470. instead of setting it to the time recorded in the archive.
  5471. This option is meaningless with @value{op-list}.
  5472. @item --same-owner
  5473. Create extracted files with the same ownership they have in the
  5474. archive.
  5475. This is the default behavior for the superuser,
  5476. so this option is meaningful only for non-root users, when @command{tar}
  5477. is executed on those systems able to give files away. This is
  5478. considered as a security flaw by many people, at least because it
  5479. makes quite difficult to correctly account users for the disk space
  5480. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5481. files are easily and silently lost when files are given away.
  5482. When writing an archive, @command{tar} writes the user id and user name
  5483. separately. If it can't find a user name (because the user id is not
  5484. in @file{/etc/passwd}), then it does not write one. When restoring,
  5485. and doing a @code{chmod} like when you use @value{op-same-permissions},
  5486. @FIXME{same-owner?}it tries to look the name (if one was written)
  5487. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5488. stored in the archive instead.
  5489. @item --no-same-owner
  5490. @itemx -o
  5491. Do not attempt to restore ownership when extracting. This is the
  5492. default behavior for ordinary users, so this option has an effect
  5493. only for the superuser.
  5494. @item --numeric-owner
  5495. The @value{op-numeric-owner} option allows (ANSI) archives to be written
  5496. without user/group name information or such information to be ignored
  5497. when extracting. It effectively disables the generation and/or use
  5498. of user/group name information. This option forces extraction using
  5499. the numeric ids from the archive, ignoring the names.
  5500. This is useful in certain circumstances, when restoring a backup from
  5501. an emergency floppy with different passwd/group files for example.
  5502. It is otherwise impossible to extract files with the right ownerships
  5503. if the password file in use during the extraction does not match the
  5504. one belonging to the filesystem(s) being extracted. This occurs,
  5505. for example, if you are restoring your files after a major crash and
  5506. had booted from an emergency floppy with no password file or put your
  5507. disk into another machine to do the restore.
  5508. The numeric ids are @emph{always} saved into @command{tar} archives.
  5509. The identifying names are added at create time when provided by the
  5510. system, unless @value{op-old-archive} is used. Numeric ids could be
  5511. used when moving archives between a collection of machines using
  5512. a centralized management for attribution of numeric ids to users
  5513. and groups. This is often made through using the NIS capabilities.
  5514. When making a @command{tar} file for distribution to other sites, it
  5515. is sometimes cleaner to use a single owner for all files in the
  5516. distribution, and nicer to specify the write permission bits of the
  5517. files as stored in the archive independently of their actual value on
  5518. the file system. The way to prepare a clean distribution is usually
  5519. to have some Makefile rule creating a directory, copying all needed
  5520. files in that directory, then setting ownership and permissions as
  5521. wanted (there are a lot of possible schemes), and only then making a
  5522. @command{tar} archive out of this directory, before cleaning
  5523. everything out. Of course, we could add a lot of options to
  5524. @GNUTAR{} for fine tuning permissions and ownership.
  5525. This is not the good way, I think. @GNUTAR{} is
  5526. already crowded with options and moreover, the approach just explained
  5527. gives you a great deal of control already.
  5528. @item -p
  5529. @itemx --same-permissions
  5530. @itemx --preserve-permissions
  5531. Extract all protection information.
  5532. This option causes @command{tar} to set the modes (access permissions) of
  5533. extracted files exactly as recorded in the archive. If this option
  5534. is not used, the current @code{umask} setting limits the permissions
  5535. on extracted files.
  5536. This option is meaningless with @value{op-list}.
  5537. @item --preserve
  5538. Same as both @value{op-same-permissions} and @value{op-same-order}.
  5539. The @value{op-preserve} option has no equivalent short option name.
  5540. It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
  5541. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  5542. @end table
  5543. @node Standard
  5544. @section The Standard Format
  5545. @UNREVISED
  5546. While an archive may contain many files, the archive itself is a
  5547. single ordinary file. Like any other file, an archive file can be
  5548. written to a storage device such as a tape or disk, sent through a
  5549. pipe or over a network, saved on the active file system, or even
  5550. stored in another archive. An archive file is not easy to read or
  5551. manipulate without using the @command{tar} utility or Tar mode in
  5552. @acronym{GNU} Emacs.
  5553. Physically, an archive consists of a series of file entries terminated
  5554. by an end-of-archive entry, which consists of 512 zero bytes. A file
  5555. entry usually describes one of the files in the archive (an
  5556. @dfn{archive member}), and consists of a file header and the contents
  5557. of the file. File headers contain file names and statistics, checksum
  5558. information which @command{tar} uses to detect file corruption, and
  5559. information about file types.
  5560. Archives are permitted to have more than one member with the same
  5561. member name. One way this situation can occur is if more than one
  5562. version of a file has been stored in the archive. For information
  5563. about adding new versions of a file to an archive, see @ref{update}.
  5564. @FIXME-xref{To learn more about having more than one archive member with the
  5565. same name, see -backup node, when it's written.}
  5566. In addition to entries describing archive members, an archive may
  5567. contain entries which @command{tar} itself uses to store information.
  5568. @value{xref-label}, for an example of such an archive entry.
  5569. A @command{tar} archive file contains a series of blocks. Each block
  5570. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  5571. of as being on magnetic tape, other media are often used.
  5572. Each file archived is represented by a header block which describes
  5573. the file, followed by zero or more blocks which give the contents
  5574. of the file. At the end of the archive file there may be a block
  5575. filled with binary zeros as an end-of-file marker. A reasonable system
  5576. should write a block of zeros at the end, but must not assume that
  5577. such a block exists when reading an archive.
  5578. The blocks may be @dfn{blocked} for physical I/O operations.
  5579. Each record of @var{n} blocks (where @var{n} is set by the
  5580. @value{op-blocking-factor} option to @command{tar}) is written with a single
  5581. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  5582. such a write is a single record. When writing an archive,
  5583. the last record of blocks should be written at the full size, with
  5584. blocks after the zero block containing all zeros. When reading
  5585. an archive, a reasonable system should properly handle an archive
  5586. whose last record is shorter than the rest, or which contains garbage
  5587. records after a zero block.
  5588. The header block is defined in C as follows. In the @GNUTAR{}
  5589. distribution, this is part of file @file{src/tar.h}:
  5590. @smallexample
  5591. @include header.texi
  5592. @end smallexample
  5593. All characters in header blocks are represented by using 8-bit
  5594. characters in the local variant of ASCII. Each field within the
  5595. structure is contiguous; that is, there is no padding used within
  5596. the structure. Each character on the archive medium is stored
  5597. contiguously.
  5598. Bytes representing the contents of files (after the header block
  5599. of each file) are not translated in any way and are not constrained
  5600. to represent characters in any character set. The @command{tar} format
  5601. does not distinguish text files from binary files, and no translation
  5602. of file contents is performed.
  5603. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  5604. @code{gname} are null-terminated character strings. All other fields
  5605. are zero-filled octal numbers in ASCII. Each numeric field of width
  5606. @var{w} contains @var{w} minus 2 digits, a space, and a null, except
  5607. @code{size}, and @code{mtime}, which do not contain the trailing null.
  5608. The @code{name} field is the file name of the file, with directory names
  5609. (if any) preceding the file name, separated by slashes.
  5610. @FIXME{how big a name before field overflows?}
  5611. The @code{mode} field provides nine bits specifying file permissions
  5612. and three bits to specify the Set UID, Set GID, and Save Text
  5613. (@dfn{sticky}) modes. Values for these bits are defined above.
  5614. When special permissions are required to create a file with a given
  5615. mode, and the user restoring files from the archive does not hold such
  5616. permissions, the mode bit(s) specifying those special permissions
  5617. are ignored. Modes which are not supported by the operating system
  5618. restoring files from the archive will be ignored. Unsupported modes
  5619. should be faked up when creating or updating an archive; e.g.@: the
  5620. group permission could be copied from the @emph{other} permission.
  5621. The @code{uid} and @code{gid} fields are the numeric user and group
  5622. ID of the file owners, respectively. If the operating system does
  5623. not support numeric user or group IDs, these fields should be ignored.
  5624. The @code{size} field is the size of the file in bytes; linked files
  5625. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  5626. particular the @value{op-incremental} option.}
  5627. The @code{mtime} field is the modification time of the file at the time
  5628. it was archived. It is the ASCII representation of the octal value of
  5629. the last time the file was modified, represented as an integer number of
  5630. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  5631. The @code{chksum} field is the ASCII representation of the octal value
  5632. of the simple sum of all bytes in the header block. Each 8-bit
  5633. byte in the header is added to an unsigned integer, initialized to
  5634. zero, the precision of which shall be no less than seventeen bits.
  5635. When calculating the checksum, the @code{chksum} field is treated as
  5636. if it were all blanks.
  5637. The @code{typeflag} field specifies the type of file archived. If a
  5638. particular implementation does not recognize or permit the specified
  5639. type, the file will be extracted as if it were a regular file. As this
  5640. action occurs, @command{tar} issues a warning to the standard error.
  5641. The @code{atime} and @code{ctime} fields are used in making incremental
  5642. backups; they store, respectively, the particular file's access time
  5643. and last inode-change time.
  5644. The @code{offset} is used by the @value{op-multi-volume} option, when
  5645. making a multi-volume archive. The offset is number of bytes into
  5646. the file that we need to restart at to continue the file on the next
  5647. tape, i.e., where we store the location that a continued file is
  5648. continued at.
  5649. The following fields were added to deal with sparse files. A file
  5650. is @dfn{sparse} if it takes in unallocated blocks which end up being
  5651. represented as zeros, i.e., no useful data. A test to see if a file
  5652. is sparse is to look at the number blocks allocated for it versus the
  5653. number of characters in the file; if there are fewer blocks allocated
  5654. for the file than would normally be allocated for a file of that
  5655. size, then the file is sparse. This is the method @command{tar} uses to
  5656. detect a sparse file, and once such a file is detected, it is treated
  5657. differently from non-sparse files.
  5658. Sparse files are often @code{dbm} files, or other database-type files
  5659. which have data at some points and emptiness in the greater part of
  5660. the file. Such files can appear to be very large when an @samp{ls
  5661. -l} is done on them, when in truth, there may be a very small amount
  5662. of important data contained in the file. It is thus undesirable
  5663. to have @command{tar} think that it must back up this entire file, as
  5664. great quantities of room are wasted on empty blocks, which can lead
  5665. to running out of room on a tape far earlier than is necessary.
  5666. Thus, sparse files are dealt with so that these empty blocks are
  5667. not written to the tape. Instead, what is written to the tape is a
  5668. description, of sorts, of the sparse file: where the holes are, how
  5669. big the holes are, and how much data is found at the end of the hole.
  5670. This way, the file takes up potentially far less room on the tape,
  5671. and when the file is extracted later on, it will look exactly the way
  5672. it looked beforehand. The following is a description of the fields
  5673. used to handle a sparse file:
  5674. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  5675. sparse} contains two 12-character strings which represent an offset
  5676. into the file and a number of bytes to be written at that offset.
  5677. The offset is absolute, and not relative to the offset in preceding
  5678. array element.
  5679. The header can hold four of these @code{struct sparse} at the moment;
  5680. if more are needed, they are not stored in the header.
  5681. The @code{isextended} flag is set when an @code{extended_header}
  5682. is needed to deal with a file. Note that this means that this flag
  5683. can only be set when dealing with a sparse file, and it is only set
  5684. in the event that the description of the file will not fit in the
  5685. allotted room for sparse structures in the header. In other words,
  5686. an extended_header is needed.
  5687. The @code{extended_header} structure is used for sparse files which
  5688. need more sparse structures than can fit in the header. The header can
  5689. fit 4 such structures; if more are needed, the flag @code{isextended}
  5690. gets set and the next block is an @code{extended_header}.
  5691. Each @code{extended_header} structure contains an array of 21
  5692. sparse structures, along with a similar @code{isextended} flag
  5693. that the header had. There can be an indeterminate number of such
  5694. @code{extended_header}s to describe a sparse file.
  5695. @table @asis
  5696. @item @code{REGTYPE}
  5697. @itemx @code{AREGTYPE}
  5698. These flags represent a regular file. In order to be compatible
  5699. with older versions of @command{tar}, a @code{typeflag} value of
  5700. @code{AREGTYPE} should be silently recognized as a regular file.
  5701. New archives should be created using @code{REGTYPE}. Also, for
  5702. backward compatibility, @command{tar} treats a regular file whose name
  5703. ends with a slash as a directory.
  5704. @item @code{LNKTYPE}
  5705. This flag represents a file linked to another file, of any type,
  5706. previously archived. Such files are identified in Unix by each
  5707. file having the same device and inode number. The linked-to name is
  5708. specified in the @code{linkname} field with a trailing null.
  5709. @item @code{SYMTYPE}
  5710. This represents a symbolic link to another file. The linked-to name
  5711. is specified in the @code{linkname} field with a trailing null.
  5712. @item @code{CHRTYPE}
  5713. @itemx @code{BLKTYPE}
  5714. These represent character special files and block special files
  5715. respectively. In this case the @code{devmajor} and @code{devminor}
  5716. fields will contain the major and minor device numbers respectively.
  5717. Operating systems may map the device specifications to their own
  5718. local specification, or may ignore the entry.
  5719. @item @code{DIRTYPE}
  5720. This flag specifies a directory or sub-directory. The directory
  5721. name in the @code{name} field should end with a slash. On systems where
  5722. disk allocation is performed on a directory basis, the @code{size} field
  5723. will contain the maximum number of bytes (which may be rounded to
  5724. the nearest disk block allocation unit) which the directory may
  5725. hold. A @code{size} field of zero indicates no such limiting. Systems
  5726. which do not support limiting in this manner should ignore the
  5727. @code{size} field.
  5728. @item @code{FIFOTYPE}
  5729. This specifies a FIFO special file. Note that the archiving of a
  5730. FIFO file archives the existence of this file and not its contents.
  5731. @item @code{CONTTYPE}
  5732. This specifies a contiguous file, which is the same as a normal
  5733. file except that, in operating systems which support it, all its
  5734. space is allocated contiguously on the disk. Operating systems
  5735. which do not allow contiguous allocation should silently treat this
  5736. type as a normal file.
  5737. @item @code{A} @dots{} @code{Z}
  5738. These are reserved for custom implementations. Some of these are
  5739. used in the @acronym{GNU} modified format, as described below.
  5740. @end table
  5741. Other values are reserved for specification in future revisions of
  5742. the P1003 standard, and should not be used by any @command{tar} program.
  5743. The @code{magic} field indicates that this archive was output in
  5744. the P1003 archive format. If this field contains @code{TMAGIC},
  5745. the @code{uname} and @code{gname} fields will contain the ASCII
  5746. representation of the owner and group of the file respectively.
  5747. If found, the user and group IDs are used rather than the values in
  5748. the @code{uid} and @code{gid} fields.
  5749. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  5750. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  5751. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  5752. (section E.4.48) for @cite{pax - Portable archive interchange}.
  5753. @node Extensions
  5754. @section @acronym{GNU} Extensions to the Archive Format
  5755. @UNREVISED
  5756. The @acronym{GNU} format uses additional file types to describe new types of
  5757. files in an archive. These are listed below.
  5758. @table @code
  5759. @item GNUTYPE_DUMPDIR
  5760. @itemx 'D'
  5761. This represents a directory and a list of files created by the
  5762. @value{op-incremental} option. The @code{size} field gives the total
  5763. size of the associated list of files. Each file name is preceded by
  5764. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  5765. (The file is a directory, or is not stored in the archive.) Each file
  5766. name is terminated by a null. There is an additional null after the
  5767. last file name.
  5768. @item GNUTYPE_MULTIVOL
  5769. @itemx 'M'
  5770. This represents a file continued from another volume of a multi-volume
  5771. archive created with the @value{op-multi-volume} option. The original
  5772. type of the file is not given here. The @code{size} field gives the
  5773. maximum size of this piece of the file (assuming the volume does
  5774. not end before the file is written out). The @code{offset} field
  5775. gives the offset from the beginning of the file where this part of
  5776. the file begins. Thus @code{size} plus @code{offset} should equal
  5777. the original size of the file.
  5778. @item GNUTYPE_SPARSE
  5779. @itemx 'S'
  5780. This flag indicates that we are dealing with a sparse file. Note
  5781. that archiving a sparse file requires special operations to find
  5782. holes in the file, which mark the positions of these holes, along
  5783. with the number of bytes of data to be found after the hole.
  5784. @item GNUTYPE_VOLHDR
  5785. @itemx 'V'
  5786. This file type is used to mark the volume header that was given with
  5787. the @value{op-label} option when the archive was created. The @code{name}
  5788. field contains the @code{name} given after the @value{op-label} option.
  5789. The @code{size} field is zero. Only the first file in each volume
  5790. of an archive should have this type.
  5791. @end table
  5792. You may have trouble reading a @acronym{GNU} format archive on a
  5793. non-@acronym{GNU} system if the options @value{op-incremental},
  5794. @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
  5795. used when writing the archive. In general, if @command{tar} does not
  5796. use the @acronym{GNU}-added fields of the header, other versions of
  5797. @command{tar} should be able to read the archive. Otherwise, the
  5798. @command{tar} program will give an error, the most likely one being a
  5799. checksum error.
  5800. @node cpio
  5801. @section Comparison of @command{tar} and @command{cpio}
  5802. @UNREVISED
  5803. @FIXME{Reorganize the following material}
  5804. The @command{cpio} archive formats, like @command{tar}, do have maximum
  5805. pathname lengths. The binary and old ASCII formats have a max path
  5806. length of 256, and the new ASCII and CRC ASCII formats have a max
  5807. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  5808. with arbitrary pathname lengths, but other @command{cpio} implementations
  5809. may crash unexplainedly trying to read them.
  5810. @command{tar} handles symbolic links in the form in which it comes in BSD;
  5811. @command{cpio} doesn't handle symbolic links in the form in which it comes
  5812. in System V prior to SVR4, and some vendors may have added symlinks
  5813. to their system without enhancing @command{cpio} to know about them.
  5814. Others may have enhanced it in a way other than the way I did it
  5815. at Sun, and which was adopted by AT&T (and which is, I think, also
  5816. present in the @command{cpio} that Berkeley picked up from AT&T and put
  5817. into a later BSD release---I think I gave them my changes).
  5818. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  5819. can handle @command{tar} format input, and write it on output, and it
  5820. probably handles symbolic links. They may not have bothered doing
  5821. anything to enhance @command{tar} as a result.)
  5822. @command{cpio} handles special files; traditional @command{tar} doesn't.
  5823. @command{tar} comes with V7, System III, System V, and BSD source;
  5824. @command{cpio} comes only with System III, System V, and later BSD
  5825. (4.3-tahoe and later).
  5826. @command{tar}'s way of handling multiple hard links to a file can handle
  5827. file systems that support 32-bit inumbers (e.g., the BSD file system);
  5828. @command{cpio}s way requires you to play some games (in its "binary"
  5829. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  5830. they're 18 bits---it would have to play games with the "file system ID"
  5831. field of the header to make sure that the file system ID/i-number pairs
  5832. of different files were always different), and I don't know which
  5833. @command{cpio}s, if any, play those games. Those that don't might get
  5834. confused and think two files are the same file when they're not, and
  5835. make hard links between them.
  5836. @command{tar}s way of handling multiple hard links to a file places only
  5837. one copy of the link on the tape, but the name attached to that copy
  5838. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  5839. way puts one copy for every link, but you can retrieve it using any
  5840. of the names.
  5841. @quotation
  5842. What type of check sum (if any) is used, and how is this calculated.
  5843. @end quotation
  5844. See the attached manual pages for @command{tar} and @command{cpio} format.
  5845. @command{tar} uses a checksum which is the sum of all the bytes in the
  5846. @command{tar} header for a file; @command{cpio} uses no checksum.
  5847. @quotation
  5848. If anyone knows why @command{cpio} was made when @command{tar} was present
  5849. at the unix scene,
  5850. @end quotation
  5851. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  5852. generally-available version of UNIX had @command{tar} at the time. I don't
  5853. know whether any version that was generally available @emph{within AT&T}
  5854. had @command{tar}, or, if so, whether the people within AT&T who did
  5855. @command{cpio} knew about it.
  5856. On restore, if there is a corruption on a tape @command{tar} will stop at
  5857. that point, while @command{cpio} will skip over it and try to restore the
  5858. rest of the files.
  5859. The main difference is just in the command syntax and header format.
  5860. @command{tar} is a little more tape-oriented in that everything is blocked
  5861. to start on a record boundary.
  5862. @quotation
  5863. Is there any differences between the ability to recover crashed
  5864. archives between the two of them. (Is there any chance of recovering
  5865. crashed archives at all.)
  5866. @end quotation
  5867. Theoretically it should be easier under @command{tar} since the blocking
  5868. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  5869. However, modern @command{cpio}'s and variations have an option to just
  5870. search for the next file header after an error with a reasonable chance
  5871. of resyncing. However, lots of tape driver software won't allow you to
  5872. continue past a media error which should be the only reason for getting
  5873. out of sync unless a file changed sizes while you were writing the
  5874. archive.
  5875. @quotation
  5876. If anyone knows why @command{cpio} was made when @command{tar} was present
  5877. at the unix scene, please tell me about this too.
  5878. @end quotation
  5879. Probably because it is more media efficient (by not blocking everything
  5880. and using only the space needed for the headers where @command{tar}
  5881. always uses 512 bytes per file header) and it knows how to archive
  5882. special files.
  5883. You might want to look at the freely available alternatives. The
  5884. major ones are @command{afio}, @GNUTAR{}, and
  5885. @command{pax}, each of which have their own extensions with some
  5886. backwards compatibility.
  5887. Sparse files were @command{tar}red as sparse files (which you can
  5888. easily test, because the resulting archive gets smaller, and
  5889. @acronym{GNU} @command{cpio} can no longer read it).
  5890. @node Media
  5891. @chapter Tapes and Other Archive Media
  5892. @UNREVISED
  5893. A few special cases about tape handling warrant more detailed
  5894. description. These special cases are discussed below.
  5895. Many complexities surround the use of @command{tar} on tape drives. Since
  5896. the creation and manipulation of archives located on magnetic tape was
  5897. the original purpose of @command{tar}, it contains many features making
  5898. such manipulation easier.
  5899. Archives are usually written on dismountable media---tape cartridges,
  5900. mag tapes, or floppy disks.
  5901. The amount of data a tape or disk holds depends not only on its size,
  5902. but also on how it is formatted. A 2400 foot long reel of mag tape
  5903. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  5904. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  5905. Magnetic media are re-usable---once the archive on a tape is no longer
  5906. needed, the archive can be erased and the tape or disk used over.
  5907. Media quality does deteriorate with use, however. Most tapes or disks
  5908. should be discarded when they begin to produce data errors. EXABYTE
  5909. tape cartridges should be discarded when they generate an @dfn{error
  5910. count} (number of non-usable bits) of more than 10k.
  5911. Magnetic media are written and erased using magnetic fields, and
  5912. should be protected from such fields to avoid damage to stored data.
  5913. Sticking a floppy disk to a filing cabinet using a magnet is probably
  5914. not a good idea.
  5915. @menu
  5916. * Device:: Device selection and switching
  5917. * Remote Tape Server::
  5918. * Common Problems and Solutions::
  5919. * Blocking:: Blocking
  5920. * Many:: Many archives on one tape
  5921. * Using Multiple Tapes:: Using Multiple Tapes
  5922. * label:: Including a Label in the Archive
  5923. * verify::
  5924. * Write Protection::
  5925. @end menu
  5926. @node Device
  5927. @section Device Selection and Switching
  5928. @UNREVISED
  5929. @table @kbd
  5930. @item -f [@var{hostname}:]@var{file}
  5931. @itemx --file=[@var{hostname}:]@var{file}
  5932. Use archive file or device @var{file} on @var{hostname}.
  5933. @end table
  5934. This option is used to specify the file name of the archive @command{tar}
  5935. works on.
  5936. If the file name is @samp{-}, @command{tar} reads the archive from standard
  5937. input (when listing or extracting), or writes it to standard output
  5938. (when creating). If the @samp{-} file name is given when updating an
  5939. archive, @command{tar} will read the original archive from its standard
  5940. input, and will write the entire new archive to its standard output.
  5941. If the file name contains a @samp{:}, it is interpreted as
  5942. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  5943. sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
  5944. either case, @command{tar} will invoke the command @command{rsh} (or
  5945. @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
  5946. you give an alternate login name, it will be given to the @command{rsh}.
  5947. Naturally, the remote machine must have an executable @file{/etc/rmt}.
  5948. This program is free software from the University of California, and a
  5949. copy of the source code can be found with the sources for @command{tar};
  5950. it's compiled and installed by default.
  5951. If this option is not given, but the environment variable @env{TAPE}
  5952. is set, its value is used; otherwise, old versions of @command{tar}
  5953. used a default archive name (which was picked when @command{tar} was
  5954. compiled). The default is normally set up to be the @dfn{first} tape
  5955. drive or other transportable I/O medium on the system.
  5956. Starting with version 1.11.5, @GNUTAR{} uses
  5957. standard input and standard output as the default device, and I will
  5958. not try anymore supporting automatic device detection at installation
  5959. time. This was failing really in too many cases, it was hopeless.
  5960. This is now completely left to the installer to override standard
  5961. input and standard output for default device, if this seems
  5962. preferable. Further, I think @emph{most} actual usages of
  5963. @command{tar} are done with pipes or disks, not really tapes,
  5964. cartridges or diskettes.
  5965. Some users think that using standard input and output is running
  5966. after trouble. This could lead to a nasty surprise on your screen if
  5967. you forget to specify an output file name---especially if you are going
  5968. through a network or terminal server capable of buffering large amounts
  5969. of output. We had so many bug reports in that area of configuring
  5970. default tapes automatically, and so many contradicting requests, that
  5971. we finally consider the problem to be portably intractable. We could
  5972. of course use something like @samp{/dev/tape} as a default, but this
  5973. is @emph{also} running after various kind of trouble, going from hung
  5974. processes to accidental destruction of real tapes. After having seen
  5975. all this mess, using standard input and output as a default really
  5976. sounds like the only clean choice left, and a very useful one too.
  5977. @GNUTAR{} reads and writes archive in records, I
  5978. suspect this is the main reason why block devices are preferred over
  5979. character devices. Most probably, block devices are more efficient
  5980. too. The installer could also check for @samp{DEFTAPE} in
  5981. @file{<sys/mtio.h>}.
  5982. @table @kbd
  5983. @item --force-local
  5984. Archive file is local even if it contains a colon.
  5985. @item --rsh-command=@var{command}
  5986. Use remote @var{command} instead of @command{rsh}. This option exists
  5987. so that people who use something other than the standard @command{rsh}
  5988. (e.g., a Kerberized @command{rsh}) can access a remote device.
  5989. When this command is not used, the shell command found when
  5990. the @command{tar} program was installed is used instead. This is
  5991. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  5992. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  5993. The installer may have overridden this by defining the environment
  5994. variable @env{RSH} @emph{at installation time}.
  5995. @item -[0-7][lmh]
  5996. Specify drive and density.
  5997. @item -M
  5998. @itemx --multi-volume
  5999. Create/list/extract multi-volume archive.
  6000. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6001. that may be larger than will fit on the medium used to hold it.
  6002. @xref{Multi-Volume Archives}.
  6003. @item -L @var{num}
  6004. @itemx --tape-length=@var{num}
  6005. Change tape after writing @var{num} x 1024 bytes.
  6006. This option might be useful when your tape drivers do not properly
  6007. detect end of physical tapes. By being slightly conservative on the
  6008. maximum tape length, you might avoid the problem entirely.
  6009. @item -F @var{file}
  6010. @itemx --info-script=@var{file}
  6011. @itemx --new-volume-script=@var{file}
  6012. Execute @file{file} at end of each tape. If @file{file} exits with
  6013. nonzero status, exit. This implies @value{op-multi-volume}.
  6014. @end table
  6015. @node Remote Tape Server
  6016. @section The Remote Tape Server
  6017. @cindex remote tape drive
  6018. @pindex rmt
  6019. In order to access the tape drive on a remote machine, @command{tar}
  6020. uses the remote tape server written at the University of California at
  6021. Berkeley. The remote tape server must be installed as @file{/etc/rmt}
  6022. on any machine whose tape drive you want to use. @command{tar} calls
  6023. @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
  6024. machine, optionally using a different login name if one is supplied.
  6025. A copy of the source for the remote tape server is provided. It is
  6026. Copyright @copyright{} 1983 by the Regents of the University of
  6027. California, but can be freely distributed. Instructions for compiling
  6028. and installing it are included in the @file{Makefile}.
  6029. @cindex absolute file names
  6030. Unless you use the @value{op-absolute-names} option, @GNUTAR{}
  6031. will not allow you to create an archive that contains
  6032. absolute file names (a file name beginning with @samp{/}.) If you try,
  6033. @command{tar} will automatically remove the leading @samp{/} from the
  6034. file names it stores in the archive. It will also type a warning
  6035. message telling you what it is doing.
  6036. When reading an archive that was created with a different
  6037. @command{tar} program, @GNUTAR{} automatically
  6038. extracts entries in the archive which have absolute file names as if
  6039. the file names were not absolute. This is an important feature. A
  6040. visitor here once gave a @command{tar} tape to an operator to restore;
  6041. the operator used Sun @command{tar} instead of @GNUTAR{},
  6042. and the result was that it replaced large portions of
  6043. our @file{/bin} and friends with versions from the tape; needless to
  6044. say, we were unhappy about having to recover the file system from
  6045. backup tapes.
  6046. For example, if the archive contained a file @file{/usr/bin/computoy},
  6047. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6048. relative to the current directory. If you want to extract the files in
  6049. an archive to the same absolute names that they had when the archive
  6050. was created, you should do a @samp{cd /} before extracting the files
  6051. from the archive, or you should either use the @value{op-absolute-names}
  6052. option, or use the command @samp{tar -C / @dots{}}.
  6053. @cindex Ultrix 3.1 and write failure
  6054. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6055. can claim that a short write near the end of a tape succeeded,
  6056. when it actually failed. This will result in the -M option not
  6057. working correctly. The best workaround at the moment is to use a
  6058. significantly larger blocking factor than the default 20.
  6059. In order to update an archive, @command{tar} must be able to backspace the
  6060. archive in order to reread or rewrite a record that was just read (or
  6061. written). This is currently possible only on two kinds of files: normal
  6062. disk files (or any other file that can be backspaced with @samp{lseek}),
  6063. and industry-standard 9-track magnetic tape (or any other kind of tape
  6064. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6065. This means that the @value{op-append}, @value{op-update},
  6066. @value{op-concatenate}, and @value{op-delete} commands will not work on any
  6067. other kind of file. Some media simply cannot be backspaced, which
  6068. means these commands and options will never be able to work on them.
  6069. These non-backspacing media include pipes and cartridge tape drives.
  6070. Some other media can be backspaced, and @command{tar} will work on them
  6071. once @command{tar} is modified to do so.
  6072. Archives created with the @value{op-multi-volume}, @value{op-label}, and
  6073. @value{op-incremental} options may not be readable by other version
  6074. of @command{tar}. In particular, restoring a file that was split over
  6075. a volume boundary will require some careful work with @command{dd}, if
  6076. it can be done at all. Other versions of @command{tar} may also create
  6077. an empty file whose name is that of the volume header. Some versions
  6078. of @command{tar} may create normal files instead of directories archived
  6079. with the @value{op-incremental} option.
  6080. @node Common Problems and Solutions
  6081. @section Some Common Problems and their Solutions
  6082. @ifclear PUBLISH
  6083. @format
  6084. errors from system:
  6085. permission denied
  6086. no such file or directory
  6087. not owner
  6088. errors from @command{tar}:
  6089. directory checksum error
  6090. header format error
  6091. errors from media/system:
  6092. i/o error
  6093. device busy
  6094. @end format
  6095. @end ifclear
  6096. @node Blocking
  6097. @section Blocking
  6098. @UNREVISED
  6099. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6100. is also confusing to the expert reader. On the other hand, readers
  6101. who are new to the field have a fresh mind, and they may safely skip
  6102. the next two paragraphs, as the remainder of this manual uses those
  6103. two terms in a quite consistent way.
  6104. John Gilmore, the writer of the public domain @command{tar} from which
  6105. @GNUTAR{} was originally derived, wrote (June 1995):
  6106. @quotation
  6107. The nomenclature of tape drives comes from IBM, where I believe
  6108. they were invented for the IBM 650 or so. On IBM mainframes, what
  6109. is recorded on tape are tape blocks. The logical organization of
  6110. data is into records. There are various ways of putting records into
  6111. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6112. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6113. to a block), @code{VB} (variable size records, @var{n} to a block),
  6114. @code{VSB} (variable spanned blocked: variable sized records that can
  6115. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6116. parameter specified this to the operating system.
  6117. The Unix man page on @command{tar} was totally confused about this.
  6118. When I wrote @code{PD TAR}, I used the historically correct terminology
  6119. (@command{tar} writes data records, which are grouped into blocks).
  6120. It appears that the bogus terminology made it into @sc{posix} (no surprise
  6121. here), and now Fran@,{c}ois has migrated that terminology back
  6122. into the source code too.
  6123. @end quotation
  6124. The term @dfn{physical block} means the basic transfer chunk from or
  6125. to a device, after which reading or writing may stop without anything
  6126. being lost. In this manual, the term @dfn{block} usually refers to
  6127. a disk physical block, @emph{assuming} that each disk block is 512
  6128. bytes in length. It is true that some disk devices have different
  6129. physical blocks, but @command{tar} ignore these differences in its own
  6130. format, which is meant to be portable, so a @command{tar} block is always
  6131. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6132. The term @dfn{logical block} often represents the basic chunk of
  6133. allocation of many disk blocks as a single entity, which the operating
  6134. system treats somewhat atomically; this concept is only barely used
  6135. in @GNUTAR{}.
  6136. The term @dfn{physical record} is another way to speak of a physical
  6137. block, those two terms are somewhat interchangeable. In this manual,
  6138. the term @dfn{record} usually refers to a tape physical block,
  6139. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6140. It is true that archives may be put on disk or used with pipes,
  6141. but nevertheless, @command{tar} tries to read and write the archive one
  6142. @dfn{record} at a time, whatever the medium in use. One record is made
  6143. up of an integral number of blocks, and this operation of putting many
  6144. disk blocks into a single tape block is called @dfn{reblocking}, or
  6145. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6146. the logical organization of many characters into something meaningful
  6147. to the application. The term @dfn{unit record} describes a small set
  6148. of characters which are transmitted whole to or by the application,
  6149. and often refers to a line of text. Those two last terms are unrelated
  6150. to what we call a @dfn{record} in @GNUTAR{}.
  6151. When writing to tapes, @command{tar} writes the contents of the archive
  6152. in chunks known as @dfn{records}. To change the default blocking
  6153. factor, use the @value{op-blocking-factor} option. Each record will
  6154. then be composed of @var{512-size} blocks. (Each @command{tar} block is
  6155. 512 bytes. @xref{Standard}.) Each file written to the archive uses
  6156. at least one full record. As a result, using a larger record size
  6157. can result in more wasted space for small files. On the other hand, a
  6158. larger record size can often be read and written much more efficiently.
  6159. Further complicating the problem is that some tape drives ignore the
  6160. blocking entirely. For these, a larger record size can still improve
  6161. performance (because the software layers above the tape drive still
  6162. honor the blocking), but not as dramatically as on tape drives that
  6163. honor blocking.
  6164. When reading an archive, @command{tar} can usually figure out the
  6165. record size on itself. When this is the case, and a non-standard
  6166. record size was used when the archive was created, @command{tar} will
  6167. print a message about a non-standard blocking factor, and then operate
  6168. normally. On some tape devices, however, @command{tar} cannot figure
  6169. out the record size itself. On most of those, you can specify a
  6170. blocking factor (with @value{op-blocking-factor}) larger than the
  6171. actual blocking factor, and then use the @value{op-read-full-records}
  6172. option. (If you specify a blocking factor with
  6173. @value{op-blocking-factor} and don't use the
  6174. @value{op-read-full-records} option, then @command{tar} will not
  6175. attempt to figure out the recording size itself.) On some devices,
  6176. you must always specify the record size exactly with
  6177. @value{op-blocking-factor} when reading, because @command{tar} cannot
  6178. figure it out. In any case, use @value{op-list} before doing any
  6179. extractions to see whether @command{tar} is reading the archive
  6180. correctly.
  6181. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6182. putting them into records is to put a whole number of them (one or
  6183. more) into each record. @command{tar} records are all the same size;
  6184. at the end of the file there's a block containing all zeros, which
  6185. is how you tell that the remainder of the last record(s) are garbage.
  6186. In a standard @command{tar} file (no options), the block size is 512
  6187. and the record size is 10240, for a blocking factor of 20. What the
  6188. @value{op-blocking-factor} option does is sets the blocking factor,
  6189. changing the record size while leaving the block size at 512 bytes.
  6190. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6191. most tape drives these days prefer much bigger records in order to
  6192. stream and not waste tape. When writing tapes for myself, some tend
  6193. to use a factor of the order of 2048, say, giving a record size of
  6194. around one megabyte.
  6195. If you use a blocking factor larger than 20, older @command{tar}
  6196. programs might not be able to read the archive, so we recommend this
  6197. as a limit to use in practice. @GNUTAR{}, however,
  6198. will support arbitrarily large record sizes, limited only by the
  6199. amount of virtual memory or the physical characteristics of the tape
  6200. device.
  6201. @menu
  6202. * Format Variations:: Format Variations
  6203. * Blocking Factor:: The Blocking Factor of an Archive
  6204. @end menu
  6205. @node Format Variations
  6206. @subsection Format Variations
  6207. @cindex Format Parameters
  6208. @cindex Format Options
  6209. @cindex Options, archive format specifying
  6210. @cindex Options, format specifying
  6211. @UNREVISED
  6212. Format parameters specify how an archive is written on the archive
  6213. media. The best choice of format parameters will vary depending on
  6214. the type and number of files being archived, and on the media used to
  6215. store the archive.
  6216. To specify format parameters when accessing or creating an archive,
  6217. you can use the options described in the following sections.
  6218. If you do not specify any format parameters, @command{tar} uses
  6219. default parameters. You cannot modify a compressed archive.
  6220. If you create an archive with the @value{op-blocking-factor} option
  6221. specified (@value{pxref-blocking-factor}), you must specify that
  6222. blocking-factor when operating on the archive. @xref{Formats}, for other
  6223. examples of format parameter considerations.
  6224. @node Blocking Factor
  6225. @subsection The Blocking Factor of an Archive
  6226. @cindex Blocking Factor
  6227. @cindex Record Size
  6228. @cindex Number of blocks per record
  6229. @cindex Number of bytes per record
  6230. @cindex Bytes per record
  6231. @cindex Blocks per record
  6232. @UNREVISED
  6233. The data in an archive is grouped into blocks, which are 512 bytes.
  6234. Blocks are read and written in whole number multiples called
  6235. @dfn{records}. The number of blocks in a record (ie. the size of a
  6236. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6237. The @value{op-blocking-factor} option specifies the blocking factor of
  6238. an archive. The default blocking factor is typically 20 (ie.@:
  6239. 10240 bytes), but can be specified at installation. To find out
  6240. the blocking factor of an existing archive, use @samp{tar --list
  6241. --file=@var{archive-name}}. This may not work on some devices.
  6242. Records are separated by gaps, which waste space on the archive media.
  6243. If you are archiving on magnetic tape, using a larger blocking factor
  6244. (and therefore larger records) provides faster throughput and allows you
  6245. to fit more data on a tape (because there are fewer gaps). If you are
  6246. archiving on cartridge, a very large blocking factor (say 126 or more)
  6247. greatly increases performance. A smaller blocking factor, on the other
  6248. hand, may be useful when archiving small files, to avoid archiving lots
  6249. of nulls as @command{tar} fills out the archive to the end of the record.
  6250. In general, the ideal record size depends on the size of the
  6251. inter-record gaps on the tape you are using, and the average size of the
  6252. files you are archiving. @xref{create}, for information on
  6253. writing archives.
  6254. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6255. Archives with blocking factors larger than 20 cannot be read
  6256. by very old versions of @command{tar}, or by some newer versions
  6257. of @command{tar} running on old machines with small address spaces.
  6258. With @GNUTAR{}, the blocking factor of an archive is limited
  6259. only by the maximum record size of the device containing the archive,
  6260. or by the amount of available virtual memory.
  6261. Also, on some systems, not using adequate blocking factors, as sometimes
  6262. imposed by the device drivers, may yield unexpected diagnostics. For
  6263. example, this has been reported:
  6264. @smallexample
  6265. Cannot write to /dev/dlt: Invalid argument
  6266. @end smallexample
  6267. @noindent
  6268. In such cases, it sometimes happen that the @command{tar} bundled by
  6269. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6270. requires an explicit specification for the block size,
  6271. which it cannot guess. This yields some people to consider
  6272. @GNUTAR{} is misbehaving, because by comparison,
  6273. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6274. for example, might resolve the problem.
  6275. If you use a non-default blocking factor when you create an archive, you
  6276. must specify the same blocking factor when you modify that archive. Some
  6277. archive devices will also require you to specify the blocking factor when
  6278. reading that archive, however this is not typically the case. Usually, you
  6279. can use @value{op-list} without specifying a blocking factor---@command{tar}
  6280. reports a non-default record size and then lists the archive members as
  6281. it would normally. To extract files from an archive with a non-standard
  6282. blocking factor (particularly if you're not sure what the blocking factor
  6283. is), you can usually use the @value{op-read-full-records} option while
  6284. specifying a blocking factor larger then the blocking factor of the archive
  6285. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6286. @xref{list}, for more information on the @value{op-list}
  6287. operation. @xref{Reading}, for a more detailed explanation of that option.
  6288. @table @kbd
  6289. @item --blocking-factor=@var{number}
  6290. @itemx -b @var{number}
  6291. Specifies the blocking factor of an archive. Can be used with any
  6292. operation, but is usually not necessary with @value{op-list}.
  6293. @end table
  6294. Device blocking
  6295. @table @kbd
  6296. @item -b @var{blocks}
  6297. @itemx --blocking-factor=@var{blocks}
  6298. Set record size to @math{@var{blocks} * 512} bytes.
  6299. This option is used to specify a @dfn{blocking factor} for the archive.
  6300. When reading or writing the archive, @command{tar}, will do reads and writes
  6301. of the archive in records of @math{@var{block}*512} bytes. This is true
  6302. even when the archive is compressed. Some devices requires that all
  6303. write operations be a multiple of a certain size, and so, @command{tar}
  6304. pads the archive out to the next record boundary.
  6305. The default blocking factor is set when @command{tar} is compiled, and is
  6306. typically 20. Blocking factors larger than 20 cannot be read by very
  6307. old versions of @command{tar}, or by some newer versions of @command{tar}
  6308. running on old machines with small address spaces.
  6309. With a magnetic tape, larger records give faster throughput and fit
  6310. more data on a tape (because there are fewer inter-record gaps).
  6311. If the archive is in a disk file or a pipe, you may want to specify
  6312. a smaller blocking factor, since a large one will result in a large
  6313. number of null bytes at the end of the archive.
  6314. When writing cartridge or other streaming tapes, a much larger
  6315. blocking factor (say 126 or more) will greatly increase performance.
  6316. However, you must specify the same blocking factor when reading or
  6317. updating the archive.
  6318. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6319. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6320. seems to disappear. Id est, we are using block size of 112 right
  6321. now, and we haven't had the problem since we switched@dots{}
  6322. With @GNUTAR{} the blocking factor is limited only
  6323. by the maximum record size of the device containing the archive, or by
  6324. the amount of available virtual memory.
  6325. However, deblocking or reblocking is virtually avoided in a special
  6326. case which often occurs in practice, but which requires all the
  6327. following conditions to be simultaneously true:
  6328. @itemize @bullet
  6329. @item
  6330. the archive is subject to a compression option,
  6331. @item
  6332. the archive is not handled through standard input or output, nor
  6333. redirected nor piped,
  6334. @item
  6335. the archive is directly handled to a local disk, instead of any special
  6336. device,
  6337. @item
  6338. @value{op-blocking-factor} is not explicitly specified on the @command{tar}
  6339. invocation.
  6340. @end itemize
  6341. If the output goes directly to a local disk, and not through
  6342. stdout, then the last write is not extended to a full record size.
  6343. Otherwise, reblocking occurs. Here are a few other remarks on this
  6344. topic:
  6345. @itemize @bullet
  6346. @item
  6347. @command{gzip} will complain about trailing garbage if asked to
  6348. uncompress a compressed archive on tape, there is an option to turn
  6349. the message off, but it breaks the regularity of simply having to use
  6350. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6351. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6352. Gailly, by sending a copy of this message to him.
  6353. @item
  6354. @command{compress} does not show this problem, but as Jean-loup pointed
  6355. out to Michael, @samp{compress -d} silently adds garbage after
  6356. the result of decompression, which tar ignores because it already
  6357. recognized its end-of-file indicator. So this bug may be safely
  6358. ignored.
  6359. @item
  6360. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6361. but will still return an exit status of 2 which tar reports in turn.
  6362. @command{tar} might ignore the exit status returned, but I hate doing
  6363. that, as it weakens the protection @command{tar} offers users against
  6364. other possible problems at decompression time. If @command{gzip} was
  6365. silently skipping trailing zeros @emph{and} also avoiding setting the
  6366. exit status in this innocuous case, that would solve this situation.
  6367. @item
  6368. @command{tar} should become more solid at not stopping to read a pipe at
  6369. the first null block encountered. This inelegantly breaks the pipe.
  6370. @command{tar} should rather drain the pipe out before exiting itself.
  6371. @end itemize
  6372. @item -i
  6373. @itemx --ignore-zeros
  6374. Ignore blocks of zeros in archive (means EOF).
  6375. The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
  6376. of zeros in the archive. Normally a block of zeros indicates the
  6377. end of the archive, but when reading a damaged archive, or one which
  6378. was created by concatenating several archives together, this option
  6379. allows @command{tar} to read the entire archive. This option is not on
  6380. by default because many versions of @command{tar} write garbage after
  6381. the zeroed blocks.
  6382. Note that this option causes @command{tar} to read to the end of the
  6383. archive file, which may sometimes avoid problems when multiple files
  6384. are stored on a single physical tape.
  6385. @item -B
  6386. @itemx --read-full-records
  6387. Reblock as we read (for reading 4.2BSD pipes).
  6388. If @value{op-read-full-records} is used, @command{tar} will not panic if an
  6389. attempt to read a record from the archive does not return a full record.
  6390. Instead, @command{tar} will keep reading until it has obtained a full
  6391. record.
  6392. This option is turned on by default when @command{tar} is reading
  6393. an archive from standard input, or from a remote machine. This is
  6394. because on BSD Unix systems, a read of a pipe will return however
  6395. much happens to be in the pipe, even if it is less than @command{tar}
  6396. requested. If this option was not used, @command{tar} would fail as
  6397. soon as it read an incomplete record from the pipe.
  6398. This option is also useful with the commands for updating an archive.
  6399. @end table
  6400. Tape blocking
  6401. @FIXME{Appropriate options should be moved here from elsewhere.}
  6402. @cindex blocking factor
  6403. @cindex tape blocking
  6404. When handling various tapes or cartridges, you have to take care of
  6405. selecting a proper blocking, that is, the number of disk blocks you
  6406. put together as a single tape block on the tape, without intervening
  6407. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6408. with no information on it, used for decelerating the tape to a
  6409. full stop, and for later regaining the reading or writing speed.
  6410. When the tape driver starts reading a record, the record has to
  6411. be read whole without stopping, as a tape gap is needed to stop the
  6412. tape motion without loosing information.
  6413. @cindex Exabyte blocking
  6414. @cindex DAT blocking
  6415. Using higher blocking (putting more disk blocks per tape block) will use
  6416. the tape more efficiently as there will be less tape gaps. But reading
  6417. such tapes may be more difficult for the system, as more memory will be
  6418. required to receive at once the whole record. Further, if there is a
  6419. reading error on a huge record, this is less likely that the system will
  6420. succeed in recovering the information. So, blocking should not be too
  6421. low, nor it should be too high. @command{tar} uses by default a blocking of
  6422. 20 for historical reasons, and it does not really matter when reading or
  6423. writing to disk. Current tape technology would easily accommodate higher
  6424. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6425. We were told that for some DLT drives, the blocking should be a multiple
  6426. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6427. Other manufacturers may use different recommendations for the same tapes.
  6428. This might also depends of the buffering techniques used inside modern
  6429. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6430. Others request blocking to be some exponent of two.
  6431. So, there is no fixed rule for blocking. But blocking at read time
  6432. should ideally be the same as blocking used at write time. At one place
  6433. I know, with a wide variety of equipment, they found it best to use a
  6434. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6435. I was also told that, for recycled tapes, prior erasure (by the same
  6436. drive unit that will be used to create the archives) sometimes lowers
  6437. the error rates observed at rewriting time.
  6438. I might also use @samp{--number-blocks} instead of
  6439. @samp{--block-number}, so @samp{--block} will then expand to
  6440. @samp{--blocking-factor} unambiguously.
  6441. @node Many
  6442. @section Many Archives on One Tape
  6443. @FIXME{Appropriate options should be moved here from elsewhere.}
  6444. @findex ntape @r{device}
  6445. Most tape devices have two entries in the @file{/dev} directory, or
  6446. entries that come in pairs, which differ only in the minor number for
  6447. this device. Let's take for example @file{/dev/tape}, which often
  6448. points to the only or usual tape device of a given system. There might
  6449. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6450. name is the @emph{rewinding} version of the device, while the name
  6451. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6452. device.
  6453. A rewinding tape device will bring back the tape to its beginning point
  6454. automatically when this device is opened or closed. Since @command{tar}
  6455. opens the archive file before using it and closes it afterwards, this
  6456. means that a simple:
  6457. @smallexample
  6458. $ @kbd{tar cf /dev/tape @var{directory}}
  6459. @end smallexample
  6460. @noindent
  6461. will reposition the tape to its beginning both prior and after saving
  6462. @var{directory} contents to it, thus erasing prior tape contents and
  6463. making it so that any subsequent write operation will destroy what has
  6464. just been saved.
  6465. @cindex tape positioning
  6466. So, a rewinding device is normally meant to hold one and only one file.
  6467. If you want to put more than one @command{tar} archive on a given tape, you
  6468. will need to avoid using the rewinding version of the tape device. You
  6469. will also have to pay special attention to tape positioning. Errors in
  6470. positioning may overwrite the valuable data already on your tape. Many
  6471. people, burnt by past experiences, will only use rewinding devices and
  6472. limit themselves to one file per tape, precisely to avoid the risk of
  6473. such errors. Be fully aware that writing at the wrong position on a
  6474. tape loses all information past this point and most probably until the
  6475. end of the tape, and this destroyed information @emph{cannot} be
  6476. recovered.
  6477. To save @var{directory-1} as a first archive at the beginning of a
  6478. tape, and leave that tape ready for a second archive, you should use:
  6479. @smallexample
  6480. $ @kbd{mt -f /dev/nrtape rewind}
  6481. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6482. @end smallexample
  6483. @cindex tape marks
  6484. @dfn{Tape marks} are special magnetic patterns written on the tape
  6485. media, which are later recognizable by the reading hardware. These
  6486. marks are used after each file, when there are many on a single tape.
  6487. An empty file (that is to say, two tape marks in a row) signal the
  6488. logical end of the tape, after which no file exist. Usually,
  6489. non-rewinding tape device drivers will react to the close request issued
  6490. by @command{tar} by first writing two tape marks after your archive, and by
  6491. backspacing over one of these. So, if you remove the tape at that time
  6492. from the tape drive, it is properly terminated. But if you write
  6493. another file at the current position, the second tape mark will be
  6494. erased by the new information, leaving only one tape mark between files.
  6495. So, you may now save @var{directory-2} as a second archive after the
  6496. first on the same tape by issuing the command:
  6497. @smallexample
  6498. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  6499. @end smallexample
  6500. @noindent
  6501. and so on for all the archives you want to put on the same tape.
  6502. Another usual case is that you do not write all the archives the same
  6503. day, and you need to remove and store the tape between two archive
  6504. sessions. In general, you must remember how many files are already
  6505. saved on your tape. Suppose your tape already has 16 files on it, and
  6506. that you are ready to write the 17th. You have to take care of skipping
  6507. the first 16 tape marks before saving @var{directory-17}, say, by using
  6508. these commands:
  6509. @smallexample
  6510. $ @kbd{mt -f /dev/nrtape rewind}
  6511. $ @kbd{mt -f /dev/nrtape fsf 16}
  6512. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  6513. @end smallexample
  6514. In all the previous examples, we put aside blocking considerations, but
  6515. you should do the proper things for that as well. @xref{Blocking}.
  6516. @menu
  6517. * Tape Positioning:: Tape Positions and Tape Marks
  6518. * mt:: The @command{mt} Utility
  6519. @end menu
  6520. @node Tape Positioning
  6521. @subsection Tape Positions and Tape Marks
  6522. @UNREVISED
  6523. Just as archives can store more than one file from the file system,
  6524. tapes can store more than one archive file. To keep track of where
  6525. archive files (or any other type of file stored on tape) begin and
  6526. end, tape archive devices write magnetic @dfn{tape marks} on the
  6527. archive media. Tape drives write one tape mark between files,
  6528. two at the end of all the file entries.
  6529. If you think of data as a series of records "rrrr"'s, and tape marks as
  6530. "*"'s, a tape might look like the following:
  6531. @smallexample
  6532. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  6533. @end smallexample
  6534. Tape devices read and write tapes using a read/write @dfn{tape
  6535. head}---a physical part of the device which can only access one
  6536. point on the tape at a time. When you use @command{tar} to read or
  6537. write archive data from a tape device, the device will begin reading
  6538. or writing from wherever on the tape the tape head happens to be,
  6539. regardless of which archive or what part of the archive the tape
  6540. head is on. Before writing an archive, you should make sure that no
  6541. data on the tape will be overwritten (unless it is no longer needed).
  6542. Before reading an archive, you should make sure the tape head is at
  6543. the beginning of the archive you want to read. (The @code{restore}
  6544. script will find the archive automatically. @FIXME{There is no such
  6545. restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
  6546. an explanation of the tape moving utility.
  6547. If you want to add new archive file entries to a tape, you should
  6548. advance the tape to the end of the existing file entries, backspace
  6549. over the last tape mark, and write the new archive file. If you were
  6550. to add two archives to the example above, the tape might look like the
  6551. following:
  6552. @smallexample
  6553. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  6554. @end smallexample
  6555. @node mt
  6556. @subsection The @command{mt} Utility
  6557. @UNREVISED
  6558. @FIXME{Is it true that this only works on non-block devices?
  6559. should explain the difference, (fixed or variable).}
  6560. @value{xref-blocking-factor}.
  6561. You can use the @command{mt} utility to advance or rewind a tape past a
  6562. specified number of archive files on the tape. This will allow you
  6563. to move to the beginning of an archive before extracting or reading
  6564. it, or to the end of all the archives before writing a new one.
  6565. @FIXME{Why isn't there an "advance 'til you find two tape marks
  6566. together"?}
  6567. The syntax of the @command{mt} command is:
  6568. @smallexample
  6569. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  6570. @end smallexample
  6571. where @var{tapename} is the name of the tape device, @var{number} is
  6572. the number of times an operation is performed (with a default of one),
  6573. and @var{operation} is one of the following:
  6574. @FIXME{is there any use for record operations?}
  6575. @table @kbd
  6576. @item eof
  6577. @itemx weof
  6578. Writes @var{number} tape marks at the current position on the tape.
  6579. @item fsf
  6580. Moves tape position forward @var{number} files.
  6581. @item bsf
  6582. Moves tape position back @var{number} files.
  6583. @item rewind
  6584. Rewinds the tape. (Ignores @var{number}).
  6585. @item offline
  6586. @itemx rewoff1
  6587. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  6588. @item status
  6589. Prints status information about the tape unit.
  6590. @end table
  6591. @FIXME{Is there a better way to frob the spacing on the list?}
  6592. If you don't specify a @var{tapename}, @command{mt} uses the environment
  6593. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  6594. @file{/dev/rmt12}.
  6595. @command{mt} returns a 0 exit status when the operation(s) were
  6596. successful, 1 if the command was unrecognized, and 2 if an operation
  6597. failed.
  6598. @FIXME{New node on how to find an archive?}
  6599. If you use @value{op-extract} with the @value{op-label} option specified,
  6600. @command{tar} will read an archive label (the tape head has to be positioned
  6601. on it) and print an error if the archive label doesn't match the
  6602. @var{archive-name} specified. @var{archive-name} can be any regular
  6603. expression. If the labels match, @command{tar} extracts the archive.
  6604. @value{xref-label}.
  6605. @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
  6606. references}@samp{tar --list --label} will cause @command{tar} to print the
  6607. label.
  6608. @FIXME{Program to list all the labels on a tape?}
  6609. @node Using Multiple Tapes
  6610. @section Using Multiple Tapes
  6611. @UNREVISED
  6612. Often you might want to write a large archive, one larger than will fit
  6613. on the actual tape you are using. In such a case, you can run multiple
  6614. @command{tar} commands, but this can be inconvenient, particularly if you
  6615. are using options like @value{op-exclude} or dumping entire filesystems.
  6616. Therefore, @command{tar} supports multiple tapes automatically.
  6617. Use @value{op-multi-volume} on the command line, and then @command{tar} will,
  6618. when it reaches the end of the tape, prompt for another tape, and
  6619. continue the archive. Each tape will have an independent archive, and
  6620. can be read without needing the other. (As an exception to this, the
  6621. file that @command{tar} was archiving when it ran out of tape will usually
  6622. be split between the two archives; in this case you need to extract from
  6623. the first archive, using @value{op-multi-volume}, and then put in the
  6624. second tape when prompted, so @command{tar} can restore both halves of the
  6625. file.)
  6626. @GNUTAR{} multi-volume archives do not use a truly
  6627. portable format. You need @GNUTAR{} at both end to
  6628. process them properly.
  6629. When prompting for a new tape, @command{tar} accepts any of the following
  6630. responses:
  6631. @table @kbd
  6632. @item ?
  6633. Request @command{tar} to explain possible responses
  6634. @item q
  6635. Request @command{tar} to exit immediately.
  6636. @item n @var{file name}
  6637. Request @command{tar} to write the next volume on the file @var{file name}.
  6638. @item !
  6639. Request @command{tar} to run a subshell.
  6640. @item y
  6641. Request @command{tar} to begin writing the next volume.
  6642. @end table
  6643. (You should only type @samp{y} after you have changed the tape;
  6644. otherwise @command{tar} will write over the volume it just finished.)
  6645. If you want more elaborate behavior than this, give @command{tar} the
  6646. @value{op-info-script} option. The file @var{script-name} is expected
  6647. to be a program (or shell script) to be run instead of the normal
  6648. prompting procedure. If the program fails, @command{tar} exits;
  6649. otherwise, @command{tar} begins writing the next volume. The behavior
  6650. of the
  6651. @samp{n} response to the normal tape-change prompt is not available
  6652. if you use @value{op-info-script}.
  6653. The method @command{tar} uses to detect end of tape is not perfect, and
  6654. fails on some operating systems or on some devices. You can use the
  6655. @value{op-tape-length} option if @command{tar} can't detect the end of the
  6656. tape itself. This option selects @value{op-multi-volume} automatically.
  6657. The @var{size} argument should then be the usable size of the tape.
  6658. But for many devices, and floppy disks in particular, this option is
  6659. never required for real, as far as we know.
  6660. The volume number used by @command{tar} in its tape-change prompt
  6661. can be changed; if you give the @value{op-volno-file} option, then
  6662. @var{file-of-number} should be an unexisting file to be created, or else,
  6663. a file already containing a decimal number. That number will be used
  6664. as the volume number of the first volume written. When @command{tar} is
  6665. finished, it will rewrite the file with the now-current volume number.
  6666. (This does not change the volume number written on a tape label, as
  6667. per @value{ref-label}, it @emph{only} affects the number used in
  6668. the prompt.)
  6669. If you want @command{tar} to cycle through a series of tape drives, then
  6670. you can use the @samp{n} response to the tape-change prompt. This is
  6671. error prone, however, and doesn't work at all with @value{op-info-script}.
  6672. Therefore, if you give @command{tar} multiple @value{op-file} options, then
  6673. the specified files will be used, in sequence, as the successive volumes
  6674. of the archive. Only when the first one in the sequence needs to be
  6675. used again will @command{tar} prompt for a tape change (or run the info
  6676. script).
  6677. Multi-volume archives
  6678. With @value{op-multi-volume}, @command{tar} will not abort when it cannot
  6679. read or write any more data. Instead, it will ask you to prepare a new
  6680. volume. If the archive is on a magnetic tape, you should change tapes
  6681. now; if the archive is on a floppy disk, you should change disks, etc.
  6682. Each volume of a multi-volume archive is an independent @command{tar}
  6683. archive, complete in itself. For example, you can list or extract any
  6684. volume alone; just don't specify @value{op-multi-volume}. However, if one
  6685. file in the archive is split across volumes, the only way to extract
  6686. it successfully is with a multi-volume extract command @samp{--extract
  6687. --multi-volume} (@samp{-xM}) starting on or before the volume where
  6688. the file begins.
  6689. For example, let's presume someone has two tape drives on a system
  6690. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  6691. to switch to the second drive when it needs to write the
  6692. second tape, and then back to the first tape, etc., just do either of:
  6693. @smallexample
  6694. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  6695. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  6696. @end smallexample
  6697. @menu
  6698. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  6699. * Tape Files:: Tape Files
  6700. @end menu
  6701. @node Multi-Volume Archives
  6702. @subsection Archives Longer than One Tape or Disk
  6703. @cindex Multi-volume archives
  6704. @UNREVISED
  6705. To create an archive that is larger than will fit on a single unit of
  6706. the media, use the @value{op-multi-volume} option in conjunction with
  6707. the @value{op-create} option (@pxref{create}). A
  6708. @dfn{multi-volume} archive can be manipulated like any other archive
  6709. (provided the @value{op-multi-volume} option is specified), but is
  6710. stored on more than one tape or disk.
  6711. When you specify @value{op-multi-volume}, @command{tar} does not report an
  6712. error when it comes to the end of an archive volume (when reading), or
  6713. the end of the media (when writing). Instead, it prompts you to load
  6714. a new storage volume. If the archive is on a magnetic tape, you
  6715. should change tapes when you see the prompt; if the archive is on a
  6716. floppy disk, you should change disks; etc.
  6717. You can read each individual volume of a multi-volume archive as if it
  6718. were an archive by itself. For example, to list the contents of one
  6719. volume, use @value{op-list}, without @value{op-multi-volume} specified.
  6720. To extract an archive member from one volume (assuming it is described
  6721. that volume), use @value{op-extract}, again without
  6722. @value{op-multi-volume}.
  6723. If an archive member is split across volumes (ie. its entry begins on
  6724. one volume of the media and ends on another), you need to specify
  6725. @value{op-multi-volume} to extract it successfully. In this case, you
  6726. should load the volume where the archive member starts, and use
  6727. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  6728. volumes as it needs them. @xref{extracting archives}, for more
  6729. information about extracting archives.
  6730. @value{op-info-script} is like @value{op-multi-volume}, except that
  6731. @command{tar} does not prompt you directly to change media volumes when
  6732. a volume is full---instead, @command{tar} runs commands you have stored
  6733. in @var{script-name}. For example, this option can be used to eject
  6734. cassettes, or to broadcast messages such as @samp{Someone please come
  6735. change my tape} when performing unattended backups. When @var{script-name}
  6736. is done, @command{tar} will assume that the media has been changed.
  6737. Multi-volume archives can be modified like any other archive. To add
  6738. files to a multi-volume archive, you need to only mount the last
  6739. volume of the archive media (and new volumes, if needed). For all
  6740. other operations, you need to use the entire archive.
  6741. If a multi-volume archive was labeled using @value{op-label}
  6742. (@value{pxref-label}) when it was created, @command{tar} will not
  6743. automatically label volumes which are added later. To label subsequent
  6744. volumes, specify @value{op-label} again in conjunction with the
  6745. @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
  6746. @cindex Labeling multi-volume archives
  6747. @FIXME{example}
  6748. @FIXME{There should be a sample program here, including an exit
  6749. before end. Is the exit status even checked in tar? :-(}
  6750. @table @kbd
  6751. @item --multi-volume
  6752. @itemx -M
  6753. Creates a multi-volume archive, when used in conjunction with
  6754. @value{op-create}. To perform any other operation on a multi-volume
  6755. archive, specify @value{op-multi-volume} in conjunction with that
  6756. operation.
  6757. @item --info-script=@var{program-file}
  6758. @itemx -F @var{program-file}
  6759. Creates a multi-volume archive via a script. Used in conjunction with
  6760. @value{op-create}.
  6761. @end table
  6762. Beware that there is @emph{no} real standard about the proper way, for
  6763. a @command{tar} archive, to span volume boundaries. If you have a
  6764. multi-volume created by some vendor's @command{tar}, there is almost
  6765. no chance you could read all the volumes with @GNUTAR{}.
  6766. The converse is also true: you may not expect
  6767. multi-volume archives created by @GNUTAR{} to be
  6768. fully recovered by vendor's @command{tar}. Since there is little
  6769. chance that, in mixed system configurations, some vendor's
  6770. @command{tar} will work on another vendor's machine, and there is a
  6771. great chance that @GNUTAR{} will work on most of
  6772. them, your best bet is to install @GNUTAR{} on all
  6773. machines between which you know exchange of files is possible.
  6774. @node Tape Files
  6775. @subsection Tape Files
  6776. @UNREVISED
  6777. To give the archive a name which will be recorded in it, use the
  6778. @value{op-label} option. This will write a special block identifying
  6779. @var{volume-label} as the name of the archive to the front of the archive
  6780. which will be displayed when the archive is listed with @value{op-list}.
  6781. If you are creating a multi-volume archive with
  6782. @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
  6783. volume label will have
  6784. @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
  6785. the number of the volume of the archive. (If you use the @value{op-label}
  6786. option when reading an archive, it checks to make sure the label on the
  6787. tape matches the one you give. @value{xref-label}.
  6788. When @command{tar} writes an archive to tape, it creates a single
  6789. tape file. If multiple archives are written to the same tape, one
  6790. after the other, they each get written as separate tape files. When
  6791. extracting, it is necessary to position the tape at the right place
  6792. before running @command{tar}. To do this, use the @command{mt} command.
  6793. For more information on the @command{mt} command and on the organization
  6794. of tapes into a sequence of tape files, see @ref{mt}.
  6795. People seem to often do:
  6796. @smallexample
  6797. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  6798. @end smallexample
  6799. or such, for pushing a common date in all volumes or an archive set.
  6800. @node label
  6801. @section Including a Label in the Archive
  6802. @cindex Labeling an archive
  6803. @cindex Labels on the archive media
  6804. @UNREVISED
  6805. @table @kbd
  6806. @item -V @var{name}
  6807. @itemx --label=@var{name}
  6808. Create archive with volume name @var{name}.
  6809. @end table
  6810. This option causes @command{tar} to write out a @dfn{volume header} at
  6811. the beginning of the archive. If @value{op-multi-volume} is used, each
  6812. volume of the archive will have a volume header of @samp{@var{name}
  6813. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  6814. next, and so on.
  6815. @FIXME{Should the arg to --label be a quoted string?? No.}
  6816. To avoid problems caused by misplaced paper labels on the archive
  6817. media, you can include a @dfn{label} entry---an archive member which
  6818. contains the name of the archive---in the archive itself. Use the
  6819. @value{op-label} option in conjunction with the @value{op-create} operation
  6820. to include a label entry in the archive as it is being created.
  6821. If you create an archive using both @value{op-label} and
  6822. @value{op-multi-volume}, each volume of the archive will have an
  6823. archive label of the form @samp{@var{archive-label} Volume @var{n}},
  6824. where @var{n} is 1 for the first volume, 2 for the next, and so on.
  6825. @FIXME-xref{Multi-Volume Archives, for information on creating multiple
  6826. volume archives.}
  6827. If you list or extract an archive using @value{op-label}, @command{tar} will
  6828. print an error if the archive label doesn't match the @var{archive-label}
  6829. specified, and will then not list nor extract the archive. In those cases,
  6830. @var{archive-label} argument is interpreted as a globbing-style pattern
  6831. which must match the actual magnetic volume label. @xref{exclude}, for
  6832. a precise description of how match is attempted@footnote{Previous versions
  6833. of @command{tar} used full regular expression matching, or before that, only
  6834. exact string matching, instead of wildcard matchers. We decided for the
  6835. sake of simplicity to use a uniform matching device through @command{tar}.}.
  6836. If the switch @value{op-multi-volume} is being used, the volume label
  6837. matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
  6838. if the initial match fails, before giving up. Since the volume numbering
  6839. is automatically added in labels at creation time, it sounded logical to
  6840. equally help the user taking care of it when the archive is being read.
  6841. The @value{op-label} was once called @samp{--volume}, but is not available
  6842. under that name anymore.
  6843. To find out an archive's label entry (or to find out if an archive has
  6844. a label at all), use @samp{tar --list --verbose}. @command{tar} will
  6845. print the label first, and then print archive member information, as
  6846. in the example below:
  6847. @smallexample
  6848. $ @kbd{tar --verbose --list --file=iamanarchive}
  6849. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  6850. -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  6851. @end smallexample
  6852. @table @kbd
  6853. @item --label=@var{archive-label}
  6854. @itemx -V @var{archive-label}
  6855. Includes an @dfn{archive-label} at the beginning of the archive when
  6856. the archive is being created, when used in conjunction with the
  6857. @value{op-create} option. Checks to make sure the archive label
  6858. matches the one specified (when used in conjunction with the
  6859. @value{op-extract} option.
  6860. @end table
  6861. To get a common information on all tapes of a series, use the
  6862. @value{op-label} option. For having this information different in each
  6863. series created through a single script used on a regular basis, just
  6864. manage to get some date string as part of the label. For example:
  6865. @smallexample
  6866. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  6867. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  6868. --volume="Daily backup for `date +%Y-%m-%d`"}
  6869. @end smallexample
  6870. Also note that each label has its own date and time, which corresponds
  6871. to when @GNUTAR{} initially attempted to write it,
  6872. often soon after the operator launches @command{tar} or types the
  6873. carriage return telling that the next tape is ready. Comparing date
  6874. labels does give an idea of tape throughput only if the delays for
  6875. rewinding tapes and the operator switching them were negligible, which
  6876. is usually not the case.
  6877. @FIXME{was --volume}
  6878. @node verify
  6879. @section Verifying Data as It is Stored
  6880. @cindex Verifying a write operation
  6881. @cindex Double-checking a write operation
  6882. @table @kbd
  6883. @item -W
  6884. @itemx --verify
  6885. Attempt to verify the archive after writing.
  6886. @end table
  6887. This option causes @command{tar} to verify the archive after writing it.
  6888. Each volume is checked after it is written, and any discrepancies
  6889. are recorded on the standard error output.
  6890. Verification requires that the archive be on a back-space-able medium.
  6891. This means pipes, some cartridge tape drives, and some other devices
  6892. cannot be verified.
  6893. You can insure the accuracy of an archive by comparing files in the
  6894. system with archive members. @command{tar} can compare an archive to the
  6895. file system as the archive is being written, to verify a write
  6896. operation, or can compare a previously written archive, to insure that
  6897. it is up to date.
  6898. To check for discrepancies in an archive immediately after it is
  6899. written, use the @value{op-verify} option in conjunction with
  6900. the @value{op-create} operation. When this option is
  6901. specified, @command{tar} checks archive members against their counterparts
  6902. in the file system, and reports discrepancies on the standard error.
  6903. To verify an archive, you must be able to read it from before the end
  6904. of the last written entry. This option is useful for detecting data
  6905. errors on some tapes. Archives written to pipes, some cartridge tape
  6906. drives, and some other devices cannot be verified.
  6907. One can explicitly compare an already made archive with the file system
  6908. by using the @value{op-compare} option, instead of using the more automatic
  6909. @value{op-verify} option. @value{xref-compare}.
  6910. Note that these two options have a slightly different intent. The
  6911. @value{op-compare} option how identical are the logical contents of some
  6912. archive with what is on your disks, while the @value{op-verify} option is
  6913. really for checking if the physical contents agree and if the recording
  6914. media itself is of dependable quality. So, for the @value{op-verify}
  6915. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  6916. the archive, while it lets the speed optimization undisturbed for the
  6917. @value{op-compare} option. If you nevertheless use @value{op-compare} for
  6918. media verification, you may have to defeat the in-memory cache yourself,
  6919. maybe by opening and reclosing the door latch of your recording unit,
  6920. forcing some doubt in your operating system about the fact this is really
  6921. the same volume as the one just written or read.
  6922. The @value{op-verify} option would not be necessary if drivers were indeed
  6923. able to detect dependably all write failures. This sometimes require many
  6924. magnetic heads, some able to read after the writes occurred. One would
  6925. not say that drivers unable to detect all cases are necessarily flawed,
  6926. as long as programming is concerned.
  6927. The @value{op-verify} option will not work in conjunction with the
  6928. @value{op-multi-volume} option or the @value{op-append},
  6929. @value{op-update} and @value{op-delete} operations. @xref{Operations},
  6930. for more information on these operations.
  6931. Also, since @command{tar} normally strips leading @samp{/} from file
  6932. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  6933. /tmp/foo.tar /etc} will work as desired only if the working directory is
  6934. @file{/}, as @command{tar} uses the archive's relative member names
  6935. (e.g., @file{etc/motd}) when verifying the archive.
  6936. @node Write Protection
  6937. @section Write Protection
  6938. Almost all tapes and diskettes, and in a few rare cases, even disks can
  6939. be @dfn{write protected}, to protect data on them from being changed.
  6940. Once an archive is written, you should write protect the media to prevent
  6941. the archive from being accidentally overwritten or deleted. (This will
  6942. protect the archive from being changed with a tape or floppy drive---it
  6943. will not protect it from magnet fields or other physical hazards).
  6944. The write protection device itself is usually an integral part of the
  6945. physical media, and can be a two position (write enabled/write
  6946. disabled) switch, a notch which can be popped out or covered, a ring
  6947. which can be removed from the center of a tape reel, or some other
  6948. changeable feature.
  6949. @node Free Software Needs Free Documentation
  6950. @appendix Free Software Needs Free Documentation
  6951. @include freemanuals.texi
  6952. @node Copying This Manual
  6953. @appendix Copying This Manual
  6954. @menu
  6955. * GNU Free Documentation License:: License for copying this manual
  6956. @end menu
  6957. @include fdl.texi
  6958. @node Index
  6959. @appendix Index
  6960. @printindex cp
  6961. @summarycontents
  6962. @contents
  6963. @bye
  6964. @c Local variables:
  6965. @c texinfo-column-for-description: 32
  6966. @c End: