tar.texi 361 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441
  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. @include rendition.texi
  11. @include value.texi
  12. @c Put everything in one index (arbitrarily chosen to be the concept index).
  13. @syncodeindex fn cp
  14. @syncodeindex ky cp
  15. @syncodeindex pg cp
  16. @syncodeindex vr cp
  17. @defindex op
  18. @copying
  19. This manual is for @acronym{GNU} @command{tar} (version
  20. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  21. from archives.
  22. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  23. 2003, 2004 Free Software Foundation, Inc.
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.1 or
  27. any later version published by the Free Software Foundation; with the
  28. Invariant Sections being "GNU General Public License", with the
  29. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  30. as in (a) below. A copy of the license is included in the section
  31. entitled "GNU Free Documentation License".
  32. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  33. this GNU Manual. Buying copies from GNU Press supports the FSF in
  34. developing GNU and promoting software freedom.''
  35. @end quotation
  36. @end copying
  37. @dircategory Archiving
  38. @direntry
  39. * Tar: (tar). Making tape (or disk) archives.
  40. @end direntry
  41. @dircategory Individual utilities
  42. @direntry
  43. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  44. @end direntry
  45. @shorttitlepage @acronym{GNU} @command{tar}
  46. @titlepage
  47. @title @acronym{GNU} tar: an archiver tool
  48. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  49. @author John Gilmore, Jay Fenlason et al.
  50. @page
  51. @vskip 0pt plus 1filll
  52. @insertcopying
  53. @end titlepage
  54. @ifnottex
  55. @node Top
  56. @top @acronym{GNU} tar: an archiver tool
  57. @insertcopying
  58. @cindex file archival
  59. @cindex archiving files
  60. The first part of this master menu lists the major nodes in this Info
  61. document. The rest of the menu lists all the lower level nodes.
  62. @end ifnottex
  63. @c The master menu, created with texinfo-master-menu, goes here.
  64. @c (However, getdate.texi's menu is interpolated by hand.)
  65. @menu
  66. * Introduction::
  67. * Tutorial::
  68. * tar invocation::
  69. * operations::
  70. * Backups::
  71. * Choosing::
  72. * Date input formats::
  73. * Formats::
  74. * Media::
  75. Appendices
  76. * Changes::
  77. * Genfile::
  78. * Snapshot Files::
  79. * Free Software Needs Free Documentation::
  80. * Copying This Manual::
  81. * Index of Command Line Options::
  82. * Index::
  83. @detailmenu
  84. --- The Detailed Node Listing ---
  85. Introduction
  86. * Book Contents:: What this Book Contains
  87. * Definitions:: Some Definitions
  88. * What tar Does:: What @command{tar} Does
  89. * Naming tar Archives:: How @command{tar} Archives are Named
  90. * Authors:: @GNUTAR{} Authors
  91. * Reports:: Reporting bugs or suggestions
  92. Tutorial Introduction to @command{tar}
  93. * assumptions::
  94. * stylistic conventions::
  95. * basic tar options:: Basic @command{tar} Operations and Options
  96. * frequent operations::
  97. * Two Frequent Options::
  98. * create:: How to Create Archives
  99. * list:: How to List Archives
  100. * extract:: How to Extract Members from an Archive
  101. * going further::
  102. Two Frequently Used Options
  103. * file tutorial::
  104. * verbose tutorial::
  105. * help tutorial::
  106. How to Create Archives
  107. * prepare for examples::
  108. * Creating the archive::
  109. * create verbose::
  110. * short create::
  111. * create dir::
  112. How to List Archives
  113. * list dir::
  114. How to Extract Members from an Archive
  115. * extracting archives::
  116. * extracting files::
  117. * extract dir::
  118. * failing commands::
  119. Invoking @GNUTAR{}
  120. * Synopsis::
  121. * using tar options::
  122. * Styles::
  123. * All Options::
  124. * help::
  125. * defaults::
  126. * verbose::
  127. * interactive::
  128. The Three Option Styles
  129. * Mnemonic Options:: Mnemonic Option Style
  130. * Short Options:: Short Option Style
  131. * Old Options:: Old Option Style
  132. * Mixing:: Mixing Option Styles
  133. All @command{tar} Options
  134. * Operation Summary::
  135. * Option Summary::
  136. * Short Option Summary::
  137. @GNUTAR{} Operations
  138. * Basic tar::
  139. * Advanced tar::
  140. * create options::
  141. * extract options::
  142. * backup::
  143. * Applications::
  144. * looking ahead::
  145. Advanced @GNUTAR{} Operations
  146. * Operations::
  147. * append::
  148. * update::
  149. * concatenate::
  150. * delete::
  151. * compare::
  152. How to Add Files to Existing Archives: @option{--append}
  153. * appending files:: Appending Files to an Archive
  154. * multiple::
  155. Updating an Archive
  156. * how to update::
  157. Options Used by @option{--create}
  158. * Ignore Failed Read::
  159. Options Used by @option{--extract}
  160. * Reading:: Options to Help Read Archives
  161. * Writing:: Changing How @command{tar} Writes Files
  162. * Scarce:: Coping with Scarce Resources
  163. Options to Help Read Archives
  164. * read full records::
  165. * Ignore Zeros::
  166. Changing How @command{tar} Writes Files
  167. * Dealing with Old Files::
  168. * Overwrite Old Files::
  169. * Keep Old Files::
  170. * Keep Newer Files::
  171. * Unlink First::
  172. * Recursive Unlink::
  173. * Data Modification Times::
  174. * Setting Access Permissions::
  175. * Writing to Standard Output::
  176. * remove files::
  177. Coping with Scarce Resources
  178. * Starting File::
  179. * Same Order::
  180. Performing Backups and Restoring Files
  181. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  182. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  183. * Backup Levels:: Levels of Backups
  184. * Backup Parameters:: Setting Parameters for Backups and Restoration
  185. * Scripted Backups:: Using the Backup Scripts
  186. * Scripted Restoration:: Using the Restore Script
  187. Setting Parameters for Backups and Restoration
  188. * General-Purpose Variables::
  189. * Magnetic Tape Control::
  190. * User Hooks::
  191. * backup-specs example:: An Example Text of @file{Backup-specs}
  192. Choosing Files and Names for @command{tar}
  193. * file:: Choosing the Archive's Name
  194. * Selecting Archive Members::
  195. * files:: Reading Names from a File
  196. * exclude:: Excluding Some Files
  197. * Wildcards::
  198. * after:: Operating Only on New Files
  199. * recurse:: Descending into Directories
  200. * one:: Crossing File System Boundaries
  201. Reading Names from a File
  202. * nul::
  203. Excluding Some Files
  204. * controlling pattern-matching with exclude::
  205. * problems with exclude::
  206. Crossing File System Boundaries
  207. * directory:: Changing Directory
  208. * absolute:: Absolute File Names
  209. Date input formats
  210. * General date syntax:: Common rules.
  211. * Calendar date items:: 19 Dec 1994.
  212. * Time of day items:: 9:20pm.
  213. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  214. * Day of week items:: Monday and others.
  215. * Relative items in date strings:: next tuesday, 2 years ago.
  216. * Pure numbers in date strings:: 19931219, 1440.
  217. * Seconds since the Epoch:: @@1078100502.
  218. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  219. Controlling the Archive Format
  220. * Portability:: Making @command{tar} Archives More Portable
  221. * Compression:: Using Less Space through Compression
  222. * Attributes:: Handling File Attributes
  223. * Standard:: The Standard Format
  224. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  225. * cpio:: Comparison of @command{tar} and @command{cpio}
  226. Making @command{tar} Archives More Portable
  227. * Portable Names:: Portable Names
  228. * dereference:: Symbolic Links
  229. * old:: Old V7 Archives
  230. * posix:: @acronym{POSIX} archives
  231. * Checksumming:: Checksumming Problems
  232. * Large or Negative Values:: Large files, negative time stamps, etc.
  233. Using Less Space through Compression
  234. * gzip:: Creating and Reading Compressed Archives
  235. * sparse:: Archiving Sparse Files
  236. Tapes and Other Archive Media
  237. * Device:: Device selection and switching
  238. * Remote Tape Server::
  239. * Common Problems and Solutions::
  240. * Blocking:: Blocking
  241. * Many:: Many archives on one tape
  242. * Using Multiple Tapes:: Using Multiple Tapes
  243. * label:: Including a Label in the Archive
  244. * verify::
  245. * Write Protection::
  246. Blocking
  247. * Format Variations:: Format Variations
  248. * Blocking Factor:: The Blocking Factor of an Archive
  249. Many Archives on One Tape
  250. * Tape Positioning:: Tape Positions and Tape Marks
  251. * mt:: The @command{mt} Utility
  252. Using Multiple Tapes
  253. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  254. * Tape Files:: Tape Files
  255. * Tarcat:: Concatenate Volumes into a Single Archive
  256. GNU tar internals and development
  257. * Genfile::
  258. * Snapshot Files::
  259. Copying This Manual
  260. * Free Software Needs Free Documentation::
  261. * GNU Free Documentation License:: License for copying this manual
  262. @end detailmenu
  263. @end menu
  264. @node Introduction
  265. @chapter Introduction
  266. @GNUTAR{} creates
  267. and manipulates @dfn{archives} which are actually collections of
  268. many other files; the program provides users with an organized and
  269. systematic method for controlling a large amount of data.
  270. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  271. archives need not (and these days, typically do not) reside on tapes.
  272. @menu
  273. * Book Contents:: What this Book Contains
  274. * Definitions:: Some Definitions
  275. * What tar Does:: What @command{tar} Does
  276. * Naming tar Archives:: How @command{tar} Archives are Named
  277. * Authors:: @GNUTAR{} Authors
  278. * Reports:: Reporting bugs or suggestions
  279. @end menu
  280. @node Book Contents
  281. @section What this Book Contains
  282. The first part of this chapter introduces you to various terms that will
  283. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  284. and its documentation, and where you should send bug reports
  285. or comments.
  286. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  287. gentle introduction for people who are new to using @command{tar}. It is
  288. meant to be self contained, not requiring any reading from subsequent
  289. chapters to make sense. It moves from topic to topic in a logical,
  290. progressive order, building on information already explained.
  291. Although the tutorial is paced and structured to allow beginners to
  292. learn how to use @command{tar}, it is not intended solely for beginners.
  293. The tutorial explains how to use the three most frequently used
  294. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  295. two frequently used options (@samp{file} and @samp{verbose}). The other
  296. chapters do not refer to the tutorial frequently; however, if a section
  297. discusses something which is a complex variant of a basic concept, there
  298. may be a cross reference to that basic concept. (The entire book,
  299. including the tutorial, assumes that the reader understands some basic
  300. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  301. The third chapter presents the remaining five operations, and
  302. information about using @command{tar} options and option syntax.
  303. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  304. than the reality. should think about whether this makes sense to say
  305. here, or not.} The other chapters are meant to be used as a
  306. reference. Each chapter presents everything that needs to be said
  307. about a specific topic.
  308. One of the chapters (@pxref{Date input formats}) exists in its
  309. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  310. In addition, one section of this manual (@pxref{Standard}) contains a
  311. big quote which is taken directly from @command{tar} sources.
  312. In general, we give both long and short (abbreviated) option names
  313. at least once in each section where the relevant option is covered, so
  314. that novice readers will become familiar with both styles. (A few
  315. options have no short versions, and the relevant sections will
  316. indicate this.)
  317. @node Definitions
  318. @section Some Definitions
  319. @cindex archive
  320. @cindex tar archive
  321. The @command{tar} program is used to create and manipulate @command{tar}
  322. archives. An @dfn{archive} is a single file which contains the contents
  323. of many files, while still identifying the names of the files, their
  324. owner(s), and so forth. (In addition, archives record access
  325. permissions, user and group, size in bytes, and data modification time.
  326. Some archives also record the file names in each archived directory, as
  327. well as other file and directory information.) You can use @command{tar}
  328. to @dfn{create} a new archive in a specified directory.
  329. @cindex member
  330. @cindex archive member
  331. @cindex file name
  332. @cindex member name
  333. The files inside an archive are called @dfn{members}. Within this
  334. manual, we use the term @dfn{file} to refer only to files accessible in
  335. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  336. @dfn{member} to refer only to the members of an archive. Similarly, a
  337. @dfn{file name} is the name of a file, as it resides in the file system,
  338. and a @dfn{member name} is the name of an archive member within the
  339. archive.
  340. @cindex extraction
  341. @cindex unpacking
  342. The term @dfn{extraction} refers to the process of copying an archive
  343. member (or multiple members) into a file in the file system. Extracting
  344. all the members of an archive is often called @dfn{extracting the
  345. archive}. The term @dfn{unpack} can also be used to refer to the
  346. extraction of many or all the members of an archive. Extracting an
  347. archive does not destroy the archive's structure, just as creating an
  348. archive does not destroy the copies of the files that exist outside of
  349. the archive. You may also @dfn{list} the members in a given archive
  350. (this is often thought of as ``printing'' them to the standard output,
  351. or the command line), or @dfn{append} members to a pre-existing archive.
  352. All of these operations can be performed using @command{tar}.
  353. @node What tar Does
  354. @section What @command{tar} Does
  355. @cindex tar
  356. The @command{tar} program provides the ability to create @command{tar}
  357. archives, as well as various other kinds of manipulation. For example,
  358. you can use @command{tar} on previously created archives to extract files,
  359. to store additional files, or to update or list files which were already
  360. stored.
  361. Initially, @command{tar} archives were used to store files conveniently on
  362. magnetic tape. The name @command{tar} comes from this use; it stands for
  363. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  364. direct its output to available devices, files, or other programs (using
  365. pipes). @command{tar} may even access remote devices or files (as archives).
  366. @FIXME{the following table entries need a bit of work..}
  367. You can use @command{tar} archives in many ways. We want to stress a few
  368. of them: storage, backup, and transportation.
  369. @table @asis
  370. @item Storage
  371. Often, @command{tar} archives are used to store related files for
  372. convenient file transfer over a network. For example, the
  373. @acronym{GNU} Project distributes its software bundled into
  374. @command{tar} archives, so that all the files relating to a particular
  375. program (or set of related programs) can be transferred as a single
  376. unit.
  377. A magnetic tape can store several files in sequence. However, the tape
  378. has no names for these files; it only knows their relative position on
  379. the tape. One way to store several files on one tape and retain their
  380. names is by creating a @command{tar} archive. Even when the basic transfer
  381. mechanism can keep track of names, as FTP can, the nuisance of handling
  382. multiple files, directories, and multiple links makes @command{tar}
  383. archives useful.
  384. Archive files are also used for long-term storage. You can think of
  385. this as transportation from the present into the future. (It is a
  386. science-fiction idiom that you can move through time as well as in
  387. space; the idea here is that @command{tar} can be used to move archives in
  388. all dimensions, even time!)
  389. @item Backup
  390. Because the archive created by @command{tar} is capable of preserving
  391. file information and directory structure, @command{tar} is commonly
  392. used for performing full and incremental backups of disks. A backup
  393. puts a collection of files (possibly pertaining to many users and
  394. projects) together on a disk or a tape. This guards against
  395. accidental destruction of the information in those files.
  396. @GNUTAR{} has special features that allow it to be
  397. used to make incremental and full dumps of all the files in a
  398. file system.
  399. @item Transportation
  400. You can create an archive on one system, transfer it to another system,
  401. and extract the contents there. This allows you to transport a group of
  402. files from one system to another.
  403. @end table
  404. @node Naming tar Archives
  405. @section How @command{tar} Archives are Named
  406. Conventionally, @command{tar} archives are given names ending with
  407. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  408. but this manual follows that convention in order to accustom readers to
  409. it and to make examples more clear.
  410. @cindex tar file
  411. @cindex entry
  412. @cindex tar entry
  413. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  414. archive members as ``files'' or ``entries''. For people familiar with
  415. the operation of @command{tar}, this causes no difficulty. However, in
  416. this manual, we consistently refer to ``archives'' and ``archive
  417. members'' to make learning to use @command{tar} easier for novice users.
  418. @node Authors
  419. @section @GNUTAR{} Authors
  420. @GNUTAR{} was originally written by John Gilmore,
  421. and modified by many people. The @acronym{GNU} enhancements were
  422. written by Jay Fenlason, then Joy Kendall, and the whole package has
  423. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  424. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  425. numerous and kind users.
  426. We wish to stress that @command{tar} is a collective work, and owes much to
  427. all those people who reported problems, offered solutions and other
  428. insights, or shared their thoughts and suggestions. An impressive, yet
  429. partial list of those contributors can be found in the @file{THANKS}
  430. file from the @GNUTAR{} distribution.
  431. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  432. sure i want to spell out the history in this detail, at least not for
  433. the printed book. i'm just not sure it needs to be said this way.
  434. i'll think about it.}
  435. @FIXME{History is more important, and surely more interesting, than
  436. actual names. Quoting names without history would be meaningless. FP}
  437. Jay Fenlason put together a draft of a @GNUTAR{}
  438. manual, borrowing notes from the original man page from John Gilmore.
  439. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  440. Gorin worked on a tutorial and manual for @GNUTAR{}.
  441. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  442. taking information from all these sources and merging them. Melissa
  443. Weisshaus finally edited and redesigned the book to create version
  444. 1.12. @FIXME{update version number as necessary; i'm being
  445. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  446. maybe melissa? maybe julie sussman?] needs to properly index the
  447. thing.}
  448. For version 1.12, Daniel Hagerty contributed a great deal of technical
  449. consulting. In particular, he is the primary author of @ref{Backups}.
  450. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  451. (see @url{http://savannah.gnu.org/projects/tar}), and
  452. active development and maintenance work has started
  453. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  454. Poznyakoff and Jeff Bailey.
  455. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  456. @node Reports
  457. @section Reporting bugs or suggestions
  458. @cindex bug reports
  459. @cindex reporting bugs
  460. If you find problems or have suggestions about this program or manual,
  461. please report them to @file{bug-tar@@gnu.org}.
  462. When reporting a bug, please be sure to include as much detail as
  463. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  464. like to make this node as detailed as 'Bug reporting' node in Emacs
  465. manual}.
  466. @node Tutorial
  467. @chapter Tutorial Introduction to @command{tar}
  468. This chapter guides you through some basic examples of three @command{tar}
  469. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  470. you already know how to use some other version of @command{tar}, then you
  471. may not need to read this chapter. This chapter omits most complicated
  472. details about how @command{tar} works.
  473. @menu
  474. * assumptions::
  475. * stylistic conventions::
  476. * basic tar options:: Basic @command{tar} Operations and Options
  477. * frequent operations::
  478. * Two Frequent Options::
  479. * create:: How to Create Archives
  480. * list:: How to List Archives
  481. * extract:: How to Extract Members from an Archive
  482. * going further::
  483. @end menu
  484. @node assumptions
  485. @section Assumptions this Tutorial Makes
  486. This chapter is paced to allow beginners to learn about @command{tar}
  487. slowly. At the same time, we will try to cover all the basic aspects of
  488. these three operations. In order to accomplish both of these tasks, we
  489. have made certain assumptions about your knowledge before reading this
  490. manual, and the hardware you will be using:
  491. @itemize @bullet
  492. @item
  493. Before you start to work through this tutorial, you should understand
  494. what the terms ``archive'' and ``archive member'' mean
  495. (@pxref{Definitions}). In addition, you should understand something
  496. about how Unix-type operating systems work, and you should know how to
  497. use some basic utilities. For example, you should know how to create,
  498. list, copy, rename, edit, and delete files and directories; how to
  499. change between directories; and how to figure out where you are in the
  500. file system. You should have some basic understanding of directory
  501. structure and how files are named according to which directory they are
  502. in. You should understand concepts such as standard output and standard
  503. input, what various definitions of the term ``argument'' mean, and the
  504. differences between relative and absolute path names. @FIXME{and what
  505. else?}
  506. @item
  507. This manual assumes that you are working from your own home directory
  508. (unless we state otherwise). In this tutorial, you will create a
  509. directory to practice @command{tar} commands in. When we show path names,
  510. we will assume that those paths are relative to your home directory.
  511. For example, my home directory path is @file{/home/fsf/melissa}. All of
  512. my examples are in a subdirectory of the directory named by that path
  513. name; the subdirectory is called @file{practice}.
  514. @item
  515. In general, we show examples of archives which exist on (or can be
  516. written to, or worked with from) a directory on a hard disk. In most
  517. cases, you could write those archives to, or work with them on any other
  518. device, such as a tape drive. However, some of the later examples in
  519. the tutorial and next chapter will not work on tape drives.
  520. Additionally, working with tapes is much more complicated than working
  521. with hard disks. For these reasons, the tutorial does not cover working
  522. with tape drives. @xref{Media}, for complete information on using
  523. @command{tar} archives with tape drives.
  524. @FIXME{this is a cop out. need to add some simple tape drive info.}
  525. @end itemize
  526. @node stylistic conventions
  527. @section Stylistic Conventions
  528. In the examples, @samp{$} represents a typical shell prompt. It
  529. precedes lines you should type; to make this more clear, those lines are
  530. shown in @kbd{this font}, as opposed to lines which represent the
  531. computer's response; those lines are shown in @code{this font}, or
  532. sometimes @samp{like this}.
  533. @c When we have lines which are too long to be
  534. @c displayed in any other way, we will show them like this:
  535. @node basic tar options
  536. @section Basic @command{tar} Operations and Options
  537. @command{tar} can take a wide variety of arguments which specify and define
  538. the actions it will have on the particular set of files or the archive.
  539. The main types of arguments to @command{tar} fall into one of two classes:
  540. operations, and options.
  541. Some arguments fall into a class called @dfn{operations}; exactly one of
  542. these is both allowed and required for any instance of using @command{tar};
  543. you may @emph{not} specify more than one. People sometimes speak of
  544. @dfn{operating modes}. You are in a particular operating mode when you
  545. have specified the operation which specifies it; there are eight
  546. operations in total, and thus there are eight operating modes.
  547. The other arguments fall into the class known as @dfn{options}. You are
  548. not required to specify any options, and you are allowed to specify more
  549. than one at a time (depending on the way you are using @command{tar} at
  550. that time). Some options are used so frequently, and are so useful for
  551. helping you type commands more carefully that they are effectively
  552. ``required''. We will discuss them in this chapter.
  553. You can write most of the @command{tar} operations and options in any
  554. of three forms: long (mnemonic) form, short form, and old style. Some
  555. of the operations and options have no short or ``old'' forms; however,
  556. the operations and options which we will cover in this tutorial have
  557. corresponding abbreviations. @FIXME{make sure this is still the case,
  558. at the end}We will indicate those abbreviations appropriately to get
  559. you used to seeing them. (Note that the ``old style'' option forms
  560. exist in @GNUTAR{} for compatibility with Unix
  561. @command{tar}. In this book we present a full discussion of this way
  562. of writing options and operations (@pxref{Old Options}), and we discuss
  563. the other two styles of writing options (@xref{Mnemonic Options}, and
  564. @pxref{Short Options}).
  565. In the examples and in the text of this tutorial, we usually use the
  566. long forms of operations and options; but the ``short'' forms produce
  567. the same result and can make typing long @command{tar} commands easier.
  568. For example, instead of typing
  569. @smallexample
  570. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  571. @end smallexample
  572. @noindent
  573. you can type
  574. @smallexample
  575. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  576. @end smallexample
  577. @noindent
  578. or even
  579. @smallexample
  580. @kbd{tar -cvf afiles.tar apple angst aspic}
  581. @end smallexample
  582. @noindent
  583. For more information on option syntax, see @ref{Advanced tar}. In
  584. discussions in the text, when we name an option by its long form, we
  585. also give the corresponding short option in parentheses.
  586. The term, ``option'', can be confusing at times, since ``operations''
  587. are often lumped in with the actual, @emph{optional} ``options'' in certain
  588. general class statements. For example, we just talked about ``short and
  589. long forms of options and operations''. However, experienced @command{tar}
  590. users often refer to these by shorthand terms such as, ``short and long
  591. options''. This term assumes that the ``operations'' are included, also.
  592. Context will help you determine which definition of ``options'' to use.
  593. Similarly, the term ``command'' can be confusing, as it is often used in
  594. two different ways. People sometimes refer to @command{tar} ``commands''.
  595. A @command{tar} @dfn{command} is the entire command line of user input
  596. which tells @command{tar} what to do --- including the operation, options,
  597. and any arguments (file names, pipes, other commands, etc). However,
  598. you will also sometimes hear the term ``the @command{tar} command''. When
  599. the word ``command'' is used specifically like this, a person is usually
  600. referring to the @command{tar} @emph{operation}, not the whole line.
  601. Again, use context to figure out which of the meanings the speaker
  602. intends.
  603. @node frequent operations
  604. @section The Three Most Frequently Used Operations
  605. Here are the three most frequently used operations (both short and long
  606. forms), as well as a brief description of their meanings. The rest of
  607. this chapter will cover how to use these operations in detail. We will
  608. present the rest of the operations in the next chapter.
  609. @table @option
  610. @item --create
  611. @itemx -c
  612. Create a new @command{tar} archive.
  613. @item --list
  614. @itemx -t
  615. List the contents of an archive.
  616. @item --extract
  617. @itemx -x
  618. Extract one or more members from an archive.
  619. @end table
  620. @node Two Frequent Options
  621. @section Two Frequently Used Options
  622. To understand how to run @command{tar} in the three operating modes listed
  623. previously, you also need to understand how to use two of the options to
  624. @command{tar}: @option{--file} (which takes an archive file as an argument)
  625. and @option{--verbose}. (You are usually not @emph{required} to specify
  626. either of these options when you run @command{tar}, but they can be very
  627. useful in making things more clear and helping you avoid errors.)
  628. @menu
  629. * file tutorial::
  630. * verbose tutorial::
  631. * help tutorial::
  632. @end menu
  633. @node file tutorial
  634. @unnumberedsubsec The @option{--file} Option
  635. @table @option
  636. @opindex file, tutorial
  637. @item --file=@var{archive-name}
  638. @itemx -f @var{archive-name}
  639. Specify the name of an archive file.
  640. @end table
  641. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  642. use @command{tar}; this option determines the name of the archive file
  643. that @command{tar} will work on.
  644. @vrindex TAPE
  645. If you don't specify this argument, then @command{tar} will examine
  646. the environment variable @env{TAPE}. If it is set, its value will be
  647. used as the archive name. Otherwise, @command{tar} will use the
  648. default archive, determined at the compile time. Usually it is
  649. standard output or some physical tape drive attached to your machine
  650. (you can verify what the default is by running @kbd{tar
  651. --show-defaults}, @pxref{defaults}). If there is no tape drive
  652. attached, or the default is not meaningful, then @command{tar} will
  653. print an error message. The error message might look roughly like one
  654. of the following:
  655. @smallexample
  656. tar: can't open /dev/rmt8 : No such device or address
  657. tar: can't open /dev/rsmt0 : I/O error
  658. @end smallexample
  659. @noindent
  660. To avoid confusion, we recommend that you always specify an archive file
  661. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  662. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  663. @ref{file}.
  664. @node verbose tutorial
  665. @unnumberedsubsec The @option{--verbose} Option
  666. @table @option
  667. @opindex verbose, introduced
  668. @item --verbose
  669. @itemx -v
  670. Show the files being worked on as @command{tar} is running.
  671. @end table
  672. @option{--verbose} (@option{-v}) shows details about the results of running
  673. @command{tar}. This can be especially useful when the results might not be
  674. obvious. For example, if you want to see the progress of @command{tar} as
  675. it writes files into the archive, you can use the @option{--verbose}
  676. option. In the beginning, you may find it useful to use
  677. @option{--verbose} at all times; when you are more accustomed to
  678. @command{tar}, you will likely want to use it at certain times but not at
  679. others. We will use @option{--verbose} at times to help make something
  680. clear, and we will give many examples both using and not using
  681. @option{--verbose} to show the differences.
  682. Sometimes, a single instance of @option{--verbose} on the command line
  683. will show a full, @samp{ls} style listing of an archive or files,
  684. giving sizes, owners, and similar information. @FIXME{Describe the
  685. exact output format, e.g., how hard links are displayed.}
  686. Other times, @option{--verbose} will only show files or members that the particular
  687. operation is operating on at the time. In the latter case, you can
  688. use @option{--verbose} twice in a command to get a listing such as that
  689. in the former case. For example, instead of saying
  690. @smallexample
  691. @kbd{tar -cvf afiles.tar apple angst aspic}
  692. @end smallexample
  693. @noindent
  694. above, you might say
  695. @smallexample
  696. @kbd{tar -cvvf afiles.tar apple angst aspic}
  697. @end smallexample
  698. @noindent
  699. This works equally well using short or long forms of options. Using
  700. long forms, you would simply write out the mnemonic form of the option
  701. twice, like this:
  702. @smallexample
  703. $ @kbd{tar --create --verbose --verbose @dots{}}
  704. @end smallexample
  705. @noindent
  706. Note that you must double the hyphens properly each time.
  707. Later in the tutorial, we will give examples using @w{@option{--verbose
  708. --verbose}}.
  709. @node help tutorial
  710. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  711. @table @option
  712. @opindex help
  713. @item --help
  714. The @option{--help} option to @command{tar} prints out a very brief list of
  715. all operations and option available for the current version of
  716. @command{tar} available on your system.
  717. @end table
  718. @node create
  719. @section How to Create Archives
  720. @UNREVISED
  721. @cindex Creation of the archive
  722. @cindex Archive, creation of
  723. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  724. you use to create a @command{tar} archive. We will explain
  725. @option{--create} first because, in order to learn about the other
  726. operations, you will find it useful to have an archive available to
  727. practice on.
  728. To make this easier, in this section you will first create a directory
  729. containing three files. Then, we will show you how to create an
  730. @emph{archive} (inside the new directory). Both the directory, and
  731. the archive are specifically for you to practice on. The rest of this
  732. chapter and the next chapter will show many examples using this
  733. directory and the files you will create: some of those files may be
  734. other directories and other archives.
  735. The three files you will archive in this example are called
  736. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  737. @file{collection.tar}.
  738. This section will proceed slowly, detailing how to use @option{--create}
  739. in @code{verbose} mode, and showing examples using both short and long
  740. forms. In the rest of the tutorial, and in the examples in the next
  741. chapter, we will proceed at a slightly quicker pace. This section
  742. moves more slowly to allow beginning users to understand how
  743. @command{tar} works.
  744. @menu
  745. * prepare for examples::
  746. * Creating the archive::
  747. * create verbose::
  748. * short create::
  749. * create dir::
  750. @end menu
  751. @node prepare for examples
  752. @subsection Preparing a Practice Directory for Examples
  753. To follow along with this and future examples, create a new directory
  754. called @file{practice} containing files called @file{blues}, @file{folk}
  755. and @file{jazz}. The files can contain any information you like:
  756. ideally, they should contain information which relates to their names,
  757. and be of different lengths. Our examples assume that @file{practice}
  758. is a subdirectory of your home directory.
  759. Now @command{cd} to the directory named @file{practice}; @file{practice}
  760. is now your @dfn{working directory}. (@emph{Please note}: Although
  761. the full path name of this directory is
  762. @file{/@var{homedir}/practice}, in our examples we will refer to
  763. this directory as @file{practice}; the @var{homedir} is presumed.
  764. In general, you should check that the files to be archived exist where
  765. you think they do (in the working directory) by running @command{ls}.
  766. Because you just created the directory and the files and have changed to
  767. that directory, you probably don't need to do that this time.
  768. It is very important to make sure there isn't already a file in the
  769. working directory with the archive name you intend to use (in this case,
  770. @samp{collection.tar}), or that you don't care about its contents.
  771. Whenever you use @samp{create}, @command{tar} will erase the current
  772. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  773. will not tell you if you are about to overwrite an archive unless you
  774. specify an option which does this (@pxref{backup}, for the
  775. information on how to do so). To add files to an existing archive,
  776. you need to use a different option, such as @option{--append} (@option{-r}); see
  777. @ref{append} for information on how to do this.
  778. @node Creating the archive
  779. @subsection Creating the Archive
  780. @opindex create, introduced
  781. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  782. archive named @file{collection.tar}, use the following command:
  783. @smallexample
  784. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  785. @end smallexample
  786. The order of the arguments is not very important, @emph{when using long
  787. option forms}. You could also say:
  788. @smallexample
  789. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  790. @end smallexample
  791. @noindent
  792. However, you can see that this order is harder to understand; this is
  793. why we will list the arguments in the order that makes the commands
  794. easiest to understand (and we encourage you to do the same when you use
  795. @command{tar}, to avoid errors).
  796. Note that the part of the command which says,
  797. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  798. If you substituted any other string of characters for
  799. @kbd{collection.tar}, then that string would become the name of the
  800. archive file you create.
  801. The order of the options becomes more important when you begin to use
  802. short forms. With short forms, if you type commands in the wrong order
  803. (even if you type them correctly in all other ways), you may end up with
  804. results you don't expect. For this reason, it is a good idea to get
  805. into the habit of typing options in the order that makes inherent sense.
  806. @xref{short create}, for more information on this.
  807. In this example, you type the command as shown above: @option{--create}
  808. is the operation which creates the new archive
  809. (@file{collection.tar}), and @option{--file} is the option which lets
  810. you give it the name you chose. The files, @file{blues}, @file{folk},
  811. and @file{jazz}, are now members of the archive, @file{collection.tar}
  812. (they are @dfn{file name arguments} to the @option{--create} operation).
  813. @FIXME{xref here to the discussion of file name args?}Now that they are
  814. in the archive, they are called @emph{archive members}, not files.
  815. (@pxref{Definitions,members}).
  816. When you create an archive, you @emph{must} specify which files you
  817. want placed in the archive. If you do not specify any archive
  818. members, @GNUTAR{} will complain.
  819. If you now list the contents of the working directory (@command{ls}), you will
  820. find the archive file listed as well as the files you saw previously:
  821. @smallexample
  822. blues folk jazz collection.tar
  823. @end smallexample
  824. @noindent
  825. Creating the archive @samp{collection.tar} did not destroy the copies of
  826. the files in the directory.
  827. Keep in mind that if you don't indicate an operation, @command{tar} will not
  828. run and will prompt you for one. If you don't name any files, @command{tar}
  829. will complain. You must have write access to the working directory,
  830. or else you will not be able to create an archive in that directory.
  831. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  832. an existing archive; it will delete the archive and write a new one.
  833. Use @option{--append} (@option{-r}) instead. @xref{append}.
  834. @node create verbose
  835. @subsection Running @option{--create} with @option{--verbose}
  836. @opindex create, using with @option{--verbose}
  837. @opindex verbose, using with @option{--create}
  838. If you include the @option{--verbose} (@option{-v}) option on the command line,
  839. @command{tar} will list the files it is acting on as it is working. In
  840. verbose mode, the @code{create} example above would appear as:
  841. @smallexample
  842. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  843. blues
  844. folk
  845. jazz
  846. @end smallexample
  847. This example is just like the example we showed which did not use
  848. @option{--verbose}, except that @command{tar} generated the remaining lines
  849. @iftex
  850. (note the different font styles).
  851. @end iftex
  852. @ifinfo
  853. .
  854. @end ifinfo
  855. In the rest of the examples in this chapter, we will frequently use
  856. @code{verbose} mode so we can show actions or @command{tar} responses that
  857. you would otherwise not see, and which are important for you to
  858. understand.
  859. @node short create
  860. @subsection Short Forms with @samp{create}
  861. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  862. basic uses of @command{tar}, and you will use it countless times.
  863. Eventually, you will probably want to use abbreviated (or ``short'')
  864. forms of options. A full discussion of the three different forms that
  865. options can take appears in @ref{Styles}; for now, here is what the
  866. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  867. using short option forms:
  868. @smallexample
  869. $ @kbd{tar -cvf collection.tar blues folk jazz}
  870. blues
  871. folk
  872. jazz
  873. @end smallexample
  874. @noindent
  875. As you can see, the system responds the same no matter whether you use
  876. long or short option forms.
  877. @FIXME{i don't like how this is worded:} One difference between using
  878. short and long option forms is that, although the exact placement of
  879. arguments following options is no more specific when using short forms,
  880. it is easier to become confused and make a mistake when using short
  881. forms. For example, suppose you attempted the above example in the
  882. following way:
  883. @smallexample
  884. $ @kbd{tar -cfv collection.tar blues folk jazz}
  885. @end smallexample
  886. @noindent
  887. In this case, @command{tar} will make an archive file called @file{v},
  888. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  889. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  890. is thus taken to be the chosen archive file name. @command{tar} will try
  891. to add a file called @file{collection.tar} to the @file{v} archive file;
  892. if the file @file{collection.tar} did not already exist, @command{tar} will
  893. report an error indicating that this file does not exist. If the file
  894. @file{collection.tar} does already exist (e.g., from a previous command
  895. you may have run), then @command{tar} will add this file to the archive.
  896. Because the @option{-v} option did not get registered, @command{tar} will not
  897. run under @samp{verbose} mode, and will not report its progress.
  898. The end result is that you may be quite confused about what happened,
  899. and possibly overwrite a file. To illustrate this further, we will show
  900. you how an example we showed previously would look using short forms.
  901. This example,
  902. @smallexample
  903. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  904. @end smallexample
  905. @noindent
  906. is confusing as it is. When shown using short forms, however, it
  907. becomes much more so:
  908. @smallexample
  909. $ @kbd{tar blues -c folk -f collection.tar jazz}
  910. @end smallexample
  911. @noindent
  912. It would be very easy to put the wrong string of characters
  913. immediately following the @option{-f}, but doing that could sacrifice
  914. valuable data.
  915. For this reason, we recommend that you pay very careful attention to
  916. the order of options and placement of file and archive names,
  917. especially when using short option forms. Not having the option name
  918. written out mnemonically can affect how well you remember which option
  919. does what, and therefore where different names have to be placed.
  920. @node create dir
  921. @subsection Archiving Directories
  922. @cindex Archiving Directories
  923. @cindex Directories, Archiving
  924. You can archive a directory by specifying its directory name as a
  925. file name argument to @command{tar}. The files in the directory will be
  926. archived relative to the working directory, and the directory will be
  927. re-created along with its contents when the archive is extracted.
  928. To archive a directory, first move to its superior directory. If you
  929. have followed the previous instructions in this tutorial, you should
  930. type:
  931. @smallexample
  932. $ @kbd{cd ..}
  933. $
  934. @end smallexample
  935. @noindent
  936. This will put you into the directory which contains @file{practice},
  937. i.e., your home directory. Once in the superior directory, you can
  938. specify the subdirectory, @file{practice}, as a file name argument. To
  939. store @file{practice} in the new archive file @file{music.tar}, type:
  940. @smallexample
  941. $ @kbd{tar --create --verbose --file=music.tar practice}
  942. @end smallexample
  943. @noindent
  944. @command{tar} should output:
  945. @smallexample
  946. practice/
  947. practice/blues
  948. practice/folk
  949. practice/jazz
  950. practice/collection.tar
  951. @end smallexample
  952. Note that the archive thus created is not in the subdirectory
  953. @file{practice}, but rather in the current working directory---the
  954. directory from which @command{tar} was invoked. Before trying to archive a
  955. directory from its superior directory, you should make sure you have
  956. write access to the superior directory itself, not only the directory
  957. you are trying archive with @command{tar}. For example, you will probably
  958. not be able to store your home directory in an archive by invoking
  959. @command{tar} from the root directory; @xref{absolute}. (Note
  960. also that @file{collection.tar}, the original archive file, has itself
  961. been archived. @command{tar} will accept any file as a file to be
  962. archived, regardless of its content. When @file{music.tar} is
  963. extracted, the archive file @file{collection.tar} will be re-written
  964. into the file system).
  965. If you give @command{tar} a command such as
  966. @smallexample
  967. $ @kbd{tar --create --file=foo.tar .}
  968. @end smallexample
  969. @noindent
  970. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  971. dumped}. This happens because @command{tar} creates the archive
  972. @file{foo.tar} in the current directory before putting any files into
  973. it. Then, when @command{tar} attempts to add all the files in the
  974. directory @file{.} to the archive, it notices that the file
  975. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  976. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  977. will continue in this case, and create the archive
  978. normally, except for the exclusion of that one file. (@emph{Please
  979. note:} Other versions of @command{tar} are not so clever; they will
  980. enter an infinite loop when this happens, so you should not depend on
  981. this behavior unless you are certain you are running @GNUTAR{}.)
  982. @FIXME{bob doesn't like this sentence, since he does
  983. it all the time, and we've been doing it in the editing passes for
  984. this manual: In general, make sure that the archive is not inside a
  985. directory being dumped.}
  986. @node list
  987. @section How to List Archives
  988. @opindex list
  989. Frequently, you will find yourself wanting to determine exactly what a
  990. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  991. to get the member names as they currently appear in the archive, as well
  992. as various attributes of the files at the time they were archived. For
  993. example, you can examine the archive @file{collection.tar} that you
  994. created in the last section with the command,
  995. @smallexample
  996. $ @kbd{tar --list --file=collection.tar}
  997. @end smallexample
  998. @noindent
  999. The output of @command{tar} would then be:
  1000. @smallexample
  1001. blues
  1002. folk
  1003. jazz
  1004. @end smallexample
  1005. @FIXME{we hope this will change. if it doesn't, need to show the
  1006. creation of bfiles somewhere above!!! : }
  1007. @noindent
  1008. The archive @file{bfiles.tar} would list as follows:
  1009. @smallexample
  1010. ./birds
  1011. baboon
  1012. ./box
  1013. @end smallexample
  1014. @noindent
  1015. Be sure to use a @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option just as with @option{--create} (@option{-c})
  1016. to specify the name of the archive.
  1017. @opindex list, using with @option{--verbose}
  1018. @opindex verbose, using with @option{--list}
  1019. If you use the @option{--verbose} (@option{-v}) option with @option{--list}, then
  1020. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1021. showing owner, file size, and so forth.
  1022. If you had used @option{--verbose} (@option{-v}) mode, the example above would look
  1023. like:
  1024. @smallexample
  1025. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1026. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1027. @end smallexample
  1028. @cindex listing member and file names
  1029. @anchor{listing member and file names}
  1030. It is important to notice that the output of @kbd{tar --list
  1031. --verbose} does not necessarily match that produced by @kbd{tar
  1032. --create --verbose} while creating the archive. It is because
  1033. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1034. prefixes from file names before storing them in the archive
  1035. (@xref{absolute}, for more information). In other
  1036. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1037. an archive and @dfn{member names} when listing it. Consider this
  1038. example:
  1039. @smallexample
  1040. @group
  1041. $ @kbd{tar cfv archive /etc/mail}
  1042. tar: Removing leading `/' from member names
  1043. /etc/mail/
  1044. /etc/mail/sendmail.cf
  1045. /etc/mail/aliases
  1046. $ @kbd{tar tf archive}
  1047. etc/mail/
  1048. etc/mail/sendmail.cf
  1049. etc/mail/aliases
  1050. @end group
  1051. @end smallexample
  1052. @opindex show-stored-names
  1053. This default behavior can sometimes be inconvenient. You can force
  1054. @GNUTAR{} show member names when creating archive by supplying
  1055. @option{--show-stored-names} option.
  1056. @table @option
  1057. @item --show-stored-names
  1058. Print member (not @emph{file}) names when creating the archive.
  1059. @end table
  1060. @cindex File name arguments, using @option{--list} with
  1061. @opindex list, using with file name arguments
  1062. You can specify one or more individual member names as arguments when
  1063. using @samp{list}. In this case, @command{tar} will only list the
  1064. names of members you identify. For example, @w{@kbd{tar --list
  1065. --file=afiles.tar apple}} would only print @file{apple}.
  1066. @FIXME{we hope the relevant aspects of this will change:}Because
  1067. @command{tar} preserves paths, file names must be specified as they appear
  1068. in the archive (ie., relative to the directory from which the archive
  1069. was created). Therefore, it is essential when specifying member names
  1070. to @command{tar} that you give the exact member names. For example,
  1071. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1072. something like @samp{tar: birds: Not found in archive}, because there is
  1073. no member named @file{birds}, only one named @file{./birds}. While the
  1074. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1075. names are compared using a simplistic name comparison, in which an exact
  1076. match is necessary. @xref{absolute}.
  1077. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1078. with @file{folk}, because @file{folk} is in the archive file
  1079. @file{collection.tar}. If you are not sure of the exact file name, try
  1080. listing all the files in the archive and searching for the one you
  1081. expect to find; remember that if you use @option{--list} with no file
  1082. names as arguments, @command{tar} will print the names of all the members
  1083. stored in the specified archive.
  1084. @menu
  1085. * list dir::
  1086. @end menu
  1087. @node list dir
  1088. @unnumberedsubsec Listing the Contents of a Stored Directory
  1089. To get information about the contents of an archived directory,
  1090. use the directory name as a file name argument in conjunction with
  1091. @option{--list} (@option{-t}). To find out file attributes, include the
  1092. @option{--verbose} (@option{-v}) option.
  1093. For example, to find out about files in the directory @file{practice}, in
  1094. the archive file @file{music.tar}, type:
  1095. @smallexample
  1096. $ @kbd{tar --list --verbose --file=music.tar practice}
  1097. @end smallexample
  1098. @command{tar} responds:
  1099. @smallexample
  1100. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1101. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1102. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1103. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1104. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1105. @end smallexample
  1106. When you use a directory name as a file name argument, @command{tar} acts on
  1107. all the files (including sub-directories) in that directory.
  1108. @node extract
  1109. @section How to Extract Members from an Archive
  1110. @UNREVISED
  1111. @cindex Extraction
  1112. @cindex Retrieving files from an archive
  1113. @cindex Resurrecting files from an archive
  1114. @opindex extract
  1115. Creating an archive is only half the job---there is no point in storing
  1116. files in an archive if you can't retrieve them. The act of retrieving
  1117. members from an archive so they can be used and manipulated as
  1118. unarchived files again is called @dfn{extraction}. To extract files
  1119. from an archive, use the @option{--extract} (@option{--get} or
  1120. @option{-x}) operation. As with @option{--create}, specify the name
  1121. of the archive with @option{--file} (@option{-f}) option. Extracting
  1122. an archive does not modify the archive in any way; you can extract it
  1123. multiple times if you want or need to.
  1124. Using @option{--extract}, you can extract an entire archive, or specific
  1125. files. The files can be directories containing other files, or not. As
  1126. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1127. long form of the operation without affecting the performance.
  1128. @menu
  1129. * extracting archives::
  1130. * extracting files::
  1131. * extract dir::
  1132. * extracting untrusted archives::
  1133. * failing commands::
  1134. @end menu
  1135. @node extracting archives
  1136. @subsection Extracting an Entire Archive
  1137. To extract an entire archive, specify the archive file name only, with
  1138. no individual file names as arguments. For example,
  1139. @smallexample
  1140. $ @kbd{tar -xvf collection.tar}
  1141. @end smallexample
  1142. @noindent
  1143. produces this:
  1144. @smallexample
  1145. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1146. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1147. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1148. @end smallexample
  1149. @node extracting files
  1150. @subsection Extracting Specific Files
  1151. To extract specific archive members, give their exact member names as
  1152. arguments, as printed by @option{--list} (@option{-t}). If you had mistakenly deleted
  1153. one of the files you had placed in the archive @file{collection.tar}
  1154. earlier (say, @file{blues}), you can extract it from the archive without
  1155. changing the archive's structure. Its contents will be identical to the
  1156. original file @file{blues} that you deleted.
  1157. First, make sure you are in the @file{practice} directory, and list the
  1158. files in the directory. Now, delete the file, @samp{blues}, and list
  1159. the files in the directory again.
  1160. You can now extract the member @file{blues} from the archive file
  1161. @file{collection.tar} like this:
  1162. @smallexample
  1163. $ @kbd{tar --extract --file=collection.tar blues}
  1164. @end smallexample
  1165. @noindent
  1166. If you list the files in the directory again, you will see that the file
  1167. @file{blues} has been restored, with its original permissions, data modification
  1168. times, and owner.@FIXME{This is only accidentally true, but not in
  1169. general. In most cases, one has to be root for restoring the owner, and
  1170. use a special option for restoring permissions. Here, it just happens
  1171. that the restoring user is also the owner of the archived members, and
  1172. that the current @code{umask} is compatible with original permissions.}
  1173. (These parameters will be identical to those which
  1174. the file had when you originally placed it in the archive; any changes
  1175. you may have made before deleting the file from the file system,
  1176. however, will @emph{not} have been made to the archive member.) The
  1177. archive file, @samp{collection.tar}, is the same as it was before you
  1178. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1179. @option{--list} (@option{-t}).
  1180. @FIXME{we hope this will change:}Remember that as with other operations,
  1181. specifying the exact member name is important. @w{@kbd{tar --extract
  1182. --file=bfiles.tar birds}} will fail, because there is no member named
  1183. @file{birds}. To extract the member named @file{./birds}, you must
  1184. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1185. exact member names of the members of an archive, use @option{--list} (@option{-t})
  1186. (@pxref{list}).
  1187. You can extract a file to standard output by combining the above options
  1188. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1189. Output}).
  1190. If you give the @option{--verbose} option, then @option{--extract}
  1191. will print the names of the archive members as it extracts them.
  1192. @node extract dir
  1193. @subsection Extracting Files that are Directories
  1194. Extracting directories which are members of an archive is similar to
  1195. extracting other files. The main difference to be aware of is that if
  1196. the extracted directory has the same name as any directory already in
  1197. the working directory, then files in the extracted directory will be
  1198. placed into the directory of the same name. Likewise, if there are
  1199. files in the pre-existing directory with the same names as the members
  1200. which you extract, the files from the extracted archive will replace
  1201. the files already in the working directory (and possible
  1202. subdirectories). This will happen regardless of whether or not the
  1203. files in the working directory were more recent than those extracted
  1204. (there exist, however, special options that alter this behavior
  1205. @pxref{Writing}).
  1206. However, if a file was stored with a directory name as part of its file
  1207. name, and that directory does not exist under the working directory when
  1208. the file is extracted, @command{tar} will create the directory.
  1209. We can demonstrate how to use @option{--extract} to extract a directory
  1210. file with an example. Change to the @file{practice} directory if you
  1211. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1212. go back to the parent directory and extract the archive
  1213. @file{music.tar}. You may either extract the entire archive, or you may
  1214. extract only the files you just deleted. To extract the entire archive,
  1215. don't give any file names as arguments after the archive name
  1216. @file{music.tar}. To extract only the files you deleted, use the
  1217. following command:
  1218. @smallexample
  1219. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1220. practice/folk
  1221. practice/jazz
  1222. @end smallexample
  1223. @noindent
  1224. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1225. would have displayed more detail about the extracted files, as shown
  1226. in the example below:
  1227. @smallexample
  1228. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1229. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1230. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1231. @end smallexample
  1232. @noindent
  1233. Because you created the directory with @file{practice} as part of the
  1234. file names of each of the files by archiving the @file{practice}
  1235. directory as @file{practice}, you must give @file{practice} as part
  1236. of the file names when you extract those files from the archive.
  1237. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1238. will be.}
  1239. @node extracting untrusted archives
  1240. @subsection Extracting Archives from Untrusted Sources
  1241. Extracting files from archives can overwrite files that already exist.
  1242. If you receive an archive from an untrusted source, you should make a
  1243. new directory and extract into that directory, so that you don't have
  1244. to worry about the extraction overwriting one of your existing files.
  1245. For example, if @file{untrusted.tar} came from somewhere else on the
  1246. Internet, and you don't necessarily trust its contents, you can
  1247. extract it as follows:
  1248. @smallexample
  1249. $ @kbd{mkdir newdir}
  1250. $ @kbd{cd newdir}
  1251. $ @kbd{tar -xvf ../untrusted.tar}
  1252. @end smallexample
  1253. It is also a good practice to examine contents of the archive
  1254. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1255. with @option{--verbose} (@option{-v}).
  1256. @node failing commands
  1257. @subsection Commands That Will Fail
  1258. Here are some sample commands you might try which will not work, and why
  1259. they won't work.
  1260. If you try to use this command,
  1261. @smallexample
  1262. $ @kbd{tar -xvf music.tar folk jazz}
  1263. @end smallexample
  1264. @noindent
  1265. you will get the following response:
  1266. @smallexample
  1267. tar: folk: Not found in archive
  1268. tar: jazz: Not found in archive
  1269. $
  1270. @end smallexample
  1271. @noindent
  1272. This is because these files were not originally @emph{in} the parent
  1273. directory @file{..}, where the archive is located; they were in the
  1274. @file{practice} directory, and their file names reflect this:
  1275. @smallexample
  1276. $ @kbd{tar -tvf music.tar}
  1277. practice/folk
  1278. practice/jazz
  1279. practice/rock
  1280. @end smallexample
  1281. @FIXME{make sure the above works when going through the examples in
  1282. order...}
  1283. @noindent
  1284. Likewise, if you try to use this command,
  1285. @smallexample
  1286. $ @kbd{tar -tvf music.tar folk jazz}
  1287. @end smallexample
  1288. @noindent
  1289. you would get a similar response. Members with those names are not in the
  1290. archive. You must use the correct member names in order to extract the
  1291. files from the archive.
  1292. If you have forgotten the correct names of the files in the archive,
  1293. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1294. @FIXME{more examples, here? hag thinks it's a good idea.}
  1295. @node going further
  1296. @section Going Further Ahead in this Manual
  1297. @FIXME{need to write up a node here about the things that are going to
  1298. be in the rest of the manual.}
  1299. @node tar invocation
  1300. @chapter Invoking @GNUTAR{}
  1301. @UNREVISED
  1302. This chapter is about how one invokes the @GNUTAR{}
  1303. command, from the command synopsis (@pxref{Synopsis}). There are
  1304. numerous options, and many styles for writing them. One mandatory
  1305. option specifies the operation @command{tar} should perform
  1306. (@pxref{Operation Summary}), other options are meant to detail how
  1307. this operation should be performed (@pxref{Option Summary}).
  1308. Non-option arguments are not always interpreted the same way,
  1309. depending on what the operation is.
  1310. You will find in this chapter everything about option styles and rules for
  1311. writing them (@pxref{Styles}). On the other hand, operations and options
  1312. are fully described elsewhere, in other chapters. Here, you will find
  1313. only synthetic descriptions for operations and options, together with
  1314. pointers to other parts of the @command{tar} manual.
  1315. Some options are so special they are fully described right in this
  1316. chapter. They have the effect of inhibiting the normal operation of
  1317. @command{tar} or else, they globally alter the amount of feedback the user
  1318. receives about what is going on. These are the @option{--help} and
  1319. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1320. and @option{--interactive} options (@pxref{interactive}).
  1321. @menu
  1322. * Synopsis::
  1323. * using tar options::
  1324. * Styles::
  1325. * All Options::
  1326. * help::
  1327. * defaults::
  1328. * verbose::
  1329. * interactive::
  1330. @end menu
  1331. @node Synopsis
  1332. @section General Synopsis of @command{tar}
  1333. The @GNUTAR{} program is invoked as either one of:
  1334. @smallexample
  1335. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1336. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1337. @end smallexample
  1338. The second form is for when old options are being used.
  1339. You can use @command{tar} to store files in an archive, to extract them from
  1340. an archive, and to do other types of archive manipulation. The primary
  1341. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1342. which action to take. The other arguments to @command{tar} are either
  1343. @dfn{options}, which change the way @command{tar} performs an operation,
  1344. or file names or archive members, which specify the files or members
  1345. @command{tar} is to act on.
  1346. You can actually type in arguments in any order, even if in this manual
  1347. the options always precede the other arguments, to make examples easier
  1348. to understand. Further, the option stating the main operation mode
  1349. (the @command{tar} main command) is usually given first.
  1350. Each @var{name} in the synopsis above is interpreted as an archive member
  1351. name when the main command is one of @option{--compare}
  1352. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1353. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1354. @option{--update} (@option{-u}). When naming archive members, you
  1355. must give the exact name of the member in the archive, as it is
  1356. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1357. @option{--create} (@option{-c}), these @var{name} arguments specify
  1358. the names of either files or directory hierarchies to place in the archive.
  1359. These files or hierarchies should already exist in the file system,
  1360. prior to the execution of the @command{tar} command.
  1361. @command{tar} interprets relative file names as being relative to the
  1362. working directory. @command{tar} will make all file names relative
  1363. (by removing leading slashes when archiving or restoring files),
  1364. unless you specify otherwise (using the @option{--absolute-names}
  1365. option). @xref{absolute}, for more information about
  1366. @option{--absolute-names}.
  1367. If you give the name of a directory as either a file name or a member
  1368. name, then @command{tar} acts recursively on all the files and directories
  1369. beneath that directory. For example, the name @file{/} identifies all
  1370. the files in the file system to @command{tar}.
  1371. The distinction between file names and archive member names is especially
  1372. important when shell globbing is used, and sometimes a source of confusion
  1373. for newcomers. @xref{Wildcards}, for more information about globbing.
  1374. The problem is that shells may only glob using existing files in the
  1375. file system. Only @command{tar} itself may glob on archive members, so when
  1376. needed, you must ensure that wildcard characters reach @command{tar} without
  1377. being interpreted by the shell first. Using a backslash before @samp{*}
  1378. or @samp{?}, or putting the whole argument between quotes, is usually
  1379. sufficient for this.
  1380. Even if @var{name}s are often specified on the command line, they
  1381. can also be read from a text file in the file system, using the
  1382. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1383. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1384. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1385. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1386. will usually yield a diagnostic and inhibit @command{tar} execution.
  1387. The other operations of @command{tar} (@option{--list},
  1388. @option{--extract}, @option{--compare}, and @option{--update})
  1389. will act on the entire contents of the archive.
  1390. @cindex exit status
  1391. @cindex return status
  1392. Besides successful exits, @GNUTAR{} may fail for
  1393. many reasons. Some reasons correspond to bad usage, that is, when the
  1394. @command{tar} command is improperly written. Errors may be
  1395. encountered later, while encountering an error processing the archive
  1396. or the files. Some errors are recoverable, in which case the failure
  1397. is delayed until @command{tar} has completed all its work. Some
  1398. errors are such that it would not meaningful, or at least risky, to
  1399. continue processing: @command{tar} then aborts processing immediately.
  1400. All abnormal exits, whether immediate or delayed, should always be
  1401. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1402. the error.
  1403. @GNUTAR{} returns only a few exit statuses. I'm really
  1404. aiming simplicity in that area, for now. If you are not using the
  1405. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1406. that everything went well, besides maybe innocuous warnings. Nonzero
  1407. means that something went wrong. Right now, as of today, ``nonzero''
  1408. is almost always 2, except for remote operations, where it may be
  1409. 128.
  1410. @node using tar options
  1411. @section Using @command{tar} Options
  1412. @GNUTAR{} has a total of eight operating modes which
  1413. allow you to perform a variety of tasks. You are required to choose
  1414. one operating mode each time you employ the @command{tar} program by
  1415. specifying one, and only one operation as an argument to the
  1416. @command{tar} command (two lists of four operations each may be found
  1417. at @ref{frequent operations} and @ref{Operations}). Depending on
  1418. circumstances, you may also wish to customize how the chosen operating
  1419. mode behaves. For example, you may wish to change the way the output
  1420. looks, or the format of the files that you wish to archive may require
  1421. you to do something special in order to make the archive look right.
  1422. You can customize and control @command{tar}'s performance by running
  1423. @command{tar} with one or more options (such as @option{--verbose}
  1424. (@option{-v}), which we used in the tutorial). As we said in the
  1425. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1426. their name suggests) optional. Depending on the operating mode, you
  1427. may specify one or more options. Different options will have different
  1428. effects, but in general they all change details of the operation, such
  1429. as archive format, archive name, or level of user interaction. Some
  1430. options make sense with all operating modes, while others are
  1431. meaningful only with particular modes. You will likely use some
  1432. options frequently, while you will only use others infrequently, or
  1433. not at all. (A full list of options is available in @pxref{All Options}.)
  1434. @vrindex TAR_OPTIONS, environment variable
  1435. @anchor{TAR_OPTIONS}
  1436. The @env{TAR_OPTIONS} environment variable specifies default options to
  1437. be placed in front of any explicit options. For example, if
  1438. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1439. if the two options @option{-v} and @option{--unlink-first} had been
  1440. specified before any explicit options. Option specifications are
  1441. separated by whitespace. A backslash escapes the next character, so it
  1442. can be used to specify an option containing whitespace or a backslash.
  1443. Note that @command{tar} options are case sensitive. For example, the
  1444. options @option{-T} and @option{-t} are different; the first requires an
  1445. argument for stating the name of a file providing a list of @var{name}s,
  1446. while the second does not require an argument and is another way to
  1447. write @option{--list} (@option{-t}).
  1448. In addition to the eight operations, there are many options to
  1449. @command{tar}, and three different styles for writing both: long (mnemonic)
  1450. form, short form, and old style. These styles are discussed below.
  1451. Both the options and the operations can be written in any of these three
  1452. styles.
  1453. @FIXME{menu at end of this node. need to think of an actual outline
  1454. for this chapter; probably do that after stuff from chapter 4 is
  1455. incorporated.}
  1456. @node Styles
  1457. @section The Three Option Styles
  1458. There are three styles for writing operations and options to the command
  1459. line invoking @command{tar}. The different styles were developed at
  1460. different times during the history of @command{tar}. These styles will be
  1461. presented below, from the most recent to the oldest.
  1462. Some options must take an argument. (For example, @option{--file}
  1463. (@option{-f})) takes the name of an archive file as an argument. If
  1464. you do not supply an archive file name, @command{tar} will use a
  1465. default, but this can be confusing; thus, we recommend that you always
  1466. supply a specific archive file name.) Where you @emph{place} the
  1467. arguments generally depends on which style of options you choose. We
  1468. will detail specific information relevant to each option style in the
  1469. sections on the different option styles, below. The differences are
  1470. subtle, yet can often be very important; incorrect option placement
  1471. can cause you to overwrite a number of important files. We urge you
  1472. to note these differences, and only use the option style(s) which
  1473. makes the most sense to you until you feel comfortable with the others.
  1474. Some options @emph{may} take an argument (currently, there are
  1475. two such options: @option{--backup} and @option{--occurrence}). Such
  1476. options may have at most long and short forms, they do not have old style
  1477. equivalent. The rules for specifying an argument for such options
  1478. are stricter than those for specifying mandatory arguments. Please,
  1479. pay special attention to them.
  1480. @menu
  1481. * Mnemonic Options:: Mnemonic Option Style
  1482. * Short Options:: Short Option Style
  1483. * Old Options:: Old Option Style
  1484. * Mixing:: Mixing Option Styles
  1485. @end menu
  1486. @node Mnemonic Options
  1487. @subsection Mnemonic Option Style
  1488. @FIXME{have to decide whether or not to replace other occurrences of
  1489. "mnemonic" with "long", or *ugh* vice versa.}
  1490. Each option has at least one long (or mnemonic) name starting with two
  1491. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1492. their corresponding short or old names. It sometimes happens that a
  1493. single mnemonic option has many different different names which are
  1494. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1495. long option names can be given unique abbreviations. For example,
  1496. @option{--cre} can be used in place of @option{--create} because there is no
  1497. other mnemonic option which begins with @samp{cre}. (One way to find
  1498. this out is by trying it and seeing what happens; if a particular
  1499. abbreviation could represent more than one option, @command{tar} will tell
  1500. you that that abbreviation is ambiguous and you'll know that that
  1501. abbreviation won't work. You may also choose to run @samp{tar --help}
  1502. to see a list of options. Be aware that if you run @command{tar} with a
  1503. unique abbreviation for the long name of an option you didn't want to
  1504. use, you are stuck; @command{tar} will perform the command as ordered.)
  1505. Mnemonic options are meant to be obvious and easy to remember, and their
  1506. meanings are generally easier to discern than those of their
  1507. corresponding short options (see below). For example:
  1508. @smallexample
  1509. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1510. @end smallexample
  1511. @noindent
  1512. gives a fairly good set of hints about what the command does, even
  1513. for those not fully acquainted with @command{tar}.
  1514. Mnemonic options which require arguments take those arguments
  1515. immediately following the option name. There are two ways of
  1516. specifying a mandatory argument. It can be separated from the
  1517. option name either by an equal sign, or by any amount of
  1518. white space characters. For example, the @option{--file} option (which
  1519. tells the name of the @command{tar} archive) is given a file such as
  1520. @file{archive.tar} as argument by using any of the following notations:
  1521. @option{--file=archive.tar} or @option{--file archive.tar}.
  1522. In contrast, optional arguments must always be introduced using
  1523. an equal sign. For example, the @option{--backup} option takes
  1524. an optional argument specifying backup type. It must be used
  1525. as @option{--backup=@var{backup-type}}.
  1526. @node Short Options
  1527. @subsection Short Option Style
  1528. Most options also have a short option name. Short options start with
  1529. a single dash, and are followed by a single character, e.g., @option{-t}
  1530. (which is equivalent to @option{--list}). The forms are absolutely
  1531. identical in function; they are interchangeable.
  1532. The short option names are faster to type than long option names.
  1533. Short options which require arguments take their arguments immediately
  1534. following the option, usually separated by white space. It is also
  1535. possible to stick the argument right after the short option name, using
  1536. no intervening space. For example, you might write @w{@option{-f
  1537. archive.tar}} or @option{-farchive.tar} instead of using
  1538. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1539. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1540. specific archive, here named @file{archive.tar}.
  1541. Short options which take optional arguments take their arguments
  1542. immediately following the option letter, @emph{without any intervening
  1543. white space characters}.
  1544. Short options' letters may be clumped together, but you are not
  1545. required to do this (as compared to old options; see below). When
  1546. short options are clumped as a set, use one (single) dash for them
  1547. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1548. such a set is allowed to have an argument@footnote{Clustering many
  1549. options, the last of which has an argument, is a rather opaque way to
  1550. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1551. even be made helpful enough for considering such usages as invalid.}.
  1552. When the options are separated, the argument for each option which requires
  1553. an argument directly follows that option, as is usual for Unix programs.
  1554. For example:
  1555. @smallexample
  1556. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1557. @end smallexample
  1558. If you reorder short options' locations, be sure to move any arguments
  1559. that belong to them. If you do not move the arguments properly, you may
  1560. end up overwriting files.
  1561. @node Old Options
  1562. @subsection Old Option Style
  1563. @UNREVISED
  1564. Like short options, old options are single letters. However, old options
  1565. must be written together as a single clumped set, without spaces separating
  1566. them or dashes preceding them@footnote{Beware that if you precede options
  1567. with a dash, you are announcing the short option style instead of the
  1568. old option style; short options are decoded differently.}. This set
  1569. of letters must be the first to appear on the command line, after the
  1570. @command{tar} program name and some white space; old options cannot appear
  1571. anywhere else. The letter of an old option is exactly the same letter as
  1572. the corresponding short option. For example, the old option @samp{t} is
  1573. the same as the short option @option{-t}, and consequently, the same as the
  1574. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1575. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1576. @FIXME{bob suggests having an uglier example. :-) }
  1577. When options that need arguments are given together with the command,
  1578. all the associated arguments follow, in the same order as the options.
  1579. Thus, the example given previously could also be written in the old
  1580. style as follows:
  1581. @smallexample
  1582. $ @kbd{tar cvbf 20 /dev/rmt0}
  1583. @end smallexample
  1584. @noindent
  1585. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1586. the argument of @option{-f}.
  1587. On the other hand, this old style syntax makes it difficult to match
  1588. option letters with their corresponding arguments, and is often
  1589. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1590. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1591. argument for @option{-f}, and @option{-v} does not have a corresponding
  1592. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1593. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1594. pertain to.
  1595. If you want to reorder the letters in the old option argument, be
  1596. sure to reorder any corresponding argument appropriately.
  1597. This old way of writing @command{tar} options can surprise even experienced
  1598. users. For example, the two commands:
  1599. @smallexample
  1600. @kbd{tar cfz archive.tar.gz file}
  1601. @kbd{tar -cfz archive.tar.gz file}
  1602. @end smallexample
  1603. @noindent
  1604. are quite different. The first example uses @file{archive.tar.gz} as
  1605. the value for option @samp{f} and recognizes the option @samp{z}. The
  1606. second example, however, uses @file{z} as the value for option
  1607. @samp{f} --- probably not what was intended.
  1608. Old options are kept for compatibility with old versions of @command{tar}.
  1609. This second example could be corrected in many ways, among which the
  1610. following are equivalent:
  1611. @smallexample
  1612. @kbd{tar -czf archive.tar.gz file}
  1613. @kbd{tar -cf archive.tar.gz -z file}
  1614. @kbd{tar cf archive.tar.gz -z file}
  1615. @end smallexample
  1616. @FIXME{still could explain this better; it's redundant:}
  1617. @cindex option syntax, traditional
  1618. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1619. non-@acronym{GNU}, support old options. @GNUTAR{}
  1620. supports them not only for historical reasons, but also because many
  1621. people are used to them. For compatibility with Unix @command{tar},
  1622. the first argument is always treated as containing command and option
  1623. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1624. equivalent to @w{@samp{tar -c}:} both of them specify the
  1625. @option{--create} (@option{-c}) command to create an archive.
  1626. @node Mixing
  1627. @subsection Mixing Option Styles
  1628. All three styles may be intermixed in a single @command{tar} command,
  1629. so long as the rules for each style are fully
  1630. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1631. a bug prevented intermixing old style options with mnemonic options in
  1632. some cases.}. Old style options and either of the modern styles of
  1633. options may be mixed within a single @command{tar} command. However,
  1634. old style options must be introduced as the first arguments only,
  1635. following the rule for old options (old options must appear directly
  1636. after the @command{tar} command and some white space). Modern options
  1637. may be given only after all arguments to the old options have been
  1638. collected. If this rule is not respected, a modern option might be
  1639. falsely interpreted as the value of the argument to one of the old
  1640. style options.
  1641. For example, all the following commands are wholly equivalent, and
  1642. illustrate the many combinations and orderings of option styles.
  1643. @smallexample
  1644. @kbd{tar --create --file=archive.tar}
  1645. @kbd{tar --create -f archive.tar}
  1646. @kbd{tar --create -farchive.tar}
  1647. @kbd{tar --file=archive.tar --create}
  1648. @kbd{tar --file=archive.tar -c}
  1649. @kbd{tar -c --file=archive.tar}
  1650. @kbd{tar -c -f archive.tar}
  1651. @kbd{tar -c -farchive.tar}
  1652. @kbd{tar -cf archive.tar}
  1653. @kbd{tar -cfarchive.tar}
  1654. @kbd{tar -f archive.tar --create}
  1655. @kbd{tar -f archive.tar -c}
  1656. @kbd{tar -farchive.tar --create}
  1657. @kbd{tar -farchive.tar -c}
  1658. @kbd{tar c --file=archive.tar}
  1659. @kbd{tar c -f archive.tar}
  1660. @kbd{tar c -farchive.tar}
  1661. @kbd{tar cf archive.tar}
  1662. @kbd{tar f archive.tar --create}
  1663. @kbd{tar f archive.tar -c}
  1664. @kbd{tar fc archive.tar}
  1665. @end smallexample
  1666. On the other hand, the following commands are @emph{not} equivalent to
  1667. the previous set:
  1668. @smallexample
  1669. @kbd{tar -f -c archive.tar}
  1670. @kbd{tar -fc archive.tar}
  1671. @kbd{tar -fcarchive.tar}
  1672. @kbd{tar -farchive.tarc}
  1673. @kbd{tar cfarchive.tar}
  1674. @end smallexample
  1675. @noindent
  1676. These last examples mean something completely different from what the
  1677. user intended (judging based on the example in the previous set which
  1678. uses long options, whose intent is therefore very clear). The first
  1679. four specify that the @command{tar} archive would be a file named
  1680. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1681. respectively. The first two examples also specify a single non-option,
  1682. @var{name} argument having the value @samp{archive.tar}. The last
  1683. example contains only old style option letters (repeating option
  1684. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1685. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1686. the first sentence of this paragraph..}
  1687. @node All Options
  1688. @section All @command{tar} Options
  1689. The coming manual sections contain an alphabetical listing of all
  1690. @command{tar} operations and options, with brief descriptions and cross
  1691. references to more in-depth explanations in the body of the manual.
  1692. They also contain an alphabetically arranged table of the short option
  1693. forms with their corresponding long option. You can use this table as
  1694. a reference for deciphering @command{tar} commands in scripts.
  1695. @menu
  1696. * Operation Summary::
  1697. * Option Summary::
  1698. * Short Option Summary::
  1699. @end menu
  1700. @node Operation Summary
  1701. @subsection Operations
  1702. @table @option
  1703. @opindex append, summary
  1704. @item --append
  1705. @itemx -r
  1706. Appends files to the end of the archive. @xref{append}.
  1707. @opindex catenate, summary
  1708. @item --catenate
  1709. @itemx -A
  1710. Same as @option{--concatenate}. @xref{concatenate}.
  1711. @opindex compare, summary
  1712. @item --compare
  1713. @itemx -d
  1714. Compares archive members with their counterparts in the file
  1715. system, and reports differences in file size, mode, owner,
  1716. modification date and contents. @xref{compare}.
  1717. @opindex concatenate, summary
  1718. @item --concatenate
  1719. @itemx -A
  1720. Appends other @command{tar} archives to the end of the archive.
  1721. @xref{concatenate}.
  1722. @opindex create, summary
  1723. @item --create
  1724. @itemx -c
  1725. Creates a new @command{tar} archive. @xref{create}.
  1726. @opindex delete, summary
  1727. @item --delete
  1728. Deletes members from the archive. Don't try this on a archive on a
  1729. tape! @xref{delete}.
  1730. @opindex diff, summary
  1731. @item --diff
  1732. @itemx -d
  1733. Same @option{--compare}. @xref{compare}.
  1734. @opindex extract, summary
  1735. @item --extract
  1736. @itemx -x
  1737. Extracts members from the archive into the file system. @xref{extract}.
  1738. @opindex get, summary
  1739. @item --get
  1740. @itemx -x
  1741. Same as @option{--extract}. @xref{extract}.
  1742. @opindex list, summary
  1743. @item --list
  1744. @itemx -t
  1745. Lists the members in an archive. @xref{list}.
  1746. @opindex update, summary
  1747. @item --update
  1748. @itemx -u
  1749. @FIXME{It was: A combination of the @option{--compare} and
  1750. @option{--append} operations. This is not true and rather misleading,
  1751. as @option{--compare} (@option{--diff}, @option{-d}) does a lot more than @option{--update} (@option{-u}) for
  1752. ensuring files are identical.} Adds files to the end of the archive,
  1753. but only if they are newer than their counterparts already in the
  1754. archive, or if they do not already exist in the archive.
  1755. @xref{update}.
  1756. @end table
  1757. @node Option Summary
  1758. @subsection @command{tar} Options
  1759. @table @option
  1760. @opindex absolute-names, summary
  1761. @item --absolute-names
  1762. @itemx -P
  1763. Normally when creating an archive, @command{tar} strips an initial
  1764. @samp{/} from member names. This option disables that behavior.
  1765. @xref{absolute}.
  1766. @opindex after-date, summary
  1767. @item --after-date
  1768. (See @option{--newer}, @pxref{after})
  1769. @opindex anchored, summary
  1770. @item --anchored
  1771. An exclude pattern must match an initial subsequence of the name's components.
  1772. @xref{controlling pattern-matching with exclude}.
  1773. @opindex atime-preserve, summary
  1774. @item --atime-preserve
  1775. @itemx --atime-preserve=replace
  1776. @itemx --atime-preserve=system
  1777. Attempt to preserve the access time of files when reading them. This
  1778. option currently is effective only on files that you own, unless you
  1779. have superuser privileges.
  1780. @option{--atime-preserve=replace} remembers the access time of a file
  1781. before reading it, and then restores the access time afterwards. This
  1782. may cause problems if other programs are reading the file at the same
  1783. time, as the times of their accesses will be lost. On most platforms
  1784. restoring the access time also requires @command{tar} to restore the
  1785. data modification time too, so this option may also cause problems if
  1786. other programs are writing the file at the same time. (Tar attempts
  1787. to detect this situation, but cannot do so reliably due to race
  1788. conditions.) Worse, on most platforms restoring the access time also
  1789. updates the status change time, which means that this option is
  1790. incompatible with incremental backups.
  1791. @option{--atime-preserve=system} avoids changing time stamps on files,
  1792. without interfering with time stamp updates
  1793. caused by other programs, so it works better with incremental backups.
  1794. However, it requires a special @code{O_NOATIME} option from the
  1795. underlying operating and file system implementation, and it also requires
  1796. that searching directories does not update their access times. As of
  1797. this writing (November 2005) this works only with Linux, and only with
  1798. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1799. way to know whether this feature actually works. Sometimes
  1800. @command{tar} knows that it does not work, and if you use
  1801. @option{--atime-preserve=system} then @command{tar} complains and
  1802. exits right away. But other times @command{tar} might think that the
  1803. option works when it actually does not.
  1804. Currently @option{--atime-preserve} with no operand defaults to
  1805. @option{--atime-preserve=replace}, but this may change in the future
  1806. as support for @option{--atime-preserve=system} improves.
  1807. If your operating system does not support
  1808. @option{--atime-preserve=system}, you might be able to preserve access
  1809. times reliably by by using the @command{mount} command. For example,
  1810. you can mount the file system read-only, or access the file system via
  1811. a read-only loopback mount, or use the @samp{noatime} mount option
  1812. available on some systems. However, mounting typically requires
  1813. superuser privileges and can be a pain to manage.
  1814. @opindex backup, summary
  1815. @item --backup=@var{backup-type}
  1816. Rather than deleting files from the file system, @command{tar} will
  1817. back them up using simple or numbered backups, depending upon
  1818. @var{backup-type}. @xref{backup}.
  1819. @opindex block-number, summary
  1820. @item --block-number
  1821. @itemx -R
  1822. With this option present, @command{tar} prints error messages for read errors
  1823. with the block number in the archive file. @xref{block-number}.
  1824. @opindex blocking-factor, summary
  1825. @item --blocking-factor=@var{blocking}
  1826. @itemx -b @var{blocking}
  1827. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1828. record. @xref{Blocking Factor}.
  1829. @opindex bzip2, summary
  1830. @item --bzip2
  1831. @itemx -j
  1832. This option tells @command{tar} to read or write archives through
  1833. @code{bzip2}. @xref{gzip}.
  1834. @opindex checkpoint, summary
  1835. @item --checkpoint
  1836. This option directs @command{tar} to print periodic checkpoint messages as it
  1837. reads through the archive. Its intended for when you want a visual
  1838. indication that @command{tar} is still running, but don't want to see
  1839. @option{--verbose} output. @FIXME-xref{}
  1840. @opindex check-links, summary
  1841. @item --check-links
  1842. @itemx -l
  1843. If this option was given, @command{tar} will check the number of links
  1844. dumped for each processed file. If this number does not match the
  1845. total number of hard links for the file, a warning message will be
  1846. output.
  1847. Future versions will take @option{-l} as a short version of
  1848. @option{--check-links}. However, current release still retains the old
  1849. semantics for @option{-l}.
  1850. @xref{Changes}, for more information.
  1851. @opindex compress, summary
  1852. @opindex uncompress, summary
  1853. @item --compress
  1854. @itemx --uncompress
  1855. @itemx -Z
  1856. @command{tar} will use the @command{compress} program when reading or
  1857. writing the archive. This allows you to directly act on archives
  1858. while saving space. @xref{gzip}.
  1859. @opindex confirmation, summary
  1860. @item --confirmation
  1861. (See @option{--interactive}.) @xref{interactive}.
  1862. @opindex dereference, summary
  1863. @item --dereference
  1864. @itemx -h
  1865. When creating a @command{tar} archive, @command{tar} will archive the
  1866. file that a symbolic link points to, rather than archiving the
  1867. symlink. @xref{dereference}.
  1868. @opindex directory, summary
  1869. @item --directory=@var{dir}
  1870. @itemx -C @var{dir}
  1871. When this option is specified, @command{tar} will change its current directory
  1872. to @var{dir} before performing any operations. When this option is used
  1873. during archive creation, it is order sensitive. @xref{directory}.
  1874. @opindex exclude, summary
  1875. @item --exclude=@var{pattern}
  1876. When performing operations, @command{tar} will skip files that match
  1877. @var{pattern}. @xref{exclude}.
  1878. @opindex exclude-from, summary
  1879. @item --exclude-from=@var{file}
  1880. @itemx -X @var{file}
  1881. Similar to @option{--exclude}, except @command{tar} will use the list of
  1882. patterns in the file @var{file}. @xref{exclude}.
  1883. @opindex exclude-caches, summary
  1884. @item --exclude-caches
  1885. Automatically excludes all directories
  1886. containing a cache directory tag. @xref{exclude}.
  1887. @opindex file, summary
  1888. @item --file=@var{archive}
  1889. @itemx -f @var{archive}
  1890. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1891. performs operations on, rather than @command{tar}'s compilation dependent
  1892. default. @xref{file tutorial}.
  1893. @opindex files-from, summary
  1894. @item --files-from=@var{file}
  1895. @itemx -T @var{file}
  1896. @command{tar} will use the contents of @var{file} as a list of archive members
  1897. or files to operate on, in addition to those specified on the
  1898. command-line. @xref{files}.
  1899. @opindex force-local, summary
  1900. @item --force-local
  1901. Forces @command{tar} to interpret the filename given to @option{--file}
  1902. as a local file, even if it looks like a remote tape drive name.
  1903. @xref{local and remote archives}.
  1904. @opindex format, summary
  1905. @item --format=@var{format}
  1906. Selects output archive format. @var{Format} may be one of the
  1907. following:
  1908. @table @samp
  1909. @item v7
  1910. Creates an archive that is compatible with Unix V7 @command{tar}.
  1911. @item oldgnu
  1912. Creates an archive that is compatible with GNU @command{tar} version
  1913. 1.12 or earlier.
  1914. @item gnu
  1915. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1916. @samp{oldgnu} with the only difference in the way it handles long
  1917. numeric fields.
  1918. @item ustar
  1919. Creates a @acronym{POSIX.1-1988} compatible archive.
  1920. @item posix
  1921. Creates a @acronym{POSIX.1-2001 archive}.
  1922. @end table
  1923. @xref{Formats}, for a detailed discussion of these formats.
  1924. @opindex group, summary
  1925. @item --group=@var{group}
  1926. Files added to the @command{tar} archive will have a group id of @var{group},
  1927. rather than the group from the source file. @var{group} is first decoded
  1928. as a group symbolic name, but if this interpretation fails, it has to be
  1929. a decimal numeric group ID. @FIXME-xref{}
  1930. Also see the comments for the @option{--owner=@var{user}} option.
  1931. @opindex gzip, summary
  1932. @opindex gunzip, summary
  1933. @opindex ungzip, summary
  1934. @item --gzip
  1935. @itemx --gunzip
  1936. @itemx --ungzip
  1937. @itemx -z
  1938. This option tells @command{tar} to read or write archives through
  1939. @command{gzip}, allowing @command{tar} to directly operate on several
  1940. kinds of compressed archives transparently. @xref{gzip}.
  1941. @opindex help, summary
  1942. @item --help
  1943. @command{tar} will print out a short message summarizing the operations and
  1944. options to @command{tar} and exit. @xref{help}.
  1945. @opindex ignore-case, summary
  1946. @item --ignore-case
  1947. Ignore case when excluding files. @xref{controlling pattern-matching
  1948. with exclude}.
  1949. @opindex ignore-command-error, summary
  1950. @item --ignore-command-error
  1951. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1952. @opindex ignore-failed-read, summary
  1953. @item --ignore-failed-read
  1954. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1955. @xref{Reading}.
  1956. @opindex ignore-zeros, summary
  1957. @item --ignore-zeros
  1958. @itemx -i
  1959. With this option, @command{tar} will ignore zeroed blocks in the
  1960. archive, which normally signals EOF. @xref{Reading}.
  1961. @opindex incremental, summary
  1962. @item --incremental
  1963. @itemx -G
  1964. Used to inform @command{tar} that it is working with an old
  1965. @acronym{GNU}-format incremental backup archive. It is intended
  1966. primarily for backwards compatibility only. @FIXME{incremental and
  1967. listed-incremental}.
  1968. @opindex index-file, summary
  1969. @item --index-file=@var{file}
  1970. Send verbose output to @var{file} instead of to standard output.
  1971. @opindex info-script, summary
  1972. @opindex new-volume-script, summary
  1973. @item --info-script=@var{script-file}
  1974. @itemx --new-volume-script=@var{script-file}
  1975. @itemx -F @var{script-file}
  1976. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1977. at the end of each tape. If @var{script-file} exits with nonzero status,
  1978. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1979. discussion of @var{script-file}.
  1980. @opindex interactive, summary
  1981. @item --interactive
  1982. @itemx --confirmation
  1983. @itemx -w
  1984. Specifies that @command{tar} should ask the user for confirmation before
  1985. performing potentially destructive options, such as overwriting files.
  1986. @xref{interactive}.
  1987. @opindex keep-newer-files, summary
  1988. @item --keep-newer-files
  1989. Do not replace existing files that are newer than their archive copies
  1990. when extracting files from an archive.
  1991. @opindex keep-old-files, summary
  1992. @item --keep-old-files
  1993. @itemx -k
  1994. Do not overwrite existing files when extracting files from an archive.
  1995. @xref{Keep Old Files}.
  1996. @opindex label, summary
  1997. @item --label=@var{name}
  1998. @itemx -V @var{name}
  1999. When creating an archive, instructs @command{tar} to write @var{name}
  2000. as a name record in the archive. When extracting or listing archives,
  2001. @command{tar} will only operate on archives that have a label matching
  2002. the pattern specified in @var{name}. @xref{Tape Files}.
  2003. @opindex listed-incremental, summary
  2004. @item --listed-incremental=@var{snapshot-file}
  2005. @itemx -g @var{snapshot-file}
  2006. During a @option{--create} operation, specifies that the archive that
  2007. @command{tar} creates is a new @acronym{GNU}-format incremental
  2008. backup, using @var{snapshot-file} to determine which files to backup.
  2009. With other operations, informs @command{tar} that the archive is in
  2010. incremental format. @FIXME{incremental and listed-incremental}.
  2011. @opindex mode, summary
  2012. @item --mode=@var{permissions}
  2013. When adding files to an archive, @command{tar} will use
  2014. @var{permissions} for the archive members, rather than the permissions
  2015. from the files. The program @command{chmod} and this @command{tar}
  2016. option share the same syntax for what @var{permissions} might be.
  2017. @xref{File permissions, Permissions, File permissions, fileutils,
  2018. @acronym{GNU} file utilities}. This reference also has useful
  2019. information for those not being overly familiar with the Unix
  2020. permission system.
  2021. Of course, @var{permissions} might be plainly specified as an octal number.
  2022. However, by using generic symbolic modifications to mode bits, this allows
  2023. more flexibility. For example, the value @samp{a+rw} adds read and write
  2024. permissions for everybody, while retaining executable bits on directories
  2025. or on any other file already marked as executable.
  2026. @opindex multi-volume, summary
  2027. @item --multi-volume
  2028. @itemx -M
  2029. Informs @command{tar} that it should create or otherwise operate on a
  2030. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2031. @opindex new-volume-script, summary
  2032. @item --new-volume-script
  2033. (see --info-script)
  2034. @opindex seek, summary
  2035. @item --seek
  2036. @itemx -n
  2037. Assume that the archive media supports seeks to arbitrary
  2038. locations. Usually @command{tar} determines automatically whether
  2039. the archive can be seeked or not. This option is intended for use
  2040. in cases when such recognition fails.
  2041. @opindex newer, summary
  2042. @item --newer=@var{date}
  2043. @itemx --after-date=@var{date}
  2044. @itemx -N
  2045. When creating an archive, @command{tar} will only add files that have changed
  2046. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2047. is taken to be the name of a file whose data modification time specifies
  2048. the date. @xref{after}.
  2049. @opindex newer-mtime, summary
  2050. @item --newer-mtime=@var{date}
  2051. Like @option{--newer}, but add only files whose
  2052. contents have changed (as opposed to just @option{--newer}, which will
  2053. also back up files for which any status information has changed).
  2054. @opindex no-anchored, summary
  2055. @item --no-anchored
  2056. An exclude pattern can match any subsequence of the name's components.
  2057. @xref{controlling pattern-matching with exclude}.
  2058. @opindex no-ignore-case, summary
  2059. @item --no-ignore-case
  2060. Use case-sensitive matching when excluding files.
  2061. @xref{controlling pattern-matching with exclude}.
  2062. @opindex no-ignore-command-error, summary
  2063. @item --no-ignore-command-error
  2064. Print warnings about subprocesses terminated with a non-zero exit
  2065. code. @xref{Writing to an External Program}.
  2066. @opindex no-recursion, summary
  2067. @item --no-recursion
  2068. With this option, @command{tar} will not recurse into directories.
  2069. @xref{recurse}.
  2070. @opindex no-same-owner, summary
  2071. @item --no-same-owner
  2072. @itemx -o
  2073. When extracting an archive, do not attempt to preserve the owner
  2074. specified in the @command{tar} archive. This the default behavior
  2075. for ordinary users.
  2076. @opindex no-same-permissions, summary
  2077. @item --no-same-permissions
  2078. When extracting an archive, subtract the user's umask from files from
  2079. the permissions specified in the archive. This is the default behavior
  2080. for ordinary users.
  2081. @opindex no-wildcards, summary
  2082. @item --no-wildcards
  2083. Do not use wildcards when excluding files.
  2084. @xref{controlling pattern-matching with exclude}.
  2085. @opindex no-wildcards-match-slash, summary
  2086. @item --no-wildcards-match-slash
  2087. Wildcards do not match @samp{/} when excluding files.
  2088. @xref{controlling pattern-matching with exclude}.
  2089. @opindex null, summary
  2090. @item --null
  2091. When @command{tar} is using the @option{--files-from} option, this option
  2092. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2093. @command{tar} can correctly work with file names that contain newlines.
  2094. @xref{nul}.
  2095. @opindex numeric-owner, summary
  2096. @item --numeric-owner
  2097. This option will notify @command{tar} that it should use numeric user
  2098. and group IDs when creating a @command{tar} file, rather than names.
  2099. @xref{Attributes}.
  2100. @item -o
  2101. When extracting files, this option is a synonym for
  2102. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2103. restoring ownership of files being extracted.
  2104. When creating an archive, @option{-o} is a synonym for
  2105. @option{--old-archive}. This behavior is for compatibility
  2106. with previous versions of @GNUTAR{}, and will be
  2107. removed in the future releases.
  2108. @xref{Changes}, for more information.
  2109. @opindex occurrence, summary
  2110. @item --occurrence[=@var{number}]
  2111. This option can be used in conjunction with one of the subcommands
  2112. @option{--delete}, @option{--diff}, @option{--extract} or
  2113. @option{--list} when a list of files is given either on the command
  2114. line or via @option{-T} option.
  2115. This option instructs @command{tar} to process only the @var{number}th
  2116. occurrence of each named file. @var{Number} defaults to 1, so
  2117. @smallexample
  2118. tar -x -f archive.tar --occurrence filename
  2119. @end smallexample
  2120. @noindent
  2121. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2122. and will terminate without scanning to the end of the archive.
  2123. @opindex old-archive, summary
  2124. @item --old-archive
  2125. Synonym for @option{--format=v7}.
  2126. @opindex one-file-system, summary
  2127. @item --one-file-system
  2128. @itemx -l
  2129. Used when creating an archive. Prevents @command{tar} from recursing into
  2130. directories that are on different file systems from the current
  2131. directory.
  2132. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2133. synonym for @option{--one-file-system}. Although such usage is still
  2134. allowed in the present version, it is @emph{strongly discouraged}.
  2135. The future versions of @GNUTAR{} will use @option{-l} as
  2136. a synonym for @option{--check-links}.
  2137. @xref{Changes}, for more information.
  2138. @opindex overwrite, summary
  2139. @item --overwrite
  2140. Overwrite existing files and directory metadata when extracting files
  2141. from an archive. @xref{Overwrite Old Files}.
  2142. @opindex overwrite-dir, summary
  2143. @item --overwrite-dir
  2144. Overwrite the metadata of existing directories when extracting files
  2145. from an archive. @xref{Overwrite Old Files}.
  2146. @opindex owner, summary
  2147. @item --owner=@var{user}
  2148. Specifies that @command{tar} should use @var{user} as the owner of members
  2149. when creating archives, instead of the user associated with the source
  2150. file. @var{user} is first decoded as a user symbolic name, but if
  2151. this interpretation fails, it has to be a decimal numeric user ID.
  2152. @FIXME-xref{}
  2153. There is no value indicating a missing number, and @samp{0} usually means
  2154. @code{root}. Some people like to force @samp{0} as the value to offer in
  2155. their distributions for the owner of files, because the @code{root} user is
  2156. anonymous anyway, so that might as well be the owner of anonymous archives.
  2157. This option does not affect extraction from archives.
  2158. @opindex pax-option, summary
  2159. @item --pax-option=@var{keyword-list}
  2160. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2161. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2162. (@pxref{posix}). It modifies the way @command{tar} handles the
  2163. extended header keywords. @var{Keyword-list} is a comma-separated
  2164. list of keyword options, each keyword option taking one of
  2165. the following forms:
  2166. @table @asis
  2167. @item delete=@var{pattern}
  2168. When used with one of archive-creation commands,
  2169. this option instructs @command{tar} to omit from extended header records
  2170. that it produces any keywords matching the string @var{pattern}.
  2171. When used in extract or list mode, this option instructs tar
  2172. to ignore any keywords matching the given @var{pattern} in the extended
  2173. header records. In both cases, matching is performed using the pattern
  2174. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2175. (See @cite{glob(7)}). For example:
  2176. @smallexample
  2177. --pax-option delete=security.*
  2178. @end smallexample
  2179. would suppress security-related information.
  2180. @item exthdr.name=@var{string}
  2181. This keyword allows user control over the name that is written into the
  2182. ustar header blocks for the extended headers. The name is obtained
  2183. from @var{string} after substituting the following meta-characters:
  2184. @multitable @columnfractions .30 .70
  2185. @headitem Meta-character @tab Replaced By
  2186. @item %d @tab The directory name of the file, equivalent to the
  2187. result of the @command{dirname} utility on the translated pathname.
  2188. @item %f @tab The filename of the file, equivalent to the result
  2189. of the @command{basename} utility on the translated pathname.
  2190. @item %p @tab The process ID of the @command{tar} process.
  2191. @item %% @tab A @samp{%} character.
  2192. @end multitable
  2193. Any other @samp{%} characters in @var{string} produce undefined
  2194. results.
  2195. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2196. will use the following default value:
  2197. @smallexample
  2198. %d/PaxHeaders.%p/%f
  2199. @end smallexample
  2200. @item globexthdr.name=@var{string}
  2201. This keyword allows user control over the name that is written into
  2202. the ustar header blocks for global extended header records. The name
  2203. shall will be obtained from the contents of @var{string}, after the
  2204. following character substitutions have been made:
  2205. @multitable @columnfractions .30 .70
  2206. @headitem Meta-character @tab Replaced By
  2207. @item %n @tab An integer that represents the
  2208. sequence number of the global extended header record in the archive,
  2209. starting at 1.
  2210. @item %p @tab The process ID of the @command{tar} process.
  2211. @item %% @tab A @samp{%} character.
  2212. @end multitable
  2213. Any other @samp{%} characters in string produce undefined results.
  2214. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2215. will use the following default value:
  2216. @smallexample
  2217. $TMPDIR/GlobalHead.%p.%n
  2218. @end smallexample
  2219. @noindent
  2220. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2221. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2222. uses @samp{/tmp}.
  2223. @item @var{keyword}=@var{value}
  2224. When used with one of archive-creation commands, these keyword/value pairs
  2225. will be included at the beginning of the archive in a global extended
  2226. header record. When used with one of archive-reading commands,
  2227. @command{tar} will behave as if it has encountered these keyword/value
  2228. pairs at the beginning of the archive in a global extended header
  2229. record.
  2230. @item @var{keyword}:=@var{value}
  2231. When used with one of archive-creation commands, these keyword/value pairs
  2232. will be included as records at the beginning of an extended header for
  2233. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2234. form except that it creates no global extended header records.
  2235. When used with one of archive-reading commands, @command{tar} will
  2236. behave as if these keyword/value pairs were included as records at the
  2237. end of each extended header; thus, they will override any global or
  2238. file-specific extended header record keywords of the same names.
  2239. For example, in the command:
  2240. @smallexample
  2241. tar --format=posix --create \
  2242. --file archive --pax-option gname:=user .
  2243. @end smallexample
  2244. the group name will be forced to a new value for all files
  2245. stored in the archive.
  2246. @end table
  2247. @opindex portability, summary
  2248. @item --portability
  2249. @itemx --old-archive
  2250. Synonym for @option{--format=v7}.
  2251. @opindex posix, summary
  2252. @item --posix
  2253. Same as @option{--format=posix}.
  2254. @opindex preserve, summary
  2255. @item --preserve
  2256. Synonymous with specifying both @option{--preserve-permissions} and
  2257. @option{--same-order}. @xref{Setting Access Permissions}.
  2258. @opindex preserve-order, summary
  2259. @item --preserve-order
  2260. (See @option{--same-order}; @pxref{Reading}.)
  2261. @opindex preserve-permissions, summary
  2262. @opindex same-permissions, summary
  2263. @item --preserve-permissions
  2264. @itemx --same-permissions
  2265. @itemx -p
  2266. When @command{tar} is extracting an archive, it normally subtracts the
  2267. users' umask from the permissions specified in the archive and uses
  2268. that number as the permissions to create the destination file.
  2269. Specifying this option instructs @command{tar} that it should use the
  2270. permissions directly from the archive. @xref{Setting Access Permissions}.
  2271. @opindex read-full-records, summary
  2272. @item --read-full-records
  2273. @itemx -B
  2274. Specifies that @command{tar} should reblock its input, for reading
  2275. from pipes on systems with buggy implementations. @xref{Reading}.
  2276. @opindex record-size, summary
  2277. @item --record-size=@var{size}
  2278. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2279. archive. @xref{Blocking Factor}.
  2280. @opindex recursion, summary
  2281. @item --recursion
  2282. With this option, @command{tar} recurses into directories.
  2283. @xref{recurse}.
  2284. @opindex recursive-unlink, summary
  2285. @item --recursive-unlink
  2286. Remove existing
  2287. directory hierarchies before extracting directories of the same name
  2288. from the archive. @xref{Recursive Unlink}.
  2289. @opindex remove-files, summary
  2290. @item --remove-files
  2291. Directs @command{tar} to remove the source file from the file system after
  2292. appending it to an archive. @xref{remove files}.
  2293. @opindex restrict, summary
  2294. @item --restrict
  2295. Disable use of some potentially harmful @command{tar} options.
  2296. Currently this option disables shell invocaton from multi-volume menu
  2297. (@pxref{Using Multiple Tapes}).
  2298. @opindex rmt-command, summary
  2299. @item --rmt-command=@var{cmd}
  2300. Notifies @command{tar} that it should use @var{cmd} instead of
  2301. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2302. @opindex rsh-command, summary
  2303. @item --rsh-command=@var{cmd}
  2304. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2305. devices. @xref{Device}.
  2306. @opindex same-order, summary
  2307. @item --same-order
  2308. @itemx --preserve-order
  2309. @itemx -s
  2310. This option is an optimization for @command{tar} when running on machines with
  2311. small amounts of memory. It informs @command{tar} that the list of file
  2312. arguments has already been sorted to match the order of files in the
  2313. archive. @xref{Reading}.
  2314. @opindex same-owner, summary
  2315. @item --same-owner
  2316. When extracting an archive, @command{tar} will attempt to preserve the owner
  2317. specified in the @command{tar} archive with this option present.
  2318. This is the default behavior for the superuser; this option has an
  2319. effect only for ordinary users. @xref{Attributes}.
  2320. @opindex same-permissions, summary
  2321. @item --same-permissions
  2322. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2323. @opindex show-defaults, summary
  2324. @item --show-defaults
  2325. Displays the default options used by @command{tar} and exits
  2326. successfully. This option is intended for use in shell scripts.
  2327. Here is an example of what you can see using this option:
  2328. @smallexample
  2329. $ tar --show-defaults
  2330. --format=gnu -f- -b20
  2331. @end smallexample
  2332. @opindex show-omitted-dirs, summary
  2333. @item --show-omitted-dirs
  2334. Instructs @command{tar} to mention directories its skipping over when
  2335. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2336. @opindex show-stored-names, summary
  2337. @item --show-stored-names
  2338. This option has effect only when used in conjunction with one of
  2339. archive creation operations. It instructs tar to list the member names
  2340. stored in the archive, as opposed to the actual file
  2341. names. @xref{listing member and file names}.
  2342. @opindex sparse, summary
  2343. @item --sparse
  2344. @itemx -S
  2345. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2346. sparse files efficiently. @xref{sparse}.
  2347. @opindex starting-file, summary
  2348. @item --starting-file=@var{name}
  2349. @itemx -K @var{name}
  2350. This option affects extraction only; @command{tar} will skip extracting
  2351. files in the archive until it finds one that matches @var{name}.
  2352. @xref{Scarce}.
  2353. @opindex strip-components, summary
  2354. @item --strip-components=@var{number}
  2355. Strip given @var{number} of leading components from file names before
  2356. extraction.@footnote{This option was called @option{--strip-path} in
  2357. version 1.14.} For example, if archive @file{archive.tar} contained
  2358. @file{/some/file/name}, then running
  2359. @smallexample
  2360. tar --extract --file archive.tar --strip-components=2
  2361. @end smallexample
  2362. @noindent
  2363. would extracted this file to file @file{name}.
  2364. @opindex suffix, summary
  2365. @item --suffix=@var{suffix}
  2366. Alters the suffix @command{tar} uses when backing up files from the default
  2367. @samp{~}. @xref{backup}.
  2368. @opindex tape-length, summary
  2369. @item --tape-length=@var{num}
  2370. @itemx -L @var{num}
  2371. Specifies the length of tapes that @command{tar} is writing as being
  2372. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2373. @opindex test-label, summary
  2374. @item --test-label
  2375. Reads the volume label. If an argument is specified, test whether it
  2376. matches the volume label. @xref{--test-label option}.
  2377. @opindex to-command, summary
  2378. @item --to-command=@var{command}
  2379. During extraction @command{tar} will pipe extracted files to the
  2380. standard input of @var{command}. @xref{Writing to an External Program}.
  2381. @opindex to-stdout, summary
  2382. @item --to-stdout
  2383. @itemx -O
  2384. During extraction, @command{tar} will extract files to stdout rather
  2385. than to the file system. @xref{Writing to Standard Output}.
  2386. @opindex totals, summary
  2387. @item --totals
  2388. Displays the total number of bytes written after creating an archive.
  2389. @xref{verbose}.
  2390. @opindex touch, summary
  2391. @item --touch
  2392. @itemx -m
  2393. Sets the data modification time of extracted files to the extraction time,
  2394. rather than the data modification time stored in the archive.
  2395. @xref{Data Modification Times}.
  2396. @opindex uncompress, summary
  2397. @item --uncompress
  2398. (See @option{--compress}. @pxref{gzip})
  2399. @opindex ungzip, summary
  2400. @item --ungzip
  2401. (See @option{--gzip}. @pxref{gzip})
  2402. @opindex unlink-first, summary
  2403. @item --unlink-first
  2404. @itemx -U
  2405. Directs @command{tar} to remove the corresponding file from the file
  2406. system before extracting it from the archive. @xref{Unlink First}.
  2407. @opindex use-compress-program, summary
  2408. @item --use-compress-program=@var{prog}
  2409. Instructs @command{tar} to access the archive through @var{prog}, which is
  2410. presumed to be a compression program of some sort. @xref{gzip}.
  2411. @opindex utc, summary
  2412. @item --utc
  2413. Display file modification dates in @acronym{UTC}. This option implies
  2414. @option{--verbose}.
  2415. @opindex verbose, summary
  2416. @item --verbose
  2417. @itemx -v
  2418. Specifies that @command{tar} should be more verbose about the operations its
  2419. performing. This option can be specified multiple times for some
  2420. operations to increase the amount of information displayed.
  2421. @xref{verbose}.
  2422. @opindex verify, summary
  2423. @item --verify
  2424. @itemx -W
  2425. Verifies that the archive was correctly written when creating an
  2426. archive. @xref{verify}.
  2427. @opindex version, summary
  2428. @item --version
  2429. @command{tar} will print an informational message about what version
  2430. it is and a copyright message, some credits, and then exit.
  2431. @xref{help}.
  2432. @opindex volno-file, summary
  2433. @item --volno-file=@var{file}
  2434. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2435. of which volume of a multi-volume archive its working in @var{file}.
  2436. @xref{volno-file}.
  2437. @opindex wildcards, summary
  2438. @item --wildcards
  2439. Use wildcards when excluding files.
  2440. @xref{controlling pattern-matching with exclude}.
  2441. @opindex wildcards-match-slash, summary
  2442. @item --wildcards-match-slash
  2443. Wildcards match @samp{/} when excluding files.
  2444. @xref{controlling pattern-matching with exclude}.
  2445. @end table
  2446. @node Short Option Summary
  2447. @subsection Short Options Cross Reference
  2448. Here is an alphabetized list of all of the short option forms, matching
  2449. them with the equivalent long option.
  2450. @table @option
  2451. @item -A
  2452. @option{--concatenate}
  2453. @item -B
  2454. @option{--read-full-records}
  2455. @item -C
  2456. @option{--directory}
  2457. @item -F
  2458. @option{--info-script}
  2459. @item -G
  2460. @option{--incremental}
  2461. @item -K
  2462. @option{--starting-file}
  2463. @item -L
  2464. @option{--tape-length}
  2465. @item -M
  2466. @option{--multi-volume}
  2467. @item -N
  2468. @option{--newer}
  2469. @item -O
  2470. @option{--to-stdout}
  2471. @item -P
  2472. @option{--absolute-names}
  2473. @item -R
  2474. @option{--block-number}
  2475. @item -S
  2476. @option{--sparse}
  2477. @item -T
  2478. @option{--files-from}
  2479. @item -U
  2480. @option{--unlink-first}
  2481. @item -V
  2482. @option{--label}
  2483. @item -W
  2484. @option{--verify}
  2485. @item -X
  2486. @option{--exclude-from}
  2487. @item -Z
  2488. @option{--compress}
  2489. @item -b
  2490. @option{--blocking-factor}
  2491. @item -c
  2492. @option{--create}
  2493. @item -d
  2494. @option{--compare}
  2495. @item -f
  2496. @option{--file}
  2497. @item -g
  2498. @option{--listed-incremental}
  2499. @item -h
  2500. @option{--dereference}
  2501. @item -i
  2502. @option{--ignore-zeros}
  2503. @item -j
  2504. @option{--bzip2}
  2505. @item -k
  2506. @option{--keep-old-files}
  2507. @item -l
  2508. @option{--one-file-system}. Use of this short option is deprecated. It
  2509. is retained for compatibility with the earlier versions of GNU
  2510. @command{tar}, and will be changed in future releases.
  2511. @xref{Changes}, for more information.
  2512. @item -m
  2513. @option{--touch}
  2514. @item -o
  2515. When creating --- @option{--no-same-owner}, when extracting ---
  2516. @option{--portability}.
  2517. The later usage is deprecated. It is retained for compatibility with
  2518. the earlier versions of @GNUTAR{}. In the future releases
  2519. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2520. @item -p
  2521. @option{--preserve-permissions}
  2522. @item -r
  2523. @option{--append}
  2524. @item -s
  2525. @option{--same-order}
  2526. @item -t
  2527. @option{--list}
  2528. @item -u
  2529. @option{--update}
  2530. @item -v
  2531. @option{--verbose}
  2532. @item -w
  2533. @option{--interactive}
  2534. @item -x
  2535. @option{--extract}
  2536. @item -z
  2537. @option{--gzip}
  2538. @end table
  2539. @node help
  2540. @section @GNUTAR{} documentation
  2541. @cindex Getting program version number
  2542. @opindex version
  2543. @cindex Version of the @command{tar} program
  2544. Being careful, the first thing is really checking that you are using
  2545. @GNUTAR{}, indeed. The @option{--version} option
  2546. will generate a message giving confirmation that you are using
  2547. @GNUTAR{}, with the precise version of @GNUTAR{}
  2548. you are using. @command{tar} identifies itself and
  2549. prints the version number to the standard output, then immediately
  2550. exits successfully, without doing anything else, ignoring all other
  2551. options. For example, @w{@samp{tar --version}} might return:
  2552. @smallexample
  2553. tar (@acronym{GNU} tar) @value{VERSION}
  2554. @end smallexample
  2555. @noindent
  2556. The first occurrence of @samp{tar} in the result above is the program
  2557. name in the package (for example, @command{rmt} is another program),
  2558. while the second occurrence of @samp{tar} is the name of the package
  2559. itself, containing possibly many programs. The package is currently
  2560. named @samp{tar}, after the name of the main program it
  2561. contains@footnote{There are plans to merge the @command{cpio} and
  2562. @command{tar} packages into a single one which would be called
  2563. @code{paxutils}. So, who knows if, one of this days, the
  2564. @option{--version} would not yield @w{@samp{tar (@acronym{GNU}
  2565. paxutils) 3.2}}}.
  2566. @cindex Obtaining help
  2567. @cindex Listing all @command{tar} options
  2568. @opindex help, introduction
  2569. Another thing you might want to do is checking the spelling or meaning
  2570. of some particular @command{tar} option, without resorting to this
  2571. manual, for once you have carefully read it. @GNUTAR{}
  2572. has a short help feature, triggerable through the
  2573. @option{--help} option. By using this option, @command{tar} will
  2574. print a usage message listing all available options on standard
  2575. output, then exit successfully, without doing anything else and
  2576. ignoring all other options. Even if this is only a brief summary, it
  2577. may be several screens long. So, if you are not using some kind of
  2578. scrollable window, you might prefer to use something like:
  2579. @smallexample
  2580. $ @kbd{tar --help | less}
  2581. @end smallexample
  2582. @noindent
  2583. presuming, here, that you like using @command{less} for a pager. Other
  2584. popular pagers are @command{more} and @command{pg}. If you know about some
  2585. @var{keyword} which interests you and do not want to read all the
  2586. @option{--help} output, another common idiom is doing:
  2587. @smallexample
  2588. tar --help | grep @var{keyword}
  2589. @end smallexample
  2590. @noindent
  2591. for getting only the pertinent lines. Notice, however, that some
  2592. @command{tar} options have long description lines and the above
  2593. command will list only the first of them.
  2594. @opindex usage
  2595. If you only wish to check the spelling of an option, running @kbd{tar
  2596. --usage} may be a better choice. This will display a terse list of
  2597. @command{tar} option without accompanying explanations.
  2598. The short help output is quite succinct, and you might have to get
  2599. back to the full documentation for precise points. If you are reading
  2600. this paragraph, you already have the @command{tar} manual in some
  2601. form. This manual is available in a variety of forms from
  2602. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2603. distribution, provided you have @TeX{} already installed somewhere,
  2604. and a laser printer around. Just configure the distribution, execute
  2605. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2606. usual way (contact your local guru to know how). If @GNUTAR{}
  2607. has been conveniently installed at your place, this
  2608. manual is also available in interactive, hypertextual form as an Info
  2609. file. Just call @w{@samp{info tar}} or, if you do not have the
  2610. @command{info} program handy, use the Info reader provided within
  2611. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2612. There is currently no @code{man} page for @GNUTAR{}.
  2613. If you observe such a @code{man} page on the system you are running,
  2614. either it does not belong to @GNUTAR{}, or it has not
  2615. been produced by @acronym{GNU}. Some package maintainers convert
  2616. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2617. any case, please bear in mind that the authoritative source of
  2618. information about @GNUTAR{} is this Texinfo documentation.
  2619. @node defaults
  2620. @section Obtaining @GNUTAR{} default values
  2621. @opindex show-defaults
  2622. @GNUTAR{} has some predefined defaults that are used when you do not
  2623. explicitely specify another values. To obtain a list of such
  2624. defaults, use @option{--show-defaults} option. This will output the
  2625. values in the form of @command{tar} command line options:
  2626. @smallexample
  2627. @group
  2628. @kbd{tar --show-defaults}
  2629. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2630. @end group
  2631. @end smallexample
  2632. @noindent
  2633. The above output shows that this version of @GNUTAR{} defaults to
  2634. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2635. output as the archive, if no @option{--file} option has been given
  2636. (@pxref{file tutorial}), the default blocking factor is 20
  2637. (@pxref{Blocking Factor}). It also shows the default locations where
  2638. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2639. @node verbose
  2640. @section Checking @command{tar} progress
  2641. Typically, @command{tar} performs most operations without reporting any
  2642. information to the user except error messages. When using @command{tar}
  2643. with many options, particularly ones with complicated or
  2644. difficult-to-predict behavior, it is possible to make serious mistakes.
  2645. @command{tar} provides several options that make observing @command{tar}
  2646. easier. These options cause @command{tar} to print information as it
  2647. progresses in its job, and you might want to use them just for being
  2648. more careful about what is going on, or merely for entertaining
  2649. yourself. If you have encountered a problem when operating on an
  2650. archive, however, you may need more information than just an error
  2651. message in order to solve the problem. The following options can be
  2652. helpful diagnostic tools.
  2653. @cindex Verbose operation
  2654. @opindex verbose
  2655. Normally, the @option{--list} (@option{-t}) command to list an archive
  2656. prints just the file names (one per line) and the other commands are
  2657. silent. When used with most operations, the @option{--verbose}
  2658. (@option{-v}) option causes @command{tar} to print the name of each
  2659. file or archive member as it is processed. This and the other options
  2660. which make @command{tar} print status information can be useful in
  2661. monitoring @command{tar}.
  2662. With @option{--create} or @option{--extract}, @option{--verbose} used
  2663. once just prints the names of the files or members as they are processed.
  2664. Using it twice causes @command{tar} to print a longer listing
  2665. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2666. already prints the names of the members, @option{--verbose} used once
  2667. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2668. type listing of the files in the archive. The following examples both
  2669. extract members with long list output:
  2670. @smallexample
  2671. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2672. $ @kbd{tar xvvf archive.tar}
  2673. @end smallexample
  2674. Verbose output appears on the standard output except when an archive is
  2675. being written to the standard output, as with @samp{tar --create
  2676. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2677. installer let standard output be the default archive). In that case
  2678. @command{tar} writes verbose output to the standard error stream.
  2679. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2680. verbose output to @var{file} rather than to standard output or standard
  2681. error.
  2682. @cindex Obtaining total status information
  2683. @opindex totals
  2684. The @option{--totals} option---which is only meaningful when used with
  2685. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2686. amount written to the archive, after it has been fully created.
  2687. @cindex Progress information
  2688. @opindex checkpoint
  2689. The @option{--checkpoint} option prints an occasional message
  2690. as @command{tar} reads or writes the archive. In fact, it prints
  2691. a message each 10 records read or written. It is designed for
  2692. those who don't need the more detailed (and voluminous) output of
  2693. @option{--block-number} (@option{-R}), but do want visual confirmation that @command{tar}
  2694. is actually making forward progress.
  2695. @FIXME{There is some confusion here. It seems that -R once wrote a
  2696. message at @samp{every} record read or written.}
  2697. @opindex show-omitted-dirs
  2698. @anchor{show-omitted-dirs}
  2699. The @option{--show-omitted-dirs} option, when reading an archive---with
  2700. @option{--list} or @option{--extract}, for example---causes a message
  2701. to be printed for each directory in the archive which is skipped.
  2702. This happens regardless of the reason for skipping: the directory might
  2703. not have been named on the command line (implicitly or explicitly),
  2704. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2705. some other reason.
  2706. @opindex block-number
  2707. @cindex Block number where error occurred
  2708. @anchor{block-number}
  2709. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2710. every message it would normally produce, the block number within the
  2711. archive where the message was triggered. Also, supplementary messages
  2712. are triggered when reading blocks full of NULs, or when hitting end of
  2713. file on the archive. As of now, if the archive if properly terminated
  2714. with a NUL block, the reading of the file may stop before end of file
  2715. is met, so the position of end of file will not usually show when
  2716. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2717. drains the archive before exiting when reading the
  2718. archive from a pipe.
  2719. @cindex Error message, block number of
  2720. This option is especially useful when reading damaged archives, since
  2721. it helps pinpoint the damaged sections. It can also be used with
  2722. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2723. choose among several backup tapes when retrieving a file later, in
  2724. favor of the tape where the file appears earliest (closest to the
  2725. front of the tape). @xref{backup}.
  2726. @node interactive
  2727. @section Asking for Confirmation During Operations
  2728. @cindex Interactive operation
  2729. Typically, @command{tar} carries out a command without stopping for
  2730. further instructions. In some situations however, you may want to
  2731. exclude some files and archive members from the operation (for instance
  2732. if disk or storage space is tight). You can do this by excluding
  2733. certain files automatically (@pxref{Choosing}), or by performing
  2734. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2735. @command{tar} also accepts @option{--confirmation} for this option.
  2736. @opindex interactive
  2737. When the @option{--interactive} (@option{-w}) option is specified, before
  2738. reading, writing, or deleting files, @command{tar} first prints a message
  2739. for each such file, telling what operation it intends to take, then asks
  2740. for confirmation on the terminal. The actions which require
  2741. confirmation include adding a file to the archive, extracting a file
  2742. from the archive, deleting a file from the archive, and deleting a file
  2743. from disk. To confirm the action, you must type a line of input
  2744. beginning with @samp{y}. If your input line begins with anything other
  2745. than @samp{y}, @command{tar} skips that file.
  2746. If @command{tar} is reading the archive from the standard input,
  2747. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2748. communications.
  2749. Verbose output is normally sent to standard output, separate from
  2750. other error messages. However, if the archive is produced directly
  2751. on standard output, then verbose output is mixed with errors on
  2752. @code{stderr}. Producing the archive on standard output may be used
  2753. as a way to avoid using disk space, when the archive is soon to be
  2754. consumed by another process reading it, say. Some people felt the need
  2755. of producing an archive on stdout, still willing to segregate between
  2756. verbose output and error output. A possible approach would be using a
  2757. named pipe to receive the archive, and having the consumer process to
  2758. read from that named pipe. This has the advantage of letting standard
  2759. output free to receive verbose output, all separate from errors.
  2760. @node operations
  2761. @chapter @GNUTAR{} Operations
  2762. @menu
  2763. * Basic tar::
  2764. * Advanced tar::
  2765. * create options::
  2766. * extract options::
  2767. * backup::
  2768. * Applications::
  2769. * looking ahead::
  2770. @end menu
  2771. @node Basic tar
  2772. @section Basic @GNUTAR{} Operations
  2773. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2774. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2775. @option{-x}), are currently presented and described in the tutorial
  2776. chapter of this manual. This section provides some complementary notes
  2777. for these operations.
  2778. @table @option
  2779. @opindex create, complementary notes
  2780. @item --create
  2781. @itemx -c
  2782. Creating an empty archive would have some kind of elegance. One can
  2783. initialize an empty archive and later use @option{--append}
  2784. (@option{-r}) for adding all members. Some applications would not
  2785. welcome making an exception in the way of adding the first archive
  2786. member. On the other hand, many people reported that it is
  2787. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2788. an empty archive@footnote{This is well described in @cite{Unix-haters
  2789. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2790. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2791. @enumerate
  2792. @item
  2793. Mistakingly using @code{create} instead of @code{extract}, when the
  2794. intent was to extract the full contents of an archive. This error
  2795. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2796. the QWERTY keyboard. Instead of being unpacked, the archive then
  2797. gets wholly destroyed. When users speak about @dfn{exploding} an
  2798. archive, they usually mean something else :-).
  2799. @item
  2800. Forgetting the argument to @code{file}, when the intent was to create
  2801. an archive with a single file in it. This error is likely because a
  2802. tired user can easily add the @kbd{f} key to the cluster of option
  2803. letters, by the mere force of habit, without realizing the full
  2804. consequence of doing so. The usual consequence is that the single
  2805. file, which was meant to be saved, is rather destroyed.
  2806. @end enumerate
  2807. So, recognizing the likelihood and the catastrophical nature of these
  2808. errors, @GNUTAR{} now takes some distance from elegance, and
  2809. cowardly refuses to create an archive when @option{--create} option is
  2810. given, there are no arguments besides options, and
  2811. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2812. around the cautiousness of @GNUTAR{} and nevertheless create an
  2813. archive with nothing in it, one may still use, as the value for the
  2814. @option{--files-from} option, a file with no names in it, as shown in
  2815. the following commands:
  2816. @smallexample
  2817. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2818. @kbd{tar cfT empty-archive.tar /dev/null}
  2819. @end smallexample
  2820. @opindex extract, complementary notes
  2821. @item --extract
  2822. @itemx --get
  2823. @itemx -x
  2824. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2825. @item @option{--list} (@option{-t})
  2826. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2827. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2828. people should get used to ISO 8601 dates. Local American dates should
  2829. be made available again with full date localization support, once
  2830. ready. In the meantime, programs not being localizable for dates
  2831. should prefer international dates, that's really the way to go.
  2832. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2833. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2834. @end table
  2835. @node Advanced tar
  2836. @section Advanced @GNUTAR{} Operations
  2837. Now that you have learned the basics of using @GNUTAR{}, you may want
  2838. to learn about further ways in which @command{tar} can help you.
  2839. This chapter presents five, more advanced operations which you probably
  2840. won't use on a daily basis, but which serve more specialized functions.
  2841. We also explain the different styles of options and why you might want
  2842. to use one or another, or a combination of them in your @command{tar}
  2843. commands. Additionally, this chapter includes options which allow you to
  2844. define the output from @command{tar} more carefully, and provide help and
  2845. error correction in special circumstances.
  2846. @FIXME{check this after the chapter is actually revised to make sure
  2847. it still introduces the info in the chapter correctly : ).}
  2848. @menu
  2849. * Operations::
  2850. * append::
  2851. * update::
  2852. * concatenate::
  2853. * delete::
  2854. * compare::
  2855. @end menu
  2856. @node Operations
  2857. @subsection The Five Advanced @command{tar} Operations
  2858. @UNREVISED
  2859. In the last chapter, you learned about the first three operations to
  2860. @command{tar}. This chapter presents the remaining five operations to
  2861. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2862. @option{--delete}, and @option{--compare}.
  2863. You are not likely to use these operations as frequently as those
  2864. covered in the last chapter; however, since they perform specialized
  2865. functions, they are quite useful when you do need to use them. We
  2866. will give examples using the same directory and files that you created
  2867. in the last chapter. As you may recall, the directory is called
  2868. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2869. @samp{rock}, and the two archive files you created are
  2870. @samp{collection.tar} and @samp{music.tar}.
  2871. We will also use the archive files @samp{afiles.tar} and
  2872. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2873. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2874. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2875. Unless we state otherwise, all practicing you do and examples you follow
  2876. in this chapter will take place in the @file{practice} directory that
  2877. you created in the previous chapter; see @ref{prepare for examples}.
  2878. (Below in this section, we will remind you of the state of the examples
  2879. where the last chapter left them.)
  2880. The five operations that we will cover in this chapter are:
  2881. @table @option
  2882. @item --append
  2883. @itemx -r
  2884. Add new entries to an archive that already exists.
  2885. @item --update
  2886. @itemx -r
  2887. Add more recent copies of archive members to the end of an archive, if
  2888. they exist.
  2889. @item --concatenate
  2890. @itemx --catenate
  2891. @itemx -A
  2892. Add one or more pre-existing archives to the end of another archive.
  2893. @item --delete
  2894. Delete items from an archive (does not work on tapes).
  2895. @item --compare
  2896. @itemx --diff
  2897. @itemx -d
  2898. Compare archive members to their counterparts in the file system.
  2899. @end table
  2900. @node append
  2901. @subsection How to Add Files to Existing Archives: @option{--append}
  2902. @UNREVISED
  2903. @opindex append
  2904. If you want to add files to an existing archive, you don't need to
  2905. create a new archive; you can use @option{--append} (@option{-r}).
  2906. The archive must already exist in order to use @option{--append}. (A
  2907. related operation is the @option{--update} operation; you can use this
  2908. to add newer versions of archive members to an existing archive. To learn how to
  2909. do this with @option{--update}, @pxref{update}.)
  2910. If you use @option{--append} to add a file that has the same name as an
  2911. archive member to an archive containing that archive member, then the
  2912. old member is not deleted. What does happen, however, is somewhat
  2913. complex. @command{tar} @emph{allows} you to have infinite number of files
  2914. with the same name. Some operations treat these same-named members no
  2915. differently than any other set of archive members: for example, if you
  2916. view an archive with @option{--list} (@option{-t}), you will see all
  2917. of those members listed, with their data modification times, owners, etc.
  2918. Other operations don't deal with these members as perfectly as you might
  2919. prefer; if you were to use @option{--extract} to extract the archive,
  2920. only the most recently added copy of a member with the same name as four
  2921. other members would end up in the working directory. This is because
  2922. @option{--extract} extracts an archive in the order the members appeared
  2923. in the archive; the most recently archived members will be extracted
  2924. last. Additionally, an extracted member will @emph{replace} a file of
  2925. the same name which existed in the directory already, and @command{tar}
  2926. will not prompt you about this@footnote{Unless you give it
  2927. @option{--keep-old-files} option, or the disk copy is newer than the
  2928. the one in the archive and you invoke @command{tar} with
  2929. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2930. member will end up being extracted, as it will replace the one
  2931. extracted before it, and so on.
  2932. There exists a special option that allows you to get around this
  2933. behavior and extract (or list) only a particular copy of the file.
  2934. This is @option{--occurrence} option. If you run @command{tar} with
  2935. this option, it will extract only the first copy of the file. You
  2936. may also give this option an argument specifying the number of
  2937. copy to be extracted. Thus, for example if the archive
  2938. @file{archive.tar} contained three copies of file @file{myfile}, then
  2939. the command
  2940. @smallexample
  2941. tar --extract --file archive.tar --occurrence=2 myfile
  2942. @end smallexample
  2943. @noindent
  2944. would extract only the second copy. @xref{Option
  2945. Summary,---occurrence}, for the description of @option{--occurrence}
  2946. option.
  2947. @FIXME{ hag -- you might want to incorporate some of the above into the
  2948. MMwtSN node; not sure. i didn't know how to make it simpler...
  2949. There are a few ways to get around this. (maybe xref Multiple Members
  2950. with the Same Name.}
  2951. @cindex Members, replacing with other members
  2952. @cindex Replacing members with other members
  2953. If you want to replace an archive member, use @option{--delete} to
  2954. delete the member you want to remove from the archive, , and then use
  2955. @option{--append} to add the member you want to be in the archive. Note
  2956. that you can not change the order of the archive; the most recently
  2957. added member will still appear last. In this sense, you cannot truly
  2958. ``replace'' one member with another. (Replacing one member with another
  2959. will not work on certain types of media, such as tapes; see @ref{delete}
  2960. and @ref{Media}, for more information.)
  2961. @menu
  2962. * appending files:: Appending Files to an Archive
  2963. * multiple::
  2964. @end menu
  2965. @node appending files
  2966. @subsubsection Appending Files to an Archive
  2967. @UNREVISED
  2968. @cindex Adding files to an Archive
  2969. @cindex Appending files to an Archive
  2970. @cindex Archives, Appending files to
  2971. The simplest way to add a file to an already existing archive is the
  2972. @option{--append} (@option{-r}) operation, which writes specified files into the
  2973. archive whether or not they are already among the archived files.
  2974. When you use @option{--append}, you @emph{must} specify file name
  2975. arguments, as there is no default. If you specify a file that already
  2976. exists in the archive, another copy of the file will be added to the
  2977. end of the archive. As with other operations, the member names of the
  2978. newly added files will be exactly the same as their names given on the
  2979. command line. The @option{--verbose} (@option{-v}) option will print
  2980. out the names of the files as they are written into the archive.
  2981. @option{--append} cannot be performed on some tape drives, unfortunately,
  2982. due to deficiencies in the formats those tape drives use. The archive
  2983. must be a valid @command{tar} archive, or else the results of using this
  2984. operation will be unpredictable. @xref{Media}.
  2985. To demonstrate using @option{--append} to add a file to an archive,
  2986. create a file called @file{rock} in the @file{practice} directory.
  2987. Make sure you are in the @file{practice} directory. Then, run the
  2988. following @command{tar} command to add @file{rock} to
  2989. @file{collection.tar}:
  2990. @smallexample
  2991. $ @kbd{tar --append --file=collection.tar rock}
  2992. @end smallexample
  2993. @noindent
  2994. If you now use the @option{--list} (@option{-t}) operation, you will see that
  2995. @file{rock} has been added to the archive:
  2996. @smallexample
  2997. $ @kbd{tar --list --file=collection.tar}
  2998. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  2999. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3000. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3001. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3002. @end smallexample
  3003. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3004. title claims it will become...}
  3005. @node multiple
  3006. @subsubsection Multiple Files with the Same Name
  3007. You can use @option{--append} (@option{-r}) to add copies of files which have been
  3008. updated since the archive was created. (However, we do not recommend
  3009. doing this since there is another @command{tar} option called
  3010. @option{--update}; @pxref{update} for more information. We describe this
  3011. use of @option{--append} here for the sake of completeness.) @FIXME{is
  3012. this really a good idea, to give this whole description for something
  3013. which i believe is basically a Stupid way of doing something? certain
  3014. aspects of it show ways in which tar is more broken than i'd personally
  3015. like to admit to, specifically the last sentence. On the other hand, i
  3016. don't think it's a good idea to be saying that we explicitly don't
  3017. recommend using something, but i can't see any better way to deal with
  3018. the situation.}When you extract the archive, the older version will be
  3019. effectively lost. This works because files are extracted from an
  3020. archive in the order in which they were archived. Thus, when the
  3021. archive is extracted, a file archived later in time will replace a
  3022. file of the same name which was archived earlier, even though the older
  3023. version of the file will remain in the archive unless you delete all
  3024. versions of the file.
  3025. Supposing you change the file @file{blues} and then append the changed
  3026. version to @file{collection.tar}. As you saw above, the original
  3027. @file{blues} is in the archive @file{collection.tar}. If you change the
  3028. file and append the new version of the file to the archive, there will
  3029. be two copies in the archive. When you extract the archive, the older
  3030. version of the file will be extracted first, and then replaced by the
  3031. newer version when it is extracted.
  3032. You can append the new, changed copy of the file @file{blues} to the
  3033. archive in this way:
  3034. @smallexample
  3035. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3036. blues
  3037. @end smallexample
  3038. @noindent
  3039. Because you specified the @option{--verbose} option, @command{tar} has
  3040. printed the name of the file being appended as it was acted on. Now
  3041. list the contents of the archive:
  3042. @smallexample
  3043. $ @kbd{tar --list --verbose --file=collection.tar}
  3044. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3045. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3046. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3047. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3048. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3049. @end smallexample
  3050. @noindent
  3051. The newest version of @file{blues} is now at the end of the archive
  3052. (note the different creation dates and file sizes). If you extract
  3053. the archive, the older version of the file @file{blues} will be
  3054. replaced by the newer version. You can confirm this by extracting
  3055. the archive and running @samp{ls} on the directory.
  3056. If you wish to extract the first occurrence of the file @file{blues}
  3057. from the archive, use @option{--occurrence} option, as shown in
  3058. the following example:
  3059. @smallexample
  3060. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3061. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3062. @end smallexample
  3063. @xref{Writing}, for more information on @option{--extract} and
  3064. @xref{Option Summary, --occurrence}, for the description of
  3065. @option{--occurrence} option.
  3066. @node update
  3067. @subsection Updating an Archive
  3068. @UNREVISED
  3069. @cindex Updating an archive
  3070. @opindex update
  3071. In the previous section, you learned how to use @option{--append} to
  3072. add a file to an existing archive. A related operation is
  3073. @option{--update} (@option{-u}). The @option{--update} operation
  3074. updates a @command{tar} archive by comparing the date of the specified
  3075. archive members against the date of the file with the same name. If
  3076. the file has been modified more recently than the archive member, then
  3077. the newer version of the file is added to the archive (as with
  3078. @option{--append}).
  3079. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3080. The operation will fail.
  3081. @FIXME{other examples of media on which --update will fail? need to ask
  3082. charles and/or mib/thomas/dave shevett..}
  3083. Both @option{--update} and @option{--append} work by adding to the end
  3084. of the archive. When you extract a file from the archive, only the
  3085. version stored last will wind up in the file system, unless you use
  3086. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3087. Same Name}
  3088. @menu
  3089. * how to update::
  3090. @end menu
  3091. @node how to update
  3092. @subsubsection How to Update an Archive Using @option{--update}
  3093. You must use file name arguments with the @option{--update} (@option{-u}) operation.
  3094. If you don't specify any files, @command{tar} won't act on any files and
  3095. won't tell you that it didn't do anything (which may end up confusing
  3096. you).
  3097. @FIXME{note: the above parenthetical added because in fact, this
  3098. behavior just confused the author. :-) }
  3099. To see the @option{--update} option at work, create a new file,
  3100. @file{classical}, in your practice directory, and some extra text to the
  3101. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3102. the @samp{update} operation and the @option{--verbose} (@option{-v}) option specified,
  3103. using the names of all the files in the practice directory as file name
  3104. arguments:
  3105. @smallexample
  3106. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3107. blues
  3108. classical
  3109. $
  3110. @end smallexample
  3111. @noindent
  3112. Because we have specified verbose mode, @command{tar} prints out the names
  3113. of the files it is working on, which in this case are the names of the
  3114. files that needed to be updated. If you run @samp{tar --list} and look
  3115. at the archive, you will see @file{blues} and @file{classical} at its
  3116. end. There will be a total of two versions of the member @samp{blues};
  3117. the one at the end will be newer and larger, since you added text before
  3118. updating it.
  3119. (The reason @command{tar} does not overwrite the older file when updating
  3120. it is because writing to the middle of a section of tape is a difficult
  3121. process. Tapes are not designed to go backward. @xref{Media}, for more
  3122. information about tapes.
  3123. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3124. reasons: it does not change directory content entries, and it
  3125. lengthens the archive every time it is used. The @GNUTAR{}
  3126. options intended specifically for backups are more
  3127. efficient. If you need to run backups, please consult @ref{Backups}.
  3128. @node concatenate
  3129. @subsection Combining Archives with @option{--concatenate}
  3130. @cindex Adding archives to an archive
  3131. @cindex Concatenating Archives
  3132. @opindex concatenate
  3133. @opindex catenate
  3134. @c @cindex @option{-A} described
  3135. Sometimes it may be convenient to add a second archive onto the end of
  3136. an archive rather than adding individual files to the archive. To add
  3137. one or more archives to the end of another archive, you should use the
  3138. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3139. To use @option{--concatenate}, give the first archive with
  3140. @option{--file} option and name the rest of archives to be
  3141. concatenated on the command line. The members, and their member
  3142. names, will be copied verbatim from those archives to the first one.
  3143. @FIXME-ref{This can cause multiple members to have the same name, for
  3144. information on how this affects reading the archive, Multiple
  3145. Members with the Same Name.}
  3146. The new, concatenated archive will be called by the same name as the
  3147. one given with the @option{--file} option. As usual, if you omit
  3148. @option{--file}, @command{tar} will use the value of the environment
  3149. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3150. @FIXME{There is no way to specify a new name...}
  3151. To demonstrate how @option{--concatenate} works, create two small archives
  3152. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3153. files from @file{practice}:
  3154. @smallexample
  3155. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3156. blues
  3157. classical
  3158. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3159. folk
  3160. jazz
  3161. @end smallexample
  3162. @noindent
  3163. If you like, You can run @samp{tar --list} to make sure the archives
  3164. contain what they are supposed to:
  3165. @smallexample
  3166. $ @kbd{tar -tvf bluesrock.tar}
  3167. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3168. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3169. $ @kbd{tar -tvf folkjazz.tar}
  3170. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3171. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3172. @end smallexample
  3173. We can concatenate these two archives with @command{tar}:
  3174. @smallexample
  3175. $ @kbd{cd ..}
  3176. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3177. @end smallexample
  3178. If you now list the contents of the @file{bluesclass.tar}, you will see
  3179. that now it also contains the archive members of @file{jazzfolk.tar}:
  3180. @smallexample
  3181. $ @kbd{tar --list --file=bluesrock.tar}
  3182. blues
  3183. rock
  3184. jazz
  3185. folk
  3186. @end smallexample
  3187. When you use @option{--concatenate}, the source and target archives must
  3188. already exist and must have been created using compatible format
  3189. parameters. Notice, that @command{tar} does not check whether the
  3190. archives it concatenates have compatible formats, it does not
  3191. even check if the files are really tar archives.
  3192. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3193. tape drives, due to deficiencies in the formats those tape drives use.
  3194. @cindex @code{concatenate} vs @command{cat}
  3195. @cindex @command{cat} vs @code{concatenate}
  3196. It may seem more intuitive to you to want or try to use @command{cat} to
  3197. concatenate two archives instead of using the @option{--concatenate}
  3198. operation; after all, @command{cat} is the utility for combining files.
  3199. However, @command{tar} archives incorporate an end-of-file marker which
  3200. must be removed if the concatenated archives are to be read properly as
  3201. one archive. @option{--concatenate} removes the end-of-archive marker
  3202. from the target archive before each new archive is appended. If you use
  3203. @command{cat} to combine the archives, the result will not be a valid
  3204. @command{tar} format archive. If you need to retrieve files from an
  3205. archive that was added to using the @command{cat} utility, use the
  3206. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3207. information on dealing with archives improperly combined using the
  3208. @command{cat} shell utility.
  3209. @node delete
  3210. @subsection Removing Archive Members Using @option{--delete}
  3211. @UNREVISED
  3212. @cindex Deleting files from an archive
  3213. @cindex Removing files from an archive
  3214. @opindex delete
  3215. You can remove members from an archive by using the @option{--delete}
  3216. option. Specify the name of the archive with @option{--file}
  3217. (@option{-f}) and then specify the names of the members to be deleted;
  3218. if you list no member names, nothing will be deleted. The
  3219. @option{--verbose} option will cause @command{tar} to print the names
  3220. of the members as they are deleted. As with @option{--extract}, you
  3221. must give the exact member names when using @samp{tar --delete}.
  3222. @option{--delete} will remove all versions of the named file from the
  3223. archive. The @option{--delete} operation can run very slowly.
  3224. Unlike other operations, @option{--delete} has no short form.
  3225. @cindex Tapes, using @option{--delete} and
  3226. @cindex Deleting from tape archives
  3227. This operation will rewrite the archive. You can only use
  3228. @option{--delete} on an archive if the archive device allows you to
  3229. write to any point on the media, such as a disk; because of this, it
  3230. does not work on magnetic tapes. Do not try to delete an archive member
  3231. from a magnetic tape; the action will not succeed, and you will be
  3232. likely to scramble the archive and damage your tape. There is no safe
  3233. way (except by completely re-writing the archive) to delete files from
  3234. most kinds of magnetic tape. @xref{Media}.
  3235. To delete all versions of the file @file{blues} from the archive
  3236. @file{collection.tar} in the @file{practice} directory, make sure you
  3237. are in that directory, and then,
  3238. @smallexample
  3239. $ @kbd{tar --list --file=collection.tar}
  3240. blues
  3241. folk
  3242. jazz
  3243. rock
  3244. practice/blues
  3245. practice/folk
  3246. practice/jazz
  3247. practice/rock
  3248. practice/blues
  3249. $ @kbd{tar --delete --file=collection.tar blues}
  3250. $ @kbd{tar --list --file=collection.tar}
  3251. folk
  3252. jazz
  3253. rock
  3254. $
  3255. @end smallexample
  3256. @FIXME{I changed the order of these nodes around and haven't had a chance
  3257. to fix the above example's results, yet. I have to play with this and
  3258. follow it and see what it actually does!}
  3259. The @option{--delete} option has been reported to work properly when
  3260. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3261. @node compare
  3262. @subsection Comparing Archive Members with the File System
  3263. @cindex Verifying the currency of an archive
  3264. @UNREVISED
  3265. @opindex compare
  3266. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3267. specified archive members against files with the same names, and then
  3268. reports differences in file size, mode, owner, modification date and
  3269. contents. You should @emph{only} specify archive member names, not file
  3270. names. If you do not name any members, then @command{tar} will compare the
  3271. entire archive. If a file is represented in the archive but does not
  3272. exist in the file system, @command{tar} reports a difference.
  3273. You have to specify the record size of the archive when modifying an
  3274. archive with a non-default record size.
  3275. @command{tar} ignores files in the file system that do not have
  3276. corresponding members in the archive.
  3277. The following example compares the archive members @file{rock},
  3278. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3279. files of the same name in the file system. (Note that there is no file,
  3280. @file{funk}; @command{tar} will report an error message.)
  3281. @smallexample
  3282. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3283. rock
  3284. blues
  3285. tar: funk not found in archive
  3286. @end smallexample
  3287. The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
  3288. archive represents the current state of files on disk, more than validating
  3289. the integrity of the archive media. For this later goal, @xref{verify}.
  3290. @node create options
  3291. @section Options Used by @option{--create}
  3292. @opindex create, additional options
  3293. The previous chapter described the basics of how to use
  3294. @option{--create} (@option{-c}) to create an archive from a set of files.
  3295. @xref{create}. This section described advanced options to be used with
  3296. @option{--create}.
  3297. @menu
  3298. * Ignore Failed Read::
  3299. @end menu
  3300. @node Ignore Failed Read
  3301. @subsection Ignore Fail Read
  3302. @table @option
  3303. @item --ignore-failed-read
  3304. Do not exit with nonzero on unreadable files or directories.
  3305. @end table
  3306. @node extract options
  3307. @section Options Used by @option{--extract}
  3308. @UNREVISED
  3309. @FIXME{i need to get dan to go over these options with me and see if
  3310. there's a better way of organizing them.}
  3311. @opindex extract, additional options
  3312. The previous chapter showed how to use @option{--extract} to extract
  3313. an archive into the file system. Various options cause @command{tar} to
  3314. extract more information than just file contents, such as the owner,
  3315. the permissions, the modification date, and so forth. This section
  3316. presents options to be used with @option{--extract} when certain special
  3317. considerations arise. You may review the information presented in
  3318. @ref{extract} for more basic information about the
  3319. @option{--extract} operation.
  3320. @menu
  3321. * Reading:: Options to Help Read Archives
  3322. * Writing:: Changing How @command{tar} Writes Files
  3323. * Scarce:: Coping with Scarce Resources
  3324. @end menu
  3325. @node Reading
  3326. @subsection Options to Help Read Archives
  3327. @cindex Options when reading archives
  3328. @UNREVISED
  3329. @cindex Reading incomplete records
  3330. @cindex Records, incomplete
  3331. @opindex read-full-records
  3332. Normally, @command{tar} will request data in full record increments from
  3333. an archive storage device. If the device cannot return a full record,
  3334. @command{tar} will report an error. However, some devices do not always
  3335. return full records, or do not require the last record of an archive to
  3336. be padded out to the next record boundary. To keep reading until you
  3337. obtain a full record, or to accept an incomplete record if it contains
  3338. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3339. in conjunction with the @option{--extract} or @option{--list} operations.
  3340. @xref{Blocking}.
  3341. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3342. @command{tar} reads an archive from standard input, or from a remote
  3343. machine. This is because on BSD Unix systems, attempting to read a
  3344. pipe returns however much happens to be in the pipe, even if it is
  3345. less than was requested. If this option were not enabled, @command{tar}
  3346. would fail as soon as it read an incomplete record from the pipe.
  3347. If you're not sure of the blocking factor of an archive, you can
  3348. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3349. @option{--blocking-factor=@var{512-size}} (@option{-b
  3350. @var{512-size}}), using a blocking factor larger than what the archive
  3351. uses. This lets you avoid having to determine the blocking factor
  3352. of an archive. @xref{Blocking Factor}.
  3353. @menu
  3354. * read full records::
  3355. * Ignore Zeros::
  3356. @end menu
  3357. @node read full records
  3358. @unnumberedsubsubsec Reading Full Records
  3359. @FIXME{need sentence or so of intro here}
  3360. @table @option
  3361. @opindex read-full-records
  3362. @item --read-full-records
  3363. @item -B
  3364. Use in conjunction with @option{--extract} (@option{--get},
  3365. @option{-x}) to read an archive which contains incomplete records, or
  3366. one which has a blocking factor less than the one specified.
  3367. @end table
  3368. @node Ignore Zeros
  3369. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3370. @cindex End-of-archive blocks, ignoring
  3371. @cindex Ignoring end-of-archive blocks
  3372. @opindex ignore-zeros
  3373. Normally, @command{tar} stops reading when it encounters a block of zeros
  3374. between file entries (which usually indicates the end of the archive).
  3375. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3376. completely read an archive which contains a block of zeros before the
  3377. end (i.e., a damaged archive, or one that was created by concatenating
  3378. several archives together).
  3379. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3380. versions of @command{tar} write garbage after the end-of-archive entry,
  3381. since that part of the media is never supposed to be read. @GNUTAR{}
  3382. does not write after the end of an archive, but seeks to
  3383. maintain compatiblity among archiving utilities.
  3384. @table @option
  3385. @item --ignore-zeros
  3386. @itemx -i
  3387. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3388. encountered while reading an archive. Use in conjunction with
  3389. @option{--extract} or @option{--list}.
  3390. @end table
  3391. @node Writing
  3392. @subsection Changing How @command{tar} Writes Files
  3393. @UNREVISED
  3394. @FIXME{Introductory paragraph}
  3395. @menu
  3396. * Dealing with Old Files::
  3397. * Overwrite Old Files::
  3398. * Keep Old Files::
  3399. * Keep Newer Files::
  3400. * Unlink First::
  3401. * Recursive Unlink::
  3402. * Data Modification Times::
  3403. * Setting Access Permissions::
  3404. * Writing to Standard Output::
  3405. * Writing to an External Program::
  3406. * remove files::
  3407. @end menu
  3408. @node Dealing with Old Files
  3409. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3410. @opindex overwrite-dir, introduced
  3411. When extracting files, if @command{tar} discovers that the extracted
  3412. file already exists, it normally replaces the file by removing it before
  3413. extracting it, to prevent confusion in the presence of hard or symbolic
  3414. links. (If the existing file is a symbolic link, it is removed, not
  3415. followed.) However, if a directory cannot be removed because it is
  3416. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3417. permission, etc.). The @option{--overwrite-dir} option enables this
  3418. default behavior. To be more cautious and preserve the metadata of
  3419. such a directory, use the @option{--no-overwrite-dir} option.
  3420. @cindex Overwriting old files, prevention
  3421. @opindex keep-old-files, introduced
  3422. To be even more cautious and prevent existing files from being replaced, use
  3423. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3424. to replace or update a file that already exists, i.e., a file with the
  3425. same name as an archive member prevents extraction of that archive
  3426. member. Instead, it reports an error.
  3427. @opindex overwrite, introduced
  3428. To be more aggressive about altering existing files, use the
  3429. @option{--overwrite} option. It causes @command{tar} to overwrite
  3430. existing files and to follow existing symbolic links when extracting.
  3431. @cindex Protecting old files
  3432. Some people argue that @GNUTAR{} should not hesitate
  3433. to overwrite files with other files when extracting. When extracting
  3434. a @command{tar} archive, they expect to see a faithful copy of the
  3435. state of the file system when the archive was created. It is debatable
  3436. that this would always be a proper behavior. For example, suppose one
  3437. has an archive in which @file{usr/local} is a link to
  3438. @file{usr/local2}. Since then, maybe the site removed the link and
  3439. renamed the whole hierarchy from @file{/usr/local2} to
  3440. @file{/usr/local}. Such things happen all the time. I guess it would
  3441. not be welcome at all that @GNUTAR{} removes the
  3442. whole hierarchy just to make room for the link to be reinstated
  3443. (unless it @emph{also} simultaneously restores the full
  3444. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3445. able to remove a whole hierarchy to reestablish a symbolic link, for
  3446. example, but @emph{only if} @option{--recursive-unlink} is specified
  3447. to allow this behavior. In any case, single files are silently
  3448. removed.
  3449. @opindex unlink-first, introduced
  3450. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3451. some cases by causing @command{tar} to remove files unconditionally
  3452. before extracting them.
  3453. @node Overwrite Old Files
  3454. @unnumberedsubsubsec Overwrite Old Files
  3455. @table @option
  3456. @opindex overwrite
  3457. @item --overwrite
  3458. Overwrite existing files and directory metadata when extracting files
  3459. from an archive.
  3460. This causes @command{tar} to write extracted files into the file system without
  3461. regard to the files already on the system; i.e., files with the same
  3462. names as archive members are overwritten when the archive is extracted.
  3463. It also causes @command{tar} to extract the ownership, permissions,
  3464. and time stamps onto any preexisting files or directories.
  3465. If the name of a corresponding file name is a symbolic link, the file
  3466. pointed to by the symbolic link will be overwritten instead of the
  3467. symbolic link itself (if this is possible). Moreover, special devices,
  3468. empty directories and even symbolic links are automatically removed if
  3469. they are in the way of extraction.
  3470. Be careful when using the @option{--overwrite} option, particularly when
  3471. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3472. can change the contents, ownership or permissions of any file on your
  3473. system. Also, many systems do not take kindly to overwriting files that
  3474. are currently being executed.
  3475. @opindex overwrite-dir
  3476. @item --overwrite-dir
  3477. Overwrite the metadata of directories when extracting files from an
  3478. archive, but remove other files before extracting.
  3479. @end table
  3480. @node Keep Old Files
  3481. @unnumberedsubsubsec Keep Old Files
  3482. @table @option
  3483. @opindex keep-old-files
  3484. @item --keep-old-files
  3485. @itemx -k
  3486. Do not replace existing files from archive. The
  3487. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3488. from replacing existing files with files with the same name from the
  3489. archive. The @option{--keep-old-files} option is meaningless with
  3490. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3491. files in the file system during extraction.
  3492. @end table
  3493. @node Keep Newer Files
  3494. @unnumberedsubsubsec Keep Newer Files
  3495. @table @option
  3496. @opindex keep-newer-files
  3497. @item --keep-newer-files
  3498. Do not replace existing files that are newer than their archive
  3499. copies. This option is meaningless with @option{--list} (@option{-t}).
  3500. @end table
  3501. @node Unlink First
  3502. @unnumberedsubsubsec Unlink First
  3503. @table @option
  3504. @opindex unlink-first
  3505. @item --unlink-first
  3506. @itemx -U
  3507. Remove files before extracting over them.
  3508. This can make @command{tar} run a bit faster if you know in advance
  3509. that the extracted files all need to be removed. Normally this option
  3510. slows @command{tar} down slightly, so it is disabled by default.
  3511. @end table
  3512. @node Recursive Unlink
  3513. @unnumberedsubsubsec Recursive Unlink
  3514. @table @option
  3515. @opindex recursive-unlink
  3516. @item --recursive-unlink
  3517. When this option is specified, try removing files and directory hierarchies
  3518. before extracting over them. @emph{This is a dangerous option!}
  3519. @end table
  3520. If you specify the @option{--recursive-unlink} option,
  3521. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3522. as far as current permissions will allow it. This could include removal
  3523. of the contents of a full directory hierarchy.
  3524. @node Data Modification Times
  3525. @unnumberedsubsubsec Setting Data Modification Times
  3526. @cindex Data modification times of extracted files
  3527. @cindex Modification times of extracted files
  3528. Normally, @command{tar} sets the data modification times of extracted
  3529. files to the corresponding times recorded for the files in the archive, but
  3530. limits the permissions of extracted files by the current @code{umask}
  3531. setting.
  3532. To set the data modification times of extracted files to the time when
  3533. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3534. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3535. @table @option
  3536. @opindex touch
  3537. @item --touch
  3538. @itemx -m
  3539. Sets the data modification time of extracted archive members to the time
  3540. they were extracted, not the time recorded for them in the archive.
  3541. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3542. @end table
  3543. @node Setting Access Permissions
  3544. @unnumberedsubsubsec Setting Access Permissions
  3545. @cindex Permissions of extracted files
  3546. @cindex Modes of extracted files
  3547. To set the modes (access permissions) of extracted files to those
  3548. recorded for those files in the archive, use @option{--same-permissions}
  3549. in conjunction with the @option{--extract} (@option{--get},
  3550. @option{-x}) operation. @FIXME{Should be aliased to ignore-umask.}
  3551. @table @option
  3552. @opindex preserve-permission
  3553. @opindex same-permission
  3554. @item --preserve-permission
  3555. @itemx --same-permission
  3556. @c @itemx --ignore-umask
  3557. @itemx -p
  3558. Set modes of extracted archive members to those recorded in the
  3559. archive, instead of current umask settings. Use in conjunction with
  3560. @option{--extract} (@option{--get}, @option{-x}).
  3561. @end table
  3562. @node Writing to Standard Output
  3563. @unnumberedsubsubsec Writing to Standard Output
  3564. @cindex Writing extracted files to standard output
  3565. @cindex Standard output, writing extracted files to
  3566. To write the extracted files to the standard output, instead of
  3567. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3568. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3569. extracting files to send them through a pipe, and do not need to
  3570. preserve them in the file system. If you extract multiple members,
  3571. they appear on standard output concatenated, in the order they are
  3572. found in the archive.
  3573. @table @option
  3574. @opindex to-stdout
  3575. @item --to-stdout
  3576. @itemx -O
  3577. Writes files to the standard output. Use only in conjunction with
  3578. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3579. used, instead of creating the files specified, @command{tar} writes
  3580. the contents of the files extracted to its standard output. This may
  3581. be useful if you are only extracting the files in order to send them
  3582. through a pipe. This option is meaningless with @option{--list}
  3583. (@option{-t}).
  3584. @end table
  3585. This can be useful, for example, if you have a tar archive containing
  3586. a big file and don't want to store the file on disk before processing
  3587. it. You can use a command like this:
  3588. @smallexample
  3589. tar -xOzf foo.tgz bigfile | process
  3590. @end smallexample
  3591. or even like this if you want to process the concatenation of the files:
  3592. @smallexample
  3593. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3594. @end smallexample
  3595. Hovewer, @option{--to-command} may be more convenient for use with
  3596. multiple files. See the next section.
  3597. @node Writing to an External Program
  3598. @unnumberedsubsubsec Writing to an External Program
  3599. You can instruct @command{tar} to send the contents of each extracted
  3600. file to the standard input of an external program:
  3601. @table @option
  3602. @opindex to-program
  3603. @item --to-program=@var{command}
  3604. Extract files and pipe their contents to the standard input of
  3605. @var{command}. When this option is used, instead of creating the
  3606. files specified, @command{tar} invokes @var{command} and pipes the
  3607. contents of the files to its standard output. @var{Command} may
  3608. contain command line arguments. The program is executed via
  3609. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3610. extracted. Non-regular files (directories, etc.) are ignored when this
  3611. option is used.
  3612. @end table
  3613. The command can obtain the information about the file it processes
  3614. from the following environment variables:
  3615. @table @var
  3616. @vrindex TAR_FILETYPE, to-command environment
  3617. @item TAR_FILETYPE
  3618. Type of the file. It is a single letter with the following meaning:
  3619. @multitable @columnfractions 0.10 0.90
  3620. @item f @tab Regular file
  3621. @item d @tab Directory
  3622. @item l @tab Symbolic link
  3623. @item h @tab Hard link
  3624. @item b @tab Block device
  3625. @item c @tab Character device
  3626. @end multitable
  3627. Currently only regular files are supported.
  3628. @vrindex TAR_MODE, to-command environment
  3629. @item TAR_MODE
  3630. File mode, an octal number.
  3631. @vrindex TAR_FILENAME, to-command environment
  3632. @item TAR_FILENAME
  3633. The name of the file.
  3634. @vrindex TAR_REALNAME, to-command environment
  3635. @item TAR_REALNAME
  3636. Name of the file as stored in the archive.
  3637. @vrindex TAR_UNAME, to-command environment
  3638. @item TAR_UNAME
  3639. Name of the file owner.
  3640. @vrindex TAR_GNAME, to-command environment
  3641. @item TAR_GNAME
  3642. Name of the file owner group.
  3643. @vrindex TAR_ATIME, to-command environment
  3644. @item TAR_ATIME
  3645. Time of last access. It is a decimal number, representing seconds
  3646. since the epoch. If the archive provides times with nanosecond
  3647. precision, the nanoseconds are appended to the timestamp after a
  3648. decimal point.
  3649. @vrindex TAR_MTIME, to-command environment
  3650. @item TAR_MTIME
  3651. Time of last modification.
  3652. @vrindex TAR_CTIME, to-command environment
  3653. @item TAR_CTIME
  3654. Time of last status change.
  3655. @vrindex TAR_SIZE, to-command environment
  3656. @item TAR_SIZE
  3657. Size of the file.
  3658. @vrindex TAR_UID, to-command environment
  3659. @item TAR_UID
  3660. UID of the file owner.
  3661. @vrindex TAR_GID, to-command environment
  3662. @item TAR_GID
  3663. GID of the file owner.
  3664. @end table
  3665. In addition to these variables, @env{TAR_VERSION} contains the
  3666. @GNUTAR{} version number.
  3667. If @var{command} exits with a non-0 status, @command{tar} will print
  3668. an error message similar to the following:
  3669. @smallexample
  3670. tar: 2345: Child returned status 1
  3671. @end smallexample
  3672. Here, @samp{2345} is the PID of the finished process.
  3673. If this behavior is not wanted, use @option{--ignore-command-error}:
  3674. @table @option
  3675. @opindex ignore-command-error
  3676. @item --ignore-command-error
  3677. Ignore exit codes of subprocesses. Notice that if the program
  3678. exits on signal or otherwise terminates abnormally, the error message
  3679. will be printed even if this option is used.
  3680. @opindex no-ignore-command-error
  3681. @item --no-ignore-command-error
  3682. Cancel the effect of any previous @option{--ignore-command-error}
  3683. option. This option is useful if you have set
  3684. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3685. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3686. @end table
  3687. @node remove files
  3688. @unnumberedsubsubsec Removing Files
  3689. @FIXME{the various macros in the front of the manual think that this
  3690. option goes in this section. i have no idea; i only know it's nowhere
  3691. else in the book...}
  3692. @table @option
  3693. @opindex remove-files
  3694. @item --remove-files
  3695. Remove files after adding them to the archive.
  3696. @end table
  3697. @node Scarce
  3698. @subsection Coping with Scarce Resources
  3699. @UNREVISED
  3700. @cindex Small memory
  3701. @cindex Running out of space
  3702. @menu
  3703. * Starting File::
  3704. * Same Order::
  3705. @end menu
  3706. @node Starting File
  3707. @unnumberedsubsubsec Starting File
  3708. @table @option
  3709. @opindex starting-file
  3710. @item --starting-file=@var{name}
  3711. @itemx -K @var{name}
  3712. Starts an operation in the middle of an archive. Use in conjunction
  3713. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3714. @end table
  3715. @cindex Middle of the archive, starting in the
  3716. If a previous attempt to extract files failed due to lack of disk
  3717. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3718. @var{name}}) to start extracting only after member @var{name} of the
  3719. archive. This assumes, of course, that there is now free space, or
  3720. that you are now extracting into a different file system. (You could
  3721. also choose to suspend @command{tar}, remove unnecessary files from
  3722. the file system, and then restart the same @command{tar} operation.
  3723. In this case, @option{--starting-file} is not necessary.
  3724. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3725. @node Same Order
  3726. @unnumberedsubsubsec Same Order
  3727. @table @option
  3728. @cindex Large lists of file names on small machines
  3729. @opindex same-order
  3730. @opindex preserve-order
  3731. @item --same-order
  3732. @itemx --preserve-order
  3733. @itemx -s
  3734. To process large lists of file names on machines with small amounts of
  3735. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3736. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3737. (@option{--get}, @option{-x}).
  3738. @end table
  3739. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3740. names to be listed or extracted is sorted in the same order as the
  3741. files in the archive. This allows a large list of names to be used,
  3742. even on a small machine that would not otherwise be able to hold all
  3743. the names in memory at the same time. Such a sorted list can easily be
  3744. created by running @samp{tar -t} on the archive and editing its output.
  3745. This option is probably never needed on modern computer systems.
  3746. @node backup
  3747. @section Backup options
  3748. @cindex backup options
  3749. @GNUTAR{} offers options for making backups of files
  3750. before writing new versions. These options control the details of
  3751. these backups. They may apply to the archive itself before it is
  3752. created or rewritten, as well as individual extracted members. Other
  3753. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3754. and @command{mv}, for example) offer similar options.
  3755. Backup options may prove unexpectedly useful when extracting archives
  3756. containing many members having identical name, or when extracting archives
  3757. on systems having file name limitations, making different members appear
  3758. has having similar names through the side-effect of name truncation.
  3759. (This is true only if we have a good scheme for truncated backup names,
  3760. which I'm not sure at all: I suspect work is needed in this area.)
  3761. When any existing file is backed up before being overwritten by extraction,
  3762. then clashing files are automatically be renamed to be unique, and the
  3763. true name is kept for only the last file of a series of clashing files.
  3764. By using verbose mode, users may track exactly what happens.
  3765. At the detail level, some decisions are still experimental, and may
  3766. change in the future, we are waiting comments from our users. So, please
  3767. do not learn to depend blindly on the details of the backup features.
  3768. For example, currently, directories themselves are never renamed through
  3769. using these options, so, extracting a file over a directory still has
  3770. good chances to fail. Also, backup options apply to created archives,
  3771. not only to extracted members. For created archives, backups will not
  3772. be attempted when the archive is a block or character device, or when it
  3773. refers to a remote file.
  3774. For the sake of simplicity and efficiency, backups are made by renaming old
  3775. files prior to creation or extraction, and not by copying. The original
  3776. name is restored if the file creation fails. If a failure occurs after a
  3777. partial extraction of a file, both the backup and the partially extracted
  3778. file are kept.
  3779. @table @samp
  3780. @item --backup[=@var{method}]
  3781. @opindex backup
  3782. @vindex VERSION_CONTROL
  3783. @cindex backups
  3784. Back up files that are about to be overwritten or removed.
  3785. Without this option, the original versions are destroyed.
  3786. Use @var{method} to determine the type of backups made.
  3787. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3788. environment variable. And if @env{VERSION_CONTROL} is not set,
  3789. use the @samp{existing} method.
  3790. @vindex version-control @r{Emacs variable}
  3791. This option corresponds to the Emacs variable @samp{version-control};
  3792. the same values for @var{method} are accepted as in Emacs. This option
  3793. also allows more descriptive names. The valid @var{method}s are:
  3794. @table @samp
  3795. @item t
  3796. @itemx numbered
  3797. @cindex numbered @r{backup method}
  3798. Always make numbered backups.
  3799. @item nil
  3800. @itemx existing
  3801. @cindex existing @r{backup method}
  3802. Make numbered backups of files that already have them, simple backups
  3803. of the others.
  3804. @item never
  3805. @itemx simple
  3806. @cindex simple @r{backup method}
  3807. Always make simple backups.
  3808. @end table
  3809. @item --suffix=@var{suffix}
  3810. @opindex suffix
  3811. @cindex backup suffix
  3812. @vindex SIMPLE_BACKUP_SUFFIX
  3813. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3814. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3815. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3816. set, the default is @samp{~}, just as in Emacs.
  3817. @end table
  3818. Some people express the desire to @emph{always} use the @option{--backup}
  3819. option, by defining some kind of alias or script. This is not as easy
  3820. as one may think, due to the fact that old style options should appear first
  3821. and consume arguments a bit unpredictably for an alias or script. But,
  3822. if you are ready to give up using old style options, you may resort to
  3823. using something like (a Bourne shell function here):
  3824. @smallexample
  3825. tar () @{ /usr/local/bin/tar --backup $*; @}
  3826. @end smallexample
  3827. @node Applications
  3828. @section Notable @command{tar} Usages
  3829. @UNREVISED
  3830. @FIXME{Using Unix file linking capability to recreate directory
  3831. structures---linking files into one subdirectory and then
  3832. @command{tar}ring that directory.}
  3833. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3834. @findex uuencode
  3835. You can easily use archive files to transport a group of files from
  3836. one system to another: put all relevant files into an archive on one
  3837. computer system, transfer the archive to another system, and extract
  3838. the contents there. The basic transfer medium might be magnetic tape,
  3839. Internet FTP, or even electronic mail (though you must encode the
  3840. archive with @command{uuencode} in order to transport it properly by
  3841. mail). Both machines do not have to use the same operating system, as
  3842. long as they both support the @command{tar} program.
  3843. For example, here is how you might copy a directory's contents from
  3844. one disk to another, while preserving the dates, modes, owners and
  3845. link-structure of all the files therein. In this case, the transfer
  3846. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3847. @smallexample
  3848. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3849. @end smallexample
  3850. @noindent
  3851. The command also works using short option forms:
  3852. @smallexample
  3853. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3854. @end smallexample
  3855. @noindent
  3856. This is one of the easiest methods to transfer a @command{tar} archive.
  3857. @node looking ahead
  3858. @section Looking Ahead: The Rest of this Manual
  3859. You have now seen how to use all eight of the operations available to
  3860. @command{tar}, and a number of the possible options. The next chapter
  3861. explains how to choose and change file and archive names, how to use
  3862. files to store names of other files which you can then call as
  3863. arguments to @command{tar} (this can help you save time if you expect to
  3864. archive the same list of files a number of times), and so forth.
  3865. @FIXME{in case it's not obvious, i'm making this up in some sense
  3866. based on my limited memory of what the next chapter *really* does. i
  3867. just wanted to flesh out this final section a little bit so i'd
  3868. remember to stick it in here. :-)}
  3869. If there are too many files to conveniently list on the command line,
  3870. you can list the names in a file, and @command{tar} will read that file.
  3871. @xref{files}.
  3872. There are various ways of causing @command{tar} to skip over some files,
  3873. and not archive them. @xref{Choosing}.
  3874. @node Backups
  3875. @chapter Performing Backups and Restoring Files
  3876. @UNREVISED
  3877. @GNUTAR{} is distributed along with the scripts
  3878. which the Free Software Foundation uses for performing backups. There
  3879. is no corresponding scripts available yet for doing restoration of
  3880. files. Even if there is a good chance those scripts may be satisfying
  3881. to you, they are not the only scripts or methods available for doing
  3882. backups and restore. You may well create your own, or use more
  3883. sophisticated packages dedicated to that purpose.
  3884. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3885. Automatic Network Disk Archiver), a backup system developed by James
  3886. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3887. This is free software, and it is available at these places:
  3888. @smallexample
  3889. http://www.cs.umd.edu/projects/amanda/amanda.html
  3890. ftp://ftp.cs.umd.edu/pub/amanda
  3891. @end smallexample
  3892. @FIXME{
  3893. Here is a possible plan for a future documentation about the backuping
  3894. scripts which are provided within the @GNUTAR{}
  3895. distribution.
  3896. @itemize @bullet
  3897. @item dumps
  3898. @itemize @minus
  3899. @item what are dumps
  3900. @item different levels of dumps
  3901. @itemize +
  3902. @item full dump = dump everything
  3903. @item level 1, level 2 dumps etc
  3904. A level @var{n} dump dumps everything changed since the last level
  3905. @var{n}-1 dump (?)
  3906. @end itemize
  3907. @item how to use scripts for dumps (ie, the concept)
  3908. @itemize +
  3909. @item scripts to run after editing backup specs (details)
  3910. @end itemize
  3911. @item Backup Specs, what is it.
  3912. @itemize +
  3913. @item how to customize
  3914. @item actual text of script [/sp/dump/backup-specs]
  3915. @end itemize
  3916. @item Problems
  3917. @itemize +
  3918. @item rsh doesn't work
  3919. @item rtape isn't installed
  3920. @item (others?)
  3921. @end itemize
  3922. @item the @option{--incremental} option of tar
  3923. @item tapes
  3924. @itemize +
  3925. @item write protection
  3926. @item types of media, different sizes and types, useful for different things
  3927. @item files and tape marks
  3928. one tape mark between files, two at end.
  3929. @item positioning the tape
  3930. MT writes two at end of write,
  3931. backspaces over one when writing again.
  3932. @end itemize
  3933. @end itemize
  3934. @end itemize
  3935. }
  3936. This chapter documents both the provided shell scripts and @command{tar}
  3937. options which are more specific to usage as a backup tool.
  3938. To @dfn{back up} a file system means to create archives that contain
  3939. all the files in that file system. Those archives can then be used to
  3940. restore any or all of those files (for instance if a disk crashes or a
  3941. file is accidentally deleted). File system @dfn{backups} are also
  3942. called @dfn{dumps}.
  3943. @menu
  3944. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3945. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  3946. * Backup Levels:: Levels of Backups
  3947. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3948. * Scripted Backups:: Using the Backup Scripts
  3949. * Scripted Restoration:: Using the Restore Script
  3950. @end menu
  3951. @node Full Dumps
  3952. @section Using @command{tar} to Perform Full Dumps
  3953. @UNREVISED
  3954. @cindex full dumps
  3955. @cindex dumps, full
  3956. @cindex corrupted archives
  3957. Full dumps should only be made when no other people or programs
  3958. are modifying files in the file system. If files are modified while
  3959. @command{tar} is making the backup, they may not be stored properly in
  3960. the archive, in which case you won't be able to restore them if you
  3961. have to. (Files not being modified are written with no trouble, and do
  3962. not corrupt the entire archive.)
  3963. You will want to use the @option{--label=@var{archive-label}}
  3964. (@option{-V @var{archive-label}}) option to give the archive a
  3965. volume label, so you can tell what this archive is even if the label
  3966. falls off the tape, or anything like that.
  3967. Unless the file system you are dumping is guaranteed to fit on
  3968. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  3969. Make sure you have enough tapes on hand to complete the backup.
  3970. If you want to dump each file system separately you will need to use
  3971. the @option{--one-file-system} (@option{-l}) option to prevent
  3972. @command{tar} from crossing file system boundaries when storing
  3973. (sub)directories.
  3974. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  3975. option is not needed, since this is a complete copy of everything in
  3976. the file system, and a full restore from this backup would only be
  3977. done onto a completely
  3978. empty disk.
  3979. Unless you are in a hurry, and trust the @command{tar} program (and your
  3980. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  3981. option, to make sure your files really made it onto the dump properly.
  3982. This will also detect cases where the file was modified while (or just
  3983. after) it was being archived. Not all media (notably cartridge tapes)
  3984. are capable of being verified, unfortunately.
  3985. @node Incremental Dumps
  3986. @section Using @command{tar} to Perform Incremental Dumps
  3987. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  3988. stores additional metadata so that exact state of the file system
  3989. can be restored when extracting the archive.
  3990. @GNUTAR{} currently offers two options for handling incremental
  3991. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  3992. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  3993. @opindex listed-incremental
  3994. The option @option{--listed-incremental} instructs tar to operate on
  3995. an incremental archive with additional metadata stored in a standalone
  3996. file, called a @dfn{snapshot file}. The purpose of this file is to help
  3997. determine which files have been changed, added or deleted since the
  3998. last backup, so that the next incremental backup will contain only
  3999. modified files. The name of the snapshot file is given as an argument
  4000. to the option:
  4001. @table @option
  4002. @item --listed-incremental=@var{file}
  4003. @itemx -g @var{file}
  4004. Handle incremental backups with snapshot data in @var{file}.
  4005. @end table
  4006. To create an incremental backup, you would use
  4007. @option{--listed-incremental} together with @option{--create}
  4008. (@pxref{create}). For example:
  4009. @smallexample
  4010. $ @kbd{tar --create \
  4011. --file=archive.1.tar \
  4012. --listed-incremental=/var/log/usr.snar \
  4013. /usr}
  4014. @end smallexample
  4015. This will create in @file{archive.1.tar} an incremental backup of
  4016. the @file{/usr} file system, storing additional metadata in the file
  4017. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4018. created. The created archive will then be a @dfn{level 0 backup};
  4019. please see the next section for more on backup levels.
  4020. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4021. determines which files are modified. In this case only these files will be
  4022. stored in the archive. Suppose, for example, that after running the
  4023. above command, you delete file @file{/usr/doc/old} and create
  4024. directory @file{/usr/local/db} with the following contents:
  4025. @smallexample
  4026. $ @kbd{ls /usr/local/db}
  4027. /usr/local/db/data
  4028. /usr/local/db/index
  4029. @end smallexample
  4030. Some time later you create another incremental backup. You will
  4031. then see:
  4032. @smallexample
  4033. $ @kbd{tar --create \
  4034. --file=archive.2.tar \
  4035. --listed-incremental=/var/log/usr.snar \
  4036. /usr}
  4037. tar: usr/local/db: Directory is new
  4038. usr/local/db/
  4039. usr/local/db/data
  4040. usr/local/db/index
  4041. @end smallexample
  4042. @noindent
  4043. The created archive @file{archive.2.tar} will contain only these
  4044. three members. This archive is called a @dfn{level 1 backup}. Notice
  4045. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4046. you plan to create more @samp{level 1} backups, it is necessary to
  4047. create a working copy of the snapshot file before running
  4048. @command{tar}. The above example will then be modified as follows:
  4049. @smallexample
  4050. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4051. $ @kbd{tar --create \
  4052. --file=archive.2.tar \
  4053. --listed-incremental=/var/log/usr.snar-1 \
  4054. /usr}
  4055. @end smallexample
  4056. Incremental dumps depend crucially on time stamps, so the results are
  4057. unreliable if you modify a file's time stamps during dumping (e.g.,
  4058. with the @option{--atime-preserve=replace} option), or if you set the clock
  4059. backwards.
  4060. Metadata stored in snapshot files include device numbers, which,
  4061. obviously is supposed to be a non-volatile value. However, it turns
  4062. out that NFS devices have undependable values when an automounter
  4063. gets in the picture. This can lead to a great deal of spurious
  4064. redumping in incremental dumps, so it is somewhat useless to compare
  4065. two NFS devices numbers over time. The solution implemented currently
  4066. is to considers all NFS devices as being equal when it comes to
  4067. comparing directories; this is fairly gross, but there does not seem
  4068. to be a better way to go.
  4069. Note that incremental archives use @command{tar} extensions and may
  4070. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4071. @opindex listed-incremental, using with @option{--extract}
  4072. @opindex extract, using with @option{--listed-incremental}
  4073. To extract from the incremental dumps, use
  4074. @option{--listed-incremental} together with @option{--extract}
  4075. option (@pxref{extracting files}). In this case, @command{tar} does
  4076. not need to access snapshot file, since all the data necessary for
  4077. extraction are stored in the archive itself. So, when extracting, you
  4078. can give whatever argument to @option{--listed-incremental}, the usual
  4079. practice is to use @option{--listed-incremental=/dev/null}.
  4080. Alternatively, you can use @option{--incremental}, which needs no
  4081. arguments. In general, @option{--incremental} (@option{-G}) can be
  4082. used as a shortcut for @option{--listed-incremental} when listing or
  4083. extracting incremental backups (for more information, regarding this
  4084. option, @pxref{incremental-op}).
  4085. When extracting from the incremental backup @GNUTAR{} attempts to
  4086. restore the exact state the file system had when the archive was
  4087. created. In particular, it will @emph{delete} those files in the file
  4088. system that did not exist in their directories when the archive was
  4089. created. If you have created several levels of incremental files,
  4090. then in order to restore the exact contents the file system had when
  4091. the last level was created, you will need to restore from all backups
  4092. in turn. Continuing our example, to restore the state of @file{/usr}
  4093. file system, one would do@footnote{Notice, that since both archives
  4094. were created withouth @option{-P} option (@pxref{absolute}), these
  4095. commands should be run from the root file system.}:
  4096. @smallexample
  4097. $ @kbd{tar --extract \
  4098. --listed-incremental=/dev/null \
  4099. --file archive.1.tar}
  4100. $ @kbd{tar --extract \
  4101. --listed-incremental=/dev/null \
  4102. --file archive.2.tar}
  4103. @end smallexample
  4104. To list the contents of an incremental archive, use @option{--list}
  4105. (@pxref{list}), as usual. To obtain more information about the
  4106. archive, use @option{--listed-incremental} or @option{--incremental}
  4107. combined with two @option{--verbose} options@footnote{Two
  4108. @option{--verbose} options were selected to avoid breaking usual
  4109. verbose listing output (@option{--list --verbose}) when using in
  4110. scripts.
  4111. @opindex incremental, using with @option{--list}
  4112. @opindex listed-incremental, using with @option{--list}
  4113. @opindex list, using with @option{--incremental}
  4114. @opindex list, using with @option{--listed-incremental}
  4115. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4116. contents of the DUMPDIR header (with terminating nulls) when
  4117. @option{--incremental} or @option{--listed-incremental} option was
  4118. given, no matter what the verbosity level. This behavior, and,
  4119. especially, the binary output it produced were considered incovenient
  4120. and were changed in version 1.16}:
  4121. @smallexample
  4122. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4123. @end smallexample
  4124. This command will print, for each directory in the archive, the list
  4125. of files in that directory at the time the archive was created. This
  4126. information is put out in a format which is both human-readable and
  4127. unambiguous for a program: each file name is printed as
  4128. @smallexample
  4129. @var{x} @var{file}
  4130. @end smallexample
  4131. @noindent
  4132. where @var{x} is a letter describing the status of the file: @samp{Y}
  4133. if the file is present in the archive, @samp{N} if the file is not
  4134. included in the archive, or a @samp{D} if the file is a directory (and
  4135. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4136. line is terminated by a newline character. The last line is followed
  4137. by an additional newline to indicate the end of the data.
  4138. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4139. gives the same behavior as @option{--listed-incremental} when used
  4140. with @option{--list} and @option{--extract} options. When used with
  4141. @option{--create} option, it creates an incremental archive without
  4142. creating snapshot file. Thus, it is impossible to create several
  4143. levels of incremental backups with @option{--incremental} option.
  4144. @node Backup Levels
  4145. @section Levels of Backups
  4146. An archive containing all the files in the file system is called a
  4147. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4148. creating a full dump every day. This strategy, however, would waste a
  4149. substantial amount of archive media and user time, as unchanged files
  4150. are daily re-archived.
  4151. It is more efficient to do a full dump only occasionally. To back up
  4152. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4153. one} dump archives all the files that have changed since the last full
  4154. dump.
  4155. A typical dump strategy would be to perform a full dump once a week,
  4156. and a level one dump once a day. This means some versions of files
  4157. will in fact be archived more than once, but this dump strategy makes
  4158. it possible to restore a file system to within one day of accuracy by
  4159. only extracting two archives---the last weekly (full) dump and the
  4160. last daily (level one) dump. The only information lost would be in
  4161. files changed or created since the last daily backup. (Doing dumps
  4162. more than once a day is usually not worth the trouble).
  4163. @GNUTAR{} comes with scripts you can use to do full
  4164. and level-one (actually, even level-two and so on) dumps. Using
  4165. scripts (shell programs) to perform backups and restoration is a
  4166. convenient and reliable alternative to typing out file name lists
  4167. and @command{tar} commands by hand.
  4168. Before you use these scripts, you need to edit the file
  4169. @file{backup-specs}, which specifies parameters used by the backup
  4170. scripts and by the restore script. This file is usually located
  4171. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4172. detailed description. Once the backup parameters are set, you can
  4173. perform backups or restoration by running the appropriate script.
  4174. The name of the backup script is @code{backup}. The name of the
  4175. restore script is @code{restore}. The following sections describe
  4176. their use in detail.
  4177. @emph{Please Note:} The backup and restoration scripts are
  4178. designed to be used together. While it is possible to restore files by
  4179. hand from an archive which was created using a backup script, and to create
  4180. an archive by hand which could then be extracted using the restore script,
  4181. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4182. making such an attempt.
  4183. @node Backup Parameters
  4184. @section Setting Parameters for Backups and Restoration
  4185. The file @file{backup-specs} specifies backup parameters for the
  4186. backup and restoration scripts provided with @command{tar}. You must
  4187. edit @file{backup-specs} to fit your system configuration and schedule
  4188. before using these scripts.
  4189. Syntactically, @file{backup-specs} is a shell script, containing
  4190. mainly variable assignments. However, any valid shell construct
  4191. is allowed in this file. Particularly, you may wish to define
  4192. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4193. For more information about shell script syntax, please refer to
  4194. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4195. g_02, the definition of the Shell Command Language}. See also
  4196. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4197. The shell variables controlling behavior of @code{backup} and
  4198. @code{restore} are described in the following subsections.
  4199. @menu
  4200. * General-Purpose Variables::
  4201. * Magnetic Tape Control::
  4202. * User Hooks::
  4203. * backup-specs example:: An Example Text of @file{Backup-specs}
  4204. @end menu
  4205. @node General-Purpose Variables
  4206. @subsection General-Purpose Variables
  4207. @defvr {Backup variable} ADMINISTRATOR
  4208. The user name of the backup administrator. @code{Backup} scripts
  4209. sends a backup report to this address.
  4210. @end defvr
  4211. @defvr {Backup variable} BACKUP_HOUR
  4212. The hour at which the backups are done. This can be a number from 0
  4213. to 23, or the time specification in form @var{hours}:@var{minutes},
  4214. or the string @samp{now}.
  4215. This variable is used by @code{backup}. Its value may be overridden
  4216. using @option{--time} option (@pxref{Scripted Backups}).
  4217. @end defvr
  4218. @defvr {Backup variable} TAPE_FILE
  4219. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4220. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4221. that your @command{mt} is able to access remote devices. If @var{RSH}
  4222. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4223. invocations of @command{mt}.
  4224. @end defvr
  4225. @defvr {Backup variable} BLOCKING
  4226. The blocking factor @command{tar} will use when writing the dump archive.
  4227. @xref{Blocking Factor}.
  4228. @end defvr
  4229. @defvr {Backup variable} BACKUP_DIRS
  4230. A list of file systems to be dumped (for @code{backup}), or restored
  4231. (for @code{restore}). You can include any directory
  4232. name in the list --- subdirectories on that file system will be
  4233. included, regardless of how they may look to other networked machines.
  4234. Subdirectories on other file systems will be ignored.
  4235. The host name specifies which host to run @command{tar} on, and should
  4236. normally be the host that actually contains the file system. However,
  4237. the host machine must have @GNUTAR{} installed, and
  4238. must be able to access the directory containing the backup scripts and
  4239. their support files using the same file name that is used on the
  4240. machine where the scripts are run (ie. what @command{pwd} will print
  4241. when in that directory on that machine). If the host that contains
  4242. the file system does not have this capability, you can specify another
  4243. host as long as it can access the file system through NFS.
  4244. If the list of file systems is very long you may wish to put it
  4245. in a separate file. This file is usually named
  4246. @file{/etc/backup/dirs}, but this name may be overridden in
  4247. @file{backup-specs} using @code{DIRLIST} variable.
  4248. @end defvr
  4249. @defvr {Backup variable} DIRLIST
  4250. A path to the file containing the list of the file systems to backup
  4251. or restore. By default it is @file{/etc/backup/dirs}.
  4252. @end defvr
  4253. @defvr {Backup variable} BACKUP_FILES
  4254. A list of individual files to be dumped (for @code{backup}), or restored
  4255. (for @code{restore}). These should be accessible from the machine on
  4256. which the backup script is run.
  4257. If the list of file systems is very long you may wish to store it
  4258. in a separate file. This file is usually named
  4259. @file{/etc/backup/files}, but this name may be overridden in
  4260. @file{backup-specs} using @code{FILELIST} variable.
  4261. @end defvr
  4262. @defvr {Backup variable} FILELIST
  4263. A path to the file containing the list of the individual files to backup
  4264. or restore. By default it is @file{/etc/backup/files}.
  4265. @end defvr
  4266. @defvr {Backup variable} MT
  4267. Full file name of @command{mt} binary.
  4268. @end defvr
  4269. @defvr {Backup variable} RSH
  4270. @anchor{RSH}
  4271. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4272. set it to @code{ssh}, to improve security. In this case you will have
  4273. to use public key authentication.
  4274. @end defvr
  4275. @defvr {Backup variable} RSH_COMMAND
  4276. Full file name of @command{rsh} binary on remote mashines. This will
  4277. be passed via @option{--rsh-command} option to the remote invocation
  4278. of @GNUTAR{}.
  4279. @end defvr
  4280. @defvr {Backup variable} VOLNO_FILE
  4281. Name of temporary file to hold volume numbers. This needs to be accessible
  4282. by all the machines which have file systems to be dumped.
  4283. @end defvr
  4284. @defvr {Backup variable} XLIST
  4285. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4286. located on the remote machine and containing the list of files to
  4287. be excluded from the backup. Exclude file lists are searched in
  4288. /etc/tar-backup directory. A common use for exclude file lists
  4289. is to exclude files containing security-sensitive information
  4290. (e.g., @file{/etc/shadow} from backups).
  4291. This variable affects only @code{backup}.
  4292. @end defvr
  4293. @defvr {Backup variable} SLEEP_TIME
  4294. Time to sleep between dumps of any two successive file systems
  4295. This variable affects only @code{backup}.
  4296. @end defvr
  4297. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4298. Script to be run when it's time to insert a new tape in for the next
  4299. volume. Administrators may want to tailor this script for their site.
  4300. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4301. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4302. the console.
  4303. @end defvr
  4304. @defvr {Backup variable} SLEEP_MESSAGE
  4305. Message to display on the terminal while waiting for dump time. Usually
  4306. this will just be some literal text.
  4307. @end defvr
  4308. @defvr {Backup variable} TAR
  4309. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4310. scripts will search @command{tar} in the current shell path.
  4311. @end defvr
  4312. @node Magnetic Tape Control
  4313. @subsection Magnetic Tape Control
  4314. Backup scripts access tape device using special @dfn{hook functions}.
  4315. These functions take a single argument -- the name of the tape
  4316. device. Their names are kept in the following variables:
  4317. @defvr {Backup variable} MT_BEGIN
  4318. The name of @dfn{begin} function. This function is called before
  4319. accessing the drive. By default it retensions the tape:
  4320. @smallexample
  4321. MT_BEGIN=mt_begin
  4322. mt_begin() @{
  4323. mt -f "$1" retension
  4324. @}
  4325. @end smallexample
  4326. @end defvr
  4327. @defvr {Backup variable} MT_REWIND
  4328. The name of @dfn{rewind} function. The default definition is as
  4329. follows:
  4330. @smallexample
  4331. MT_REWIND=mt_rewind
  4332. mt_rewind() @{
  4333. mt -f "$1" rewind
  4334. @}
  4335. @end smallexample
  4336. @end defvr
  4337. @defvr {Backup variable} MT_OFFLINE
  4338. The name of the function switching the tape off line. By default
  4339. it is defined as follows:
  4340. @smallexample
  4341. MT_OFFLINE=mt_offline
  4342. mt_offline() @{
  4343. mt -f "$1" offl
  4344. @}
  4345. @end smallexample
  4346. @end defvr
  4347. @defvr {Backup variable} MT_STATUS
  4348. The name of the function used to obtain the status of the archive device,
  4349. including error count. Default definition:
  4350. @smallexample
  4351. MT_STATUS=mt_status
  4352. mt_status() @{
  4353. mt -f "$1" status
  4354. @}
  4355. @end smallexample
  4356. @end defvr
  4357. @node User Hooks
  4358. @subsection User Hooks
  4359. @dfn{User hooks} are shell functions executed before and after
  4360. each @command{tar} invocation. Thus, there are @dfn{backup
  4361. hooks}, which are executed before and after dumping each file
  4362. system, and @dfn{restore hooks}, executed before and
  4363. after restoring a file system. Each user hook is a shell function
  4364. taking four arguments:
  4365. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4366. Its arguments are:
  4367. @table @var
  4368. @item level
  4369. Current backup or restore level.
  4370. @item host
  4371. Name or IP address of the host machine being dumped or restored.
  4372. @item fs
  4373. Full path name to the file system being dumped or restored.
  4374. @item fsname
  4375. File system name with directory separators replaced with colons. This
  4376. is useful, e.g., for creating unique files.
  4377. @end table
  4378. @end deffn
  4379. Following variables keep the names of user hook functions
  4380. @defvr {Backup variable} DUMP_BEGIN
  4381. Dump begin function. It is executed before dumping the file system.
  4382. @end defvr
  4383. @defvr {Backup variable} DUMP_END
  4384. Executed after dumping the file system.
  4385. @end defvr
  4386. @defvr {Backup variable} RESTORE_BEGIN
  4387. Executed before restoring the file system.
  4388. @end defvr
  4389. @defvr {Backup variable} RESTORE_END
  4390. Executed after restoring the file system.
  4391. @end defvr
  4392. @node backup-specs example
  4393. @subsection An Example Text of @file{Backup-specs}
  4394. The following is an example of @file{backup-specs}:
  4395. @smallexample
  4396. # site-specific parameters for file system backup.
  4397. ADMINISTRATOR=friedman
  4398. BACKUP_HOUR=1
  4399. TAPE_FILE=/dev/nrsmt0
  4400. # Use @code{ssh} instead of the less secure @code{rsh}
  4401. RSH=/usr/bin/ssh
  4402. RSH_COMMAND=/usr/bin/ssh
  4403. # Override MT_STATUS function:
  4404. my_status() @{
  4405. mts -t $TAPE_FILE
  4406. @}
  4407. MT_STATUS=my_status
  4408. # Disable MT_OFFLINE function
  4409. MT_OFFLINE=:
  4410. BLOCKING=124
  4411. BACKUP_DIRS="
  4412. albert:/fs/fsf
  4413. apple-gunkies:/gd
  4414. albert:/fs/gd2
  4415. albert:/fs/gp
  4416. geech:/usr/jla
  4417. churchy:/usr/roland
  4418. albert:/
  4419. albert:/usr
  4420. apple-gunkies:/
  4421. apple-gunkies:/usr
  4422. gnu:/hack
  4423. gnu:/u
  4424. apple-gunkies:/com/mailer/gnu
  4425. apple-gunkies:/com/archive/gnu"
  4426. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4427. @end smallexample
  4428. @node Scripted Backups
  4429. @section Using the Backup Scripts
  4430. The syntax for running a backup script is:
  4431. @smallexample
  4432. backup --level=@var{level} --time=@var{time}
  4433. @end smallexample
  4434. The @option{level} option requests the dump level. Thus, to produce
  4435. a full dump, specify @code{--level=0} (this is the default, so
  4436. @option{--level} may be omitted if its value is @code{0}).
  4437. @footnote{For backward compatibility, the @code{backup} will also
  4438. try to deduce the requested dump level from the name of the
  4439. script itself. If the name consists of a string @samp{level-}
  4440. followed by a single decimal digit, that digit is taken as
  4441. the dump level number. Thus, you may create a link from @code{backup}
  4442. to @code{level-1} and then run @code{level-1} whenever you need to
  4443. create a level one dump.}
  4444. The @option{--time} option determines when should the backup be
  4445. run. @var{Time} may take three forms:
  4446. @table @asis
  4447. @item @var{hh}:@var{mm}
  4448. The dump must be run at @var{hh} hours @var{mm} minutes.
  4449. @item @var{hh}
  4450. The dump must be run at @var{hh} hours
  4451. @item now
  4452. The dump must be run immediately.
  4453. @end table
  4454. You should start a script with a tape or disk mounted. Once you
  4455. start a script, it prompts you for new tapes or disks as it
  4456. needs them. Media volumes don't have to correspond to archive
  4457. files --- a multi-volume archive can be started in the middle of a
  4458. tape that already contains the end of another multi-volume archive.
  4459. The @code{restore} script prompts for media by its archive volume,
  4460. so to avoid an error message you should keep track of which tape
  4461. (or disk) contains which volume of the archive (@pxref{Scripted
  4462. Restoration}).
  4463. The backup scripts write two files on the file system. The first is a
  4464. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4465. to store and retrieve information about which files were dumped. This
  4466. file is not meant to be read by humans, and should not be deleted by
  4467. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4468. file.
  4469. The second file is a log file containing the names of the file systems
  4470. and files dumped, what time the backup was made, and any error
  4471. messages that were generated, as well as how much space was left in
  4472. the media volume after the last volume of the archive was written.
  4473. You should check this log file after every backup. The file name is
  4474. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4475. represents current date, and @var{n} represents current dump level number.
  4476. The script also prints the name of each system being dumped to the
  4477. standard output.
  4478. Following is the full list of options accepted by @code{backup}
  4479. script:
  4480. @table @option
  4481. @item -l @var{level}
  4482. @itemx --level=@var{level}
  4483. Do backup level @var{level} (default 0).
  4484. @item -f
  4485. @itemx --force
  4486. Force backup even if today's log file already exists.
  4487. @item -v[@var{level}]
  4488. @itemx --verbose[=@var{level}]
  4489. Set verbosity level. The higher the level is, the more debugging
  4490. information will be output during execution. Devault @var{level}
  4491. is 100, which means the highest debugging level.
  4492. @item -t @var{start-time}
  4493. @itemx --time=@var{start-time}
  4494. Wait till @var{time}, then do backup.
  4495. @item -h
  4496. @itemx --help
  4497. Display short help message and exit.
  4498. @item -L
  4499. @itemx --license
  4500. Display program license and exit.
  4501. @item -V
  4502. @itemx --version
  4503. Display program version and exit.
  4504. @end table
  4505. @node Scripted Restoration
  4506. @section Using the Restore Script
  4507. To restore files that were archived using a scripted backup, use the
  4508. @code{restore} script. Its usage is quite straightforward. In the
  4509. simplest form, invoke @code{restore --all}, it will
  4510. then restore all the file systems and files specified in
  4511. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4512. You may select the file systems (and/or files) to restore by
  4513. giving @code{restore} list of @dfn{patterns} in its command
  4514. line. For example, running
  4515. @smallexample
  4516. restore 'albert:*'
  4517. @end smallexample
  4518. @noindent
  4519. will restore all file systems on the machine @samp{albert}. A more
  4520. complicated example:
  4521. @smallexample
  4522. restore 'albert:*' '*:/var'
  4523. @end smallexample
  4524. @noindent
  4525. This command will restore all file systems on the machine @samp{albert}
  4526. as well as @file{/var} file system on all machines.
  4527. By default @code{restore} will start restoring files from the lowest
  4528. available dump level (usually zero) and will continue through
  4529. all available dump levels. There may be situations where such a
  4530. thorough restore is not necessary. For example, you may wish to
  4531. restore only files from the recent level one backup. To do so,
  4532. use @option{--level} option, as shown in the example below:
  4533. @smallexample
  4534. restore --level=1
  4535. @end smallexample
  4536. The full list of options accepted by @code{restore} follows:
  4537. @table @option
  4538. @item -a
  4539. @itemx --all
  4540. Restore all file systems and files specified in @file{backup-specs}
  4541. @item -l @var{level}
  4542. @itemx --level=@var{level}
  4543. Start restoring from the given backup level, instead of the default 0.
  4544. @item -v[@var{level}]
  4545. @itemx --verbose[=@var{level}]
  4546. Set verbosity level. The higher the level is, the more debugging
  4547. information will be output during execution. Devault @var{level}
  4548. is 100, which means the highest debugging level.
  4549. @item -h
  4550. @itemx --help
  4551. Display short help message and exit.
  4552. @item -L
  4553. @itemx --license
  4554. Display program license and exit.
  4555. @item -V
  4556. @itemx --version
  4557. Display program version and exit.
  4558. @end table
  4559. You should start the restore script with the media containing the
  4560. first volume of the archive mounted. The script will prompt for other
  4561. volumes as they are needed. If the archive is on tape, you don't need
  4562. to rewind the tape to to its beginning---if the tape head is
  4563. positioned past the beginning of the archive, the script will rewind
  4564. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4565. positioning.}
  4566. @quotation
  4567. @strong{Warning:} The script will delete files from the active file
  4568. system if they were not in the file system when the archive was made.
  4569. @end quotation
  4570. @xref{Incremental Dumps}, for an explanation of how the script makes
  4571. that determination.
  4572. @node Choosing
  4573. @chapter Choosing Files and Names for @command{tar}
  4574. @UNREVISED
  4575. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4576. Certain options to @command{tar} enable you to specify a name for your
  4577. archive. Other options let you decide which files to include or exclude
  4578. from the archive, based on when or whether files were modified, whether
  4579. the file names do or don't match specified patterns, or whether files
  4580. are in specified directories.
  4581. @menu
  4582. * file:: Choosing the Archive's Name
  4583. * Selecting Archive Members::
  4584. * files:: Reading Names from a File
  4585. * exclude:: Excluding Some Files
  4586. * Wildcards::
  4587. * after:: Operating Only on New Files
  4588. * recurse:: Descending into Directories
  4589. * one:: Crossing File System Boundaries
  4590. @end menu
  4591. @node file
  4592. @section Choosing and Naming Archive Files
  4593. @UNREVISED
  4594. @FIXME{should the title of this section actually be, "naming an
  4595. archive"?}
  4596. @cindex Naming an archive
  4597. @cindex Archive Name
  4598. @cindex Choosing an archive file
  4599. @cindex Where is the archive?
  4600. By default, @command{tar} uses an archive file name that was compiled when
  4601. it was built on the system; usually this name refers to some physical
  4602. tape drive on the machine. However, the person who installed @command{tar}
  4603. on the system may not set the default to a meaningful value as far as
  4604. most users are concerned. As a result, you will usually want to tell
  4605. @command{tar} where to find (or create) the archive. The @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4606. option allows you to either specify or name a file to use as the archive
  4607. instead of the default archive file location.
  4608. @table @option
  4609. @opindex file, short description
  4610. @item --file=@var{archive-name}
  4611. @itemx -f @var{archive-name}
  4612. Name the archive to create or operate on. Use in conjunction with
  4613. any operation.
  4614. @end table
  4615. For example, in this @command{tar} command,
  4616. @smallexample
  4617. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4618. @end smallexample
  4619. @noindent
  4620. @file{collection.tar} is the name of the archive. It must directly
  4621. follow the @option{-f} option, since whatever directly follows @option{-f}
  4622. @emph{will} end up naming the archive. If you neglect to specify an
  4623. archive name, you may end up overwriting a file in the working directory
  4624. with the archive you create since @command{tar} will use this file's name
  4625. for the archive name.
  4626. An archive can be saved as a file in the file system, sent through a
  4627. pipe or over a network, or written to an I/O device such as a tape,
  4628. floppy disk, or CD write drive.
  4629. @cindex Writing new archives
  4630. @cindex Archive creation
  4631. If you do not name the archive, @command{tar} uses the value of the
  4632. environment variable @env{TAPE} as the file name for the archive. If
  4633. that is not available, @command{tar} uses a default, compiled-in archive
  4634. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4635. @command{tar} always needs an archive name.
  4636. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4637. archive from standard input (when listing or extracting files), or
  4638. writes it to standard output (when creating an archive). If you use
  4639. @file{-} as an @var{archive-name} when modifying an archive,
  4640. @command{tar} reads the original archive from its standard input and
  4641. writes the entire new archive to its standard output.
  4642. @FIXME{might want a different example here; this is already used in
  4643. "notable tar usages".}
  4644. @smallexample
  4645. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4646. @end smallexample
  4647. @FIXME{help!}
  4648. @cindex Standard input and output
  4649. @cindex tar to standard input and output
  4650. @anchor{remote-dev}
  4651. To specify an archive file on a device attached to a remote machine,
  4652. use the following:
  4653. @smallexample
  4654. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4655. @end smallexample
  4656. @noindent
  4657. @command{tar} will complete the remote connection, if possible, and
  4658. prompt you for a username and password. If you use
  4659. @option{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4660. will complete the remote connection, if possible, using your username
  4661. as the username on the remote machine.
  4662. @cindex Local and remote archives
  4663. @anchor{local and remote archives}
  4664. If the archive file name includes a colon (@samp{:}), then it is assumed
  4665. to be a file on another machine. If the archive file is
  4666. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4667. host @var{host}. The remote host is accessed using the @command{rsh}
  4668. program, with a username of @var{user}. If the username is omitted
  4669. (along with the @samp{@@} sign), then your user name will be used.
  4670. (This is the normal @command{rsh} behavior.) It is necessary for the
  4671. remote machine, in addition to permitting your @command{rsh} access, to
  4672. have the @file{rmt} program installed (This command is included in
  4673. the @GNUTAR{} distribution and by default is installed under
  4674. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4675. installation prefix). If you need to use a file whose name includes a
  4676. colon, then the remote tape drive behavior
  4677. can be inhibited by using the @option{--force-local} option.
  4678. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4679. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4680. into what came before it well enough <<i moved it now, is it better
  4681. here?>>. bob also comments that if Amanda isn't free software, we
  4682. shouldn't mention it..}
  4683. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4684. tries to minimize input and output operations. The
  4685. Amanda backup system, when used with @GNUTAR{}, has
  4686. an initial sizing pass which uses this feature.
  4687. @node Selecting Archive Members
  4688. @section Selecting Archive Members
  4689. @cindex Specifying files to act on
  4690. @cindex Specifying archive members
  4691. @dfn{File Name arguments} specify which files in the file system
  4692. @command{tar} operates on, when creating or adding to an archive, or which
  4693. archive members @command{tar} operates on, when reading or deleting from
  4694. an archive. @xref{Operations}.
  4695. To specify file names, you can include them as the last arguments on
  4696. the command line, as follows:
  4697. @smallexample
  4698. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4699. @end smallexample
  4700. If a file name begins with dash (@samp{-}), preceede it with
  4701. @option{--add-file} option to preventit from being treated as an
  4702. option.
  4703. If you specify a directory name as a file name argument, all the files
  4704. in that directory are operated on by @command{tar}.
  4705. If you do not specify files when @command{tar} is invoked with
  4706. @option{--create} (@option{-c}), @command{tar} operates on all the non-directory files in
  4707. the working directory. If you specify either @option{--list} (@option{-t}) or
  4708. @option{--extract} (@option{--get}, @option{-x}), @command{tar} operates on all the archive members in the
  4709. archive. If you specify any operation other than one of these three,
  4710. @command{tar} does nothing.
  4711. By default, @command{tar} takes file names from the command line. However,
  4712. there are other ways to specify file or member names, or to modify the
  4713. manner in which @command{tar} selects the files or members upon which to
  4714. operate. @FIXME{add xref here}In general, these methods work both for
  4715. specifying the names of files and archive members.
  4716. @node files
  4717. @section Reading Names from a File
  4718. @cindex Reading file names from a file
  4719. @cindex Lists of file names
  4720. @cindex File Name arguments, alternatives
  4721. Instead of giving the names of files or archive members on the command
  4722. line, you can put the names into a file, and then use the
  4723. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option to @command{tar}. Give the name of the file
  4724. which contains the list of files to include as the argument to
  4725. @option{--files-from}. In the list, the file names should be separated by
  4726. newlines. You will frequently use this option when you have generated
  4727. the list of files to archive with the @command{find} utility.
  4728. @table @option
  4729. @opindex files-from
  4730. @item --files-from=@var{file name}
  4731. @itemx -T @var{file name}
  4732. Get names to extract or create from file @var{file name}.
  4733. @end table
  4734. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4735. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4736. names are read from standard input.
  4737. Unless you are running @command{tar} with @option{--create}, you can not use
  4738. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4739. command.
  4740. Any number of @option{-T} options can be given in the command line.
  4741. @FIXME{add bob's example, from his message on 2-10-97}
  4742. The following example shows how to use @command{find} to generate a list of
  4743. files smaller than 400K in length and put that list into a file
  4744. called @file{small-files}. You can then use the @option{-T} option to
  4745. @command{tar} to specify the files from that file, @file{small-files}, to
  4746. create the archive @file{little.tgz}. (The @option{-z} option to
  4747. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4748. more information.)
  4749. @smallexample
  4750. $ @kbd{find . -size -400 -print > small-files}
  4751. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4752. @end smallexample
  4753. @noindent
  4754. In the file list given by @option{-T} option, any file name beginning
  4755. with @samp{-} character is considered a @command{tar} option and is
  4756. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4757. recognized only @option{-C} option in file lists, and only if the
  4758. option and its argument occupied two consecutive lines.} For example,
  4759. the common use of this feature is to change to another directory by
  4760. specifying @option{-C} option:
  4761. @smallexample
  4762. @group
  4763. $ @kbd{cat list}
  4764. -C/etc
  4765. passwd
  4766. hosts
  4767. -C/lib
  4768. libc.a
  4769. $ @kbd{tar -c -f foo.tar --files-from list}
  4770. @end group
  4771. @end smallexample
  4772. @noindent
  4773. In this example, @command{tar} will first switch to @file{/etc}
  4774. directory and add files @file{passwd} and @file{hosts} to the
  4775. archive. Then it will change to @file{/lib} directory and will archive
  4776. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4777. contain:
  4778. @smallexample
  4779. @group
  4780. $ @kbd{tar tf foo.tar}
  4781. passwd
  4782. hosts
  4783. libc.a
  4784. @end group
  4785. @end smallexample
  4786. @noindent
  4787. @opindex directory, using in @option{--files-from} argument
  4788. Notice that the option parsing algorithm used with @option{-T} is
  4789. stricter than the one used by shell. Namely, when specifying option
  4790. arguments, you should observe the following rules:
  4791. @itemize @bullet
  4792. @item
  4793. When using short (single-letter) option form, its argument must
  4794. immediately follow the option letter, without any intervening
  4795. whitespace. For example: @code{-Cdir}.
  4796. @item
  4797. When using long option form, the option argument must be separated
  4798. from the option by a single equal sign. No whitespace is allowed on
  4799. any side of the equal sign. For example: @code{--directory=dir}.
  4800. @item
  4801. For both short and long option forms, the option argument can be given
  4802. on the next line after the option name, e.g.:
  4803. @smallexample
  4804. @group
  4805. --directory
  4806. dir
  4807. @end group
  4808. @end smallexample
  4809. @noindent
  4810. and
  4811. @smallexample
  4812. @group
  4813. -C
  4814. dir
  4815. @end group
  4816. @end smallexample
  4817. @end itemize
  4818. @opindex add-file
  4819. If you happen to have a file whose name starts with @samp{-},
  4820. precede it with @option{--add-file} option to prevent it from
  4821. being recognized as an option. For example: @code{--add-file --my-file}.
  4822. @menu
  4823. * nul::
  4824. @end menu
  4825. @node nul
  4826. @subsection @code{NUL} Terminated File Names
  4827. @cindex File names, terminated by @code{NUL}
  4828. @cindex @code{NUL} terminated file names
  4829. The @option{--null} option causes @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) to read file
  4830. names terminated by a @code{NUL} instead of a newline, so files whose
  4831. names contain newlines can be archived using @option{--files-from}.
  4832. @table @option
  4833. @opindex null
  4834. @item --null
  4835. Only consider @code{NUL} terminated file names, instead of files that
  4836. terminate in a newline.
  4837. @end table
  4838. The @option{--null} option is just like the one in @acronym{GNU}
  4839. @command{xargs} and @command{cpio}, and is useful with the
  4840. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4841. @command{tar}, @option{--null} also disables special handling for
  4842. file names that begin with dash.
  4843. This example shows how to use @command{find} to generate a list of files
  4844. larger than 800K in length and put that list into a file called
  4845. @file{long-files}. The @option{-print0} option to @command{find} is just
  4846. like @option{-print}, except that it separates files with a @code{NUL}
  4847. rather than with a newline. You can then run @command{tar} with both the
  4848. @option{--null} and @option{-T} options to specify that @command{tar} get the
  4849. files from that file, @file{long-files}, to create the archive
  4850. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  4851. @command{tar} to recognize the @code{NUL} separator between files.
  4852. @smallexample
  4853. $ @kbd{find . -size +800 -print0 > long-files}
  4854. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4855. @end smallexample
  4856. @FIXME{say anything else here to conclude the section?}
  4857. @node exclude
  4858. @section Excluding Some Files
  4859. @UNREVISED
  4860. @cindex File names, excluding files by
  4861. @cindex Excluding files by name and pattern
  4862. @cindex Excluding files by file system
  4863. To avoid operating on files whose names match a particular pattern,
  4864. use the @option{--exclude} or @option{--exclude-from} options.
  4865. @table @option
  4866. @opindex exclude
  4867. @item --exclude=@var{pattern}
  4868. Causes @command{tar} to ignore files that match the @var{pattern}.
  4869. @end table
  4870. @findex exclude
  4871. The @option{--exclude=@var{pattern}} option prevents any file or member whose name
  4872. matches the shell wildcard (@var{pattern}) from being operated on.
  4873. For example, to create an archive with all the contents of the directory
  4874. @file{src} except for files whose names end in @file{.o}, use the
  4875. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4876. You may give multiple @option{--exclude} options.
  4877. @table @option
  4878. @opindex exclude-from
  4879. @item --exclude-from=@var{file}
  4880. @itemx -X @var{file}
  4881. Causes @command{tar} to ignore files that match the patterns listed in
  4882. @var{file}.
  4883. @end table
  4884. @findex exclude-from
  4885. Use the @option{--exclude-from} option to read a
  4886. list of patterns, one per line, from @var{file}; @command{tar} will
  4887. ignore files matching those patterns. Thus if @command{tar} is
  4888. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4889. single line @file{*.o}, no files whose names end in @file{.o} will be
  4890. added to the archive.
  4891. @FIXME{do the exclude options files need to have stuff separated by
  4892. newlines the same as the files-from option does?}
  4893. @table @option
  4894. @opindex exclude-caches
  4895. @item --exclude-caches
  4896. Causes @command{tar} to ignore directories containing a cache directory tag.
  4897. @end table
  4898. @findex exclude-caches
  4899. When creating an archive, the @option{--exclude-caches} option causes
  4900. @command{tar} to exclude all directories that contain a @dfn{cache
  4901. directory tag}. A cache directory tag is a short file with the
  4902. well-known name @file{CACHEDIR.TAG} and having a standard header
  4903. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  4904. Various applications write cache directory tags into directories they
  4905. use to hold regenerable, non-precious data, so that such data can be
  4906. more easily excluded from backups.
  4907. @menu
  4908. * controlling pattern-matching with exclude::
  4909. * problems with exclude::
  4910. @end menu
  4911. @node controlling pattern-matching with exclude
  4912. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4913. Normally, a pattern matches a name if an initial subsequence of the
  4914. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4915. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4916. and wildcards can match @samp{/}.
  4917. Other than optionally stripping leading @samp{/} from names
  4918. (@pxref{absolute}), patterns and names are used as-is. For
  4919. example, trailing @samp{/} is not trimmed from a user-specified name
  4920. before deciding whether to exclude it.
  4921. However, this matching procedure can be altered by the options listed
  4922. below. These options accumulate. For example:
  4923. @smallexample
  4924. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4925. @end smallexample
  4926. ignores case when excluding @samp{makefile}, but not when excluding
  4927. @samp{readme}.
  4928. @table @option
  4929. @opindex anchored
  4930. @opindex no-anchored
  4931. @item --anchored
  4932. @itemx --no-anchored
  4933. If anchored, a pattern must match an initial subsequence
  4934. of the name's components. Otherwise, the pattern can match any
  4935. subsequence. Default is @option{--no-anchored}.
  4936. @opindex ignore-case
  4937. @opindex no-ignore-case
  4938. @item --ignore-case
  4939. @itemx --no-ignore-case
  4940. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4941. When not ignoring case (the default), matching is case-sensitive.
  4942. @opindex wildcards
  4943. @opindex no-wildcards
  4944. @item --wildcards
  4945. @itemx --no-wildcards
  4946. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4947. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4948. Otherwise, none of these characters are special, and patterns must match
  4949. names literally.
  4950. @opindex wildcards-match-slash
  4951. @opindex no-wildcards-match-slash
  4952. @item --wildcards-match-slash
  4953. @itemx --no-wildcards-match-slash
  4954. When wildcards match slash (the default), a wildcard like @samp{*} in
  4955. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4956. matched only by @samp{/}.
  4957. @end table
  4958. The @option{--recursion} and @option{--no-recursion} options
  4959. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4960. recursion is in effect, a pattern excludes a name if it matches any of
  4961. the name's parent directories.
  4962. @node problems with exclude
  4963. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4964. @opindex exclude, potential problems with
  4965. Some users find @samp{exclude} options confusing. Here are some common
  4966. pitfalls:
  4967. @itemize @bullet
  4968. @item
  4969. The main operating mode of @command{tar} does not act on a path name
  4970. explicitly listed on the command line if one of its file name
  4971. components is excluded. In the example above, if
  4972. you create an archive and exclude files that end with @samp{*.o}, but
  4973. explicitly name the file @samp{dir.o/foo} after all the options have been
  4974. listed, @samp{dir.o/foo} will be excluded from the archive.
  4975. @item
  4976. You can sometimes confuse the meanings of @option{--exclude} and
  4977. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  4978. to be excluded are given as a pattern on the command line. Use
  4979. @option{--exclude-from} to introduce the name of a file which contains
  4980. a list of patterns, one per line; each of these patterns can exclude
  4981. zero, one, or many files.
  4982. @item
  4983. When you use @option{--exclude=@var{pattern}}, be sure to quote the @var{pattern}
  4984. parameter, so @GNUTAR{} sees wildcard characters
  4985. like @samp{*}. If you do not do this, the shell might expand the
  4986. @samp{*} itself using files at hand, so @command{tar} might receive a
  4987. list of files instead of one pattern, or none at all, making the
  4988. command somewhat illegal. This might not correspond to what you want.
  4989. For example, write:
  4990. @smallexample
  4991. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4992. @end smallexample
  4993. @noindent
  4994. rather than:
  4995. @smallexample
  4996. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4997. @end smallexample
  4998. @item
  4999. You must use use shell syntax, or globbing, rather than @code{regexp}
  5000. syntax, when using exclude options in @command{tar}. If you try to use
  5001. @code{regexp} syntax to describe files to be excluded, your command
  5002. might fail.
  5003. @item
  5004. In earlier versions of @command{tar}, what is now the
  5005. @option{--exclude-from} option was called @option{--exclude} instead.
  5006. Now, @option{--exclude} applies to patterns listed on the command
  5007. line and @option{--exclude-from} applies to patterns listed in a
  5008. file.
  5009. @end itemize
  5010. @node Wildcards
  5011. @section Wildcards Patterns and Matching
  5012. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5013. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5014. existing files matching the given pattern. However, @command{tar} often
  5015. uses wildcard patterns for matching (or globbing) archive members instead
  5016. of actual files in the file system. Wildcard patterns are also used for
  5017. verifying volume labels of @command{tar} archives. This section has the
  5018. purpose of explaining wildcard syntax for @command{tar}.
  5019. @FIXME{the next few paragraphs need work.}
  5020. A @var{pattern} should be written according to shell syntax, using wildcard
  5021. characters to effect globbing. Most characters in the pattern stand
  5022. for themselves in the matched string, and case is significant: @samp{a}
  5023. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5024. pattern matches any single character in the matched string. The character
  5025. @samp{*} in the pattern matches zero, one, or more single characters in
  5026. the matched string. The character @samp{\} says to take the following
  5027. character of the pattern @emph{literally}; it is useful when one needs to
  5028. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5029. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5030. class. A @dfn{character class} is a list of acceptable characters
  5031. for the next single character of the matched string. For example,
  5032. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5033. Note that within a character class, all of the ``special characters''
  5034. listed above other than @samp{\} lose their special meaning; for example,
  5035. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5036. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5037. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5038. @emph{last} in a character class.)
  5039. @cindex Excluding characters from a character class
  5040. @cindex Character class, excluding characters from
  5041. If the first character of the class after the opening @samp{[}
  5042. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5043. Rather than listing character to match, it lists those characters which
  5044. are @emph{forbidden} as the next single character of the matched string.
  5045. Other characters of the class stand for themselves. The special
  5046. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5047. letters, is meant to represent all characters between @var{a} and
  5048. @var{e}, inclusive.
  5049. @FIXME{need to add a sentence or so here to make this clear for those
  5050. who don't have dan around.}
  5051. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5052. special for wildcard matches. However, if a pattern completely matches
  5053. a directory prefix of a matched string, then it matches the full matched
  5054. string: excluding a directory also excludes all the files beneath it.
  5055. @node after
  5056. @section Operating Only on New Files
  5057. @UNREVISED
  5058. @cindex Excluding file by age
  5059. @cindex Data Modification time, excluding files by
  5060. @cindex Modification time, excluding files by
  5061. @cindex Age, excluding files by
  5062. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5063. @option{-N @var{date}}) option causes @command{tar} to only work on
  5064. files whose data modification or status change times are newer than
  5065. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5066. it is taken to be a file name; the data modification time of that file
  5067. is used as the date. If you use this option when creating or appending
  5068. to an archive, the archive will only include new files. If you use
  5069. @option{--after-date} when extracting an archive, @command{tar} will
  5070. only extract files newer than the @var{date} you specify.
  5071. If you only want @command{tar} to make the date comparison based on
  5072. modification of the file's data (rather than status
  5073. changes), then use the @option{--newer-mtime=@var{date}} option.
  5074. You may use these options with any operation. Note that these options
  5075. differ from the @option{--update} (@option{-u}) operation in that they
  5076. allow you to specify a particular date against which @command{tar} can
  5077. compare when deciding whether or not to archive the files.
  5078. @table @option
  5079. @opindex after-date
  5080. @opindex newer
  5081. @item --after-date=@var{date}
  5082. @itemx --newer=@var{date}
  5083. @itemx -N @var{date}
  5084. Only store files newer than @var{date}.
  5085. Acts on files only if their data modification or status change times are
  5086. later than @var{date}. Use in conjunction with any operation.
  5087. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5088. name; the data modification time of that file is used as the date.
  5089. @opindex newer-mtime
  5090. @item --newer-mtime=@var{date}
  5091. Acts like @option{--after-date}, but only looks at data modification times.
  5092. @end table
  5093. These options limit @command{tar} to operate only on files which have
  5094. been modified after the date specified. A file's status is considered to have
  5095. changed if its contents have been modified, or if its owner,
  5096. permissions, and so forth, have been changed. (For more information on
  5097. how to specify a date, see @ref{Date input formats}; remember that the
  5098. entire date argument must be quoted if it contains any spaces.)
  5099. Gurus would say that @option{--after-date} tests both the data
  5100. modification time (@code{mtime}, the time the contents of the file
  5101. were last modified) and the status change time (@code{ctime}, the time
  5102. the file's status was last changed: owner, permissions, etc.@:)
  5103. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5104. field.
  5105. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5106. @code{ctime} and processes the file if either one is more recent than
  5107. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5108. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5109. contents of the file were looked at).
  5110. Date specifiers can have embedded spaces. Because of this, you may need
  5111. to quote date arguments to keep the shell from parsing them as separate
  5112. arguments.
  5113. @FIXME{Need example of --newer-mtime with quoted argument.}
  5114. @quotation
  5115. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5116. should not be used for incremental backups. Some files (such as those
  5117. in renamed directories) are not selected properly by these options.
  5118. @xref{Incremental Dumps}.
  5119. @end quotation
  5120. @noindent
  5121. @FIXME{which tells -- need to fill this in!}
  5122. @node recurse
  5123. @section Descending into Directories
  5124. @UNREVISED
  5125. @cindex Avoiding recursion in directories
  5126. @cindex Descending directories, avoiding
  5127. @cindex Directories, avoiding recursion
  5128. @cindex Recursion in directories, avoiding
  5129. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5130. @FIXME{show dan bob's comments, from 2-10-97}
  5131. Usually, @command{tar} will recursively explore all directories (either
  5132. those given on the command line or through the @option{--files-from}
  5133. option) for the various files they contain. However, you may not always
  5134. want @command{tar} to act this way.
  5135. @opindex no-recursion
  5136. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5137. into specified directories. If you specify @option{--no-recursion}, you can
  5138. use the @command{find} utility for hunting through levels of directories to
  5139. construct a list of file names which you could then pass to @command{tar}.
  5140. @command{find} allows you to be more selective when choosing which files to
  5141. archive; see @ref{files} for more information on using @command{find} with
  5142. @command{tar}, or look.
  5143. @table @option
  5144. @item --no-recursion
  5145. Prevents @command{tar} from recursively descending directories.
  5146. @opindex recursion
  5147. @item --recursion
  5148. Requires @command{tar} to recursively descend directories.
  5149. This is the default.
  5150. @end table
  5151. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5152. directory entries themselves, but does not descend on them
  5153. recursively. Many people use @command{find} for locating files they
  5154. want to back up, and since @command{tar} @emph{usually} recursively
  5155. descends on directories, they have to use the @samp{@w{! -d}} option
  5156. to @command{find} @FIXME{needs more explanation or a cite to another
  5157. info file}as they usually do not want all the files in a directory.
  5158. They then use the @option{--files-from} option to archive the files
  5159. located via @command{find}.
  5160. The problem when restoring files archived in this manner is that the
  5161. directories themselves are not in the archive; so the
  5162. @option{--same-permissions} (@option{--preserve-permissions},
  5163. @option{-p}) option does not affect them---while users might really
  5164. like it to. Specifying @option{--no-recursion} is a way to tell
  5165. @command{tar} to grab only the directory entries given to it, adding
  5166. no new files on its own.
  5167. The @option{--no-recursion} option also applies when extracting: it
  5168. causes @command{tar} to extract only the matched directory entries, not
  5169. the files under those directories.
  5170. The @option{--no-recursion} option also affects how exclude patterns
  5171. are interpreted (@pxref{controlling pattern-matching with exclude}).
  5172. The @option{--no-recursion} and @option{--recursion} options apply to
  5173. later options and operands, and can be overridden by later occurrences
  5174. of @option{--no-recursion} and @option{--recursion}. For example:
  5175. @smallexample
  5176. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5177. @end smallexample
  5178. @noindent
  5179. creates an archive with one entry for @file{grape}, and the recursive
  5180. contents of @file{grape/concord}, but no entries under @file{grape}
  5181. other than @file{grape/concord}.
  5182. @node one
  5183. @section Crossing File System Boundaries
  5184. @cindex File system boundaries, not crossing
  5185. @UNREVISED
  5186. @command{tar} will normally automatically cross file system boundaries in
  5187. order to archive files which are part of a directory tree. You can
  5188. change this behavior by running @command{tar} and specifying
  5189. @option{--one-file-system} (@option{-l}). This option only affects files that are
  5190. archived because they are in a directory that is being archived;
  5191. @command{tar} will still archive files explicitly named on the command line
  5192. or through @option{--files-from}, regardless of where they reside.
  5193. @table @option
  5194. @opindex one-file-system
  5195. @item --one-file-system
  5196. @itemx -l
  5197. Prevents @command{tar} from crossing file system boundaries when
  5198. archiving. Use in conjunction with any write operation.
  5199. @end table
  5200. The @option{--one-file-system} option causes @command{tar} to modify its
  5201. normal behavior in archiving the contents of directories. If a file in
  5202. a directory is not on the same file system as the directory itself, then
  5203. @command{tar} will not archive that file. If the file is a directory
  5204. itself, @command{tar} will not archive anything beneath it; in other words,
  5205. @command{tar} will not cross mount points.
  5206. It is reported that using this option, the mount point is is archived,
  5207. but nothing under it.
  5208. This option is useful for making full or incremental archival backups of
  5209. a file system. If this option is used in conjunction with
  5210. @option{--verbose} (@option{-v}), files that are excluded are mentioned by name on the
  5211. standard error.
  5212. @menu
  5213. * directory:: Changing Directory
  5214. * absolute:: Absolute File Names
  5215. @end menu
  5216. @node directory
  5217. @subsection Changing the Working Directory
  5218. @UNREVISED
  5219. @FIXME{need to read over this node now for continuity; i've switched
  5220. things around some.}
  5221. @cindex Changing directory mid-stream
  5222. @cindex Directory, changing mid-stream
  5223. @cindex Working directory, specifying
  5224. To change the working directory in the middle of a list of file names,
  5225. either on the command line or in a file specified using
  5226. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5227. This will change the working directory to the specified directory
  5228. after that point in the list.
  5229. @table @option
  5230. @opindex directory
  5231. @item --directory=@var{directory}
  5232. @itemx -C @var{directory}
  5233. Changes the working directory in the middle of a command line.
  5234. @end table
  5235. For example,
  5236. @smallexample
  5237. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5238. @end smallexample
  5239. @noindent
  5240. will place the files @file{grape} and @file{prune} from the current
  5241. directory into the archive @file{jams.tar}, followed by the file
  5242. @file{cherry} from the directory @file{food}. This option is especially
  5243. useful when you have several widely separated files that you want to
  5244. store in the same archive.
  5245. Note that the file @file{cherry} is recorded in the archive under the
  5246. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5247. archive will contain three files that all appear to have come from the
  5248. same directory; if the archive is extracted with plain @samp{tar
  5249. --extract}, all three files will be written in the current directory.
  5250. Contrast this with the command,
  5251. @smallexample
  5252. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5253. @end smallexample
  5254. @noindent
  5255. which records the third file in the archive under the name
  5256. @file{red/cherry} so that, if the archive is extracted using
  5257. @samp{tar --extract}, the third file will be written in a subdirectory
  5258. named @file{orange-colored}.
  5259. You can use the @option{--directory} option to make the archive
  5260. independent of the original name of the directory holding the files.
  5261. The following command places the files @file{/etc/passwd},
  5262. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5263. @file{foo.tar}:
  5264. @smallexample
  5265. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5266. @end smallexample
  5267. @noindent
  5268. However, the names of the archive members will be exactly what they were
  5269. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5270. They will not appear to be related by file name to the original
  5271. directories where those files were located.
  5272. Note that @option{--directory} options are interpreted consecutively. If
  5273. @option{--directory} specifies a relative file name, it is interpreted
  5274. relative to the then current directory, which might not be the same as
  5275. the original current working directory of @command{tar}, due to a previous
  5276. @option{--directory} option.
  5277. When using @option{--files-from} (@pxref{files}), you can put various
  5278. @command{tar} options (including @option{-C}) in the file list. Notice,
  5279. however, that in this case the option and its argument may not be
  5280. separated by whitespace. If you use short option, its argument must
  5281. either follow the option letter immediately, without any intervening
  5282. whitespace, or occupy the next line. Otherwise, if you use long
  5283. option, separate its argument by an equal sign.
  5284. For instance, the file list for the above example will be:
  5285. @smallexample
  5286. @group
  5287. -C
  5288. /etc
  5289. passwd
  5290. hosts
  5291. -C
  5292. /lib
  5293. libc.a
  5294. @end group
  5295. @end smallexample
  5296. @noindent
  5297. To use it, you would invoke @command{tar} as follows:
  5298. @smallexample
  5299. $ @kbd{tar -c -f foo.tar --files-from list}
  5300. @end smallexample
  5301. Notice also that you can only use the short option variant in the file
  5302. list, i.e., always use @option{-C}, not @option{--directory}.
  5303. The interpretation of @option{--directory} is disabled by
  5304. @option{--null} option.
  5305. @node absolute
  5306. @subsection Absolute File Names
  5307. @UNREVISED
  5308. @table @option
  5309. @opindex absolute-names
  5310. @item --absolute-names
  5311. @itemx -P
  5312. Do not strip leading slashes from file names, and permit file names
  5313. containing a @file{..} file name component.
  5314. @end table
  5315. By default, @GNUTAR{} drops a leading @samp{/} on
  5316. input or output, and complains about file names containing a @file{..}
  5317. component. This option turns off this behavior.
  5318. When @command{tar} extracts archive members from an archive, it strips any
  5319. leading slashes (@samp{/}) from the member name. This causes absolute
  5320. member names in the archive to be treated as relative file names. This
  5321. allows you to have such members extracted wherever you want, instead of
  5322. being restricted to extracting the member in the exact directory named
  5323. in the archive. For example, if the archive member has the name
  5324. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5325. really @file{etc/passwd}.
  5326. File names containing @file{..} can cause problems when extracting, so
  5327. @command{tar} normally warns you about such files when creating an
  5328. archive, and rejects attempts to extracts such files.
  5329. Other @command{tar} programs do not do this. As a result, if you
  5330. create an archive whose member names start with a slash, they will be
  5331. difficult for other people with a non-@GNUTAR{}
  5332. program to use. Therefore, @GNUTAR{} also strips
  5333. leading slashes from member names when putting members into the
  5334. archive. For example, if you ask @command{tar} to add the file
  5335. @file{/bin/ls} to an archive, it will do so, but the member name will
  5336. be @file{bin/ls}.@footnote{A side effect of this is that when
  5337. @option{--create} is used with @option{--verbose} the resulting output
  5338. is not, generally speaking, the same as the one you'd get running
  5339. @kbd{tar --list} command. This may be important if you use some
  5340. scripts for comparing both outputs. @xref{listing member and file names},
  5341. for the information on how to handle this case.}
  5342. If you use the @option{--absolute-names} (@option{-P}) option,
  5343. @command{tar} will do none of these transformations.
  5344. To archive or extract files relative to the root directory, specify
  5345. the @option{--absolute-names} (@option{-P}) option.
  5346. Normally, @command{tar} acts on files relative to the working
  5347. directory---ignoring superior directory names when archiving, and
  5348. ignoring leading slashes when extracting.
  5349. When you specify @option{--absolute-names} (@option{-P}),
  5350. @command{tar} stores file names including all superior directory
  5351. names, and preserves leading slashes. If you only invoked
  5352. @command{tar} from the root directory you would never need the
  5353. @option{--absolute-names} option, but using this option
  5354. may be more convenient than switching to root.
  5355. @FIXME{Should be an example in the tutorial/wizardry section using this
  5356. to transfer files between systems.}
  5357. @FIXME{Is write access an issue?}
  5358. @table @option
  5359. @item --absolute-names
  5360. Preserves full file names (including superior directory names) when
  5361. archiving files. Preserves leading slash when extracting files.
  5362. @end table
  5363. @FIXME{this is still horrible; need to talk with dan on monday.}
  5364. @command{tar} prints out a message about removing the @samp{/} from
  5365. file names. This message appears once per @GNUTAR{}
  5366. invocation. It represents something which ought to be told; ignoring
  5367. what it means can cause very serious surprises, later.
  5368. Some people, nevertheless, do not want to see this message. Wanting to
  5369. play really dangerously, one may of course redirect @command{tar} standard
  5370. error to the sink. For example, under @command{sh}:
  5371. @smallexample
  5372. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5373. @end smallexample
  5374. @noindent
  5375. Another solution, both nicer and simpler, would be to change to
  5376. the @file{/} directory first, and then avoid absolute notation.
  5377. For example:
  5378. @smallexample
  5379. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5380. $ @kbd{tar -c -f archive.tar -C / home}
  5381. @end smallexample
  5382. @include getdate.texi
  5383. @node Formats
  5384. @chapter Controlling the Archive Format
  5385. @cindex Tar archive formats
  5386. Due to historical reasons, there are several formats of tar archives.
  5387. All of them are based on the same principles, but have some subtle
  5388. differences that often make them incompatible with each other.
  5389. GNU tar is able to create and handle archives in a variety of formats.
  5390. The most frequently used formats are (in alphabetical order):
  5391. @table @asis
  5392. @item gnu
  5393. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5394. from an early @acronym{POSIX} standard, adding some improvements such as
  5395. sparse file handling and incremental archives. Unfortunately these
  5396. features were implemented in a way incompatible with other archive
  5397. formats.
  5398. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5399. length.
  5400. @item oldgnu
  5401. Format used by @GNUTAR{} of versions prior to 1.12.
  5402. @item v7
  5403. Archive format, compatible with the V7 implementation of tar. This
  5404. format imposes a number of limitations. The most important of them
  5405. are:
  5406. @enumerate
  5407. @item The maximum length of a file name is limited to 99 characters.
  5408. @item The maximum length of a symbolic link is limited to 99 characters.
  5409. @item It is impossible to store special files (block and character
  5410. devices, fifos etc.)
  5411. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5412. octal)
  5413. @item V7 archives do not contain symbolic ownership information (user
  5414. and group name of the file owner).
  5415. @end enumerate
  5416. This format has traditionally been used by Automake when producing
  5417. Makefiles. This practice will change in the future, in the meantime,
  5418. however this means that projects containing filenames more than 99
  5419. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5420. Automake prior to 1.9.
  5421. @item ustar
  5422. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5423. symbolic ownership information. It is also able to store
  5424. special files. However, it imposes several restrictions as well:
  5425. @enumerate
  5426. @item The maximum length of a file name is limited to 256 characters,
  5427. provided that the filename can be split at directory separator in
  5428. two parts, first of them being at most 155 bytes long. So, in most
  5429. cases the maximum file name length will be shorter than 256
  5430. characters.
  5431. @item The maximum length of a symbolic link name is limited to
  5432. 100 characters.
  5433. @item Maximum size of a file the archive is able to accomodate
  5434. is 8GB
  5435. @item Maximum value of UID/GID is 2097151.
  5436. @item Maximum number of bits in device major and minor numbers is 21.
  5437. @end enumerate
  5438. @item star
  5439. Format used by J@"org Schilling @command{star}
  5440. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5441. currently does not produce them.
  5442. @item posix
  5443. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5444. most flexible and feature-rich format. It does not impose any
  5445. restrictions on file sizes or filename lengths. This format is quite
  5446. recent, so not all tar implementations are able to handle it properly.
  5447. However, this format is designed in such a way that any tar
  5448. implementation able to read @samp{ustar} archives will be able to read
  5449. most @samp{posix} archives as well, with the only exception that any
  5450. additional information (such as long file names etc.) will in such
  5451. case be extracted as plain text files along with the files it refers to.
  5452. This archive format will be the default format for future versions
  5453. of @GNUTAR{}.
  5454. @end table
  5455. The following table summarizes the limitations of each of these
  5456. formats:
  5457. @multitable @columnfractions .10 .20 .20 .20 .20
  5458. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5459. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5460. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5461. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5462. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5463. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5464. @end multitable
  5465. The default format for @GNUTAR{} is defined at compilation
  5466. time. You may check it by running @command{tar --help}, and examining
  5467. the last lines of its output. Usually, @GNUTAR{} is configured
  5468. to create archives in @samp{gnu} format, however, future version will
  5469. switch to @samp{posix}.
  5470. @menu
  5471. * Portability:: Making @command{tar} Archives More Portable
  5472. * Compression:: Using Less Space through Compression
  5473. * Attributes:: Handling File Attributes
  5474. * Standard:: The Standard Format
  5475. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5476. * cpio:: Comparison of @command{tar} and @command{cpio}
  5477. @end menu
  5478. @node Portability
  5479. @section Making @command{tar} Archives More Portable
  5480. Creating a @command{tar} archive on a particular system that is meant to be
  5481. useful later on many other machines and with other versions of @command{tar}
  5482. is more challenging than you might think. @command{tar} archive formats
  5483. have been evolving since the first versions of Unix. Many such formats
  5484. are around, and are not always compatible with each other. This section
  5485. discusses a few problems, and gives some advice about making @command{tar}
  5486. archives more portable.
  5487. One golden rule is simplicity. For example, limit your @command{tar}
  5488. archives to contain only regular files and directories, avoiding
  5489. other kind of special files. Do not attempt to save sparse files or
  5490. contiguous files as such. Let's discuss a few more problems, in turn.
  5491. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5492. archives and archive labels) in GNU and PAX formats.}
  5493. @menu
  5494. * Portable Names:: Portable Names
  5495. * dereference:: Symbolic Links
  5496. * old:: Old V7 Archives
  5497. * ustar:: Ustar Archives
  5498. * gnu:: GNU and old GNU format archives.
  5499. * posix:: @acronym{POSIX} archives
  5500. * Checksumming:: Checksumming Problems
  5501. * Large or Negative Values:: Large files, negative time stamps, etc.
  5502. @end menu
  5503. @node Portable Names
  5504. @subsection Portable Names
  5505. Use portable file and member names. A name is portable if it contains
  5506. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5507. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5508. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5509. old Unix hosts, limit your file name components to 14 characters or
  5510. less.
  5511. If you intend to have your @command{tar} archives to be read under
  5512. MSDOS, you should not rely on case distinction for file names, and you
  5513. might use the @acronym{GNU} @command{doschk} program for helping you
  5514. further diagnosing illegal MSDOS names, which are even more limited
  5515. than System V's.
  5516. @node dereference
  5517. @subsection Symbolic Links
  5518. @cindex File names, using symbolic links
  5519. @cindex Symbolic link as file name
  5520. @opindex dereference
  5521. Normally, when @command{tar} archives a symbolic link, it writes a
  5522. block to the archive naming the target of the link. In that way, the
  5523. @command{tar} archive is a faithful record of the file system contents.
  5524. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5525. @command{tar} to archive the files symbolic links point to, instead of
  5526. the links themselves. When this option is used, when @command{tar}
  5527. encounters a symbolic link, it will archive the linked-to file,
  5528. instead of simply recording the presence of a symbolic link.
  5529. The name under which the file is stored in the file system is not
  5530. recorded in the archive. To record both the symbolic link name and
  5531. the file name in the system, archive the file under both names. If
  5532. all links were recorded automatically by @command{tar}, an extracted file
  5533. might be linked to a file name that no longer exists in the file
  5534. system.
  5535. If a linked-to file is encountered again by @command{tar} while creating
  5536. the same archive, an entire second copy of it will be stored. (This
  5537. @emph{might} be considered a bug.)
  5538. So, for portable archives, do not archive symbolic links as such,
  5539. and use @option{--dereference} (@option{-h}): many systems do not support
  5540. symbolic links, and moreover, your distribution might be unusable if
  5541. it contains unresolved symbolic links.
  5542. @node old
  5543. @subsection Old V7 Archives
  5544. @cindex Format, old style
  5545. @cindex Old style format
  5546. @cindex Old style archives
  5547. @cindex v7 archive format
  5548. Certain old versions of @command{tar} cannot handle additional
  5549. information recorded by newer @command{tar} programs. To create an
  5550. archive in V7 format (not ANSI), which can be read by these old
  5551. versions, specify the @option{--format=v7} option in
  5552. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5553. accepts @option{--portability} or @samp{op-old-archive} for this
  5554. option). When you specify it,
  5555. @command{tar} leaves out information about directories, pipes, fifos,
  5556. contiguous files, and device files, and specifies file ownership by
  5557. group and user IDs instead of group and user names.
  5558. When updating an archive, do not use @option{--format=v7}
  5559. unless the archive was created using this option.
  5560. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5561. @command{tar} program without serious trouble, so this option should
  5562. seldom be needed. On the other hand, most modern @command{tar}s are
  5563. able to read old format archives, so it might be safer for you to
  5564. always use @option{--format=v7} for your distributions.
  5565. @node ustar
  5566. @subsection Ustar Archive Format
  5567. @cindex ustar archive format
  5568. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5569. @code{ustar}. Although it is more flexible than the V7 format, it
  5570. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5571. description of @code{ustar} format). Along with V7 format,
  5572. @code{ustar} format is a good choice for archives intended to be read
  5573. with other implementations of @command{tar}.
  5574. To create archive in @code{ustar} format, use @option{--format=ustar}
  5575. option in conjunction with the @option{--create} (@option{-c}).
  5576. @node gnu
  5577. @subsection @acronym{GNU} and old @GNUTAR{} format
  5578. @cindex GNU archive format
  5579. @cindex Old GNU archive format
  5580. @GNUTAR{} was based on an early draft of the
  5581. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5582. @command{tar}, such as the support for file names longer than 100
  5583. characters, use portions of the @command{tar} header record which were
  5584. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5585. @acronym{POSIX} have allocated the same parts of the header record for
  5586. other purposes. As a result, @GNUTAR{} format is
  5587. incompatible with the current @acronym{POSIX} specification, and with
  5588. @command{tar} programs that follow it.
  5589. In the majority of cases, @command{tar} will be configured to create
  5590. this format by default. This will change in the future releases, since
  5591. we plan to make @samp{posix} format the default.
  5592. To force creation a @GNUTAR{} archive, use option
  5593. @option{--format=gnu}.
  5594. @node posix
  5595. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5596. @cindex POSIX archive format
  5597. @cindex PAX archive format
  5598. The version @value{VERSION} of @GNUTAR{} is able
  5599. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5600. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5601. was given @option{--format=posix} option.
  5602. @node Checksumming
  5603. @subsection Checksumming Problems
  5604. SunOS and HP-UX @command{tar} fail to accept archives created using
  5605. @GNUTAR{} and containing non-ASCII file names, that
  5606. is, file names having characters with the eight bit set, because they
  5607. use signed checksums, while @GNUTAR{} uses unsigned
  5608. checksums while creating archives, as per @acronym{POSIX} standards. On
  5609. reading, @GNUTAR{} computes both checksums and
  5610. accept any. It is somewhat worrying that a lot of people may go
  5611. around doing backup of their files using faulty (or at least
  5612. non-standard) software, not learning about it until it's time to
  5613. restore their missing files with an incompatible file extractor, or
  5614. vice versa.
  5615. @GNUTAR{} compute checksums both ways, and accept
  5616. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5617. wrong checksums. @GNUTAR{} produces the standard
  5618. checksum, however, raising incompatibilities with Sun. That is to
  5619. say, @GNUTAR{} has not been modified to
  5620. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5621. I've been told that more recent Sun @command{tar} now read standard
  5622. archives, so maybe Sun did a similar patch, after all?
  5623. The story seems to be that when Sun first imported @command{tar}
  5624. sources on their system, they recompiled it without realizing that
  5625. the checksums were computed differently, because of a change in
  5626. the default signing of @code{char}'s in their compiler. So they
  5627. started computing checksums wrongly. When they later realized their
  5628. mistake, they merely decided to stay compatible with it, and with
  5629. themselves afterwards. Presumably, but I do not really know, HP-UX
  5630. has chosen that their @command{tar} archives to be compatible with Sun's.
  5631. The current standards do not favor Sun @command{tar} format. In any
  5632. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5633. a @command{tar} able to read the good archives they receive.
  5634. @node Large or Negative Values
  5635. @subsection Large or Negative Values
  5636. @cindex large values
  5637. @cindex future time stamps
  5638. @cindex negative time stamps
  5639. @UNREVISED{}
  5640. The above sections suggest to use @samp{oldest possible} archive
  5641. format if in doubt. However, sometimes it is not possible. If you
  5642. attempt to archive a file whose metadata cannot be represented using
  5643. required format, @GNUTAR{} will print error message and ignore such a
  5644. file. You will than have to switch to a format that is able to
  5645. handle such values. The format summary table (@pxref{Formats}) will
  5646. help you to do so.
  5647. In particular, when trying to archive files larger than 8GB or with
  5648. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  5649. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  5650. @acronym{POSIX} archive formats. When considering which format to
  5651. choose, bear in mind that the @acronym{GNU} format uses
  5652. two's-complement base-256 notation to stores values that do not fit
  5653. into standard @acronym{ustar} range. Such archives can generally be
  5654. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  5655. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  5656. example, using two's complement representation for negative time
  5657. stamps that assumes a signed 32-bit @code{time_t} generates archives
  5658. that are not portable to hosts with differing @code{time_t}
  5659. representations.
  5660. On the other hand, @acronym{POSIX} archives, generally speaking, can
  5661. be extracted by any tar implementation that understands older
  5662. @acronym{ustar} format. The only exception are files larger than 8GB.
  5663. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  5664. POSIX-aware tars.}
  5665. @node Compression
  5666. @section Using Less Space through Compression
  5667. @menu
  5668. * gzip:: Creating and Reading Compressed Archives
  5669. * sparse:: Archiving Sparse Files
  5670. @end menu
  5671. @node gzip
  5672. @subsection Creating and Reading Compressed Archives
  5673. @cindex Compressed archives
  5674. @cindex Storing archives in compressed format
  5675. @GNUTAR{} is able to create and read compressed archives. It supports
  5676. @command{gzip} and @command{bzip2} compression programs. For backward
  5677. compatibilty, it also supports @command{compress} command, although
  5678. we strongly recommend against using it, since there is a patent
  5679. covering the algorithm it uses and you could be sued for patent
  5680. infringement merely by running @command{compress}! Besides, it is less
  5681. effective than @command{gzip} and @command{bzip2}.
  5682. Creating a compressed archive is simple: you just specify a
  5683. @dfn{compression option} along with the usual archive creation
  5684. commands. The compression option is @option{-z} (@option{--gzip}) to
  5685. create a @command{gzip} compressed archive, @option{-j}
  5686. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  5687. @option{-Z} (@option{--compress}) to use @command{compress} program.
  5688. For example:
  5689. @smallexample
  5690. $ @kbd{tar cfz archive.tar.gz .}
  5691. @end smallexample
  5692. Reading compressed archive is even simpler: you don't need to specify
  5693. any additional options as @GNUTAR{} recognizes its format
  5694. automatically. Thus, the following commands will list and extract the
  5695. archive created in previous example:
  5696. @smallexample
  5697. # List the compressed archive
  5698. $ @kbd{tar tf archive.tar.gz}
  5699. # Extract the compressed archive
  5700. $ @kbd{tar xf archive.tar.gz}
  5701. @end smallexample
  5702. The only case when you have to specify a decompression option while
  5703. reading the archive is when reading from a pipe or from a tape drive
  5704. that does not support random access. However, in this case @GNUTAR{}
  5705. will indicate which option you should use. For example:
  5706. @smallexample
  5707. $ @kbd{cat archive.tar.gz | tar tf -}
  5708. tar: Archive is compressed. Use -z option
  5709. tar: Error is not recoverable: exiting now
  5710. @end smallexample
  5711. If you see such diagnostics, just add the suggested option to the
  5712. invocation of @GNUTAR{}:
  5713. @smallexample
  5714. $ @kbd{cat archive.tar.gz | tar tfz -}
  5715. @end smallexample
  5716. Notice also, that there are several restrictions on operations on
  5717. compressed archives. First of all, compressed archives cannot be
  5718. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  5719. (@option{--delete}) members from them. Likewise, you cannot append
  5720. another @command{tar} archive to a compressed archive using
  5721. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  5722. compressed.
  5723. The following table summarizes compression options used by @GNUTAR{}.
  5724. @table @option
  5725. @opindex gzip
  5726. @opindex ungzip
  5727. @item -z
  5728. @itemx --gzip
  5729. @itemx --ungzip
  5730. Filter the archive through @command{gzip}.
  5731. You can use @option{--gzip} and @option{--gunzip} on physical devices
  5732. (tape drives, etc.) and remote files as well as on normal files; data
  5733. to or from such devices or remote files is reblocked by another copy
  5734. of the @command{tar} program to enforce the specified (or default) record
  5735. size. The default compression parameters are used; if you need to
  5736. override them, set @env{GZIP} environment variable, e.g.:
  5737. @smallexample
  5738. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  5739. @end smallexample
  5740. @noindent
  5741. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  5742. @command{gzip} explicitly:
  5743. @smallexample
  5744. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  5745. @end smallexample
  5746. @cindex corrupted archives
  5747. About corrupted compressed archives: @command{gzip}'ed files have no
  5748. redundancy, for maximum compression. The adaptive nature of the
  5749. compression scheme means that the compression tables are implicitly
  5750. spread all over the archive. If you lose a few blocks, the dynamic
  5751. construction of the compression tables becomes unsynchronized, and there
  5752. is little chance that you could recover later in the archive.
  5753. There are pending suggestions for having a per-volume or per-file
  5754. compression in @GNUTAR{}. This would allow for viewing the
  5755. contents without decompression, and for resynchronizing decompression at
  5756. every volume or file, in case of corrupted archives. Doing so, we might
  5757. lose some compressibility. But this would have make recovering easier.
  5758. So, there are pros and cons. We'll see!
  5759. @opindex bzip2
  5760. @item -j
  5761. @itemx --bzip2
  5762. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  5763. @opindex compress
  5764. @opindex uncompress
  5765. @item -Z
  5766. @itemx --compress
  5767. @itemx --uncompress
  5768. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  5769. The @acronym{GNU} Project recommends you not use
  5770. @command{compress}, because there is a patent covering the algorithm it
  5771. uses. You could be sued for patent infringement merely by running
  5772. @command{compress}.
  5773. @opindex use-compress-program
  5774. @item --use-compress-program=@var{prog}
  5775. Use external compression program @var{prog}. Use this option if you
  5776. have a compression program that @GNUTAR{} does not support. There
  5777. are two requirements to which @var{prog} should comply:
  5778. First, when called without options, it should read data from standard
  5779. input, compress it and output it on standard output.
  5780. Secondly, if called with @option{-d} argument, it should do exactly
  5781. the opposite, i.e., read the compressed data from the standard input
  5782. and produce uncompressed data on the standard output.
  5783. @end table
  5784. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5785. to do it now. I would like to use @option{--gzip}, but I'd also like
  5786. the output to be fed through a program like @acronym{GNU}
  5787. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5788. to use :-)), basically adding ECC protection on top of compression.
  5789. It seems as if this should be quite easy to do, but I can't work out
  5790. exactly how to go about it. Of course, I can pipe the standard output
  5791. of @command{tar} through @command{ecc}, but then I lose (though I
  5792. haven't started using it yet, I confess) the ability to have
  5793. @command{tar} use @command{rmt} for it's I/O (I think).
  5794. I think the most straightforward thing would be to let me specify a
  5795. general set of filters outboard of compression (preferably ordered,
  5796. so the order can be automatically reversed on input operations, and
  5797. with the options they require specifiable), but beggars shouldn't be
  5798. choosers and anything you decide on would be fine with me.
  5799. By the way, I like @command{ecc} but if (as the comments say) it can't
  5800. deal with loss of block sync, I'm tempted to throw some time at adding
  5801. that capability. Supposing I were to actually do such a thing and
  5802. get it (apparently) working, do you accept contributed changes to
  5803. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5804. Isn't that exactly the role of the @option{--use-compress-prog=@var{program}} option?
  5805. I never tried it myself, but I suspect you may want to write a
  5806. @var{prog} script or program able to filter stdin to stdout to
  5807. way you want. It should recognize the @option{-d} option, for when
  5808. extraction is needed rather than creation.
  5809. It has been reported that if one writes compressed data (through the
  5810. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  5811. the DLT compression mode, the data will actually get bigger and one will
  5812. end up with less space on the tape.}
  5813. @node sparse
  5814. @subsection Archiving Sparse Files
  5815. @cindex Sparse Files
  5816. @UNREVISED
  5817. @table @option
  5818. @opindex sparse
  5819. @item -S
  5820. @itemx --sparse
  5821. Handle sparse files efficiently.
  5822. @end table
  5823. This option causes all files to be put in the archive to be tested for
  5824. sparseness, and handled specially if they are. The @option{--sparse}
  5825. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  5826. backed up. Using this option dramatically decreases the amount of
  5827. space needed to store such a file.
  5828. In later versions, this option may be removed, and the testing and
  5829. treatment of sparse files may be done automatically with any special
  5830. @acronym{GNU} options. For now, it is an option needing to be specified on
  5831. the command line with the creation or updating of an archive.
  5832. Files in the file system occasionally have ``holes.'' A hole in a file
  5833. is a section of the file's contents which was never written. The
  5834. contents of a hole read as all zeros. On many operating systems,
  5835. actual disk storage is not allocated for holes, but they are counted
  5836. in the length of the file. If you archive such a file, @command{tar}
  5837. could create an archive longer than the original. To have @command{tar}
  5838. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  5839. you use this option, then, for any file using less disk space than
  5840. would be expected from its length, @command{tar} searches the file for
  5841. consecutive stretches of zeros. It then records in the archive for
  5842. the file where the consecutive stretches of zeros are, and only
  5843. archives the ``real contents'' of the file. On extraction (using
  5844. @option{--sparse} is not needed on extraction) any such
  5845. files have holes created wherever the continuous stretches of zeros
  5846. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  5847. won't take more space than the original.
  5848. A file is sparse if it contains blocks of zeros whose existence is
  5849. recorded, but that have no space allocated on disk. When you specify
  5850. the @option{--sparse} option in conjunction with the @option{--create}
  5851. (@option{-c}) operation, @command{tar} tests all files for sparseness
  5852. while archiving. If @command{tar} finds a file to be sparse, it uses a
  5853. sparse representation of the file in the archive. @xref{create}, for
  5854. more information about creating archives.
  5855. @option{--sparse} is useful when archiving files, such as dbm files,
  5856. likely to contain many nulls. This option dramatically
  5857. decreases the amount of space needed to store such an archive.
  5858. @quotation
  5859. @strong{Please Note:} Always use @option{--sparse} when performing file
  5860. system backups, to avoid archiving the expanded forms of files stored
  5861. sparsely in the system.
  5862. Even if your system has no sparse files currently, some may be
  5863. created in the future. If you use @option{--sparse} while making file
  5864. system backups as a matter of course, you can be assured the archive
  5865. will never take more space on the media than the files take on disk
  5866. (otherwise, archiving a disk filled with sparse files might take
  5867. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5868. @end quotation
  5869. @command{tar} ignores the @option{--sparse} option when reading an archive.
  5870. @table @option
  5871. @item --sparse
  5872. @itemx -S
  5873. Files stored sparsely in the file system are represented sparsely in
  5874. the archive. Use in conjunction with write operations.
  5875. @end table
  5876. However, users should be well aware that at archive creation time,
  5877. @GNUTAR{} still has to read whole disk file to
  5878. locate the @dfn{holes}, and so, even if sparse files use little space
  5879. on disk and in the archive, they may sometimes require inordinate
  5880. amount of time for reading and examining all-zero blocks of a file.
  5881. Although it works, it's painfully slow for a large (sparse) file, even
  5882. though the resulting tar archive may be small. (One user reports that
  5883. dumping a @file{core} file of over 400 megabytes, but with only about
  5884. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5885. ELC, with full CPU utilization.)
  5886. This reading is required in all cases and is not related to the fact
  5887. the @option{--sparse} option is used or not, so by merely @emph{not}
  5888. using the option, you are not saving time@footnote{Well! We should say
  5889. the whole truth, here. When @option{--sparse} is selected while creating
  5890. an archive, the current @command{tar} algorithm requires sparse files to be
  5891. read twice, not once. We hope to develop a new archive format for saving
  5892. sparse files in which one pass will be sufficient.}.
  5893. Programs like @command{dump} do not have to read the entire file; by
  5894. examining the file system directly, they can determine in advance
  5895. exactly where the holes are and thus avoid reading through them. The
  5896. only data it need read are the actual allocated data blocks.
  5897. @GNUTAR{} uses a more portable and straightforward
  5898. archiving approach, it would be fairly difficult that it does
  5899. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5900. 1990-12-10:
  5901. @quotation
  5902. What I did say is that you cannot tell the difference between a hole and an
  5903. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5904. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5905. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5906. to name one that does?), they may also care where the holes are (I have
  5907. no examples of this one either, but it's equally imaginable).
  5908. I conclude from this that good archivers are not portable. One can
  5909. arguably conclude that if you want a portable program, you can in good
  5910. conscience restore files with as many holes as possible, since you can't
  5911. get it right.
  5912. @end quotation
  5913. @node Attributes
  5914. @section Handling File Attributes
  5915. @UNREVISED
  5916. When @command{tar} reads files, it updates their access times. To
  5917. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  5918. reset the access time retroactively or avoid changing it in the first
  5919. place.
  5920. Handling of file attributes
  5921. @table @option
  5922. @opindex atime-preserve
  5923. @item --atime-preserve
  5924. @itemx --atime-preserve=replace
  5925. @itemx --atime-preserve=system
  5926. Preserve the access times of files that are read. This works only for
  5927. files that you own, unless you have superuser privileges.
  5928. @option{--atime-preserve=replace} works on most systems, but it also
  5929. restores the data modification time and updates the status change
  5930. time. Hence it doesn't interact with incremental dumps nicely
  5931. (@pxref{Backups}), and it can set access or data modification times
  5932. incorrectly if other programs access the file while @command{tar} is
  5933. running.
  5934. @option{--atime-preserve=system} avoids changing the access time in
  5935. the first place, if the operating system supports this.
  5936. Unfortunately, this may or may not work on any given operating system
  5937. or file system. If @command{tar} knows for sure it won't work, it
  5938. complains right away.
  5939. Currently @option{--atime-preserve} with no operand defaults to
  5940. @option{--atime-preserve=replace}, but this is intended to change to
  5941. @option{--atime-preserve=system} when the latter is better-supported.
  5942. @opindex touch
  5943. @item -m
  5944. @itemx --touch
  5945. Do not extract data modification time.
  5946. When this option is used, @command{tar} leaves the data modification times
  5947. of the files it extracts as the times when the files were extracted,
  5948. instead of setting it to the times recorded in the archive.
  5949. This option is meaningless with @option{--list} (@option{-t}).
  5950. @opindex same-owner
  5951. @item --same-owner
  5952. Create extracted files with the same ownership they have in the
  5953. archive.
  5954. This is the default behavior for the superuser,
  5955. so this option is meaningful only for non-root users, when @command{tar}
  5956. is executed on those systems able to give files away. This is
  5957. considered as a security flaw by many people, at least because it
  5958. makes quite difficult to correctly account users for the disk space
  5959. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5960. files are easily and silently lost when files are given away.
  5961. When writing an archive, @command{tar} writes the user id and user name
  5962. separately. If it can't find a user name (because the user id is not
  5963. in @file{/etc/passwd}), then it does not write one. When restoring,
  5964. and doing a @code{chmod} like when you use @option{--same-permissions},
  5965. @FIXME{same-owner?}it tries to look the name (if one was written)
  5966. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5967. stored in the archive instead.
  5968. @opindex no-same-owner
  5969. @item --no-same-owner
  5970. @itemx -o
  5971. Do not attempt to restore ownership when extracting. This is the
  5972. default behavior for ordinary users, so this option has an effect
  5973. only for the superuser.
  5974. @opindex numeric-owner
  5975. @item --numeric-owner
  5976. The @option{--numeric-owner} option allows (ANSI) archives to be written
  5977. without user/group name information or such information to be ignored
  5978. when extracting. It effectively disables the generation and/or use
  5979. of user/group name information. This option forces extraction using
  5980. the numeric ids from the archive, ignoring the names.
  5981. This is useful in certain circumstances, when restoring a backup from
  5982. an emergency floppy with different passwd/group files for example.
  5983. It is otherwise impossible to extract files with the right ownerships
  5984. if the password file in use during the extraction does not match the
  5985. one belonging to the file system(s) being extracted. This occurs,
  5986. for example, if you are restoring your files after a major crash and
  5987. had booted from an emergency floppy with no password file or put your
  5988. disk into another machine to do the restore.
  5989. The numeric ids are @emph{always} saved into @command{tar} archives.
  5990. The identifying names are added at create time when provided by the
  5991. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  5992. used when moving archives between a collection of machines using
  5993. a centralized management for attribution of numeric ids to users
  5994. and groups. This is often made through using the NIS capabilities.
  5995. When making a @command{tar} file for distribution to other sites, it
  5996. is sometimes cleaner to use a single owner for all files in the
  5997. distribution, and nicer to specify the write permission bits of the
  5998. files as stored in the archive independently of their actual value on
  5999. the file system. The way to prepare a clean distribution is usually
  6000. to have some Makefile rule creating a directory, copying all needed
  6001. files in that directory, then setting ownership and permissions as
  6002. wanted (there are a lot of possible schemes), and only then making a
  6003. @command{tar} archive out of this directory, before cleaning
  6004. everything out. Of course, we could add a lot of options to
  6005. @GNUTAR{} for fine tuning permissions and ownership.
  6006. This is not the good way, I think. @GNUTAR{} is
  6007. already crowded with options and moreover, the approach just explained
  6008. gives you a great deal of control already.
  6009. @opindex same-permissions, short description
  6010. @opindex preserve-permissions, short description
  6011. @item -p
  6012. @itemx --same-permissions
  6013. @itemx --preserve-permissions
  6014. Extract all protection information.
  6015. This option causes @command{tar} to set the modes (access permissions) of
  6016. extracted files exactly as recorded in the archive. If this option
  6017. is not used, the current @code{umask} setting limits the permissions
  6018. on extracted files. This option is by default enabled when
  6019. @command{tar} is executed by a superuser.
  6020. This option is meaningless with @option{--list} (@option{-t}).
  6021. @opindex preserve
  6022. @item --preserve
  6023. Same as both @option{--same-permissions} and @option{--same-order}.
  6024. The @option{--preserve} option has no equivalent short option name.
  6025. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6026. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  6027. @end table
  6028. @node Standard
  6029. @section Basic Tar Format
  6030. @UNREVISED
  6031. While an archive may contain many files, the archive itself is a
  6032. single ordinary file. Like any other file, an archive file can be
  6033. written to a storage device such as a tape or disk, sent through a
  6034. pipe or over a network, saved on the active file system, or even
  6035. stored in another archive. An archive file is not easy to read or
  6036. manipulate without using the @command{tar} utility or Tar mode in
  6037. @acronym{GNU} Emacs.
  6038. Physically, an archive consists of a series of file entries terminated
  6039. by an end-of-archive entry, which consists of two 512 blocks of zero
  6040. bytes. A file
  6041. entry usually describes one of the files in the archive (an
  6042. @dfn{archive member}), and consists of a file header and the contents
  6043. of the file. File headers contain file names and statistics, checksum
  6044. information which @command{tar} uses to detect file corruption, and
  6045. information about file types.
  6046. Archives are permitted to have more than one member with the same
  6047. member name. One way this situation can occur is if more than one
  6048. version of a file has been stored in the archive. For information
  6049. about adding new versions of a file to an archive, see @ref{update}.
  6050. @FIXME-xref{To learn more about having more than one archive member with the
  6051. same name, see -backup node, when it's written.}
  6052. In addition to entries describing archive members, an archive may
  6053. contain entries which @command{tar} itself uses to store information.
  6054. @xref{label}, for an example of such an archive entry.
  6055. A @command{tar} archive file contains a series of blocks. Each block
  6056. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6057. of as being on magnetic tape, other media are often used.
  6058. Each file archived is represented by a header block which describes
  6059. the file, followed by zero or more blocks which give the contents
  6060. of the file. At the end of the archive file there are two 512-byte blocks
  6061. filled with binary zeros as an end-of-file marker. A reasonable system
  6062. should write such end-of-file marker at the end of an archive, but
  6063. must not assume that such a block exists when reading an archive. In
  6064. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6065. The blocks may be @dfn{blocked} for physical I/O operations.
  6066. Each record of @var{n} blocks (where @var{n} is set by the
  6067. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6068. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6069. such a write is a single record. When writing an archive,
  6070. the last record of blocks should be written at the full size, with
  6071. blocks after the zero block containing all zeros. When reading
  6072. an archive, a reasonable system should properly handle an archive
  6073. whose last record is shorter than the rest, or which contains garbage
  6074. records after a zero block.
  6075. The header block is defined in C as follows. In the @GNUTAR{}
  6076. distribution, this is part of file @file{src/tar.h}:
  6077. @smallexample
  6078. @include header.texi
  6079. @end smallexample
  6080. All characters in header blocks are represented by using 8-bit
  6081. characters in the local variant of ASCII. Each field within the
  6082. structure is contiguous; that is, there is no padding used within
  6083. the structure. Each character on the archive medium is stored
  6084. contiguously.
  6085. Bytes representing the contents of files (after the header block
  6086. of each file) are not translated in any way and are not constrained
  6087. to represent characters in any character set. The @command{tar} format
  6088. does not distinguish text files from binary files, and no translation
  6089. of file contents is performed.
  6090. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6091. @code{gname} are null-terminated character strings. All other fields
  6092. are zero-filled octal numbers in ASCII. Each numeric field of width
  6093. @var{w} contains @var{w} minus 1 digits, and a null.
  6094. The @code{name} field is the file name of the file, with directory names
  6095. (if any) preceding the file name, separated by slashes.
  6096. @FIXME{how big a name before field overflows?}
  6097. The @code{mode} field provides nine bits specifying file permissions
  6098. and three bits to specify the Set UID, Set GID, and Save Text
  6099. (@dfn{sticky}) modes. Values for these bits are defined above.
  6100. When special permissions are required to create a file with a given
  6101. mode, and the user restoring files from the archive does not hold such
  6102. permissions, the mode bit(s) specifying those special permissions
  6103. are ignored. Modes which are not supported by the operating system
  6104. restoring files from the archive will be ignored. Unsupported modes
  6105. should be faked up when creating or updating an archive; e.g., the
  6106. group permission could be copied from the @emph{other} permission.
  6107. The @code{uid} and @code{gid} fields are the numeric user and group
  6108. ID of the file owners, respectively. If the operating system does
  6109. not support numeric user or group IDs, these fields should be ignored.
  6110. The @code{size} field is the size of the file in bytes; linked files
  6111. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6112. particular the @option{--incremental} (@option{-G}) option.}
  6113. The @code{mtime} field is the data modification time of the file at
  6114. the time it was archived. It is the ASCII representation of the octal
  6115. value of the last time the file's contents were modified, represented
  6116. as an integer number of
  6117. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6118. The @code{chksum} field is the ASCII representation of the octal value
  6119. of the simple sum of all bytes in the header block. Each 8-bit
  6120. byte in the header is added to an unsigned integer, initialized to
  6121. zero, the precision of which shall be no less than seventeen bits.
  6122. When calculating the checksum, the @code{chksum} field is treated as
  6123. if it were all blanks.
  6124. The @code{typeflag} field specifies the type of file archived. If a
  6125. particular implementation does not recognize or permit the specified
  6126. type, the file will be extracted as if it were a regular file. As this
  6127. action occurs, @command{tar} issues a warning to the standard error.
  6128. The @code{atime} and @code{ctime} fields are used in making incremental
  6129. backups; they store, respectively, the particular file's access and
  6130. status change times.
  6131. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6132. making a multi-volume archive. The offset is number of bytes into
  6133. the file that we need to restart at to continue the file on the next
  6134. tape, i.e., where we store the location that a continued file is
  6135. continued at.
  6136. The following fields were added to deal with sparse files. A file
  6137. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6138. represented as zeros, i.e., no useful data. A test to see if a file
  6139. is sparse is to look at the number blocks allocated for it versus the
  6140. number of characters in the file; if there are fewer blocks allocated
  6141. for the file than would normally be allocated for a file of that
  6142. size, then the file is sparse. This is the method @command{tar} uses to
  6143. detect a sparse file, and once such a file is detected, it is treated
  6144. differently from non-sparse files.
  6145. Sparse files are often @code{dbm} files, or other database-type files
  6146. which have data at some points and emptiness in the greater part of
  6147. the file. Such files can appear to be very large when an @samp{ls
  6148. -l} is done on them, when in truth, there may be a very small amount
  6149. of important data contained in the file. It is thus undesirable
  6150. to have @command{tar} think that it must back up this entire file, as
  6151. great quantities of room are wasted on empty blocks, which can lead
  6152. to running out of room on a tape far earlier than is necessary.
  6153. Thus, sparse files are dealt with so that these empty blocks are
  6154. not written to the tape. Instead, what is written to the tape is a
  6155. description, of sorts, of the sparse file: where the holes are, how
  6156. big the holes are, and how much data is found at the end of the hole.
  6157. This way, the file takes up potentially far less room on the tape,
  6158. and when the file is extracted later on, it will look exactly the way
  6159. it looked beforehand. The following is a description of the fields
  6160. used to handle a sparse file:
  6161. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6162. sparse} contains two 12-character strings which represent an offset
  6163. into the file and a number of bytes to be written at that offset.
  6164. The offset is absolute, and not relative to the offset in preceding
  6165. array element.
  6166. The header can hold four of these @code{struct sparse} at the moment;
  6167. if more are needed, they are not stored in the header.
  6168. The @code{isextended} flag is set when an @code{extended_header}
  6169. is needed to deal with a file. Note that this means that this flag
  6170. can only be set when dealing with a sparse file, and it is only set
  6171. in the event that the description of the file will not fit in the
  6172. allotted room for sparse structures in the header. In other words,
  6173. an extended_header is needed.
  6174. The @code{extended_header} structure is used for sparse files which
  6175. need more sparse structures than can fit in the header. The header can
  6176. fit 4 such structures; if more are needed, the flag @code{isextended}
  6177. gets set and the next block is an @code{extended_header}.
  6178. Each @code{extended_header} structure contains an array of 21
  6179. sparse structures, along with a similar @code{isextended} flag
  6180. that the header had. There can be an indeterminate number of such
  6181. @code{extended_header}s to describe a sparse file.
  6182. @table @asis
  6183. @item @code{REGTYPE}
  6184. @itemx @code{AREGTYPE}
  6185. These flags represent a regular file. In order to be compatible
  6186. with older versions of @command{tar}, a @code{typeflag} value of
  6187. @code{AREGTYPE} should be silently recognized as a regular file.
  6188. New archives should be created using @code{REGTYPE}. Also, for
  6189. backward compatibility, @command{tar} treats a regular file whose name
  6190. ends with a slash as a directory.
  6191. @item @code{LNKTYPE}
  6192. This flag represents a file linked to another file, of any type,
  6193. previously archived. Such files are identified in Unix by each
  6194. file having the same device and inode number. The linked-to name is
  6195. specified in the @code{linkname} field with a trailing null.
  6196. @item @code{SYMTYPE}
  6197. This represents a symbolic link to another file. The linked-to name
  6198. is specified in the @code{linkname} field with a trailing null.
  6199. @item @code{CHRTYPE}
  6200. @itemx @code{BLKTYPE}
  6201. These represent character special files and block special files
  6202. respectively. In this case the @code{devmajor} and @code{devminor}
  6203. fields will contain the major and minor device numbers respectively.
  6204. Operating systems may map the device specifications to their own
  6205. local specification, or may ignore the entry.
  6206. @item @code{DIRTYPE}
  6207. This flag specifies a directory or sub-directory. The directory
  6208. name in the @code{name} field should end with a slash. On systems where
  6209. disk allocation is performed on a directory basis, the @code{size} field
  6210. will contain the maximum number of bytes (which may be rounded to
  6211. the nearest disk block allocation unit) which the directory may
  6212. hold. A @code{size} field of zero indicates no such limiting. Systems
  6213. which do not support limiting in this manner should ignore the
  6214. @code{size} field.
  6215. @item @code{FIFOTYPE}
  6216. This specifies a FIFO special file. Note that the archiving of a
  6217. FIFO file archives the existence of this file and not its contents.
  6218. @item @code{CONTTYPE}
  6219. This specifies a contiguous file, which is the same as a normal
  6220. file except that, in operating systems which support it, all its
  6221. space is allocated contiguously on the disk. Operating systems
  6222. which do not allow contiguous allocation should silently treat this
  6223. type as a normal file.
  6224. @item @code{A} @dots{} @code{Z}
  6225. These are reserved for custom implementations. Some of these are
  6226. used in the @acronym{GNU} modified format, as described below.
  6227. @end table
  6228. Other values are reserved for specification in future revisions of
  6229. the P1003 standard, and should not be used by any @command{tar} program.
  6230. The @code{magic} field indicates that this archive was output in
  6231. the P1003 archive format. If this field contains @code{TMAGIC},
  6232. the @code{uname} and @code{gname} fields will contain the ASCII
  6233. representation of the owner and group of the file respectively.
  6234. If found, the user and group IDs are used rather than the values in
  6235. the @code{uid} and @code{gid} fields.
  6236. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6237. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6238. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6239. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6240. @node Extensions
  6241. @section @acronym{GNU} Extensions to the Archive Format
  6242. @UNREVISED
  6243. The @acronym{GNU} format uses additional file types to describe new types of
  6244. files in an archive. These are listed below.
  6245. @table @code
  6246. @item GNUTYPE_DUMPDIR
  6247. @itemx 'D'
  6248. This represents a directory and a list of files created by the
  6249. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6250. size of the associated list of files. Each file name is preceded by
  6251. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6252. (The file is a directory, or is not stored in the archive.) Each file
  6253. name is terminated by a null. There is an additional null after the
  6254. last file name.
  6255. @item GNUTYPE_MULTIVOL
  6256. @itemx 'M'
  6257. This represents a file continued from another volume of a multi-volume
  6258. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6259. type of the file is not given here. The @code{size} field gives the
  6260. maximum size of this piece of the file (assuming the volume does
  6261. not end before the file is written out). The @code{offset} field
  6262. gives the offset from the beginning of the file where this part of
  6263. the file begins. Thus @code{size} plus @code{offset} should equal
  6264. the original size of the file.
  6265. @item GNUTYPE_SPARSE
  6266. @itemx 'S'
  6267. This flag indicates that we are dealing with a sparse file. Note
  6268. that archiving a sparse file requires special operations to find
  6269. holes in the file, which mark the positions of these holes, along
  6270. with the number of bytes of data to be found after the hole.
  6271. @item GNUTYPE_VOLHDR
  6272. @itemx 'V'
  6273. This file type is used to mark the volume header that was given with
  6274. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6275. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6276. The @code{size} field is zero. Only the first file in each volume
  6277. of an archive should have this type.
  6278. @end table
  6279. You may have trouble reading a @acronym{GNU} format archive on a
  6280. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6281. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6282. used when writing the archive. In general, if @command{tar} does not
  6283. use the @acronym{GNU}-added fields of the header, other versions of
  6284. @command{tar} should be able to read the archive. Otherwise, the
  6285. @command{tar} program will give an error, the most likely one being a
  6286. checksum error.
  6287. @node cpio
  6288. @section Comparison of @command{tar} and @command{cpio}
  6289. @UNREVISED
  6290. @FIXME{Reorganize the following material}
  6291. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6292. pathname lengths. The binary and old ASCII formats have a max path
  6293. length of 256, and the new ASCII and CRC ASCII formats have a max
  6294. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6295. with arbitrary pathname lengths, but other @command{cpio} implementations
  6296. may crash unexplainedly trying to read them.
  6297. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6298. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6299. in System V prior to SVR4, and some vendors may have added symlinks
  6300. to their system without enhancing @command{cpio} to know about them.
  6301. Others may have enhanced it in a way other than the way I did it
  6302. at Sun, and which was adopted by AT&T (and which is, I think, also
  6303. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6304. into a later BSD release---I think I gave them my changes).
  6305. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6306. can handle @command{tar} format input, and write it on output, and it
  6307. probably handles symbolic links. They may not have bothered doing
  6308. anything to enhance @command{tar} as a result.)
  6309. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6310. @command{tar} comes with V7, System III, System V, and BSD source;
  6311. @command{cpio} comes only with System III, System V, and later BSD
  6312. (4.3-tahoe and later).
  6313. @command{tar}'s way of handling multiple hard links to a file can handle
  6314. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6315. @command{cpio}s way requires you to play some games (in its "binary"
  6316. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6317. they're 18 bits---it would have to play games with the "file system ID"
  6318. field of the header to make sure that the file system ID/i-number pairs
  6319. of different files were always different), and I don't know which
  6320. @command{cpio}s, if any, play those games. Those that don't might get
  6321. confused and think two files are the same file when they're not, and
  6322. make hard links between them.
  6323. @command{tar}s way of handling multiple hard links to a file places only
  6324. one copy of the link on the tape, but the name attached to that copy
  6325. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6326. way puts one copy for every link, but you can retrieve it using any
  6327. of the names.
  6328. @quotation
  6329. What type of check sum (if any) is used, and how is this calculated.
  6330. @end quotation
  6331. See the attached manual pages for @command{tar} and @command{cpio} format.
  6332. @command{tar} uses a checksum which is the sum of all the bytes in the
  6333. @command{tar} header for a file; @command{cpio} uses no checksum.
  6334. @quotation
  6335. If anyone knows why @command{cpio} was made when @command{tar} was present
  6336. at the unix scene,
  6337. @end quotation
  6338. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6339. generally-available version of UNIX had @command{tar} at the time. I don't
  6340. know whether any version that was generally available @emph{within AT&T}
  6341. had @command{tar}, or, if so, whether the people within AT&T who did
  6342. @command{cpio} knew about it.
  6343. On restore, if there is a corruption on a tape @command{tar} will stop at
  6344. that point, while @command{cpio} will skip over it and try to restore the
  6345. rest of the files.
  6346. The main difference is just in the command syntax and header format.
  6347. @command{tar} is a little more tape-oriented in that everything is blocked
  6348. to start on a record boundary.
  6349. @quotation
  6350. Is there any differences between the ability to recover crashed
  6351. archives between the two of them. (Is there any chance of recovering
  6352. crashed archives at all.)
  6353. @end quotation
  6354. Theoretically it should be easier under @command{tar} since the blocking
  6355. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6356. However, modern @command{cpio}'s and variations have an option to just
  6357. search for the next file header after an error with a reasonable chance
  6358. of resyncing. However, lots of tape driver software won't allow you to
  6359. continue past a media error which should be the only reason for getting
  6360. out of sync unless a file changed sizes while you were writing the
  6361. archive.
  6362. @quotation
  6363. If anyone knows why @command{cpio} was made when @command{tar} was present
  6364. at the unix scene, please tell me about this too.
  6365. @end quotation
  6366. Probably because it is more media efficient (by not blocking everything
  6367. and using only the space needed for the headers where @command{tar}
  6368. always uses 512 bytes per file header) and it knows how to archive
  6369. special files.
  6370. You might want to look at the freely available alternatives. The
  6371. major ones are @command{afio}, @GNUTAR{}, and
  6372. @command{pax}, each of which have their own extensions with some
  6373. backwards compatibility.
  6374. Sparse files were @command{tar}red as sparse files (which you can
  6375. easily test, because the resulting archive gets smaller, and
  6376. @acronym{GNU} @command{cpio} can no longer read it).
  6377. @node Media
  6378. @chapter Tapes and Other Archive Media
  6379. @UNREVISED
  6380. A few special cases about tape handling warrant more detailed
  6381. description. These special cases are discussed below.
  6382. Many complexities surround the use of @command{tar} on tape drives. Since
  6383. the creation and manipulation of archives located on magnetic tape was
  6384. the original purpose of @command{tar}, it contains many features making
  6385. such manipulation easier.
  6386. Archives are usually written on dismountable media---tape cartridges,
  6387. mag tapes, or floppy disks.
  6388. The amount of data a tape or disk holds depends not only on its size,
  6389. but also on how it is formatted. A 2400 foot long reel of mag tape
  6390. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6391. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6392. Magnetic media are re-usable---once the archive on a tape is no longer
  6393. needed, the archive can be erased and the tape or disk used over.
  6394. Media quality does deteriorate with use, however. Most tapes or disks
  6395. should be discarded when they begin to produce data errors. EXABYTE
  6396. tape cartridges should be discarded when they generate an @dfn{error
  6397. count} (number of non-usable bits) of more than 10k.
  6398. Magnetic media are written and erased using magnetic fields, and
  6399. should be protected from such fields to avoid damage to stored data.
  6400. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6401. not a good idea.
  6402. @menu
  6403. * Device:: Device selection and switching
  6404. * Remote Tape Server::
  6405. * Common Problems and Solutions::
  6406. * Blocking:: Blocking
  6407. * Many:: Many archives on one tape
  6408. * Using Multiple Tapes:: Using Multiple Tapes
  6409. * label:: Including a Label in the Archive
  6410. * verify::
  6411. * Write Protection::
  6412. @end menu
  6413. @node Device
  6414. @section Device Selection and Switching
  6415. @UNREVISED
  6416. @table @option
  6417. @item -f [@var{hostname}:]@var{file}
  6418. @itemx --file=[@var{hostname}:]@var{file}
  6419. Use archive file or device @var{file} on @var{hostname}.
  6420. @end table
  6421. This option is used to specify the file name of the archive @command{tar}
  6422. works on.
  6423. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6424. input (when listing or extracting), or writes it to standard output
  6425. (when creating). If the @samp{-} file name is given when updating an
  6426. archive, @command{tar} will read the original archive from its standard
  6427. input, and will write the entire new archive to its standard output.
  6428. If the file name contains a @samp{:}, it is interpreted as
  6429. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6430. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6431. either case, @command{tar} will invoke the command @command{rsh} (or
  6432. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6433. machine. If you give an alternate login name, it will be given to the
  6434. @command{rsh}.
  6435. Naturally, the remote machine must have an executable
  6436. @command{/usr/libexec/rmt}. This program is free software from the
  6437. University of California, and a copy of the source code can be found
  6438. with the sources for @command{tar}; it's compiled and installed by default.
  6439. The exact path to this utility is determined when configuring the package.
  6440. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6441. your installation prefix. This location may also be overridden at
  6442. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6443. ---rmt-command}, for detailed description of this option. @xref{Remote
  6444. Tape Server}, for the description of @command{rmt} command).
  6445. If this option is not given, but the environment variable @env{TAPE}
  6446. is set, its value is used; otherwise, old versions of @command{tar}
  6447. used a default archive name (which was picked when @command{tar} was
  6448. compiled). The default is normally set up to be the @dfn{first} tape
  6449. drive or other transportable I/O medium on the system.
  6450. Starting with version 1.11.5, @GNUTAR{} uses
  6451. standard input and standard output as the default device, and I will
  6452. not try anymore supporting automatic device detection at installation
  6453. time. This was failing really in too many cases, it was hopeless.
  6454. This is now completely left to the installer to override standard
  6455. input and standard output for default device, if this seems
  6456. preferable. Further, I think @emph{most} actual usages of
  6457. @command{tar} are done with pipes or disks, not really tapes,
  6458. cartridges or diskettes.
  6459. Some users think that using standard input and output is running
  6460. after trouble. This could lead to a nasty surprise on your screen if
  6461. you forget to specify an output file name---especially if you are going
  6462. through a network or terminal server capable of buffering large amounts
  6463. of output. We had so many bug reports in that area of configuring
  6464. default tapes automatically, and so many contradicting requests, that
  6465. we finally consider the problem to be portably intractable. We could
  6466. of course use something like @samp{/dev/tape} as a default, but this
  6467. is @emph{also} running after various kind of trouble, going from hung
  6468. processes to accidental destruction of real tapes. After having seen
  6469. all this mess, using standard input and output as a default really
  6470. sounds like the only clean choice left, and a very useful one too.
  6471. @GNUTAR{} reads and writes archive in records, I
  6472. suspect this is the main reason why block devices are preferred over
  6473. character devices. Most probably, block devices are more efficient
  6474. too. The installer could also check for @samp{DEFTAPE} in
  6475. @file{<sys/mtio.h>}.
  6476. @table @option
  6477. @opindex force-local, short description
  6478. @item --force-local
  6479. Archive file is local even if it contains a colon.
  6480. @opindex rsh-command
  6481. @item --rsh-command=@var{command}
  6482. Use remote @var{command} instead of @command{rsh}. This option exists
  6483. so that people who use something other than the standard @command{rsh}
  6484. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6485. When this command is not used, the shell command found when
  6486. the @command{tar} program was installed is used instead. This is
  6487. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6488. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6489. The installer may have overridden this by defining the environment
  6490. variable @env{RSH} @emph{at installation time}.
  6491. @item -[0-7][lmh]
  6492. Specify drive and density.
  6493. @opindex multi-volume, short description
  6494. @item -M
  6495. @itemx --multi-volume
  6496. Create/list/extract multi-volume archive.
  6497. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6498. that may be larger than will fit on the medium used to hold it.
  6499. @xref{Multi-Volume Archives}.
  6500. @opindex tape-length, short description
  6501. @item -L @var{num}
  6502. @itemx --tape-length=@var{num}
  6503. Change tape after writing @var{num} x 1024 bytes.
  6504. This option might be useful when your tape drivers do not properly
  6505. detect end of physical tapes. By being slightly conservative on the
  6506. maximum tape length, you might avoid the problem entirely.
  6507. @opindex info-script, short description
  6508. @opindex new-volume-script, short description
  6509. @item -F @var{file}
  6510. @itemx --info-script=@var{file}
  6511. @itemx --new-volume-script=@var{file}
  6512. Execute @file{file} at end of each tape. This implies
  6513. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6514. description of this option.
  6515. @end table
  6516. @node Remote Tape Server
  6517. @section The Remote Tape Server
  6518. @cindex remote tape drive
  6519. @pindex rmt
  6520. In order to access the tape drive on a remote machine, @command{tar}
  6521. uses the remote tape server written at the University of California at
  6522. Berkeley. The remote tape server must be installed as
  6523. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6524. want to use. @command{tar} calls @command{rmt} by running an
  6525. @command{rsh} or @command{remsh} to the remote machine, optionally
  6526. using a different login name if one is supplied.
  6527. A copy of the source for the remote tape server is provided. It is
  6528. Copyright @copyright{} 1983 by the Regents of the University of
  6529. California, but can be freely distributed. It is compiled and
  6530. installed by default.
  6531. @cindex absolute file names
  6532. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6533. @GNUTAR{} will not allow you to create an archive that contains
  6534. absolute file names (a file name beginning with @samp{/}.) If you try,
  6535. @command{tar} will automatically remove the leading @samp{/} from the
  6536. file names it stores in the archive. It will also type a warning
  6537. message telling you what it is doing.
  6538. When reading an archive that was created with a different
  6539. @command{tar} program, @GNUTAR{} automatically
  6540. extracts entries in the archive which have absolute file names as if
  6541. the file names were not absolute. This is an important feature. A
  6542. visitor here once gave a @command{tar} tape to an operator to restore;
  6543. the operator used Sun @command{tar} instead of @GNUTAR{},
  6544. and the result was that it replaced large portions of
  6545. our @file{/bin} and friends with versions from the tape; needless to
  6546. say, we were unhappy about having to recover the file system from
  6547. backup tapes.
  6548. For example, if the archive contained a file @file{/usr/bin/computoy},
  6549. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6550. relative to the current directory. If you want to extract the files in
  6551. an archive to the same absolute names that they had when the archive
  6552. was created, you should do a @samp{cd /} before extracting the files
  6553. from the archive, or you should either use the @option{--absolute-names}
  6554. option, or use the command @samp{tar -C / @dots{}}.
  6555. @cindex Ultrix 3.1 and write failure
  6556. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6557. can claim that a short write near the end of a tape succeeded,
  6558. when it actually failed. This will result in the -M option not
  6559. working correctly. The best workaround at the moment is to use a
  6560. significantly larger blocking factor than the default 20.
  6561. In order to update an archive, @command{tar} must be able to backspace the
  6562. archive in order to reread or rewrite a record that was just read (or
  6563. written). This is currently possible only on two kinds of files: normal
  6564. disk files (or any other file that can be backspaced with @samp{lseek}),
  6565. and industry-standard 9-track magnetic tape (or any other kind of tape
  6566. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6567. This means that the @option{--append}, @option{--concatenate}, and
  6568. @option{--delete} commands will not work on any other kind of file.
  6569. Some media simply cannot be backspaced, which means these commands and
  6570. options will never be able to work on them. These non-backspacing
  6571. media include pipes and cartridge tape drives.
  6572. Some other media can be backspaced, and @command{tar} will work on them
  6573. once @command{tar} is modified to do so.
  6574. Archives created with the @option{--multi-volume}, @option{--label}, and
  6575. @option{--incremental} (@option{-G}) options may not be readable by other version
  6576. of @command{tar}. In particular, restoring a file that was split over
  6577. a volume boundary will require some careful work with @command{dd}, if
  6578. it can be done at all. Other versions of @command{tar} may also create
  6579. an empty file whose name is that of the volume header. Some versions
  6580. of @command{tar} may create normal files instead of directories archived
  6581. with the @option{--incremental} (@option{-G}) option.
  6582. @node Common Problems and Solutions
  6583. @section Some Common Problems and their Solutions
  6584. @ifclear PUBLISH
  6585. @format
  6586. errors from system:
  6587. permission denied
  6588. no such file or directory
  6589. not owner
  6590. errors from @command{tar}:
  6591. directory checksum error
  6592. header format error
  6593. errors from media/system:
  6594. i/o error
  6595. device busy
  6596. @end format
  6597. @end ifclear
  6598. @node Blocking
  6599. @section Blocking
  6600. @UNREVISED
  6601. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6602. is also confusing to the expert reader. On the other hand, readers
  6603. who are new to the field have a fresh mind, and they may safely skip
  6604. the next two paragraphs, as the remainder of this manual uses those
  6605. two terms in a quite consistent way.
  6606. John Gilmore, the writer of the public domain @command{tar} from which
  6607. @GNUTAR{} was originally derived, wrote (June 1995):
  6608. @quotation
  6609. The nomenclature of tape drives comes from IBM, where I believe
  6610. they were invented for the IBM 650 or so. On IBM mainframes, what
  6611. is recorded on tape are tape blocks. The logical organization of
  6612. data is into records. There are various ways of putting records into
  6613. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6614. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6615. to a block), @code{VB} (variable size records, @var{n} to a block),
  6616. @code{VSB} (variable spanned blocked: variable sized records that can
  6617. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6618. parameter specified this to the operating system.
  6619. The Unix man page on @command{tar} was totally confused about this.
  6620. When I wrote @code{PD TAR}, I used the historically correct terminology
  6621. (@command{tar} writes data records, which are grouped into blocks).
  6622. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6623. here), and now Fran@,{c}ois has migrated that terminology back
  6624. into the source code too.
  6625. @end quotation
  6626. The term @dfn{physical block} means the basic transfer chunk from or
  6627. to a device, after which reading or writing may stop without anything
  6628. being lost. In this manual, the term @dfn{block} usually refers to
  6629. a disk physical block, @emph{assuming} that each disk block is 512
  6630. bytes in length. It is true that some disk devices have different
  6631. physical blocks, but @command{tar} ignore these differences in its own
  6632. format, which is meant to be portable, so a @command{tar} block is always
  6633. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6634. The term @dfn{logical block} often represents the basic chunk of
  6635. allocation of many disk blocks as a single entity, which the operating
  6636. system treats somewhat atomically; this concept is only barely used
  6637. in @GNUTAR{}.
  6638. The term @dfn{physical record} is another way to speak of a physical
  6639. block, those two terms are somewhat interchangeable. In this manual,
  6640. the term @dfn{record} usually refers to a tape physical block,
  6641. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6642. It is true that archives may be put on disk or used with pipes,
  6643. but nevertheless, @command{tar} tries to read and write the archive one
  6644. @dfn{record} at a time, whatever the medium in use. One record is made
  6645. up of an integral number of blocks, and this operation of putting many
  6646. disk blocks into a single tape block is called @dfn{reblocking}, or
  6647. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6648. the logical organization of many characters into something meaningful
  6649. to the application. The term @dfn{unit record} describes a small set
  6650. of characters which are transmitted whole to or by the application,
  6651. and often refers to a line of text. Those two last terms are unrelated
  6652. to what we call a @dfn{record} in @GNUTAR{}.
  6653. When writing to tapes, @command{tar} writes the contents of the archive
  6654. in chunks known as @dfn{records}. To change the default blocking
  6655. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  6656. @var{512-size}}) option. Each record will then be composed of
  6657. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  6658. @xref{Standard}.) Each file written to the archive uses at least one
  6659. full record. As a result, using a larger record size can result in
  6660. more wasted space for small files. On the other hand, a larger record
  6661. size can often be read and written much more efficiently.
  6662. Further complicating the problem is that some tape drives ignore the
  6663. blocking entirely. For these, a larger record size can still improve
  6664. performance (because the software layers above the tape drive still
  6665. honor the blocking), but not as dramatically as on tape drives that
  6666. honor blocking.
  6667. When reading an archive, @command{tar} can usually figure out the
  6668. record size on itself. When this is the case, and a non-standard
  6669. record size was used when the archive was created, @command{tar} will
  6670. print a message about a non-standard blocking factor, and then operate
  6671. normally. On some tape devices, however, @command{tar} cannot figure
  6672. out the record size itself. On most of those, you can specify a
  6673. blocking factor (with @option{--blocking-factor}) larger than the
  6674. actual blocking factor, and then use the @option{--read-full-records}
  6675. (@option{-B}) option. (If you specify a blocking factor with
  6676. @option{--blocking-factor} and don't use the
  6677. @option{--read-full-records} option, then @command{tar} will not
  6678. attempt to figure out the recording size itself.) On some devices,
  6679. you must always specify the record size exactly with
  6680. @option{--blocking-factor} when reading, because @command{tar} cannot
  6681. figure it out. In any case, use @option{--list} (@option{-t}) before
  6682. doing any extractions to see whether @command{tar} is reading the archive
  6683. correctly.
  6684. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6685. putting them into records is to put a whole number of them (one or
  6686. more) into each record. @command{tar} records are all the same size;
  6687. at the end of the file there's a block containing all zeros, which
  6688. is how you tell that the remainder of the last record(s) are garbage.
  6689. In a standard @command{tar} file (no options), the block size is 512
  6690. and the record size is 10240, for a blocking factor of 20. What the
  6691. @option{--blocking-factor} option does is sets the blocking factor,
  6692. changing the record size while leaving the block size at 512 bytes.
  6693. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6694. most tape drives these days prefer much bigger records in order to
  6695. stream and not waste tape. When writing tapes for myself, some tend
  6696. to use a factor of the order of 2048, say, giving a record size of
  6697. around one megabyte.
  6698. If you use a blocking factor larger than 20, older @command{tar}
  6699. programs might not be able to read the archive, so we recommend this
  6700. as a limit to use in practice. @GNUTAR{}, however,
  6701. will support arbitrarily large record sizes, limited only by the
  6702. amount of virtual memory or the physical characteristics of the tape
  6703. device.
  6704. @menu
  6705. * Format Variations:: Format Variations
  6706. * Blocking Factor:: The Blocking Factor of an Archive
  6707. @end menu
  6708. @node Format Variations
  6709. @subsection Format Variations
  6710. @cindex Format Parameters
  6711. @cindex Format Options
  6712. @cindex Options, archive format specifying
  6713. @cindex Options, format specifying
  6714. @UNREVISED
  6715. Format parameters specify how an archive is written on the archive
  6716. media. The best choice of format parameters will vary depending on
  6717. the type and number of files being archived, and on the media used to
  6718. store the archive.
  6719. To specify format parameters when accessing or creating an archive,
  6720. you can use the options described in the following sections.
  6721. If you do not specify any format parameters, @command{tar} uses
  6722. default parameters. You cannot modify a compressed archive.
  6723. If you create an archive with the @option{--blocking-factor} option
  6724. specified (@pxref{Blocking Factor}), you must specify that
  6725. blocking-factor when operating on the archive. @xref{Formats}, for other
  6726. examples of format parameter considerations.
  6727. @node Blocking Factor
  6728. @subsection The Blocking Factor of an Archive
  6729. @cindex Blocking Factor
  6730. @cindex Record Size
  6731. @cindex Number of blocks per record
  6732. @cindex Number of bytes per record
  6733. @cindex Bytes per record
  6734. @cindex Blocks per record
  6735. @UNREVISED
  6736. @opindex blocking-factor
  6737. The data in an archive is grouped into blocks, which are 512 bytes.
  6738. Blocks are read and written in whole number multiples called
  6739. @dfn{records}. The number of blocks in a record (ie. the size of a
  6740. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6741. The @option{--blocking-factor=@var{512-size}} (@option{-b
  6742. @var{512-size}}) option specifies the blocking factor of an archive.
  6743. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  6744. can be specified at installation. To find out the blocking factor of
  6745. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  6746. This may not work on some devices.
  6747. Records are separated by gaps, which waste space on the archive media.
  6748. If you are archiving on magnetic tape, using a larger blocking factor
  6749. (and therefore larger records) provides faster throughput and allows you
  6750. to fit more data on a tape (because there are fewer gaps). If you are
  6751. archiving on cartridge, a very large blocking factor (say 126 or more)
  6752. greatly increases performance. A smaller blocking factor, on the other
  6753. hand, may be useful when archiving small files, to avoid archiving lots
  6754. of nulls as @command{tar} fills out the archive to the end of the record.
  6755. In general, the ideal record size depends on the size of the
  6756. inter-record gaps on the tape you are using, and the average size of the
  6757. files you are archiving. @xref{create}, for information on
  6758. writing archives.
  6759. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6760. Archives with blocking factors larger than 20 cannot be read
  6761. by very old versions of @command{tar}, or by some newer versions
  6762. of @command{tar} running on old machines with small address spaces.
  6763. With @GNUTAR{}, the blocking factor of an archive is limited
  6764. only by the maximum record size of the device containing the archive,
  6765. or by the amount of available virtual memory.
  6766. Also, on some systems, not using adequate blocking factors, as sometimes
  6767. imposed by the device drivers, may yield unexpected diagnostics. For
  6768. example, this has been reported:
  6769. @smallexample
  6770. Cannot write to /dev/dlt: Invalid argument
  6771. @end smallexample
  6772. @noindent
  6773. In such cases, it sometimes happen that the @command{tar} bundled by
  6774. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6775. requires an explicit specification for the block size,
  6776. which it cannot guess. This yields some people to consider
  6777. @GNUTAR{} is misbehaving, because by comparison,
  6778. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6779. for example, might resolve the problem.
  6780. If you use a non-default blocking factor when you create an archive, you
  6781. must specify the same blocking factor when you modify that archive. Some
  6782. archive devices will also require you to specify the blocking factor when
  6783. reading that archive, however this is not typically the case. Usually, you
  6784. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  6785. reports a non-default record size and then lists the archive members as
  6786. it would normally. To extract files from an archive with a non-standard
  6787. blocking factor (particularly if you're not sure what the blocking factor
  6788. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  6789. specifying a blocking factor larger then the blocking factor of the archive
  6790. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6791. @xref{list}, for more information on the @option{--list} (@option{-t})
  6792. operation. @xref{Reading}, for a more detailed explanation of that option.
  6793. @table @option
  6794. @item --blocking-factor=@var{number}
  6795. @itemx -b @var{number}
  6796. Specifies the blocking factor of an archive. Can be used with any
  6797. operation, but is usually not necessary with @option{--list} (@option{-t}).
  6798. @end table
  6799. Device blocking
  6800. @table @option
  6801. @item -b @var{blocks}
  6802. @itemx --blocking-factor=@var{blocks}
  6803. Set record size to @math{@var{blocks} * 512} bytes.
  6804. This option is used to specify a @dfn{blocking factor} for the archive.
  6805. When reading or writing the archive, @command{tar}, will do reads and writes
  6806. of the archive in records of @math{@var{block}*512} bytes. This is true
  6807. even when the archive is compressed. Some devices requires that all
  6808. write operations be a multiple of a certain size, and so, @command{tar}
  6809. pads the archive out to the next record boundary.
  6810. The default blocking factor is set when @command{tar} is compiled, and is
  6811. typically 20. Blocking factors larger than 20 cannot be read by very
  6812. old versions of @command{tar}, or by some newer versions of @command{tar}
  6813. running on old machines with small address spaces.
  6814. With a magnetic tape, larger records give faster throughput and fit
  6815. more data on a tape (because there are fewer inter-record gaps).
  6816. If the archive is in a disk file or a pipe, you may want to specify
  6817. a smaller blocking factor, since a large one will result in a large
  6818. number of null bytes at the end of the archive.
  6819. When writing cartridge or other streaming tapes, a much larger
  6820. blocking factor (say 126 or more) will greatly increase performance.
  6821. However, you must specify the same blocking factor when reading or
  6822. updating the archive.
  6823. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6824. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6825. seems to disappear. Id est, we are using block size of 112 right
  6826. now, and we haven't had the problem since we switched@dots{}
  6827. With @GNUTAR{} the blocking factor is limited only
  6828. by the maximum record size of the device containing the archive, or by
  6829. the amount of available virtual memory.
  6830. However, deblocking or reblocking is virtually avoided in a special
  6831. case which often occurs in practice, but which requires all the
  6832. following conditions to be simultaneously true:
  6833. @itemize @bullet
  6834. @item
  6835. the archive is subject to a compression option,
  6836. @item
  6837. the archive is not handled through standard input or output, nor
  6838. redirected nor piped,
  6839. @item
  6840. the archive is directly handled to a local disk, instead of any special
  6841. device,
  6842. @item
  6843. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  6844. invocation.
  6845. @end itemize
  6846. If the output goes directly to a local disk, and not through
  6847. stdout, then the last write is not extended to a full record size.
  6848. Otherwise, reblocking occurs. Here are a few other remarks on this
  6849. topic:
  6850. @itemize @bullet
  6851. @item
  6852. @command{gzip} will complain about trailing garbage if asked to
  6853. uncompress a compressed archive on tape, there is an option to turn
  6854. the message off, but it breaks the regularity of simply having to use
  6855. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6856. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6857. Gailly, by sending a copy of this message to him.
  6858. @item
  6859. @command{compress} does not show this problem, but as Jean-loup pointed
  6860. out to Michael, @samp{compress -d} silently adds garbage after
  6861. the result of decompression, which tar ignores because it already
  6862. recognized its end-of-file indicator. So this bug may be safely
  6863. ignored.
  6864. @item
  6865. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6866. but will still return an exit status of 2 which tar reports in turn.
  6867. @command{tar} might ignore the exit status returned, but I hate doing
  6868. that, as it weakens the protection @command{tar} offers users against
  6869. other possible problems at decompression time. If @command{gzip} was
  6870. silently skipping trailing zeros @emph{and} also avoiding setting the
  6871. exit status in this innocuous case, that would solve this situation.
  6872. @item
  6873. @command{tar} should become more solid at not stopping to read a pipe at
  6874. the first null block encountered. This inelegantly breaks the pipe.
  6875. @command{tar} should rather drain the pipe out before exiting itself.
  6876. @end itemize
  6877. @opindex ignore-zeros, short description
  6878. @item -i
  6879. @itemx --ignore-zeros
  6880. Ignore blocks of zeros in archive (means EOF).
  6881. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  6882. of zeros in the archive. Normally a block of zeros indicates the
  6883. end of the archive, but when reading a damaged archive, or one which
  6884. was created by concatenating several archives together, this option
  6885. allows @command{tar} to read the entire archive. This option is not on
  6886. by default because many versions of @command{tar} write garbage after
  6887. the zeroed blocks.
  6888. Note that this option causes @command{tar} to read to the end of the
  6889. archive file, which may sometimes avoid problems when multiple files
  6890. are stored on a single physical tape.
  6891. @opindex read-full-records, short description
  6892. @item -B
  6893. @itemx --read-full-records
  6894. Reblock as we read (for reading 4.2BSD pipes).
  6895. If @option{--read-full-records} is used, @command{tar}
  6896. will not panic if an attempt to read a record from the archive does
  6897. not return a full record. Instead, @command{tar} will keep reading
  6898. until it has obtained a full
  6899. record.
  6900. This option is turned on by default when @command{tar} is reading
  6901. an archive from standard input, or from a remote machine. This is
  6902. because on BSD Unix systems, a read of a pipe will return however
  6903. much happens to be in the pipe, even if it is less than @command{tar}
  6904. requested. If this option was not used, @command{tar} would fail as
  6905. soon as it read an incomplete record from the pipe.
  6906. This option is also useful with the commands for updating an archive.
  6907. @end table
  6908. Tape blocking
  6909. @FIXME{Appropriate options should be moved here from elsewhere.}
  6910. @cindex blocking factor
  6911. @cindex tape blocking
  6912. When handling various tapes or cartridges, you have to take care of
  6913. selecting a proper blocking, that is, the number of disk blocks you
  6914. put together as a single tape block on the tape, without intervening
  6915. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6916. with no information on it, used for decelerating the tape to a
  6917. full stop, and for later regaining the reading or writing speed.
  6918. When the tape driver starts reading a record, the record has to
  6919. be read whole without stopping, as a tape gap is needed to stop the
  6920. tape motion without loosing information.
  6921. @cindex Exabyte blocking
  6922. @cindex DAT blocking
  6923. Using higher blocking (putting more disk blocks per tape block) will use
  6924. the tape more efficiently as there will be less tape gaps. But reading
  6925. such tapes may be more difficult for the system, as more memory will be
  6926. required to receive at once the whole record. Further, if there is a
  6927. reading error on a huge record, this is less likely that the system will
  6928. succeed in recovering the information. So, blocking should not be too
  6929. low, nor it should be too high. @command{tar} uses by default a blocking of
  6930. 20 for historical reasons, and it does not really matter when reading or
  6931. writing to disk. Current tape technology would easily accommodate higher
  6932. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6933. We were told that for some DLT drives, the blocking should be a multiple
  6934. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6935. Other manufacturers may use different recommendations for the same tapes.
  6936. This might also depends of the buffering techniques used inside modern
  6937. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6938. Others request blocking to be some exponent of two.
  6939. So, there is no fixed rule for blocking. But blocking at read time
  6940. should ideally be the same as blocking used at write time. At one place
  6941. I know, with a wide variety of equipment, they found it best to use a
  6942. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6943. I was also told that, for recycled tapes, prior erasure (by the same
  6944. drive unit that will be used to create the archives) sometimes lowers
  6945. the error rates observed at rewriting time.
  6946. I might also use @option{--number-blocks} instead of
  6947. @option{--block-number}, so @option{--block} will then expand to
  6948. @option{--blocking-factor} unambiguously.
  6949. @node Many
  6950. @section Many Archives on One Tape
  6951. @FIXME{Appropriate options should be moved here from elsewhere.}
  6952. @findex ntape @r{device}
  6953. Most tape devices have two entries in the @file{/dev} directory, or
  6954. entries that come in pairs, which differ only in the minor number for
  6955. this device. Let's take for example @file{/dev/tape}, which often
  6956. points to the only or usual tape device of a given system. There might
  6957. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6958. name is the @emph{rewinding} version of the device, while the name
  6959. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6960. device.
  6961. A rewinding tape device will bring back the tape to its beginning point
  6962. automatically when this device is opened or closed. Since @command{tar}
  6963. opens the archive file before using it and closes it afterwards, this
  6964. means that a simple:
  6965. @smallexample
  6966. $ @kbd{tar cf /dev/tape @var{directory}}
  6967. @end smallexample
  6968. @noindent
  6969. will reposition the tape to its beginning both prior and after saving
  6970. @var{directory} contents to it, thus erasing prior tape contents and
  6971. making it so that any subsequent write operation will destroy what has
  6972. just been saved.
  6973. @cindex tape positioning
  6974. So, a rewinding device is normally meant to hold one and only one file.
  6975. If you want to put more than one @command{tar} archive on a given tape, you
  6976. will need to avoid using the rewinding version of the tape device. You
  6977. will also have to pay special attention to tape positioning. Errors in
  6978. positioning may overwrite the valuable data already on your tape. Many
  6979. people, burnt by past experiences, will only use rewinding devices and
  6980. limit themselves to one file per tape, precisely to avoid the risk of
  6981. such errors. Be fully aware that writing at the wrong position on a
  6982. tape loses all information past this point and most probably until the
  6983. end of the tape, and this destroyed information @emph{cannot} be
  6984. recovered.
  6985. To save @var{directory-1} as a first archive at the beginning of a
  6986. tape, and leave that tape ready for a second archive, you should use:
  6987. @smallexample
  6988. $ @kbd{mt -f /dev/nrtape rewind}
  6989. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6990. @end smallexample
  6991. @cindex tape marks
  6992. @dfn{Tape marks} are special magnetic patterns written on the tape
  6993. media, which are later recognizable by the reading hardware. These
  6994. marks are used after each file, when there are many on a single tape.
  6995. An empty file (that is to say, two tape marks in a row) signal the
  6996. logical end of the tape, after which no file exist. Usually,
  6997. non-rewinding tape device drivers will react to the close request issued
  6998. by @command{tar} by first writing two tape marks after your archive, and by
  6999. backspacing over one of these. So, if you remove the tape at that time
  7000. from the tape drive, it is properly terminated. But if you write
  7001. another file at the current position, the second tape mark will be
  7002. erased by the new information, leaving only one tape mark between files.
  7003. So, you may now save @var{directory-2} as a second archive after the
  7004. first on the same tape by issuing the command:
  7005. @smallexample
  7006. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7007. @end smallexample
  7008. @noindent
  7009. and so on for all the archives you want to put on the same tape.
  7010. Another usual case is that you do not write all the archives the same
  7011. day, and you need to remove and store the tape between two archive
  7012. sessions. In general, you must remember how many files are already
  7013. saved on your tape. Suppose your tape already has 16 files on it, and
  7014. that you are ready to write the 17th. You have to take care of skipping
  7015. the first 16 tape marks before saving @var{directory-17}, say, by using
  7016. these commands:
  7017. @smallexample
  7018. $ @kbd{mt -f /dev/nrtape rewind}
  7019. $ @kbd{mt -f /dev/nrtape fsf 16}
  7020. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7021. @end smallexample
  7022. In all the previous examples, we put aside blocking considerations, but
  7023. you should do the proper things for that as well. @xref{Blocking}.
  7024. @menu
  7025. * Tape Positioning:: Tape Positions and Tape Marks
  7026. * mt:: The @command{mt} Utility
  7027. @end menu
  7028. @node Tape Positioning
  7029. @subsection Tape Positions and Tape Marks
  7030. @UNREVISED
  7031. Just as archives can store more than one file from the file system,
  7032. tapes can store more than one archive file. To keep track of where
  7033. archive files (or any other type of file stored on tape) begin and
  7034. end, tape archive devices write magnetic @dfn{tape marks} on the
  7035. archive media. Tape drives write one tape mark between files,
  7036. two at the end of all the file entries.
  7037. If you think of data as a series of records "rrrr"'s, and tape marks as
  7038. "*"'s, a tape might look like the following:
  7039. @smallexample
  7040. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7041. @end smallexample
  7042. Tape devices read and write tapes using a read/write @dfn{tape
  7043. head}---a physical part of the device which can only access one
  7044. point on the tape at a time. When you use @command{tar} to read or
  7045. write archive data from a tape device, the device will begin reading
  7046. or writing from wherever on the tape the tape head happens to be,
  7047. regardless of which archive or what part of the archive the tape
  7048. head is on. Before writing an archive, you should make sure that no
  7049. data on the tape will be overwritten (unless it is no longer needed).
  7050. Before reading an archive, you should make sure the tape head is at
  7051. the beginning of the archive you want to read. You can do it manually
  7052. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7053. that automatically (@pxref{Scripted Restoration}).
  7054. If you want to add new archive file entries to a tape, you should
  7055. advance the tape to the end of the existing file entries, backspace
  7056. over the last tape mark, and write the new archive file. If you were
  7057. to add two archives to the example above, the tape might look like the
  7058. following:
  7059. @smallexample
  7060. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7061. @end smallexample
  7062. @node mt
  7063. @subsection The @command{mt} Utility
  7064. @UNREVISED
  7065. @FIXME{Is it true that this only works on non-block devices?
  7066. should explain the difference, (fixed or variable).}
  7067. @xref{Blocking Factor}.
  7068. You can use the @command{mt} utility to advance or rewind a tape past a
  7069. specified number of archive files on the tape. This will allow you
  7070. to move to the beginning of an archive before extracting or reading
  7071. it, or to the end of all the archives before writing a new one.
  7072. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7073. together"?}
  7074. The syntax of the @command{mt} command is:
  7075. @smallexample
  7076. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7077. @end smallexample
  7078. where @var{tapename} is the name of the tape device, @var{number} is
  7079. the number of times an operation is performed (with a default of one),
  7080. and @var{operation} is one of the following:
  7081. @FIXME{is there any use for record operations?}
  7082. @table @option
  7083. @item eof
  7084. @itemx weof
  7085. Writes @var{number} tape marks at the current position on the tape.
  7086. @item fsf
  7087. Moves tape position forward @var{number} files.
  7088. @item bsf
  7089. Moves tape position back @var{number} files.
  7090. @item rewind
  7091. Rewinds the tape. (Ignores @var{number}).
  7092. @item offline
  7093. @itemx rewoff1
  7094. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7095. @item status
  7096. Prints status information about the tape unit.
  7097. @end table
  7098. @FIXME{Is there a better way to frob the spacing on the list?}
  7099. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7100. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7101. @file{/dev/rmt12}.
  7102. @command{mt} returns a 0 exit status when the operation(s) were
  7103. successful, 1 if the command was unrecognized, and 2 if an operation
  7104. failed.
  7105. @node Using Multiple Tapes
  7106. @section Using Multiple Tapes
  7107. @UNREVISED
  7108. Often you might want to write a large archive, one larger than will fit
  7109. on the actual tape you are using. In such a case, you can run multiple
  7110. @command{tar} commands, but this can be inconvenient, particularly if you
  7111. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7112. Therefore, @command{tar} supports multiple tapes automatically.
  7113. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7114. then @command{tar} will, when it reaches the end of the tape, prompt
  7115. for another tape, and continue the archive. Each tape will have an
  7116. independent archive, and can be read without needing the other. (As
  7117. an exception to this, the file that @command{tar} was archiving when
  7118. it ran out of tape will usually be split between the two archives; in
  7119. this case you need to extract from the first archive, using
  7120. @option{--multi-volume}, and then put in the second tape when
  7121. prompted, so @command{tar} can restore both halves of the file.)
  7122. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7123. You need @GNUTAR{} at both ends to process them properly.
  7124. When prompting for a new tape, @command{tar} accepts any of the following
  7125. responses:
  7126. @table @kbd
  7127. @item ?
  7128. Request @command{tar} to explain possible responses
  7129. @item q
  7130. Request @command{tar} to exit immediately.
  7131. @item n @var{file name}
  7132. Request @command{tar} to write the next volume on the file @var{file name}.
  7133. @item !
  7134. Request @command{tar} to run a subshell. This option can be disabled
  7135. by giving @option{--restrict} command line option to @command{tar}.
  7136. @item y
  7137. Request @command{tar} to begin writing the next volume.
  7138. @end table
  7139. (You should only type @samp{y} after you have changed the tape;
  7140. otherwise @command{tar} will write over the volume it just finished.)
  7141. @cindex End-of-archive info script
  7142. @cindex Info script
  7143. @anchor{info-script}
  7144. @opindex info-script
  7145. @opindex new-volume-script
  7146. If you want more elaborate behavior than this, give @command{tar} the
  7147. @option{--info-script=@var{script-name}}
  7148. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7149. @var{script-name}}) option. The file @var{script-name} is expected to
  7150. be a program (or shell script) to be run instead of the normal
  7151. prompting procedure. It is executed without any command line
  7152. arguments. Additional data is passed to it via the following
  7153. environment variables:
  7154. @table @env
  7155. @vrindex TAR_VERSION, info script environment variable
  7156. @item TAR_VERSION
  7157. @GNUTAR{} version number.
  7158. @vrindex TAR_ARCHIVE, info script environment variable
  7159. @item TAR_ARCHIVE
  7160. The name of the archive @command{tar} is processing.
  7161. @vrindex TAR_VOLUME, info script environment variable
  7162. @item TAR_VOLUME
  7163. Ordinal number of the volume @command{tar} is about to start.
  7164. @vrindex TAR_SUBCOMMAND, info script environment variable
  7165. @item TAR_SUBCOMMAND
  7166. Short option describing the operation @command{tar} is executed.
  7167. @xref{Operations}, for a complete list of subcommand options.
  7168. @vrindex TAR_FORMAT, info script environment variable
  7169. @item TAR_FORMAT
  7170. Format of the archive being processed. @xref{Formats}, for a complete
  7171. list of archive format names.
  7172. @end table
  7173. The info script can instruct @command{tar} to use new archive name,
  7174. by writing in to file descriptor 3 (see below for an
  7175. example).
  7176. If the info script fails, @command{tar} exits; otherwise, it begins
  7177. writing the next volume.
  7178. The method @command{tar} uses to detect end of tape is not perfect, and
  7179. fails on some operating systems or on some devices. You can use the
  7180. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7181. @command{tar} can't detect the end of the tape itself. This option
  7182. selects @option{--multi-volume} (@option{-M}) automatically. The
  7183. @var{size} argument should then be the usable size of the tape in
  7184. units of 1024 bytes. But for many devices, and floppy disks in
  7185. particular, this option is never required for real, as far as we know.
  7186. @cindex Volume number file
  7187. @cindex volno file
  7188. @anchor{volno-file}
  7189. @opindex volno-file
  7190. The volume number used by @command{tar} in its tape-change prompt
  7191. can be changed; if you give the
  7192. @option{--volno-file=@var{file-of-number}} option, then
  7193. @var{file-of-number} should be an unexisting file to be created, or
  7194. else, a file already containing a decimal number. That number will be
  7195. used as the volume number of the first volume written. When
  7196. @command{tar} is finished, it will rewrite the file with the
  7197. now-current volume number. (This does not change the volume number
  7198. written on a tape label, as per @ref{label}, it @emph{only} affects
  7199. the number used in the prompt.)
  7200. If you want @command{tar} to cycle through a series of files or tape
  7201. drives, there are three approaches to choose from. First of all, you
  7202. can give @command{tar} multiple @option{--file} options. In this case
  7203. the specified files will be used, in sequence, as the successive
  7204. volumes of the archive. Only when the first one in the sequence needs
  7205. to be used again will @command{tar} prompt for a tape change (or run
  7206. the info script). Secondly, you can use the @samp{n} response to the
  7207. tape-change prompt, and, finally, you can use an info script, that
  7208. writes new archive name to file descriptor. The following example
  7209. illustrates this approach:
  7210. @smallexample
  7211. @group
  7212. #! /bin/sh
  7213. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7214. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7215. case $TAR_SUBCOMMAND in
  7216. -c) ;;
  7217. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7218. ;;
  7219. *) exit 1
  7220. esac
  7221. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7222. @end group
  7223. @end smallexample
  7224. Each volume of a multi-volume archive is an independent @command{tar}
  7225. archive, complete in itself. For example, you can list or extract any
  7226. volume alone; just don't specify @option{--multi-volume}
  7227. (@option{-M}). However, if one file in the archive is split across
  7228. volumes, the only way to extract it successfully is with a
  7229. multi-volume extract command @option{--extract --multi-volume}
  7230. (@option{-xM}) starting on or before the volume where the file begins.
  7231. For example, let's presume someone has two tape drives on a system
  7232. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7233. to switch to the second drive when it needs to write the
  7234. second tape, and then back to the first tape, etc., just do either of:
  7235. @smallexample
  7236. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7237. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7238. @end smallexample
  7239. @menu
  7240. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7241. * Tape Files:: Tape Files
  7242. * Tarcat:: Concatenate Volumes into a Single Archive
  7243. @end menu
  7244. @node Multi-Volume Archives
  7245. @subsection Archives Longer than One Tape or Disk
  7246. @cindex Multi-volume archives
  7247. @UNREVISED
  7248. @opindex multi-volume
  7249. To create an archive that is larger than will fit on a single unit of
  7250. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7251. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7252. archive can be manipulated like any other archive (provided the
  7253. @option{--multi-volume} option is specified), but is stored on more
  7254. than one tape or disk.
  7255. When you specify @option{--multi-volume}, @command{tar} does not report an
  7256. error when it comes to the end of an archive volume (when reading), or
  7257. the end of the media (when writing). Instead, it prompts you to load
  7258. a new storage volume. If the archive is on a magnetic tape, you
  7259. should change tapes when you see the prompt; if the archive is on a
  7260. floppy disk, you should change disks; etc.
  7261. You can read each individual volume of a multi-volume archive as if it
  7262. were an archive by itself. For example, to list the contents of one
  7263. volume, use @option{--list}, without @option{--multi-volume} specified.
  7264. To extract an archive member from one volume (assuming it is described
  7265. that volume), use @option{--extract}, again without
  7266. @option{--multi-volume}.
  7267. If an archive member is split across volumes (ie. its entry begins on
  7268. one volume of the media and ends on another), you need to specify
  7269. @option{--multi-volume} to extract it successfully. In this case, you
  7270. should load the volume where the archive member starts, and use
  7271. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7272. volumes as it needs them. @xref{extracting archives}, for more
  7273. information about extracting archives.
  7274. @option{--info-script=@var{script-name}}
  7275. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7276. @var{script-name}}) (@pxref{info-script}) is like
  7277. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7278. not prompt you directly to change media volumes when a volume is
  7279. full---instead, @command{tar} runs commands you have stored in
  7280. @var{script-name}. For example, this option can be used to eject
  7281. cassettes, or to broadcast messages such as @samp{Someone please come
  7282. change my tape} when performing unattended backups. When
  7283. @var{script-name} is done, @command{tar} will assume that the media
  7284. has been changed.
  7285. Multi-volume archives can be modified like any other archive. To add
  7286. files to a multi-volume archive, you need to only mount the last
  7287. volume of the archive media (and new volumes, if needed). For all
  7288. other operations, you need to use the entire archive.
  7289. If a multi-volume archive was labeled using
  7290. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7291. (@pxref{label}) when it was created, @command{tar} will not
  7292. automatically label volumes which are added later. To label
  7293. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7294. in conjunction with the @option{--append}, @option{--update} or
  7295. @option{--concatenate} operation.
  7296. @cindex Labeling multi-volume archives
  7297. @FIXME{example}
  7298. @FIXME{There should be a sample program here, including an exit
  7299. before end. Is the exit status even checked in tar? :-(}
  7300. @table @option
  7301. @item --multi-volume
  7302. @itemx -M
  7303. Creates a multi-volume archive, when used in conjunction with
  7304. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7305. archive, specify @option{--multi-volume} in conjunction with that
  7306. operation.
  7307. @item --info-script=@var{program-file}
  7308. @itemx --new-volume-script=@var{program-file}
  7309. @itemx -F @var{program-file}
  7310. Creates a multi-volume archive via a script. Used in conjunction with
  7311. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7312. @end table
  7313. Beware that there is @emph{no} real standard about the proper way, for
  7314. a @command{tar} archive, to span volume boundaries. If you have a
  7315. multi-volume created by some vendor's @command{tar}, there is almost
  7316. no chance you could read all the volumes with @GNUTAR{}.
  7317. The converse is also true: you may not expect
  7318. multi-volume archives created by @GNUTAR{} to be
  7319. fully recovered by vendor's @command{tar}. Since there is little
  7320. chance that, in mixed system configurations, some vendor's
  7321. @command{tar} will work on another vendor's machine, and there is a
  7322. great chance that @GNUTAR{} will work on most of
  7323. them, your best bet is to install @GNUTAR{} on all
  7324. machines between which you know exchange of files is possible.
  7325. @node Tape Files
  7326. @subsection Tape Files
  7327. @UNREVISED
  7328. To give the archive a name which will be recorded in it, use the
  7329. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7330. option. This will write a special block identifying
  7331. @var{volume-label} as the name of the archive to the front of the
  7332. archive which will be displayed when the archive is listed with
  7333. @option{--list}. If you are creating a multi-volume archive with
  7334. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7335. volume label will have @samp{Volume @var{nnn}} appended to the name
  7336. you give, where @var{nnn} is the number of the volume of the archive.
  7337. (If you use the @option{--label=@var{volume-label}}) option when
  7338. reading an archive, it checks to make sure the label on the tape
  7339. matches the one you give. @xref{label}.
  7340. When @command{tar} writes an archive to tape, it creates a single
  7341. tape file. If multiple archives are written to the same tape, one
  7342. after the other, they each get written as separate tape files. When
  7343. extracting, it is necessary to position the tape at the right place
  7344. before running @command{tar}. To do this, use the @command{mt} command.
  7345. For more information on the @command{mt} command and on the organization
  7346. of tapes into a sequence of tape files, see @ref{mt}.
  7347. People seem to often do:
  7348. @smallexample
  7349. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7350. @end smallexample
  7351. or such, for pushing a common date in all volumes or an archive set.
  7352. @node Tarcat
  7353. @subsection Concatenate Volumes into a Single Archive
  7354. @pindex tarcat
  7355. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7356. archive to a single @command{tar} archive. Simply concatenating all
  7357. volumes into one will not work, since each volume carries an additional
  7358. information at the beginning. @GNUTAR{} is shipped with the shell
  7359. script @command{tarcat} designed for this purpose.
  7360. The script takes a list of files comprising a multi-volume archive
  7361. and creates the resulting archive at the standard output. For example:
  7362. @smallexample
  7363. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7364. @end smallexample
  7365. The script implements a simple heuristics to determine the format of
  7366. the first volume file and to decide how to process the rest of the
  7367. files. However, it makes no attempt to verify whether the files are
  7368. given in order or even if they are valid @command{tar} archives.
  7369. It uses @command{dd} and does not filter its standard error, so you
  7370. will usually see lots of spurious messages.
  7371. @FIXME{The script is not installed. Should we install it?}
  7372. @node label
  7373. @section Including a Label in the Archive
  7374. @cindex Labeling an archive
  7375. @cindex Labels on the archive media
  7376. @UNREVISED
  7377. @opindex label
  7378. To avoid problems caused by misplaced paper labels on the archive
  7379. media, you can include a @dfn{label} entry---an archive member which
  7380. contains the name of the archive---in the archive itself. Use the
  7381. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7382. option in conjunction with the @option{--create} operation to include
  7383. a label entry in the archive as it is being created.
  7384. @table @option
  7385. @item --label=@var{archive-label}
  7386. @itemx -V @var{archive-label}
  7387. Includes an @dfn{archive-label} at the beginning of the archive when
  7388. the archive is being created, when used in conjunction with the
  7389. @option{--create} operation. Checks to make sure the archive label
  7390. matches the one specified (when used in conjunction with any other
  7391. operation.
  7392. @end table
  7393. If you create an archive using both
  7394. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7395. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7396. will have an archive label of the form @samp{@var{archive-label}
  7397. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7398. next, and so on. @xref{Using Multiple Tapes}, for information on
  7399. creating multiple volume archives.
  7400. @cindex Volume label, listing
  7401. @cindex Listing volume label
  7402. The volume label will be displayed by @option{--list} along with
  7403. the file contents. If verbose display is requested, it will also be
  7404. explicitely marked as in the example below:
  7405. @smallexample
  7406. @group
  7407. $ @kbd{tar --verbose --list --file=iamanarchive}
  7408. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7409. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7410. @end group
  7411. @end smallexample
  7412. @opindex test-label
  7413. @anchor{--test-label option}
  7414. However, @option{--list} option will cause listing entire
  7415. contents of the archive, which may be undesirable (for example, if the
  7416. archive is stored on a tape). You can request checking only the volume
  7417. by specifying @option{--test-label} option. This option reads only the
  7418. first block of an archive, so it can be used with slow storage
  7419. devices. For example:
  7420. @smallexample
  7421. @group
  7422. $ @kbd{tar --test-label --file=iamanarchive}
  7423. iamalabel
  7424. @end group
  7425. @end smallexample
  7426. If @option{--test-label} is used with a single command line
  7427. argument, @command{tar} compares the volume label with the
  7428. argument. It exits with code 0 if the two strings match, and with code
  7429. 2 otherwise. In this case no output is displayed. For example:
  7430. @smallexample
  7431. @group
  7432. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7433. @result{} 0
  7434. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7435. @result{} 1
  7436. @end group
  7437. @end smallexample
  7438. If you request any operation, other than @option{--create}, along
  7439. with using @option{--label} option, @command{tar} will first check if
  7440. the archive label matches the one specified and will refuse to proceed
  7441. if it does not. Use this as a safety precaution to avoid accidentally
  7442. overwriting existing archives. For example, if you wish to add files
  7443. to @file{archive}, presumably labelled with string @samp{My volume},
  7444. you will get:
  7445. @smallexample
  7446. @group
  7447. $ @kbd{tar -rf archive --label 'My volume' .}
  7448. tar: Archive not labeled to match `My volume'
  7449. @end group
  7450. @end smallexample
  7451. @noindent
  7452. in case its label does not match. This will work even if
  7453. @file{archive} is not labelled at all.
  7454. Similarly, @command{tar} will refuse to list or extract the
  7455. archive if its label doesn't match the @var{archive-label}
  7456. specified. In those cases, @var{archive-label} argument is interpreted
  7457. as a globbing-style pattern which must match the actual magnetic
  7458. volume label. @xref{exclude}, for a precise description of how match
  7459. is attempted@footnote{Previous versions of @command{tar} used full
  7460. regular expression matching, or before that, only exact string
  7461. matching, instead of wildcard matchers. We decided for the sake of
  7462. simplicity to use a uniform matching device through
  7463. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7464. the volume label matcher will also suffix @var{archive-label} by
  7465. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7466. up. Since the volume numbering is automatically added in labels at
  7467. creation time, it sounded logical to equally help the user taking care
  7468. of it when the archive is being read.
  7469. The @option{--label} was once called @option{--volume}, but is not
  7470. available under that name anymore.
  7471. You can also use @option{--label} to get a common information on
  7472. all tapes of a series. For having this information different in each
  7473. series created through a single script used on a regular basis, just
  7474. manage to get some date string as part of the label. For example:
  7475. @smallexample
  7476. @group
  7477. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7478. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7479. --volume="Daily backup for `date +%Y-%m-%d`"}
  7480. @end group
  7481. @end smallexample
  7482. Also note that each label has its own date and time, which corresponds
  7483. to when @GNUTAR{} initially attempted to write it,
  7484. often soon after the operator launches @command{tar} or types the
  7485. carriage return telling that the next tape is ready. Comparing date
  7486. labels does give an idea of tape throughput only if the delays for
  7487. rewinding tapes and the operator switching them were negligible, which
  7488. is usually not the case.
  7489. @node verify
  7490. @section Verifying Data as It is Stored
  7491. @cindex Verifying a write operation
  7492. @cindex Double-checking a write operation
  7493. @table @option
  7494. @item -W
  7495. @itemx --verify
  7496. @opindex verify, short description
  7497. Attempt to verify the archive after writing.
  7498. @end table
  7499. This option causes @command{tar} to verify the archive after writing it.
  7500. Each volume is checked after it is written, and any discrepancies
  7501. are recorded on the standard error output.
  7502. Verification requires that the archive be on a back-space-able medium.
  7503. This means pipes, some cartridge tape drives, and some other devices
  7504. cannot be verified.
  7505. You can insure the accuracy of an archive by comparing files in the
  7506. system with archive members. @command{tar} can compare an archive to the
  7507. file system as the archive is being written, to verify a write
  7508. operation, or can compare a previously written archive, to insure that
  7509. it is up to date.
  7510. @opindex verify, using with @option{--create}
  7511. @opindex create, using with @option{--verify}
  7512. To check for discrepancies in an archive immediately after it is
  7513. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7514. the @option{--create} operation. When this option is
  7515. specified, @command{tar} checks archive members against their counterparts
  7516. in the file system, and reports discrepancies on the standard error.
  7517. To verify an archive, you must be able to read it from before the end
  7518. of the last written entry. This option is useful for detecting data
  7519. errors on some tapes. Archives written to pipes, some cartridge tape
  7520. drives, and some other devices cannot be verified.
  7521. One can explicitly compare an already made archive with the file
  7522. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7523. option, instead of using the more automatic @option{--verify} option.
  7524. @xref{compare}.
  7525. Note that these two options have a slightly different intent. The
  7526. @option{--compare} option checks how identical are the logical contents of some
  7527. archive with what is on your disks, while the @option{--verify} option is
  7528. really for checking if the physical contents agree and if the recording
  7529. media itself is of dependable quality. So, for the @option{--verify}
  7530. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7531. the archive, while it lets the speed optimization undisturbed for the
  7532. @option{--compare} option. If you nevertheless use @option{--compare} for
  7533. media verification, you may have to defeat the in-memory cache yourself,
  7534. maybe by opening and reclosing the door latch of your recording unit,
  7535. forcing some doubt in your operating system about the fact this is really
  7536. the same volume as the one just written or read.
  7537. The @option{--verify} option would not be necessary if drivers were indeed
  7538. able to detect dependably all write failures. This sometimes require many
  7539. magnetic heads, some able to read after the writes occurred. One would
  7540. not say that drivers unable to detect all cases are necessarily flawed,
  7541. as long as programming is concerned.
  7542. The @option{--verify} (@option{-W}) option will not work in
  7543. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7544. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7545. and @option{--delete} operations. @xref{Operations}, for more
  7546. information on these operations.
  7547. Also, since @command{tar} normally strips leading @samp{/} from file
  7548. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7549. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7550. @file{/}, as @command{tar} uses the archive's relative member names
  7551. (e.g., @file{etc/motd}) when verifying the archive.
  7552. @node Write Protection
  7553. @section Write Protection
  7554. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7555. be @dfn{write protected}, to protect data on them from being changed.
  7556. Once an archive is written, you should write protect the media to prevent
  7557. the archive from being accidentally overwritten or deleted. (This will
  7558. protect the archive from being changed with a tape or floppy drive---it
  7559. will not protect it from magnet fields or other physical hazards).
  7560. The write protection device itself is usually an integral part of the
  7561. physical media, and can be a two position (write enabled/write
  7562. disabled) switch, a notch which can be popped out or covered, a ring
  7563. which can be removed from the center of a tape reel, or some other
  7564. changeable feature.
  7565. @node Changes
  7566. @appendix Changes
  7567. This appendix lists some important user-visible changes between
  7568. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  7569. version of this document is available at
  7570. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  7571. @GNUTAR{} documentation page}.
  7572. @table @asis
  7573. @item Use of short option @option{-o}.
  7574. Earlier versions of @GNUTAR{} understood @option{-o} command line
  7575. option as a synonym for @option{--old-archive}.
  7576. @GNUTAR{} starting from version 1.13.90 understands this option as
  7577. a synonym for @option{--no-same-owner}. This is compatible with
  7578. UNIX98 @command{tar} implementations.
  7579. However, to facilitate transition, @option{-o} option retains its
  7580. old semantics when it is used with one of archive-creation commands.
  7581. Users are encouraged to use @option{--format=oldgnu} instead.
  7582. It is especially important, since versions of @acronym{GNU} Automake
  7583. up to and including 1.8.4 invoke tar with this option to produce
  7584. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  7585. of this issue and its implications.
  7586. Future versions of @GNUTAR{} will understand @option{-o} only as a
  7587. synonym for @option{--no-same-owner}.
  7588. @item Use of short option @option{-l}
  7589. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  7590. synonym for @option{--one-file-system}. Such usage is deprecated.
  7591. For compatibility with other implementations future versions of
  7592. @GNUTAR{} will understand this option as a synonym for
  7593. @option{--check-links}.
  7594. @item Use of options @option{--portability} and @option{--old-archive}
  7595. These options are deprecated. Please use @option{--format=v7} instead.
  7596. @item Use of option @option{--posix}
  7597. This option is deprecated. Please use @option{--format=posix} instead.
  7598. @end table
  7599. @node Genfile
  7600. @appendix Genfile
  7601. @include genfile.texi
  7602. @node Snapshot Files
  7603. @appendix Format of the Incremental Snapshot Files
  7604. @include snapshot.texi
  7605. @node Free Software Needs Free Documentation
  7606. @appendix Free Software Needs Free Documentation
  7607. @include freemanuals.texi
  7608. @node Copying This Manual
  7609. @appendix Copying This Manual
  7610. @menu
  7611. * GNU Free Documentation License:: License for copying this manual
  7612. @end menu
  7613. @include fdl.texi
  7614. @node Index of Command Line Options
  7615. @appendix Index of Command Line Options
  7616. This appendix contains an index of all @GNUTAR{} long command line
  7617. options. The options are listed without the preceeding double-dash.
  7618. @FIXME{@itemize
  7619. @item Make sure @emph{all} options are indexed.
  7620. @item Provide an index of short options
  7621. @end itemize}
  7622. @printindex op
  7623. @node Index
  7624. @appendix Index
  7625. @printindex cp
  7626. @summarycontents
  7627. @contents
  7628. @bye
  7629. @c Local variables:
  7630. @c texinfo-column-for-description: 32
  7631. @c End: