tar.texi 352 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c ======================================================================
  11. @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
  12. @c as decided by @set symbols. The PUBLISH rendition does not show
  13. @c notes or marks asking for revision. Most users will prefer having more
  14. @c information, even if this information is not fully revised for adequacy,
  15. @c so DISTRIB is the default for tar distributions. The PROOF rendition
  16. @c show all marks to the point of ugliness, but is nevertheless useful to
  17. @c those working on the manual itself.
  18. @c ======================================================================
  19. @ifclear PUBLISH
  20. @ifclear DISTRIB
  21. @ifclear PROOF
  22. @set DISTRIB
  23. @end ifclear
  24. @end ifclear
  25. @end ifclear
  26. @ifset PUBLISH
  27. @set RENDITION The book, version
  28. @end ifset
  29. @ifset DISTRIB
  30. @set RENDITION FTP release, version
  31. @end ifset
  32. @ifset PROOF
  33. @set RENDITION Proof reading version
  34. @end ifset
  35. @c ---------------------------------------------------------------------
  36. @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
  37. @c plan. These annotations are somewhat precious to him; he asks that I
  38. @c do not alter them inconsiderately. Much work is needed for GNU tar
  39. @c internals (the sources, the programs themselves). Revising the
  40. @c adequacy of the manual while revising the sources, and cleaning them
  41. @c both at the same time, is a good way to proceed.
  42. @c ---------------------------------------------------------------------
  43. @c Output marks for nodes needing revision, but not in PUBLISH rendition.
  44. @macro UNREVISED
  45. @ifclear PUBLISH
  46. @quotation
  47. @emph{(This message will disappear, once this node revised.)}
  48. @end quotation
  49. @end ifclear
  50. @end macro
  51. @c Output various FIXME information only in PROOF rendition.
  52. @macro FIXME{string}
  53. @allow-recursion
  54. @quote-arg
  55. @ifset PROOF
  56. @strong{<FIXME>} \string\ @strong{</>}
  57. @end ifset
  58. @end macro
  59. @macro FIXME-ref{string}
  60. @quote-arg
  61. @ifset PROOF
  62. @strong{<REF>} \string\ @strong{</>}
  63. @end ifset
  64. @end macro
  65. @macro FIXME-pxref{string}
  66. @quote-arg
  67. @ifset PROOF
  68. @strong{<PXREF>} \string\ @strong{</>}
  69. @end ifset
  70. @end macro
  71. @macro FIXME-xref{string}
  72. @quote-arg
  73. @ifset PROOF
  74. @strong{<XREF>} \string\ @strong{</>}
  75. @end ifset
  76. @end macro
  77. @c @macro option{entry}
  78. @c @quote-arg
  79. @c @opindex{--\entry\}
  80. @c @value{\entry\}
  81. @c @end macro
  82. @macro GNUTAR
  83. @acronym{GNU} @command{tar}
  84. @end macro
  85. @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
  86. @set ref-absolute-names @ref{absolute}
  87. @set xref-absolute-names @xref{absolute}
  88. @set pxref-absolute-names @pxref{absolute}
  89. @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
  90. @set ref-after-date @ref{after}
  91. @set xref-after-date @xref{after}
  92. @set pxref-after-date @pxref{after}
  93. @set op-append @kbd{--append} (@kbd{-r})
  94. @set ref-append @ref{add}
  95. @set xref-append @xref{add}
  96. @set pxref-append @pxref{add}
  97. @set op-atime-preserve @kbd{--atime-preserve}
  98. @set ref-atime-preserve @ref{Attributes}
  99. @set xref-atime-preserve @xref{Attributes}
  100. @set pxref-atime-preserve @pxref{Attributes}
  101. @set op-backup @kbd{--backup}
  102. @set ref-backup @ref{Backup options}
  103. @set xref-backup @xref{Backup options}
  104. @set pxref-backup @pxref{Backup options}
  105. @set op-block-number @kbd{--block-number} (@kbd{-R})
  106. @set ref-block-number @ref{verbose}
  107. @set xref-block-number @xref{verbose}
  108. @set pxref-block-number @pxref{verbose}
  109. @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
  110. @set ref-blocking-factor @ref{Blocking Factor}
  111. @set xref-blocking-factor @xref{Blocking Factor}
  112. @set pxref-blocking-factor @pxref{Blocking Factor}
  113. @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
  114. @set ref-bzip2 @ref{gzip}
  115. @set xref-bzip2 @xref{gzip}
  116. @set pxref-bzip2 @pxref{gzip}
  117. @set op-check-links @kbd{--check-links} (@kbd{-l})
  118. @set ref-check-links @ref{--check-links}
  119. @set xref-check-links @xref{--check-links}
  120. @set pxref-check-links @pxref{--check-links}
  121. @set op-checkpoint @kbd{--checkpoint}
  122. @set ref-checkpoint @ref{verbose}
  123. @set xref-checkpoint @xref{verbose}
  124. @set pxref-checkpoint @pxref{verbose}
  125. @set op-check-links @kbd{--check-links}
  126. @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
  127. @set ref-compare @ref{compare}
  128. @set xref-compare @xref{compare}
  129. @set pxref-compare @pxref{compare}
  130. @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
  131. @set ref-compress @ref{gzip}
  132. @set xref-compress @xref{gzip}
  133. @set pxref-compress @pxref{gzip}
  134. @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
  135. @set ref-concatenate @ref{concatenate}
  136. @set xref-concatenate @xref{concatenate}
  137. @set pxref-concatenate @pxref{concatenate}
  138. @set op-create @kbd{--create} (@kbd{-c})
  139. @set ref-create @ref{create}
  140. @set xref-create @xref{create}
  141. @set pxref-create @pxref{create}
  142. @set op-delete @kbd{--delete}
  143. @set ref-delete @ref{delete}
  144. @set xref-delete @xref{delete}
  145. @set pxref-delete @pxref{delete}
  146. @set op-dereference @kbd{--dereference} (@kbd{-h})
  147. @set ref-dereference @ref{dereference}
  148. @set xref-dereference @xref{dereference}
  149. @set pxref-dereference @pxref{dereference}
  150. @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
  151. @set ref-directory @ref{directory}
  152. @set xref-directory @xref{directory}
  153. @set pxref-directory @pxref{directory}
  154. @set op-exclude @kbd{--exclude=@var{pattern}}
  155. @set ref-exclude @ref{exclude}
  156. @set xref-exclude @xref{exclude}
  157. @set pxref-exclude @pxref{exclude}
  158. @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
  159. @set ref-exclude-from @ref{exclude}
  160. @set xref-exclude-from @xref{exclude}
  161. @set pxref-exclude-from @pxref{exclude}
  162. @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
  163. @set ref-extract @ref{extract}
  164. @set xref-extract @xref{extract}
  165. @set pxref-extract @pxref{extract}
  166. @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
  167. @set ref-file @ref{file}
  168. @set xref-file @xref{file}
  169. @set pxref-file @pxref{file}
  170. @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
  171. @set ref-files-from @ref{files}
  172. @set xref-files-from @xref{files}
  173. @set pxref-files-from @pxref{files}
  174. @set op-force-local @kbd{--force-local}
  175. @set ref-force-local @ref{file}
  176. @set xref-force-local @xref{file}
  177. @set pxref-force-local @pxref{file}
  178. @set op-group @kbd{--group=@var{group}}
  179. @set ref-group @ref{Option Summary}
  180. @set xref-group @xref{Option Summary}
  181. @set pxref-group @pxref{Option Summary}
  182. @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
  183. @set ref-gzip @ref{gzip}
  184. @set xref-gzip @xref{gzip}
  185. @set pxref-gzip @pxref{gzip}
  186. @set op-help @kbd{--help}
  187. @set ref-help @ref{help}
  188. @set xref-help @xref{help}
  189. @set pxref-help @pxref{help}
  190. @set op-ignore-failed-read @kbd{--ignore-failed-read}
  191. @set ref-ignore-failed-read @ref{create options}
  192. @set xref-ignore-failed-read @xref{create options}
  193. @set pxref-ignore-failed-read @pxref{create options}
  194. @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
  195. @set ref-ignore-zeros @ref{Reading}
  196. @set xref-ignore-zeros @xref{Reading}
  197. @set pxref-ignore-zeros @pxref{Reading}
  198. @set op-incremental @kbd{--incremental} (@kbd{-G})
  199. @set ref-incremental @ref{Inc Dumps}
  200. @set xref-incremental @xref{Inc Dumps}
  201. @set pxref-incremental @pxref{Inc Dumps}
  202. @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
  203. @set ref-info-script @ref{Multi-Volume Archives}
  204. @set xref-info-script @xref{Multi-Volume Archives}
  205. @set pxref-info-script @pxref{Multi-Volume Archives}
  206. @set op-interactive @kbd{--interactive} (@kbd{-w})
  207. @set ref-interactive @ref{interactive}
  208. @set xref-interactive @xref{interactive}
  209. @set pxref-interactive @pxref{interactive}
  210. @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
  211. @set ref-keep-old-files @ref{Keep Old Files}
  212. @set xref-keep-old-files @xref{Keep Old Files}
  213. @set pxref-keep-old-files @pxref{Keep Old Files}
  214. @set op-keep-newer-files @kbd{--keep-old-files}
  215. @set ref-keep-newer-files @ref{Keep Newer Files}
  216. @set xref-keep-newer-files @xref{Keep Newer Files}
  217. @set pxref-keep-newer-files @pxref{Keep Newer Files}
  218. @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
  219. @set ref-label @ref{label}
  220. @set xref-label @xref{label}
  221. @set pxref-label @pxref{label}
  222. @set op-list @kbd{--list} (@kbd{-t})
  223. @set ref-list @ref{list}
  224. @set xref-list @xref{list}
  225. @set pxref-list @pxref{list}
  226. @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
  227. @set ref-listed-incremental @ref{Inc Dumps}
  228. @set xref-listed-incremental @xref{Inc Dumps}
  229. @set pxref-listed-incremental @pxref{Inc Dumps}
  230. @set op-mode @kbd{--mode=@var{permissions}}
  231. @set ref-mode @ref{Option Summary}
  232. @set xref-mode @xref{Option Summary}
  233. @set pxref-mode @pxref{Option Summary}
  234. @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
  235. @set ref-multi-volume @ref{Multi-Volume Archives}
  236. @set xref-multi-volume @xref{Multi-Volume Archives}
  237. @set pxref-multi-volume @pxref{Multi-Volume Archives}
  238. @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
  239. @set ref-newer-mtime @ref{after}
  240. @set xref-newer-mtime @xref{after}
  241. @set pxref-newer-mtime @pxref{after}
  242. @set op-no-recursion @kbd{--no-recursion}
  243. @set ref-no-recursion @ref{recurse}
  244. @set xref-no-recursion @xref{recurse}
  245. @set pxref-no-recursion @pxref{recurse}
  246. @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
  247. @set ref-no-same-owner @ref{Attributes}
  248. @set xref-no-same-owner @xref{Attributes}
  249. @set pxref-no-same-owner @pxref{Attributes}
  250. @set op-no-same-permissions @kbd{--no-same-permissions}
  251. @set ref-no-same-permissions @ref{Attributes}
  252. @set xref-no-same-permissions @xref{Attributes}
  253. @set pxref-no-same-permissions @pxref{Attributes}
  254. @set op-null @kbd{--null}
  255. @set ref-null @ref{files}
  256. @set xref-null @xref{files}
  257. @set pxref-null @pxref{files}
  258. @set op-numeric-owner @kbd{--numeric-owner}
  259. @set ref-numeric-owner @ref{Attributes}
  260. @set xref-numeric-owner @xref{Attributes}
  261. @set pxref-numeric-owner @pxref{Attributes}
  262. @set op-occurrence @kbd{--occurrence}
  263. @set ref-occurrence @ref{--occurrence}
  264. @set xref-occurrence @xref{--occurrence}
  265. @set pxref-occurrence @pxref{--occurrence}
  266. @set op-old-archive @kbd{--old-archive} (@kbd{-o})
  267. @set ref-old-archive @ref{old}
  268. @set xref-old-archive @xref{old}
  269. @set pxref-old-archive @pxref{old}
  270. @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
  271. @set ref-one-file-system @ref{one}
  272. @set xref-one-file-system @xref{one}
  273. @set pxref-one-file-system @pxref{one}
  274. @set op-overwrite @kbd{--overwrite}
  275. @set ref-overwrite @ref{Overwrite Old Files}
  276. @set xref-overwrite @xref{Overwrite Old Files}
  277. @set pxref-overwrite @pxref{Overwrite Old Files}
  278. @set op-owner @kbd{--owner=@var{user}}
  279. @set ref-owner @ref{Option Summary}
  280. @set xref-owner @xref{Option Summary}
  281. @set pxref-owner @pxref{Option Summary}
  282. @set op-format @kbd{--format} (@kbd{-H})
  283. @set ref-format @ref{format}
  284. @set xref-format @xref{format}
  285. @set pxref-format @pxref{format}
  286. @set op-format-v7 @kbd{--format=v7}
  287. @set op-format-gnu @kbd{--format=gnu}
  288. @set op-format-oldgnu @kbd{--format=oldgnu}
  289. @set op-format-posix @kbd{--format=posix}
  290. @set op-format-ustar @kbd{--format=ustar}
  291. @set op-posix @kbd{--posix}
  292. @set ref-posix @ref{posix}
  293. @set xref-posix @xref{posix}
  294. @set pxref-posix @pxref{posix}
  295. @set op-preserve @kbd{--preserve}
  296. @set ref-preserve @ref{Attributes}
  297. @set xref-preserve @xref{Attributes}
  298. @set pxref-preserve @pxref{Attributes}
  299. @set op-record-size @kbd{--record-size=@var{size}}
  300. @set ref-record-size @ref{Blocking}
  301. @set xref-record-size @xref{Blocking}
  302. @set pxref-record-size @pxref{Blocking}
  303. @set op-recursive-unlink @kbd{--recursive-unlink}
  304. @set ref-recursive-unlink @ref{Writing}
  305. @set xref-recursive-unlink @xref{Writing}
  306. @set pxref-recursive-unlink @pxref{Writing}
  307. @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
  308. @set ref-read-full-records @ref{Blocking}
  309. @set xref-read-full-records @xref{Blocking}
  310. @set pxref-read-full-records @pxref{Blocking}
  311. @c FIXME: or should it be Reading, or Blocking Factor
  312. @set op-remove-files @kbd{--remove-files}
  313. @set ref-remove-files @ref{Writing}
  314. @set xref-remove-files @xref{Writing}
  315. @set pxref-remove-files @pxref{Writing}
  316. @set op-rmt-command @kbd{rmt-command=@var{command}}
  317. @set op-rsh-command @kbd{rsh-command=@var{command}}
  318. @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
  319. @set ref-same-order @ref{Scarce}
  320. @set xref-same-order @xref{Scarce}
  321. @set pxref-same-order @pxref{Scarce}
  322. @c FIXME: or should it be Reading, or Attributes?
  323. @set op-same-owner @kbd{--same-owner}
  324. @set ref-same-owner @ref{Attributes}
  325. @set xref-same-owner @xref{Attributes}
  326. @set pxref-same-owner @pxref{Attributes}
  327. @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
  328. @set ref-same-permissions @ref{Attributes}
  329. @set xref-same-permissions @xref{Attributes}
  330. @set pxref-same-permissions @pxref{Attributes}
  331. @c FIXME: or should it be Writing?
  332. @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
  333. @set ref-show-omitted-dirs @ref{verbose}
  334. @set xref-show-omitted-dirs @xref{verbose}
  335. @set pxref-show-omitted-dirs @pxref{verbose}
  336. @set op-sparse @kbd{--sparse} (@kbd{-S})
  337. @set ref-sparse @ref{sparse}
  338. @set xref-sparse @xref{sparse}
  339. @set pxref-sparse @pxref{sparse}
  340. @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
  341. @set ref-starting-file @ref{Scarce}
  342. @set xref-starting-file @xref{Scarce}
  343. @set pxref-starting-file @pxref{Scarce}
  344. @set op-strip-components @kbd{--strip-components}
  345. @set ref-strip-components @ref{--strip-components}
  346. @set xref-strip-components @xref{--strip-components}
  347. @set pxref-strip-components @pxref{--strip-components}
  348. @set op-suffix @kbd{--suffix=@var{suffix}}
  349. @set ref-suffix @ref{Backup options}
  350. @set xref-suffix @xref{Backup options}
  351. @set pxref-suffix @pxref{Backup options}
  352. @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
  353. @set ref-tape-length @ref{Using Multiple Tapes}
  354. @set xref-tape-length @xref{Using Multiple Tapes}
  355. @set pxref-tape-length @pxref{Using Multiple Tapes}
  356. @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
  357. @set ref-to-stdout @ref{Writing}
  358. @set xref-to-stdout @xref{Writing}
  359. @set pxref-to-stdout @pxref{Writing}
  360. @set op-totals @kbd{--totals}
  361. @set ref-totals @ref{verbose}
  362. @set xref-totals @xref{verbose}
  363. @set pxref-totals @pxref{verbose}
  364. @set op-touch @kbd{--touch} (@kbd{-m})
  365. @set ref-touch @ref{Writing}
  366. @set xref-touch @xref{Writing}
  367. @set pxref-touch @pxref{Writing}
  368. @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
  369. @set ref-unlink-first @ref{Writing}
  370. @set xref-unlink-first @xref{Writing}
  371. @set pxref-unlink-first @pxref{Writing}
  372. @set op-update @kbd{--update} (@kbd{-u})
  373. @set ref-update @ref{update}
  374. @set xref-update @xref{update}
  375. @set pxref-update @pxref{update}
  376. @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
  377. @set ref-use-compress-prog @ref{gzip}
  378. @set xref-use-compress-prog @xref{gzip}
  379. @set pxref-use-compress-prog @pxref{gzip}
  380. @set op-verbose @kbd{--verbose} (@kbd{-v})
  381. @set ref-verbose @ref{verbose}
  382. @set xref-verbose @xref{verbose}
  383. @set pxref-verbose @pxref{verbose}
  384. @set op-verify @kbd{--verify} (@kbd{-W})
  385. @set ref-verify @ref{verify}
  386. @set xref-verify @xref{verify}
  387. @set pxref-verify @pxref{verify}
  388. @set op-version @kbd{--version}
  389. @set ref-version @ref{help}
  390. @set xref-version @xref{help}
  391. @set pxref-version @pxref{help}
  392. @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
  393. @set ref-volno-file @ref{Using Multiple Tapes}
  394. @set xref-volno-file @xref{Using Multiple Tapes}
  395. @set pxref-volno-file @pxref{Using Multiple Tapes}
  396. @c Put everything in one index (arbitrarily chosen to be the concept index).
  397. @syncodeindex fn cp
  398. @syncodeindex ky cp
  399. @syncodeindex pg cp
  400. @syncodeindex vr cp
  401. @defindex op
  402. @syncodeindex op cp
  403. @copying
  404. This manual is for @acronym{GNU} @command{tar} (version
  405. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  406. from archives.
  407. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  408. 2003, 2004 Free Software Foundation, Inc.
  409. @quotation
  410. Permission is granted to copy, distribute and/or modify this document
  411. under the terms of the GNU Free Documentation License, Version 1.1 or
  412. any later version published by the Free Software Foundation; with the
  413. Invariant Sections being "GNU General Public License", with the
  414. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  415. as in (a) below. A copy of the license is included in the section
  416. entitled "GNU Free Documentation License".
  417. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  418. this GNU Manual. Buying copies from GNU Press supports the FSF in
  419. developing GNU and promoting software freedom.''
  420. @end quotation
  421. @end copying
  422. @dircategory Archiving
  423. @direntry
  424. * Tar: (tar). Making tape (or disk) archives.
  425. @end direntry
  426. @dircategory Individual utilities
  427. @direntry
  428. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  429. @end direntry
  430. @shorttitlepage @acronym{GNU} @command{tar}
  431. @titlepage
  432. @title @acronym{GNU} tar: an archiver tool
  433. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  434. @author Melissa Weisshaus, Jay Fenlason,
  435. @author Thomas Bushnell, n/BSG, Amy Gorin
  436. @c he said to remove it: Fran@,{c}ois Pinard
  437. @c i'm thinking about how the author page *should* look. -mew 2may96
  438. @page
  439. @vskip 0pt plus 1filll
  440. @insertcopying
  441. @end titlepage
  442. @ifnottex
  443. @node Top
  444. @top @acronym{GNU} tar: an archiver tool
  445. @insertcopying
  446. @cindex file archival
  447. @cindex archiving files
  448. The first part of this master menu lists the major nodes in this Info
  449. document. The rest of the menu lists all the lower level nodes.
  450. @end ifnottex
  451. @c The master menu, created with texinfo-master-menu, goes here.
  452. @c (However, getdate.texi's menu is interpolated by hand.)
  453. @menu
  454. * Introduction::
  455. * Tutorial::
  456. * tar invocation::
  457. * operations::
  458. * Backups::
  459. * Choosing::
  460. * Date input formats::
  461. * Formats::
  462. * Media::
  463. * Free Software Needs Free Documentation::
  464. * Copying This Manual::
  465. * Index::
  466. @detailmenu
  467. --- The Detailed Node Listing ---
  468. Introduction
  469. * Book Contents:: What this Book Contains
  470. * Definitions:: Some Definitions
  471. * What tar Does:: What @command{tar} Does
  472. * Naming tar Archives:: How @command{tar} Archives are Named
  473. * Current status:: Current development status of @GNUTAR{}
  474. * Authors:: @GNUTAR{} Authors
  475. * Reports:: Reporting bugs or suggestions
  476. Tutorial Introduction to @command{tar}
  477. * assumptions::
  478. * stylistic conventions::
  479. * basic tar options:: Basic @command{tar} Operations and Options
  480. * frequent operations::
  481. * Two Frequent Options::
  482. * create:: How to Create Archives
  483. * list:: How to List Archives
  484. * extract:: How to Extract Members from an Archive
  485. * going further::
  486. Two Frequently Used Options
  487. * file tutorial::
  488. * verbose tutorial::
  489. * help tutorial::
  490. How to Create Archives
  491. * prepare for examples::
  492. * Creating the archive::
  493. * create verbose::
  494. * short create::
  495. * create dir::
  496. How to List Archives
  497. * list dir::
  498. How to Extract Members from an Archive
  499. * extracting archives::
  500. * extracting files::
  501. * extract dir::
  502. * failing commands::
  503. Invoking @GNUTAR{}
  504. * Synopsis::
  505. * using tar options::
  506. * Styles::
  507. * All Options::
  508. * help::
  509. * verbose::
  510. * interactive::
  511. The Three Option Styles
  512. * Mnemonic Options:: Mnemonic Option Style
  513. * Short Options:: Short Option Style
  514. * Old Options:: Old Option Style
  515. * Mixing:: Mixing Option Styles
  516. All @command{tar} Options
  517. * Operation Summary::
  518. * Option Summary::
  519. * Short Option Summary::
  520. @GNUTAR{} Operations
  521. * Basic tar::
  522. * Advanced tar::
  523. * create options::
  524. * extract options::
  525. * backup::
  526. * Applications::
  527. * looking ahead::
  528. Advanced @GNUTAR{} Operations
  529. * Operations::
  530. * append::
  531. * update::
  532. * concatenate::
  533. * delete::
  534. * compare::
  535. How to Add Files to Existing Archives: @code{--append}
  536. * appending files:: Appending Files to an Archive
  537. * multiple::
  538. Updating an Archive
  539. * how to update::
  540. Options Used by @code{--create}
  541. * Ignore Failed Read::
  542. Options Used by @code{--extract}
  543. * Reading:: Options to Help Read Archives
  544. * Writing:: Changing How @command{tar} Writes Files
  545. * Scarce:: Coping with Scarce Resources
  546. Options to Help Read Archives
  547. * read full records::
  548. * Ignore Zeros::
  549. Changing How @command{tar} Writes Files
  550. * Dealing with Old Files::
  551. * Overwrite Old Files::
  552. * Keep Old Files::
  553. * Keep Newer Files::
  554. * Unlink First::
  555. * Recursive Unlink::
  556. * Modification Times::
  557. * Setting Access Permissions::
  558. * Writing to Standard Output::
  559. * remove files::
  560. Coping with Scarce Resources
  561. * Starting File::
  562. * Same Order::
  563. Performing Backups and Restoring Files
  564. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  565. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  566. * incremental and listed-incremental:: The Incremental Options
  567. * Backup Levels:: Levels of Backups
  568. * Backup Parameters:: Setting Parameters for Backups and Restoration
  569. * Scripted Backups:: Using the Backup Scripts
  570. * Scripted Restoration:: Using the Restore Script
  571. Setting Parameters for Backups and Restoration
  572. * General-Purpose Variables::
  573. * Magnetic Tape Control::
  574. * User Hooks::
  575. * backup-specs example:: An Example Text of @file{Backup-specs}
  576. Choosing Files and Names for @command{tar}
  577. * file:: Choosing the Archive's Name
  578. * Selecting Archive Members::
  579. * files:: Reading Names from a File
  580. * exclude:: Excluding Some Files
  581. * Wildcards::
  582. * after:: Operating Only on New Files
  583. * recurse:: Descending into Directories
  584. * one:: Crossing Filesystem Boundaries
  585. Reading Names from a File
  586. * nul::
  587. Excluding Some Files
  588. * controlling pattern-patching with exclude::
  589. * problems with exclude::
  590. Crossing Filesystem Boundaries
  591. * directory:: Changing Directory
  592. * absolute:: Absolute File Names
  593. Date input formats
  594. * General date syntax:: Common rules.
  595. * Calendar date items:: 19 Dec 1994.
  596. * Time of day items:: 9:20pm.
  597. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  598. * Day of week items:: Monday and others.
  599. * Relative items in date strings:: next tuesday, 2 years ago.
  600. * Pure numbers in date strings:: 19931219, 1440.
  601. * Seconds since the Epoch:: @@1078100502.
  602. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  603. Controlling the Archive Format
  604. * Portability:: Making @command{tar} Archives More Portable
  605. * Compression:: Using Less Space through Compression
  606. * Attributes:: Handling File Attributes
  607. * Standard:: The Standard Format
  608. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  609. * cpio:: Comparison of @command{tar} and @command{cpio}
  610. Making @command{tar} Archives More Portable
  611. * Portable Names:: Portable Names
  612. * dereference:: Symbolic Links
  613. * old:: Old V7 Archives
  614. * posix:: @acronym{POSIX} archives
  615. * Checksumming:: Checksumming Problems
  616. * Large or Negative Values:: Large files, negative time stamps, etc.
  617. Using Less Space through Compression
  618. * gzip:: Creating and Reading Compressed Archives
  619. * sparse:: Archiving Sparse Files
  620. Tapes and Other Archive Media
  621. * Device:: Device selection and switching
  622. * Remote Tape Server::
  623. * Common Problems and Solutions::
  624. * Blocking:: Blocking
  625. * Many:: Many archives on one tape
  626. * Using Multiple Tapes:: Using Multiple Tapes
  627. * label:: Including a Label in the Archive
  628. * verify::
  629. * Write Protection::
  630. Blocking
  631. * Format Variations:: Format Variations
  632. * Blocking Factor:: The Blocking Factor of an Archive
  633. Many Archives on One Tape
  634. * Tape Positioning:: Tape Positions and Tape Marks
  635. * mt:: The @command{mt} Utility
  636. Using Multiple Tapes
  637. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  638. * Tape Files:: Tape Files
  639. Copying This Manual
  640. * GNU Free Documentation License:: License for copying this manual
  641. @end detailmenu
  642. @end menu
  643. @node Introduction
  644. @chapter Introduction
  645. @GNUTAR{} creates
  646. and manipulates @dfn{archives} which are actually collections of
  647. many other files; the program provides users with an organized and
  648. systematic method for controlling a large amount of data.
  649. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  650. archives need not (and these days, typically do not) reside on tapes.
  651. @menu
  652. * Book Contents:: What this Book Contains
  653. * Definitions:: Some Definitions
  654. * What tar Does:: What @command{tar} Does
  655. * Naming tar Archives:: How @command{tar} Archives are Named
  656. * Current status:: Current development status of @GNUTAR{}
  657. * Authors:: @GNUTAR{} Authors
  658. * Reports:: Reporting bugs or suggestions
  659. @end menu
  660. @node Book Contents
  661. @section What this Book Contains
  662. The first part of this chapter introduces you to various terms that will
  663. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  664. and its documentation, and where you should send bug reports
  665. or comments.
  666. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  667. gentle introduction for people who are new to using @command{tar}. It is
  668. meant to be self contained, not requiring any reading from subsequent
  669. chapters to make sense. It moves from topic to topic in a logical,
  670. progressive order, building on information already explained.
  671. Although the tutorial is paced and structured to allow beginners to
  672. learn how to use @command{tar}, it is not intended solely for beginners.
  673. The tutorial explains how to use the three most frequently used
  674. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  675. two frequently used options (@samp{file} and @samp{verbose}). The other
  676. chapters do not refer to the tutorial frequently; however, if a section
  677. discusses something which is a complex variant of a basic concept, there
  678. may be a cross reference to that basic concept. (The entire book,
  679. including the tutorial, assumes that the reader understands some basic
  680. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  681. The third chapter presents the remaining five operations, and
  682. information about using @command{tar} options and option syntax.
  683. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  684. than the reality. should think about whether this makes sense to say
  685. here, or not.} The other chapters are meant to be used as a
  686. reference. Each chapter presents everything that needs to be said
  687. about a specific topic.
  688. One of the chapters (@pxref{Date input formats}) exists in its
  689. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  690. In addition, one section of this manual (@pxref{Standard}) contains a
  691. big quote which is taken directly from @command{tar} sources.
  692. In general, we give both long and short (abbreviated) option names
  693. at least once in each section where the relevant option is covered, so
  694. that novice readers will become familiar with both styles. (A few
  695. options have no short versions, and the relevant sections will
  696. indicate this.)
  697. @node Definitions
  698. @section Some Definitions
  699. @cindex archive
  700. @cindex tar archive
  701. The @command{tar} program is used to create and manipulate @command{tar}
  702. archives. An @dfn{archive} is a single file which contains the contents
  703. of many files, while still identifying the names of the files, their
  704. owner(s), and so forth. (In addition, archives record access
  705. permissions, user and group, size in bytes, and last modification time.
  706. Some archives also record the file names in each archived directory, as
  707. well as other file and directory information.) You can use @command{tar}
  708. to @dfn{create} a new archive in a specified directory.
  709. @cindex member
  710. @cindex archive member
  711. @cindex file name
  712. @cindex member name
  713. The files inside an archive are called @dfn{members}. Within this
  714. manual, we use the term @dfn{file} to refer only to files accessible in
  715. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  716. @dfn{member} to refer only to the members of an archive. Similarly, a
  717. @dfn{file name} is the name of a file, as it resides in the filesystem,
  718. and a @dfn{member name} is the name of an archive member within the
  719. archive.
  720. @cindex extraction
  721. @cindex unpacking
  722. The term @dfn{extraction} refers to the process of copying an archive
  723. member (or multiple members) into a file in the filesystem. Extracting
  724. all the members of an archive is often called @dfn{extracting the
  725. archive}. The term @dfn{unpack} can also be used to refer to the
  726. extraction of many or all the members of an archive. Extracting an
  727. archive does not destroy the archive's structure, just as creating an
  728. archive does not destroy the copies of the files that exist outside of
  729. the archive. You may also @dfn{list} the members in a given archive
  730. (this is often thought of as ``printing'' them to the standard output,
  731. or the command line), or @dfn{append} members to a pre-existing archive.
  732. All of these operations can be performed using @command{tar}.
  733. @node What tar Does
  734. @section What @command{tar} Does
  735. @cindex tar
  736. The @command{tar} program provides the ability to create @command{tar}
  737. archives, as well as various other kinds of manipulation. For example,
  738. you can use @command{tar} on previously created archives to extract files,
  739. to store additional files, or to update or list files which were already
  740. stored.
  741. Initially, @command{tar} archives were used to store files conveniently on
  742. magnetic tape. The name @command{tar} comes from this use; it stands for
  743. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  744. direct its output to available devices, files, or other programs (using
  745. pipes). @command{tar} may even access remote devices or files (as archives).
  746. @FIXME{the following table entries need a bit of work..}
  747. You can use @command{tar} archives in many ways. We want to stress a few
  748. of them: storage, backup, and transportation.
  749. @table @asis
  750. @item Storage
  751. Often, @command{tar} archives are used to store related files for
  752. convenient file transfer over a network. For example, the
  753. @acronym{GNU} Project distributes its software bundled into
  754. @command{tar} archives, so that all the files relating to a particular
  755. program (or set of related programs) can be transferred as a single
  756. unit.
  757. A magnetic tape can store several files in sequence. However, the tape
  758. has no names for these files; it only knows their relative position on
  759. the tape. One way to store several files on one tape and retain their
  760. names is by creating a @command{tar} archive. Even when the basic transfer
  761. mechanism can keep track of names, as FTP can, the nuisance of handling
  762. multiple files, directories, and multiple links makes @command{tar}
  763. archives useful.
  764. Archive files are also used for long-term storage. You can think of
  765. this as transportation from the present into the future. (It is a
  766. science-fiction idiom that you can move through time as well as in
  767. space; the idea here is that @command{tar} can be used to move archives in
  768. all dimensions, even time!)
  769. @item Backup
  770. Because the archive created by @command{tar} is capable of preserving
  771. file information and directory structure, @command{tar} is commonly
  772. used for performing full and incremental backups of disks. A backup
  773. puts a collection of files (possibly pertaining to many users and
  774. projects) together on a disk or a tape. This guards against
  775. accidental destruction of the information in those files.
  776. @GNUTAR{} has special features that allow it to be
  777. used to make incremental and full dumps of all the files in a
  778. filesystem.
  779. @item Transportation
  780. You can create an archive on one system, transfer it to another system,
  781. and extract the contents there. This allows you to transport a group of
  782. files from one system to another.
  783. @end table
  784. @node Naming tar Archives
  785. @section How @command{tar} Archives are Named
  786. Conventionally, @command{tar} archives are given names ending with
  787. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  788. but this manual follows that convention in order to accustom readers to
  789. it and to make examples more clear.
  790. @cindex tar file
  791. @cindex entry
  792. @cindex tar entry
  793. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  794. archive members as ``files'' or ``entries''. For people familiar with
  795. the operation of @command{tar}, this causes no difficulty. However, in
  796. this manual, we consistently refer to ``archives'' and ``archive
  797. members'' to make learning to use @command{tar} easier for novice users.
  798. @node Current status
  799. @section Current development status of @GNUTAR{}
  800. @GNUTAR{} is currently in the process of active development, whose
  801. primary aims are:
  802. @itemize @bullet
  803. @item Improve compatibility between @GNUTAR{} and other @command{tar}
  804. implementations.
  805. @item Switch to using @acronym{POSIX} archives.
  806. @item Revise sparse file handling and multiple volume processing.
  807. @item Merge with the @acronym{GNU} @code{paxutils} project.
  808. @end itemize
  809. Some of these aims are already attained, while others are still
  810. being worked upon. From the point of view of an end user, the
  811. following issues need special mentioning:
  812. @table @asis
  813. @item Use of short option @option{-o}.
  814. Earlier versions of @GNUTAR{} understood @option{-o} command line
  815. option as a synonym for @option{--old-archive}.
  816. @GNUTAR{} starting from version 1.13.90 understands this option as
  817. a synonym for @option{--no-same-owner}. This is compatible with
  818. UNIX98 @command{tar} implementations.
  819. However, to facilitate transition, @option{-o} option retains its
  820. old semantics when it is used with one of archive-creation commands.
  821. Users are encouraged to use @value{op-format-oldgnu} instead.
  822. It is especially important, since versions of @acronym{GNU} Automake
  823. up to and including 1.8.4 invoke tar with this option to produce
  824. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  825. of this issue and its implications.
  826. Future versions of @GNUTAR{} will understand @option{-o} only as a
  827. synonym for @option{--no-same-owner}.
  828. @item Use of short option @option{-l}
  829. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  830. synonym for @samp{--one-file-system}. Such usage is deprecated.
  831. For compatibility with other implementations future versions of
  832. @GNUTAR{} will understand this option as a synonym for
  833. @option{--check-links}.
  834. @item Use of options @option{--portability} and @option{--old-archive}
  835. These options are deprecated. Please use @option{--format=v7} instead.
  836. @item Use of option @option{--posix}
  837. This option is deprecated. Please use @option{--format=posix} instead.
  838. @end table
  839. @node Authors
  840. @section @GNUTAR{} Authors
  841. @GNUTAR{} was originally written by John Gilmore,
  842. and modified by many people. The @acronym{GNU} enhancements were
  843. written by Jay Fenlason, then Joy Kendall, and the whole package has
  844. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  845. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  846. numerous and kind users.
  847. We wish to stress that @command{tar} is a collective work, and owes much to
  848. all those people who reported problems, offered solutions and other
  849. insights, or shared their thoughts and suggestions. An impressive, yet
  850. partial list of those contributors can be found in the @file{THANKS}
  851. file from the @GNUTAR{} distribution.
  852. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  853. sure i want to spell out the history in this detail, at least not for
  854. the printed book. i'm just not sure it needs to be said this way.
  855. i'll think about it.}
  856. @FIXME{History is more important, and surely more interesting, than
  857. actual names. Quoting names without history would be meaningless. FP}
  858. Jay Fenlason put together a draft of a @GNUTAR{}
  859. manual, borrowing notes from the original man page from John Gilmore.
  860. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  861. Gorin worked on a tutorial and manual for @GNUTAR{}.
  862. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  863. taking information from all these sources and merging them. Melissa
  864. Weisshaus finally edited and redesigned the book to create version
  865. 1.12. @FIXME{update version number as necessary; i'm being
  866. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  867. maybe melissa? maybe julie sussman?] needs to properly index the
  868. thing.}
  869. For version 1.12, Daniel Hagerty contributed a great deal of technical
  870. consulting. In particular, he is the primary author of @ref{Backups}.
  871. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  872. (see @url{http://savannah.gnu.org/projects/tar}), and
  873. active development and maintenance work has started
  874. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  875. Poznyakoff and Jeff Bailey.
  876. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  877. @node Reports
  878. @section Reporting bugs or suggestions
  879. @cindex bug reports
  880. @cindex reporting bugs
  881. If you find problems or have suggestions about this program or manual,
  882. please report them to @file{bug-tar@@gnu.org}.
  883. When reporting a bug, please be sure to include as much detail as
  884. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  885. like to make this node as detailed as 'Bug reporting' node in Emacs
  886. manual}.
  887. @node Tutorial
  888. @chapter Tutorial Introduction to @command{tar}
  889. This chapter guides you through some basic examples of three @command{tar}
  890. operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
  891. you already know how to use some other version of @command{tar}, then you
  892. may not need to read this chapter. This chapter omits most complicated
  893. details about how @command{tar} works.
  894. @menu
  895. * assumptions::
  896. * stylistic conventions::
  897. * basic tar options:: Basic @command{tar} Operations and Options
  898. * frequent operations::
  899. * Two Frequent Options::
  900. * create:: How to Create Archives
  901. * list:: How to List Archives
  902. * extract:: How to Extract Members from an Archive
  903. * going further::
  904. @end menu
  905. @node assumptions
  906. @section Assumptions this Tutorial Makes
  907. This chapter is paced to allow beginners to learn about @command{tar}
  908. slowly. At the same time, we will try to cover all the basic aspects of
  909. these three operations. In order to accomplish both of these tasks, we
  910. have made certain assumptions about your knowledge before reading this
  911. manual, and the hardware you will be using:
  912. @itemize @bullet
  913. @item
  914. Before you start to work through this tutorial, you should understand
  915. what the terms ``archive'' and ``archive member'' mean
  916. (@pxref{Definitions}). In addition, you should understand something
  917. about how Unix-type operating systems work, and you should know how to
  918. use some basic utilities. For example, you should know how to create,
  919. list, copy, rename, edit, and delete files and directories; how to
  920. change between directories; and how to figure out where you are in the
  921. filesystem. You should have some basic understanding of directory
  922. structure and how files are named according to which directory they are
  923. in. You should understand concepts such as standard output and standard
  924. input, what various definitions of the term ``argument'' mean, and the
  925. differences between relative and absolute path names. @FIXME{and what
  926. else?}
  927. @item
  928. This manual assumes that you are working from your own home directory
  929. (unless we state otherwise). In this tutorial, you will create a
  930. directory to practice @command{tar} commands in. When we show path names,
  931. we will assume that those paths are relative to your home directory.
  932. For example, my home directory path is @file{/home/fsf/melissa}. All of
  933. my examples are in a subdirectory of the directory named by that path
  934. name; the subdirectory is called @file{practice}.
  935. @item
  936. In general, we show examples of archives which exist on (or can be
  937. written to, or worked with from) a directory on a hard disk. In most
  938. cases, you could write those archives to, or work with them on any other
  939. device, such as a tape drive. However, some of the later examples in
  940. the tutorial and next chapter will not work on tape drives.
  941. Additionally, working with tapes is much more complicated than working
  942. with hard disks. For these reasons, the tutorial does not cover working
  943. with tape drives. @xref{Media}, for complete information on using
  944. @command{tar} archives with tape drives.
  945. @FIXME{this is a cop out. need to add some simple tape drive info.}
  946. @end itemize
  947. @node stylistic conventions
  948. @section Stylistic Conventions
  949. In the examples, @samp{$} represents a typical shell prompt. It
  950. precedes lines you should type; to make this more clear, those lines are
  951. shown in @kbd{this font}, as opposed to lines which represent the
  952. computer's response; those lines are shown in @code{this font}, or
  953. sometimes @samp{like this}.
  954. @c When we have lines which are too long to be
  955. @c displayed in any other way, we will show them like this:
  956. @node basic tar options
  957. @section Basic @command{tar} Operations and Options
  958. @command{tar} can take a wide variety of arguments which specify and define
  959. the actions it will have on the particular set of files or the archive.
  960. The main types of arguments to @command{tar} fall into one of two classes:
  961. operations, and options.
  962. Some arguments fall into a class called @dfn{operations}; exactly one of
  963. these is both allowed and required for any instance of using @command{tar};
  964. you may @emph{not} specify more than one. People sometimes speak of
  965. @dfn{operating modes}. You are in a particular operating mode when you
  966. have specified the operation which specifies it; there are eight
  967. operations in total, and thus there are eight operating modes.
  968. The other arguments fall into the class known as @dfn{options}. You are
  969. not required to specify any options, and you are allowed to specify more
  970. than one at a time (depending on the way you are using @command{tar} at
  971. that time). Some options are used so frequently, and are so useful for
  972. helping you type commands more carefully that they are effectively
  973. ``required''. We will discuss them in this chapter.
  974. You can write most of the @command{tar} operations and options in any
  975. of three forms: long (mnemonic) form, short form, and old style. Some
  976. of the operations and options have no short or ``old'' forms; however,
  977. the operations and options which we will cover in this tutorial have
  978. corresponding abbreviations. @FIXME{make sure this is still the case,
  979. at the end}We will indicate those abbreviations appropriately to get
  980. you used to seeing them. (Note that the ``old style'' option forms
  981. exist in @GNUTAR{} for compatibility with Unix
  982. @command{tar}. We present a full discussion of this way of writing
  983. options and operations appears in @ref{Old Options}, and we discuss
  984. the other two styles of writing options in @ref{Mnemonic Options}, and
  985. @ref{Short Options}.)
  986. In the examples and in the text of this tutorial, we usually use the
  987. long forms of operations and options; but the ``short'' forms produce
  988. the same result and can make typing long @command{tar} commands easier.
  989. For example, instead of typing
  990. @smallexample
  991. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  992. @end smallexample
  993. @noindent
  994. you can type
  995. @smallexample
  996. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  997. @end smallexample
  998. @noindent
  999. or even
  1000. @smallexample
  1001. @kbd{tar -cvf afiles.tar apple angst aspic}
  1002. @end smallexample
  1003. @noindent
  1004. For more information on option syntax, see @ref{Advanced tar}. In
  1005. discussions in the text, when we name an option by its long form, we
  1006. also give the corresponding short option in parentheses.
  1007. The term, ``option'', can be confusing at times, since ``operations''
  1008. are often lumped in with the actual, @emph{optional} ``options'' in certain
  1009. general class statements. For example, we just talked about ``short and
  1010. long forms of options and operations''. However, experienced @command{tar}
  1011. users often refer to these by shorthand terms such as, ``short and long
  1012. options''. This term assumes that the ``operations'' are included, also.
  1013. Context will help you determine which definition of ``options'' to use.
  1014. Similarly, the term ``command'' can be confusing, as it is often used in
  1015. two different ways. People sometimes refer to @command{tar} ``commands''.
  1016. A @command{tar} @dfn{command} is the entire command line of user input
  1017. which tells @command{tar} what to do --- including the operation, options,
  1018. and any arguments (file names, pipes, other commands, etc). However,
  1019. you will also sometimes hear the term ``the @command{tar} command''. When
  1020. the word ``command'' is used specifically like this, a person is usually
  1021. referring to the @command{tar} @emph{operation}, not the whole line.
  1022. Again, use context to figure out which of the meanings the speaker
  1023. intends.
  1024. @node frequent operations
  1025. @section The Three Most Frequently Used Operations
  1026. Here are the three most frequently used operations (both short and long
  1027. forms), as well as a brief description of their meanings. The rest of
  1028. this chapter will cover how to use these operations in detail. We will
  1029. present the rest of the operations in the next chapter.
  1030. @table @kbd
  1031. @item --create
  1032. @itemx -c
  1033. Create a new @command{tar} archive.
  1034. @item --list
  1035. @itemx -t
  1036. List the contents of an archive.
  1037. @item --extract
  1038. @itemx -x
  1039. Extract one or more members from an archive.
  1040. @end table
  1041. @node Two Frequent Options
  1042. @section Two Frequently Used Options
  1043. To understand how to run @command{tar} in the three operating modes listed
  1044. previously, you also need to understand how to use two of the options to
  1045. @command{tar}: @samp{--file} (which takes an archive file as an argument)
  1046. and @samp{--verbose}. (You are usually not @emph{required} to specify
  1047. either of these options when you run @command{tar}, but they can be very
  1048. useful in making things more clear and helping you avoid errors.)
  1049. @menu
  1050. * file tutorial::
  1051. * verbose tutorial::
  1052. * help tutorial::
  1053. @end menu
  1054. @node file tutorial
  1055. @unnumberedsubsec The @samp{--file} Option
  1056. @table @kbd
  1057. @item --file=@var{archive-name}
  1058. @itemx -f @var{archive-name}
  1059. Specify the name of an archive file.
  1060. @end table
  1061. You can specify an argument for the @value{op-file} option whenever you
  1062. use @command{tar}; this option determines the name of the archive file
  1063. that @command{tar} will work on.
  1064. If you don't specify this argument, then @command{tar} will use a
  1065. default, usually some physical tape drive attached to your machine.
  1066. If there is no tape drive attached, or the default is not meaningful,
  1067. then @command{tar} will print an error message. The error message might
  1068. look roughly like one of the following:
  1069. @smallexample
  1070. tar: can't open /dev/rmt8 : No such device or address
  1071. tar: can't open /dev/rsmt0 : I/O error
  1072. @end smallexample
  1073. @noindent
  1074. To avoid confusion, we recommend that you always specify an archive file
  1075. name by using @value{op-file} when writing your @command{tar} commands.
  1076. For more information on using the @value{op-file} option, see
  1077. @ref{file}.
  1078. @node verbose tutorial
  1079. @unnumberedsubsec The @samp{--verbose} Option
  1080. @table @kbd
  1081. @item --verbose
  1082. @itemx -v
  1083. Show the files being worked on as @command{tar} is running.
  1084. @end table
  1085. @value{op-verbose} shows details about the results of running
  1086. @command{tar}. This can be especially useful when the results might not be
  1087. obvious. For example, if you want to see the progress of @command{tar} as
  1088. it writes files into the archive, you can use the @samp{--verbose}
  1089. option. In the beginning, you may find it useful to use
  1090. @samp{--verbose} at all times; when you are more accustomed to
  1091. @command{tar}, you will likely want to use it at certain times but not at
  1092. others. We will use @samp{--verbose} at times to help make something
  1093. clear, and we will give many examples both using and not using
  1094. @samp{--verbose} to show the differences.
  1095. Sometimes, a single instance of @samp{--verbose} on the command line
  1096. will show a full, @samp{ls} style listing of an archive or files,
  1097. @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
  1098. giving sizes, owners, and similar information. Other times,
  1099. @samp{--verbose} will only show files or members that the particular
  1100. operation is operating on at the time. In the latter case, you can
  1101. use @samp{--verbose} twice in a command to get a listing such as that
  1102. in the former case. For example, instead of saying
  1103. @smallexample
  1104. @kbd{tar -cvf afiles.tar apple angst aspic}
  1105. @end smallexample
  1106. @noindent
  1107. above, you might say
  1108. @smallexample
  1109. @kbd{tar -cvvf afiles.tar apple angst aspic}
  1110. @end smallexample
  1111. @noindent
  1112. This works equally well using short or long forms of options. Using
  1113. long forms, you would simply write out the mnemonic form of the option
  1114. twice, like this:
  1115. @smallexample
  1116. $ @kbd{tar --create --verbose --verbose @dots{}}
  1117. @end smallexample
  1118. @noindent
  1119. Note that you must double the hyphens properly each time.
  1120. Later in the tutorial, we will give examples using @w{@samp{--verbose
  1121. --verbose}}.
  1122. @node help tutorial
  1123. @unnumberedsubsec Getting Help: Using the @code{--help} Option
  1124. @table @kbd
  1125. @item --help
  1126. The @samp{--help} option to @command{tar} prints out a very brief list of
  1127. all operations and option available for the current version of
  1128. @command{tar} available on your system.
  1129. @end table
  1130. @node create
  1131. @section How to Create Archives
  1132. @UNREVISED
  1133. One of the basic operations of @command{tar} is @value{op-create}, which
  1134. you use to create a @command{tar} archive. We will explain
  1135. @samp{--create} first because, in order to learn about the other
  1136. operations, you will find it useful to have an archive available to
  1137. practice on.
  1138. To make this easier, in this section you will first create a directory
  1139. containing three files. Then, we will show you how to create an
  1140. @emph{archive} (inside the new directory). Both the directory, and
  1141. the archive are specifically for you to practice on. The rest of this
  1142. chapter and the next chapter will show many examples using this
  1143. directory and the files you will create: some of those files may be
  1144. other directories and other archives.
  1145. The three files you will archive in this example are called
  1146. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  1147. @file{collection.tar}.
  1148. This section will proceed slowly, detailing how to use @samp{--create}
  1149. in @code{verbose} mode, and showing examples using both short and long
  1150. forms. In the rest of the tutorial, and in the examples in the next
  1151. chapter, we will proceed at a slightly quicker pace. This section
  1152. moves more slowly to allow beginning users to understand how
  1153. @command{tar} works.
  1154. @menu
  1155. * prepare for examples::
  1156. * Creating the archive::
  1157. * create verbose::
  1158. * short create::
  1159. * create dir::
  1160. @end menu
  1161. @node prepare for examples
  1162. @subsection Preparing a Practice Directory for Examples
  1163. To follow along with this and future examples, create a new directory
  1164. called @file{practice} containing files called @file{blues}, @file{folk}
  1165. and @file{jazz}. The files can contain any information you like:
  1166. ideally, they should contain information which relates to their names,
  1167. and be of different lengths. Our examples assume that @file{practice}
  1168. is a subdirectory of your home directory.
  1169. Now @command{cd} to the directory named @file{practice}; @file{practice}
  1170. is now your @dfn{working directory}. (@emph{Please note}: Although
  1171. the full path name of this directory is
  1172. @file{/@var{homedir}/practice}, in our examples we will refer to
  1173. this directory as @file{practice}; the @var{homedir} is presumed.
  1174. In general, you should check that the files to be archived exist where
  1175. you think they do (in the working directory) by running @command{ls}.
  1176. Because you just created the directory and the files and have changed to
  1177. that directory, you probably don't need to do that this time.
  1178. It is very important to make sure there isn't already a file in the
  1179. working directory with the archive name you intend to use (in this case,
  1180. @samp{collection.tar}), or that you don't care about its contents.
  1181. Whenever you use @samp{create}, @command{tar} will erase the current
  1182. contents of the file named by @value{op-file} if it exists. @command{tar}
  1183. will not tell you if you are about to overwrite an archive unless you
  1184. specify an option which does this. @FIXME{xref to the node for
  1185. --backup!}To add files to an existing archive, you need to use a
  1186. different option, such as @value{op-append}; see @ref{append} for
  1187. information on how to do this.
  1188. @node Creating the archive
  1189. @subsection Creating the Archive
  1190. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  1191. archive named @file{collection.tar}, use the following command:
  1192. @smallexample
  1193. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  1194. @end smallexample
  1195. The order of the arguments is not very important, @emph{when using long
  1196. option forms}. You could also say:
  1197. @smallexample
  1198. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1199. @end smallexample
  1200. @noindent
  1201. However, you can see that this order is harder to understand; this is
  1202. why we will list the arguments in the order that makes the commands
  1203. easiest to understand (and we encourage you to do the same when you use
  1204. @command{tar}, to avoid errors).
  1205. Note that the part of the command which says,
  1206. @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
  1207. If you substituted any other string of characters for
  1208. @kbd{collection.tar}, then that string would become the name of the
  1209. archive file you create.
  1210. The order of the options becomes more important when you begin to use
  1211. short forms. With short forms, if you type commands in the wrong order
  1212. (even if you type them correctly in all other ways), you may end up with
  1213. results you don't expect. For this reason, it is a good idea to get
  1214. into the habit of typing options in the order that makes inherent sense.
  1215. @xref{short create}, for more information on this.
  1216. In this example, you type the command as shown above: @samp{--create}
  1217. is the operation which creates the new archive
  1218. (@file{collection.tar}), and @samp{--file} is the option which lets
  1219. you give it the name you chose. The files, @file{blues}, @file{folk},
  1220. and @file{jazz}, are now members of the archive, @file{collection.tar}
  1221. (they are @dfn{file name arguments} to the @samp{--create} operation).
  1222. @FIXME{xref here to the discussion of file name args?}Now that they are
  1223. in the archive, they are called @emph{archive members}, not files.
  1224. (@pxref{Definitions,members}).
  1225. When you create an archive, you @emph{must} specify which files you
  1226. want placed in the archive. If you do not specify any archive
  1227. members, @GNUTAR{} will complain.
  1228. If you now list the contents of the working directory (@kbd{ls}), you will
  1229. find the archive file listed as well as the files you saw previously:
  1230. @smallexample
  1231. blues folk jazz collection.tar
  1232. @end smallexample
  1233. @noindent
  1234. Creating the archive @samp{collection.tar} did not destroy the copies of
  1235. the files in the directory.
  1236. Keep in mind that if you don't indicate an operation, @command{tar} will not
  1237. run and will prompt you for one. If you don't name any files, @command{tar}
  1238. will complain. You must have write access to the working directory,
  1239. or else you will not be able to create an archive in that directory.
  1240. @emph{Caution}: Do not attempt to use @value{op-create} to add files to
  1241. an existing archive; it will delete the archive and write a new one.
  1242. Use @value{op-append} instead. @xref{append}.
  1243. @node create verbose
  1244. @subsection Running @samp{--create} with @samp{--verbose}
  1245. If you include the @value{op-verbose} option on the command line,
  1246. @command{tar} will list the files it is acting on as it is working. In
  1247. verbose mode, the @code{create} example above would appear as:
  1248. @smallexample
  1249. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  1250. blues
  1251. folk
  1252. jazz
  1253. @end smallexample
  1254. This example is just like the example we showed which did not use
  1255. @samp{--verbose}, except that @command{tar} generated the remaining lines
  1256. @iftex
  1257. (note the different font styles).
  1258. @end iftex
  1259. @ifinfo
  1260. .
  1261. @end ifinfo
  1262. In the rest of the examples in this chapter, we will frequently use
  1263. @code{verbose} mode so we can show actions or @command{tar} responses that
  1264. you would otherwise not see, and which are important for you to
  1265. understand.
  1266. @node short create
  1267. @subsection Short Forms with @samp{create}
  1268. As we said before, the @value{op-create} operation is one of the most
  1269. basic uses of @command{tar}, and you will use it countless times.
  1270. Eventually, you will probably want to use abbreviated (or ``short'')
  1271. forms of options. A full discussion of the three different forms that
  1272. options can take appears in @ref{Styles}; for now, here is what the
  1273. previous example (including the @value{op-verbose} option) looks like
  1274. using short option forms:
  1275. @smallexample
  1276. $ @kbd{tar -cvf collection.tar blues folk jazz}
  1277. blues
  1278. folk
  1279. jazz
  1280. @end smallexample
  1281. @noindent
  1282. As you can see, the system responds the same no matter whether you use
  1283. long or short option forms.
  1284. @FIXME{i don't like how this is worded:} One difference between using
  1285. short and long option forms is that, although the exact placement of
  1286. arguments following options is no more specific when using short forms,
  1287. it is easier to become confused and make a mistake when using short
  1288. forms. For example, suppose you attempted the above example in the
  1289. following way:
  1290. @smallexample
  1291. $ @kbd{tar -cfv collection.tar blues folk jazz}
  1292. @end smallexample
  1293. @noindent
  1294. In this case, @command{tar} will make an archive file called @file{v},
  1295. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  1296. the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
  1297. is thus taken to be the chosen archive file name. @command{tar} will try
  1298. to add a file called @file{collection.tar} to the @file{v} archive file;
  1299. if the file @file{collection.tar} did not already exist, @command{tar} will
  1300. report an error indicating that this file does not exist. If the file
  1301. @file{collection.tar} does already exist (e.g., from a previous command
  1302. you may have run), then @command{tar} will add this file to the archive.
  1303. Because the @samp{-v} option did not get registered, @command{tar} will not
  1304. run under @samp{verbose} mode, and will not report its progress.
  1305. The end result is that you may be quite confused about what happened,
  1306. and possibly overwrite a file. To illustrate this further, we will show
  1307. you how an example we showed previously would look using short forms.
  1308. This example,
  1309. @smallexample
  1310. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1311. @end smallexample
  1312. @noindent
  1313. is confusing as it is. When shown using short forms, however, it
  1314. becomes much more so:
  1315. @smallexample
  1316. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1317. @end smallexample
  1318. @noindent
  1319. It would be very easy to put the wrong string of characters
  1320. immediately following the @samp{-f}, but doing that could sacrifice
  1321. valuable data.
  1322. For this reason, we recommend that you pay very careful attention to
  1323. the order of options and placement of file and archive names,
  1324. especially when using short option forms. Not having the option name
  1325. written out mnemonically can affect how well you remember which option
  1326. does what, and therefore where different names have to be placed.
  1327. (Placing options in an unusual order can also cause @command{tar} to
  1328. report an error if you have set the shell environment variable
  1329. @env{POSIXLY_CORRECT}.)
  1330. @node create dir
  1331. @subsection Archiving Directories
  1332. @cindex Archiving Directories
  1333. @cindex Directories, Archiving
  1334. You can archive a directory by specifying its directory name as a
  1335. file name argument to @command{tar}. The files in the directory will be
  1336. archived relative to the working directory, and the directory will be
  1337. re-created along with its contents when the archive is extracted.
  1338. To archive a directory, first move to its superior directory. If you
  1339. have followed the previous instructions in this tutorial, you should
  1340. type:
  1341. @smallexample
  1342. $ @kbd{cd ..}
  1343. $
  1344. @end smallexample
  1345. @noindent
  1346. This will put you into the directory which contains @file{practice},
  1347. i.e. your home directory. Once in the superior directory, you can
  1348. specify the subdirectory, @file{practice}, as a file name argument. To
  1349. store @file{practice} in the new archive file @file{music.tar}, type:
  1350. @smallexample
  1351. $ @kbd{tar --create --verbose --file=music.tar practice}
  1352. @end smallexample
  1353. @noindent
  1354. @command{tar} should output:
  1355. @smallexample
  1356. practice/
  1357. practice/blues
  1358. practice/folk
  1359. practice/jazz
  1360. practice/collection.tar
  1361. @end smallexample
  1362. Note that the archive thus created is not in the subdirectory
  1363. @file{practice}, but rather in the current working directory---the
  1364. directory from which @command{tar} was invoked. Before trying to archive a
  1365. directory from its superior directory, you should make sure you have
  1366. write access to the superior directory itself, not only the directory
  1367. you are trying archive with @command{tar}. For example, you will probably
  1368. not be able to store your home directory in an archive by invoking
  1369. @command{tar} from the root directory; @value{xref-absolute-names}. (Note
  1370. also that @file{collection.tar}, the original archive file, has itself
  1371. been archived. @command{tar} will accept any file as a file to be
  1372. archived, regardless of its content. When @file{music.tar} is
  1373. extracted, the archive file @file{collection.tar} will be re-written
  1374. into the file system).
  1375. If you give @command{tar} a command such as
  1376. @smallexample
  1377. $ @kbd{tar --create --file=foo.tar .}
  1378. @end smallexample
  1379. @noindent
  1380. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1381. dumped}. This happens because @command{tar} creates the archive
  1382. @file{foo.tar} in the current directory before putting any files into
  1383. it. Then, when @command{tar} attempts to add all the files in the
  1384. directory @file{.} to the archive, it notices that the file
  1385. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1386. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1387. will continue in this case, and create the archive
  1388. normally, except for the exclusion of that one file. (@emph{Please
  1389. note:} Other versions of @command{tar} are not so clever; they will
  1390. enter an infinite loop when this happens, so you should not depend on
  1391. this behavior unless you are certain you are running @GNUTAR{}.)
  1392. @FIXME{bob doesn't like this sentence, since he does
  1393. it all the time, and we've been doing it in the editing passes for
  1394. this manual: In general, make sure that the archive is not inside a
  1395. directory being dumped.}
  1396. @node list
  1397. @section How to List Archives
  1398. Frequently, you will find yourself wanting to determine exactly what a
  1399. particular archive contains. You can use the @value{op-list} operation
  1400. to get the member names as they currently appear in the archive, as well
  1401. as various attributes of the files at the time they were archived. For
  1402. example, you can examine the archive @file{collection.tar} that you
  1403. created in the last section with the command,
  1404. @smallexample
  1405. $ @kbd{tar --list --file=collection.tar}
  1406. @end smallexample
  1407. @noindent
  1408. The output of @command{tar} would then be:
  1409. @smallexample
  1410. blues
  1411. folk
  1412. jazz
  1413. @end smallexample
  1414. @FIXME{we hope this will change. if it doesn't, need to show the
  1415. creation of bfiles somewhere above!!! : }
  1416. @noindent
  1417. The archive @file{bfiles.tar} would list as follows:
  1418. @smallexample
  1419. ./birds
  1420. baboon
  1421. ./box
  1422. @end smallexample
  1423. @noindent
  1424. Be sure to use a @value{op-file} option just as with @value{op-create}
  1425. to specify the name of the archive.
  1426. If you use the @value{op-verbose} option with @samp{--list}, then
  1427. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1428. showing owner, file size, and so forth.
  1429. If you had used @value{op-verbose} mode, the example above would look
  1430. like:
  1431. @smallexample
  1432. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1433. -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
  1434. @end smallexample
  1435. @cindex File name arguments, using @code{--list} with
  1436. @cindex @code{--list} with file name arguments
  1437. You can specify one or more individual member names as arguments when
  1438. using @samp{list}. In this case, @command{tar} will only list the
  1439. names of members you identify. For example, @w{@kbd{tar --list
  1440. --file=afiles.tar apple}} would only print @file{apple}.
  1441. @FIXME{we hope the relevant aspects of this will change:}Because
  1442. @command{tar} preserves paths, file names must be specified as they appear
  1443. in the archive (ie., relative to the directory from which the archive
  1444. was created). Therefore, it is essential when specifying member names
  1445. to @command{tar} that you give the exact member names. For example,
  1446. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1447. something like @samp{tar: birds: Not found in archive}, because there is
  1448. no member named @file{birds}, only one named @file{./birds}. While the
  1449. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1450. names are compared using a simplistic name comparison, in which an exact
  1451. match is necessary. @xref{absolute}.
  1452. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1453. with @file{folk}, because @file{folk} is in the archive file
  1454. @file{collection.tar}. If you are not sure of the exact file name, try
  1455. listing all the files in the archive and searching for the one you
  1456. expect to find; remember that if you use @samp{--list} with no file
  1457. names as arguments, @command{tar} will print the names of all the members
  1458. stored in the specified archive.
  1459. @menu
  1460. * list dir::
  1461. @end menu
  1462. @node list dir
  1463. @unnumberedsubsec Listing the Contents of a Stored Directory
  1464. To get information about the contents of an archived directory,
  1465. use the directory name as a file name argument in conjunction with
  1466. @value{op-list}. To find out file attributes, include the
  1467. @value{op-verbose} option.
  1468. For example, to find out about files in the directory @file{practice}, in
  1469. the archive file @file{music.tar}, type:
  1470. @smallexample
  1471. $ @kbd{tar --list --verbose --file=music.tar practice}
  1472. @end smallexample
  1473. @command{tar} responds:
  1474. @smallexample
  1475. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1476. -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
  1477. -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
  1478. -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
  1479. -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1480. @end smallexample
  1481. When you use a directory name as a file name argument, @command{tar} acts on
  1482. all the files (including sub-directories) in that directory.
  1483. @node extract
  1484. @section How to Extract Members from an Archive
  1485. @UNREVISED
  1486. @cindex Extraction
  1487. @cindex Retrieving files from an archive
  1488. @cindex Resurrecting files from an archive
  1489. Creating an archive is only half the job---there is no point in storing
  1490. files in an archive if you can't retrieve them. The act of retrieving
  1491. members from an archive so they can be used and manipulated as
  1492. unarchived files again is called @dfn{extraction}. To extract files
  1493. from an archive, use the @value{op-extract} operation. As with
  1494. @value{op-create}, specify the name of the archive with @value{op-file}.
  1495. Extracting an archive does not modify the archive in any way; you can
  1496. extract it multiple times if you want or need to.
  1497. Using @samp{--extract}, you can extract an entire archive, or specific
  1498. files. The files can be directories containing other files, or not. As
  1499. with @value{op-create} and @value{op-list}, you may use the short or the
  1500. long form of the operation without affecting the performance.
  1501. @menu
  1502. * extracting archives::
  1503. * extracting files::
  1504. * extract dir::
  1505. * extracting untrusted archives::
  1506. * failing commands::
  1507. @end menu
  1508. @node extracting archives
  1509. @subsection Extracting an Entire Archive
  1510. To extract an entire archive, specify the archive file name only, with
  1511. no individual file names as arguments. For example,
  1512. @smallexample
  1513. $ @kbd{tar -xvf collection.tar}
  1514. @end smallexample
  1515. @noindent
  1516. produces this:
  1517. @smallexample
  1518. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  1519. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  1520. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  1521. @end smallexample
  1522. @node extracting files
  1523. @subsection Extracting Specific Files
  1524. To extract specific archive members, give their exact member names as
  1525. arguments, as printed by @value{op-list}. If you had mistakenly deleted
  1526. one of the files you had placed in the archive @file{collection.tar}
  1527. earlier (say, @file{blues}), you can extract it from the archive without
  1528. changing the archive's structure. It will be identical to the original
  1529. file @file{blues} that you deleted. @FIXME{At the time of this
  1530. writing, atime and ctime are not restored. Since this is a tutorial
  1531. for a beginnig user, it should hardly be mentioned here. Maybe in
  1532. a footnote? --gray}.
  1533. First, make sure you are in the @file{practice} directory, and list the
  1534. files in the directory. Now, delete the file, @samp{blues}, and list
  1535. the files in the directory again.
  1536. You can now extract the member @file{blues} from the archive file
  1537. @file{collection.tar} like this:
  1538. @smallexample
  1539. $ @kbd{tar --extract --file=collection.tar blues}
  1540. @end smallexample
  1541. @noindent
  1542. If you list the files in the directory again, you will see that the file
  1543. @file{blues} has been restored, with its original permissions, creation
  1544. times, and owner.@FIXME{This is only accidentally true, but not in
  1545. general. In most cases, one has to be root for restoring the owner, and
  1546. use a special option for restoring permissions. Here, it just happens
  1547. that the restoring user is also the owner of the archived members, and
  1548. that the current @code{umask} is compatible with original permissions.}
  1549. (These parameters will be identical to those which
  1550. the file had when you originally placed it in the archive; any changes
  1551. you may have made before deleting the file from the file system,
  1552. however, will @emph{not} have been made to the archive member.) The
  1553. archive file, @samp{collection.tar}, is the same as it was before you
  1554. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1555. @value{op-list}.
  1556. @FIXME{we hope this will change:}Remember that as with other operations,
  1557. specifying the exact member name is important. @w{@kbd{tar --extract
  1558. --file=bfiles.tar birds}} will fail, because there is no member named
  1559. @file{birds}. To extract the member named @file{./birds}, you must
  1560. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1561. exact member names of the members of an archive, use @value{op-list}
  1562. (@pxref{list}).
  1563. You can extract a file to standard output by combining the above options
  1564. with the @value{op-to-stdout} option (@pxref{Writing to Standard
  1565. Output}).
  1566. If you give the @value{op-verbose} option, then @value{op-extract} will
  1567. print the names of the archive members as it extracts them.
  1568. @node extract dir
  1569. @subsection Extracting Files that are Directories
  1570. Extracting directories which are members of an archive is similar to
  1571. extracting other files. The main difference to be aware of is that if
  1572. the extracted directory has the same name as any directory already in
  1573. the working directory, then files in the extracted directory will be
  1574. placed into the directory of the same name. Likewise, if there are
  1575. files in the pre-existing directory with the same names as the members
  1576. which you extract, the files from the extracted archive will replace
  1577. the files already in the working directory (and possible
  1578. subdirectories). This will happen regardless of whether or not the
  1579. files in the working directory were more recent than those extracted
  1580. (there exist, however, special options that alter this behavior
  1581. @pxref{Writing}).
  1582. However, if a file was stored with a directory name as part of its file
  1583. name, and that directory does not exist under the working directory when
  1584. the file is extracted, @command{tar} will create the directory.
  1585. We can demonstrate how to use @samp{--extract} to extract a directory
  1586. file with an example. Change to the @file{practice} directory if you
  1587. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1588. go back to the parent directory and extract the archive
  1589. @file{music.tar}. You may either extract the entire archive, or you may
  1590. extract only the files you just deleted. To extract the entire archive,
  1591. don't give any file names as arguments after the archive name
  1592. @file{music.tar}. To extract only the files you deleted, use the
  1593. following command:
  1594. @smallexample
  1595. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1596. practice/folk
  1597. practice/jazz
  1598. @end smallexample
  1599. @noindent
  1600. If you were to specify two @value{op-verbose} options, @command{tar}
  1601. would have displayed more detail about the extracted files, as shown
  1602. in the example below:
  1603. @smallexample
  1604. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1605. -rw-rw-rw- me user 28 1996-10-18 16:31 practice/jazz
  1606. -rw-rw-rw- me user 20 1996-09-23 16:44 practice/folk
  1607. @end smallexample
  1608. @noindent
  1609. Because you created the directory with @file{practice} as part of the
  1610. file names of each of the files by archiving the @file{practice}
  1611. directory as @file{practice}, you must give @file{practice} as part
  1612. of the file names when you extract those files from the archive.
  1613. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1614. will be.}
  1615. @node extracting untrusted archives
  1616. @subsection Extracting Archives from Untrusted Sources
  1617. Extracting files from archives can overwrite files that already exist.
  1618. If you receive an archive from an untrusted source, you should make a
  1619. new directory and extract into that directory, so that you don't have
  1620. to worry about the extraction overwriting one of your existing files.
  1621. For example, if @file{untrusted.tar} came from somewhere else on the
  1622. Internet, and you don't necessarily trust its contents, you can
  1623. extract it as follows:
  1624. @smallexample
  1625. $ @kbd{mkdir newdir}
  1626. $ @kbd{cd newdir}
  1627. $ @kbd{tar -xvf ../untrusted.tar}
  1628. @end smallexample
  1629. It is also a good practice to examine contents of the archive
  1630. before extracting it, using @value{op-list} option, possibly combined
  1631. with @value{op-verbose}.
  1632. @node failing commands
  1633. @subsection Commands That Will Fail
  1634. Here are some sample commands you might try which will not work, and why
  1635. they won't work.
  1636. If you try to use this command,
  1637. @smallexample
  1638. $ @kbd{tar -xvf music.tar folk jazz}
  1639. @end smallexample
  1640. @noindent
  1641. you will get the following response:
  1642. @smallexample
  1643. tar: folk: Not found in archive
  1644. tar: jazz: Not found in archive
  1645. $
  1646. @end smallexample
  1647. @noindent
  1648. This is because these files were not originally @emph{in} the parent
  1649. directory @file{..}, where the archive is located; they were in the
  1650. @file{practice} directory, and their file names reflect this:
  1651. @smallexample
  1652. $ @kbd{tar -tvf music.tar}
  1653. practice/folk
  1654. practice/jazz
  1655. practice/rock
  1656. @end smallexample
  1657. @FIXME{make sure the above works when going through the examples in
  1658. order...}
  1659. @noindent
  1660. Likewise, if you try to use this command,
  1661. @smallexample
  1662. $ @kbd{tar -tvf music.tar folk jazz}
  1663. @end smallexample
  1664. @noindent
  1665. you would get a similar response. Members with those names are not in the
  1666. archive. You must use the correct member names in order to extract the
  1667. files from the archive.
  1668. If you have forgotten the correct names of the files in the archive,
  1669. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1670. @FIXME{more examples, here? hag thinks it's a good idea.}
  1671. @node going further
  1672. @section Going Further Ahead in this Manual
  1673. @FIXME{need to write up a node here about the things that are going to
  1674. be in the rest of the manual.}
  1675. @node tar invocation
  1676. @chapter Invoking @GNUTAR{}
  1677. @UNREVISED
  1678. This chapter is about how one invokes the @GNUTAR{}
  1679. command, from the command synopsis (@pxref{Synopsis}). There are
  1680. numerous options, and many styles for writing them. One mandatory
  1681. option specifies the operation @command{tar} should perform
  1682. (@pxref{Operation Summary}), other options are meant to detail how
  1683. this operation should be performed (@pxref{Option Summary}).
  1684. Non-option arguments are not always interpreted the same way,
  1685. depending on what the operation is.
  1686. You will find in this chapter everything about option styles and rules for
  1687. writing them (@pxref{Styles}). On the other hand, operations and options
  1688. are fully described elsewhere, in other chapters. Here, you will find
  1689. only synthetic descriptions for operations and options, together with
  1690. pointers to other parts of the @command{tar} manual.
  1691. Some options are so special they are fully described right in this
  1692. chapter. They have the effect of inhibiting the normal operation of
  1693. @command{tar} or else, they globally alter the amount of feedback the user
  1694. receives about what is going on. These are the @value{op-help} and
  1695. @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
  1696. and @value{op-interactive} options (@pxref{interactive}).
  1697. @menu
  1698. * Synopsis::
  1699. * using tar options::
  1700. * Styles::
  1701. * All Options::
  1702. * help::
  1703. * verbose::
  1704. * interactive::
  1705. @end menu
  1706. @node Synopsis
  1707. @section General Synopsis of @command{tar}
  1708. The @GNUTAR{} program is invoked as either one of:
  1709. @smallexample
  1710. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1711. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1712. @end smallexample
  1713. The second form is for when old options are being used.
  1714. You can use @command{tar} to store files in an archive, to extract them from
  1715. an archive, and to do other types of archive manipulation. The primary
  1716. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1717. which action to take. The other arguments to @command{tar} are either
  1718. @dfn{options}, which change the way @command{tar} performs an operation,
  1719. or file names or archive members, which specify the files or members
  1720. @command{tar} is to act on.
  1721. You can actually type in arguments in any order, even if in this manual
  1722. the options always precede the other arguments, to make examples easier
  1723. to understand. Further, the option stating the main operation mode
  1724. (the @command{tar} main command) is usually given first.
  1725. Each @var{name} in the synopsis above is interpreted as an archive member
  1726. name when the main command is one of @value{op-compare}, @value{op-delete},
  1727. @value{op-extract}, @value{op-list} or @value{op-update}. When naming
  1728. archive members, you must give the exact name of the member in the
  1729. archive, as it is printed by @value{op-list}. For @value{op-append}
  1730. and @value{op-create}, these @var{name} arguments specify the names
  1731. of either files or directory hierarchies to place in the archive.
  1732. These files or hierarchies should already exist in the file system,
  1733. prior to the execution of the @command{tar} command.
  1734. @command{tar} interprets relative file names as being relative to the
  1735. working directory. @command{tar} will make all file names relative
  1736. (by removing leading slashes when archiving or restoring files),
  1737. unless you specify otherwise (using the @value{op-absolute-names}
  1738. option). @value{xref-absolute-names}, for more information about
  1739. @value{op-absolute-names}.
  1740. If you give the name of a directory as either a file name or a member
  1741. name, then @command{tar} acts recursively on all the files and directories
  1742. beneath that directory. For example, the name @file{/} identifies all
  1743. the files in the filesystem to @command{tar}.
  1744. The distinction between file names and archive member names is especially
  1745. important when shell globbing is used, and sometimes a source of confusion
  1746. for newcomers. @xref{Wildcards}, for more information about globbing.
  1747. The problem is that shells may only glob using existing files in the
  1748. file system. Only @command{tar} itself may glob on archive members, so when
  1749. needed, you must ensure that wildcard characters reach @command{tar} without
  1750. being interpreted by the shell first. Using a backslash before @samp{*}
  1751. or @samp{?}, or putting the whole argument between quotes, is usually
  1752. sufficient for this.
  1753. Even if @var{name}s are often specified on the command line, they
  1754. can also be read from a text file in the file system, using the
  1755. @value{op-files-from} option.
  1756. If you don't use any file name arguments, @value{op-append},
  1757. @value{op-delete} and @value{op-concatenate} will do nothing, while
  1758. @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
  1759. execution. The other operations of @command{tar} (@value{op-list},
  1760. @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
  1761. on the entire contents of the archive.
  1762. @cindex exit status
  1763. @cindex return status
  1764. Besides successful exits, @GNUTAR{} may fail for
  1765. many reasons. Some reasons correspond to bad usage, that is, when the
  1766. @command{tar} command is improperly written. Errors may be
  1767. encountered later, while encountering an error processing the archive
  1768. or the files. Some errors are recoverable, in which case the failure
  1769. is delayed until @command{tar} has completed all its work. Some
  1770. errors are such that it would not meaningful, or at least risky, to
  1771. continue processing: @command{tar} then aborts processing immediately.
  1772. All abnormal exits, whether immediate or delayed, should always be
  1773. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1774. the error.
  1775. @GNUTAR{} returns only a few exit statuses. I'm really
  1776. aiming simplicity in that area, for now. If you are not using the
  1777. @value{op-compare} option, zero means that everything went well, besides
  1778. maybe innocuous warnings. Nonzero means that something went wrong.
  1779. Right now, as of today, ``nonzero'' is almost always 2, except for
  1780. remote operations, where it may be 128.
  1781. @node using tar options
  1782. @section Using @command{tar} Options
  1783. @GNUTAR{} has a total of eight operating modes which
  1784. allow you to perform a variety of tasks. You are required to choose
  1785. one operating mode each time you employ the @command{tar} program by
  1786. specifying one, and only one operation as an argument to the
  1787. @command{tar} command (two lists of four operations each may be found
  1788. at @ref{frequent operations} and @ref{Operations}). Depending on
  1789. circumstances, you may also wish to customize how the chosen operating
  1790. mode behaves. For example, you may wish to change the way the output
  1791. looks, or the format of the files that you wish to archive may require
  1792. you to do something special in order to make the archive look right.
  1793. You can customize and control @command{tar}'s performance by running
  1794. @command{tar} with one or more options (such as @value{op-verbose}, which
  1795. we used in the tutorial). As we said in the tutorial, @dfn{options} are
  1796. arguments to @command{tar} which are (as their name suggests) optional.
  1797. Depending on the operating mode, you may specify one or more options.
  1798. Different options will have different effects, but in general they all
  1799. change details of the operation, such as archive format, archive name,
  1800. or level of user interaction. Some options make sense with all
  1801. operating modes, while others are meaningful only with particular modes.
  1802. You will likely use some options frequently, while you will only use
  1803. others infrequently, or not at all. (A full list of options is
  1804. available in @pxref{All Options}.)
  1805. The @env{TAR_OPTIONS} environment variable specifies default options to
  1806. be placed in front of any explicit options. For example, if
  1807. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1808. if the two options @option{-v} and @option{--unlink-first} had been
  1809. specified before any explicit options. Option specifications are
  1810. separated by whitespace. A backslash escapes the next character, so it
  1811. can be used to specify an option containing whitespace or a backslash.
  1812. Note that @command{tar} options are case sensitive. For example, the
  1813. options @samp{-T} and @samp{-t} are different; the first requires an
  1814. argument for stating the name of a file providing a list of @var{name}s,
  1815. while the second does not require an argument and is another way to
  1816. write @value{op-list}.
  1817. In addition to the eight operations, there are many options to
  1818. @command{tar}, and three different styles for writing both: long (mnemonic)
  1819. form, short form, and old style. These styles are discussed below.
  1820. Both the options and the operations can be written in any of these three
  1821. styles.
  1822. @FIXME{menu at end of this node. need to think of an actual outline
  1823. for this chapter; probably do that after stuff from chap. 4 is
  1824. incorporated.}
  1825. @node Styles
  1826. @section The Three Option Styles
  1827. There are three styles for writing operations and options to the command
  1828. line invoking @command{tar}. The different styles were developed at
  1829. different times during the history of @command{tar}. These styles will be
  1830. presented below, from the most recent to the oldest.
  1831. Some options must take an argument. (For example, @value{op-file} takes
  1832. the name of an archive file as an argument. If you do not supply an
  1833. archive file name, @command{tar} will use a default, but this can be
  1834. confusing; thus, we recommend that you always supply a specific archive
  1835. file name.) Where you @emph{place} the arguments generally depends on
  1836. which style of options you choose. We will detail specific information
  1837. relevant to each option style in the sections on the different option
  1838. styles, below. The differences are subtle, yet can often be very
  1839. important; incorrect option placement can cause you to overwrite a
  1840. number of important files. We urge you to note these differences, and
  1841. only use the option style(s) which makes the most sense to you until you
  1842. feel comfortable with the others.
  1843. Some options @emph{may} take an argument (currently, there are
  1844. two such options: @value{op-backup} and @value{op-occurrence}). Such
  1845. options may have at most long and short forms, they do not have old style
  1846. equivalent. The rules for specifying an argument for such options
  1847. are stricter than those for specifying mandatory arguments. Please,
  1848. pay special attention to them.
  1849. @menu
  1850. * Mnemonic Options:: Mnemonic Option Style
  1851. * Short Options:: Short Option Style
  1852. * Old Options:: Old Option Style
  1853. * Mixing:: Mixing Option Styles
  1854. @end menu
  1855. @node Mnemonic Options
  1856. @subsection Mnemonic Option Style
  1857. @FIXME{have to decide whether or not to replace other occurrences of
  1858. "mnemonic" with "long", or *ugh* vice versa.}
  1859. Each option has at least one long (or mnemonic) name starting with two
  1860. dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
  1861. their corresponding short or old names. It sometimes happens that a
  1862. single mnemonic option has many different different names which are
  1863. synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
  1864. long option names can be given unique abbreviations. For example,
  1865. @samp{--cre} can be used in place of @samp{--create} because there is no
  1866. other mnemonic option which begins with @samp{cre}. (One way to find
  1867. this out is by trying it and seeing what happens; if a particular
  1868. abbreviation could represent more than one option, @command{tar} will tell
  1869. you that that abbreviation is ambiguous and you'll know that that
  1870. abbreviation won't work. You may also choose to run @samp{tar --help}
  1871. to see a list of options. Be aware that if you run @command{tar} with a
  1872. unique abbreviation for the long name of an option you didn't want to
  1873. use, you are stuck; @command{tar} will perform the command as ordered.)
  1874. Mnemonic options are meant to be obvious and easy to remember, and their
  1875. meanings are generally easier to discern than those of their
  1876. corresponding short options (see below). For example:
  1877. @smallexample
  1878. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1879. @end smallexample
  1880. @noindent
  1881. gives a fairly good set of hints about what the command does, even
  1882. for those not fully acquainted with @command{tar}.
  1883. Mnemonic options which require arguments take those arguments
  1884. immediately following the option name. There are two ways of
  1885. specifying a mandatory argument. It can be separated from the
  1886. option name either by an equal sign, or by any amount of
  1887. white space characters. For example, the @samp{--file} option (which
  1888. tells the name of the @command{tar} archive) is given a file such as
  1889. @file{archive.tar} as argument by using any of the following notations:
  1890. @samp{--file=archive.tar} or @samp{--file archive.tar}.
  1891. In contrast, optional arguments must always be introduced using
  1892. an equal sign. For example, the @samp{--backup} option takes
  1893. an optional argument specifying backup type. It must be used
  1894. as @samp{--backup=@var{backup-type}}.
  1895. @node Short Options
  1896. @subsection Short Option Style
  1897. Most options also have a short option name. Short options start with
  1898. a single dash, and are followed by a single character, e.g.@: @samp{-t}
  1899. (which is equivalent to @samp{--list}). The forms are absolutely
  1900. identical in function; they are interchangeable.
  1901. The short option names are faster to type than long option names.
  1902. Short options which require arguments take their arguments immediately
  1903. following the option, usually separated by white space. It is also
  1904. possible to stick the argument right after the short option name, using
  1905. no intervening space. For example, you might write @w{@samp{-f
  1906. archive.tar}} or @samp{-farchive.tar} instead of using
  1907. @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
  1908. @w{@samp{-f @var{archive-name}}} denote the option which indicates a
  1909. specific archive, here named @file{archive.tar}.
  1910. Short options which take optional arguments take their arguments
  1911. immediately following the option letter, @emph{without any intervening
  1912. white space characters}.
  1913. Short options' letters may be clumped together, but you are not
  1914. required to do this (as compared to old options; see below). When
  1915. short options are clumped as a set, use one (single) dash for them
  1916. all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
  1917. such a set is allowed to have an argument@footnote{Clustering many
  1918. options, the last of which has an argument, is a rather opaque way to
  1919. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1920. even be made helpful enough for considering such usages as invalid.}.
  1921. When the options are separated, the argument for each option which requires
  1922. an argument directly follows that option, as is usual for Unix programs.
  1923. For example:
  1924. @smallexample
  1925. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1926. @end smallexample
  1927. If you reorder short options' locations, be sure to move any arguments
  1928. that belong to them. If you do not move the arguments properly, you may
  1929. end up overwriting files.
  1930. @node Old Options
  1931. @subsection Old Option Style
  1932. @UNREVISED
  1933. Like short options, old options are single letters. However, old options
  1934. must be written together as a single clumped set, without spaces separating
  1935. them or dashes preceding them@footnote{Beware that if you precede options
  1936. with a dash, you are announcing the short option style instead of the
  1937. old option style; short options are decoded differently.}. This set
  1938. of letters must be the first to appear on the command line, after the
  1939. @command{tar} program name and some white space; old options cannot appear
  1940. anywhere else. The letter of an old option is exactly the same letter as
  1941. the corresponding short option. For example, the old option @samp{t} is
  1942. the same as the short option @samp{-t}, and consequently, the same as the
  1943. mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
  1944. cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
  1945. @FIXME{bob suggests having an uglier example. :-) }
  1946. When options that need arguments are given together with the command,
  1947. all the associated arguments follow, in the same order as the options.
  1948. Thus, the example given previously could also be written in the old
  1949. style as follows:
  1950. @smallexample
  1951. $ @kbd{tar cvbf 20 /dev/rmt0}
  1952. @end smallexample
  1953. @noindent
  1954. Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
  1955. the argument of @samp{-f}.
  1956. On the other hand, this old style syntax makes it difficult to match
  1957. option letters with their corresponding arguments, and is often
  1958. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1959. @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
  1960. argument for @samp{-f}, and @samp{-v} does not have a corresponding
  1961. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1962. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1963. pertain to.
  1964. If you want to reorder the letters in the old option argument, be
  1965. sure to reorder any corresponding argument appropriately.
  1966. This old way of writing @command{tar} options can surprise even experienced
  1967. users. For example, the two commands:
  1968. @smallexample
  1969. @kbd{tar cfz archive.tar.gz file}
  1970. @kbd{tar -cfz archive.tar.gz file}
  1971. @end smallexample
  1972. @noindent
  1973. are quite different. The first example uses @file{archive.tar.gz} as
  1974. the value for option @samp{f} and recognizes the option @samp{z}. The
  1975. second example, however, uses @file{z} as the value for option
  1976. @samp{f} --- probably not what was intended.
  1977. Old options are kept for compatibility with old versions of @command{tar}.
  1978. This second example could be corrected in many ways, among which the
  1979. following are equivalent:
  1980. @smallexample
  1981. @kbd{tar -czf archive.tar.gz file}
  1982. @kbd{tar -cf archive.tar.gz -z file}
  1983. @kbd{tar cf archive.tar.gz -z file}
  1984. @end smallexample
  1985. @FIXME{still could explain this better; it's redundant:}
  1986. @cindex option syntax, traditional
  1987. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1988. non-@acronym{GNU}, support old options. @GNUTAR{}
  1989. supports them not only for historical reasons, but also because many
  1990. people are used to them. For compatibility with Unix @command{tar},
  1991. the first argument is always treated as containing command and option
  1992. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1993. equivalent to @w{@samp{tar -c}:} both of them specify the
  1994. @value{op-create} command to create an archive.
  1995. @node Mixing
  1996. @subsection Mixing Option Styles
  1997. All three styles may be intermixed in a single @command{tar} command,
  1998. so long as the rules for each style are fully
  1999. respected@footnote{Before @GNUTAR{} version 1.11.6,
  2000. a bug prevented intermixing old style options with mnemonic options in
  2001. some cases.}. Old style options and either of the modern styles of
  2002. options may be mixed within a single @command{tar} command. However,
  2003. old style options must be introduced as the first arguments only,
  2004. following the rule for old options (old options must appear directly
  2005. after the @command{tar} command and some white space). Modern options
  2006. may be given only after all arguments to the old options have been
  2007. collected. If this rule is not respected, a modern option might be
  2008. falsely interpreted as the value of the argument to one of the old
  2009. style options.
  2010. For example, all the following commands are wholly equivalent, and
  2011. illustrate the many combinations and orderings of option styles.
  2012. @smallexample
  2013. @kbd{tar --create --file=archive.tar}
  2014. @kbd{tar --create -f archive.tar}
  2015. @kbd{tar --create -farchive.tar}
  2016. @kbd{tar --file=archive.tar --create}
  2017. @kbd{tar --file=archive.tar -c}
  2018. @kbd{tar -c --file=archive.tar}
  2019. @kbd{tar -c -f archive.tar}
  2020. @kbd{tar -c -farchive.tar}
  2021. @kbd{tar -cf archive.tar}
  2022. @kbd{tar -cfarchive.tar}
  2023. @kbd{tar -f archive.tar --create}
  2024. @kbd{tar -f archive.tar -c}
  2025. @kbd{tar -farchive.tar --create}
  2026. @kbd{tar -farchive.tar -c}
  2027. @kbd{tar c --file=archive.tar}
  2028. @kbd{tar c -f archive.tar}
  2029. @kbd{tar c -farchive.tar}
  2030. @kbd{tar cf archive.tar}
  2031. @kbd{tar f archive.tar --create}
  2032. @kbd{tar f archive.tar -c}
  2033. @kbd{tar fc archive.tar}
  2034. @end smallexample
  2035. On the other hand, the following commands are @emph{not} equivalent to
  2036. the previous set:
  2037. @smallexample
  2038. @kbd{tar -f -c archive.tar}
  2039. @kbd{tar -fc archive.tar}
  2040. @kbd{tar -fcarchive.tar}
  2041. @kbd{tar -farchive.tarc}
  2042. @kbd{tar cfarchive.tar}
  2043. @end smallexample
  2044. @noindent
  2045. These last examples mean something completely different from what the
  2046. user intended (judging based on the example in the previous set which
  2047. uses long options, whose intent is therefore very clear). The first
  2048. four specify that the @command{tar} archive would be a file named
  2049. @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  2050. respectively. The first two examples also specify a single non-option,
  2051. @var{name} argument having the value @samp{archive.tar}. The last
  2052. example contains only old style option letters (repeating option
  2053. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  2054. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  2055. the first sentence of this paragraph..}
  2056. @node All Options
  2057. @section All @command{tar} Options
  2058. The coming manual sections contain an alphabetical listing of all
  2059. @command{tar} operations and options, with brief descriptions and cross
  2060. references to more in-depth explanations in the body of the manual.
  2061. They also contain an alphabetically arranged table of the short option
  2062. forms with their corresponding long option. You can use this table as
  2063. a reference for deciphering @command{tar} commands in scripts.
  2064. @menu
  2065. * Operation Summary::
  2066. * Option Summary::
  2067. * Short Option Summary::
  2068. @end menu
  2069. @node Operation Summary
  2070. @subsection Operations
  2071. @table @kbd
  2072. @item --append
  2073. @itemx -r
  2074. Appends files to the end of the archive. @xref{append}.
  2075. @item --catenate
  2076. @itemx -A
  2077. Same as @samp{--concatenate}. @xref{concatenate}.
  2078. @item --compare
  2079. @itemx -d
  2080. Compares archive members with their counterparts in the file
  2081. system, and reports differences in file size, mode, owner,
  2082. modification date and contents. @xref{compare}.
  2083. @item --concatenate
  2084. @itemx -A
  2085. Appends other @command{tar} archives to the end of the archive.
  2086. @xref{concatenate}.
  2087. @item --create
  2088. @itemx -c
  2089. Creates a new @command{tar} archive. @xref{create}.
  2090. @item --delete
  2091. Deletes members from the archive. Don't try this on a archive on a
  2092. tape! @xref{delete}.
  2093. @item --diff
  2094. @itemx -d
  2095. Same @samp{--compare}. @xref{compare}.
  2096. @item --extract
  2097. @itemx -x
  2098. Extracts members from the archive into the file system. @xref{extract}.
  2099. @item --get
  2100. @itemx -x
  2101. Same as @samp{--extract}. @xref{extract}.
  2102. @item --list
  2103. @itemx -t
  2104. Lists the members in an archive. @xref{list}.
  2105. @item --update
  2106. @itemx -u
  2107. @FIXME{It was: A combination of the @samp{--compare} and
  2108. @samp{--append} operations. This is not true and rather misleading,
  2109. as @value{op-compare} does a lot more than @value{op-update} for
  2110. ensuring files are identical.} Adds files to the end of the archive,
  2111. but only if they are newer than their counterparts already in the
  2112. archive, or if they do not already exist in the archive.
  2113. @xref{update}.
  2114. @end table
  2115. @node Option Summary
  2116. @subsection @command{tar} Options
  2117. @table @kbd
  2118. @item --absolute-names
  2119. @itemx -P
  2120. Normally when creating an archive, @command{tar} strips an initial
  2121. @samp{/} from member names. This option disables that behavior.
  2122. @FIXME-xref{}
  2123. @item --after-date
  2124. (See @samp{--newer}.) @FIXME-pxref{}
  2125. @item --anchored
  2126. An exclude pattern must match an initial subsequence of the name's components.
  2127. @FIXME-xref{}
  2128. @item --atime-preserve
  2129. Tells @command{tar} to preserve the access time field in a file's inode when
  2130. reading it. Due to limitations in the @code{utimes} system call, the
  2131. modification time field is also preserved, which may cause problems if
  2132. the file is simultaneously being modified by another program.
  2133. This option is incompatible with incremental backups, because
  2134. preserving the access time involves updating the last-changed time.
  2135. Also, this option does not work on files that you do not own,
  2136. unless you're root.
  2137. @FIXME-xref{}
  2138. @item --backup=@var{backup-type}
  2139. Rather than deleting files from the file system, @command{tar} will
  2140. back them up using simple or numbered backups, depending upon
  2141. @var{backup-type}. @FIXME-xref{}
  2142. @item --block-number
  2143. @itemx -R
  2144. With this option present, @command{tar} prints error messages for read errors
  2145. with the block number in the archive file. @FIXME-xref{}
  2146. @item --blocking-factor=@var{blocking}
  2147. @itemx -b @var{blocking}
  2148. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  2149. record. @FIXME-xref{}
  2150. @item --bzip2
  2151. @itemx -j
  2152. This option tells @command{tar} to read or write archives through
  2153. @code{bzip2}. @FIXME-xref{}
  2154. @item --checkpoint
  2155. This option directs @command{tar} to print periodic checkpoint messages as it
  2156. reads through the archive. Its intended for when you want a visual
  2157. indication that @command{tar} is still running, but don't want to see
  2158. @samp{--verbose} output. @FIXME-xref{}
  2159. @item --check-links
  2160. @itemx -l
  2161. If this option was given, @command{tar} will check the number of links
  2162. dumped for each processed file. If this number does not match the
  2163. total number of hard links for the file, a warning message will be
  2164. output.
  2165. Future versions will take @option{-l} as a short version of
  2166. @option{--check-links}. However, current release still retains the old
  2167. semantics for @option{-l}.
  2168. @xref{Current status}, for more information.
  2169. @item --compress
  2170. @itemx --uncompress
  2171. @itemx -Z
  2172. @command{tar} will use the @command{compress} program when reading or
  2173. writing the archive. This allows you to directly act on archives
  2174. while saving space. @FIXME-xref{}
  2175. @item --confirmation
  2176. (See @samp{--interactive}.) @FIXME-pxref{}
  2177. @item --dereference
  2178. @itemx -h
  2179. When creating a @command{tar} archive, @command{tar} will archive the
  2180. file that a symbolic link points to, rather than archiving the
  2181. symlink. @FIXME-xref{}
  2182. @item --directory=@var{dir}
  2183. @itemx -C @var{dir}
  2184. When this option is specified, @command{tar} will change its current directory
  2185. to @var{dir} before performing any operations. When this option is used
  2186. during archive creation, it is order sensitive. @FIXME-xref{}
  2187. @item --exclude=@var{pattern}
  2188. When performing operations, @command{tar} will skip files that match
  2189. @var{pattern}. @FIXME-xref{}
  2190. @item --exclude-from=@var{file}
  2191. @itemx -X @var{file}
  2192. Similar to @samp{--exclude}, except @command{tar} will use the list of
  2193. patterns in the file @var{file}. @FIXME-xref{}
  2194. @item --file=@var{archive}
  2195. @itemx -f @var{archive}
  2196. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2197. performs operations on, rather than @command{tar}'s compilation dependent
  2198. default. @FIXME-xref{}
  2199. @item --files-from=@var{file}
  2200. @itemx -T @var{file}
  2201. @command{tar} will use the contents of @var{file} as a list of archive members
  2202. or files to operate on, in addition to those specified on the
  2203. command-line. @FIXME-xref{}
  2204. @item --force-local
  2205. Forces @command{tar} to interpret the filename given to @samp{--file}
  2206. as a local file, even if it looks like a remote tape drive name.
  2207. @FIXME-xref{}
  2208. @item --format=@var{format}
  2209. Selects output archive format. @var{Format} may be one of the
  2210. following:
  2211. @table @samp
  2212. @item v7
  2213. Creates an archive that is compatible with Unix V7 @command{tar}.
  2214. @item oldgnu
  2215. Creates an archive that is compatible with GNU @command{tar} version
  2216. 1.12 or earlier.
  2217. @item gnu
  2218. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2219. @samp{oldgnu} with the only difference in the way it handles long
  2220. numeric fields.
  2221. @item ustar
  2222. Creates a @acronym{POSIX.1-1988} compatible archive.
  2223. @item posix
  2224. Creates a @acronym{POSIX.1-2001 archive}.
  2225. @end table
  2226. @xref{Formats}, for a detailed discussion of these formats.
  2227. @item --group=@var{group}
  2228. Files added to the @command{tar} archive will have a group id of @var{group},
  2229. rather than the group from the source file. @var{group} is first decoded
  2230. as a group symbolic name, but if this interpretation fails, it has to be
  2231. a decimal numeric group ID. @FIXME-xref{}
  2232. Also see the comments for the @value{op-owner} option.
  2233. @item --gzip
  2234. @itemx --gunzip
  2235. @itemx --ungzip
  2236. @itemx -z
  2237. This option tells @command{tar} to read or write archives through
  2238. @command{gzip}, allowing @command{tar} to directly operate on several
  2239. kinds of compressed archives transparently. @FIXME-xref{}
  2240. @item --help
  2241. @command{tar} will print out a short message summarizing the operations and
  2242. options to @command{tar} and exit. @FIXME-xref{}
  2243. @item --ignore-case
  2244. Ignore case when excluding files.
  2245. @FIXME-xref{}
  2246. @item --ignore-failed-read
  2247. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2248. @xref{Reading}.
  2249. @item --ignore-zeros
  2250. @itemx -i
  2251. With this option, @command{tar} will ignore zeroed blocks in the
  2252. archive, which normally signals EOF. @xref{Reading}.
  2253. @item --incremental
  2254. @itemx -G
  2255. Used to inform @command{tar} that it is working with an old
  2256. @acronym{GNU}-format incremental backup archive. It is intended
  2257. primarily for backwards compatibility only. @FIXME-xref{}
  2258. @item --index-file=@var{file}
  2259. Send verbose output to @var{file} instead of to standard output.
  2260. @item --info-script=@var{script-file}
  2261. @itemx --new-volume-script=@var{script-file}
  2262. @itemx -F @var{script-file}
  2263. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2264. at the end of each tape. If @var{script-file} exits with nonzero status,
  2265. @command{tar} fails immediately. @FIXME-xref{}
  2266. @item --interactive
  2267. @itemx --confirmation
  2268. @itemx -w
  2269. Specifies that @command{tar} should ask the user for confirmation before
  2270. performing potentially destructive options, such as overwriting files.
  2271. @FIXME-xref{}
  2272. @item --keep-newer-files
  2273. Do not replace existing files that are newer than their archive copies
  2274. when extracting files from an archive.
  2275. @item --keep-old-files
  2276. @itemx -k
  2277. Do not overwrite existing files when extracting files from an archive.
  2278. @xref{Writing}.
  2279. @item --label=@var{name}
  2280. @itemx -V @var{name}
  2281. When creating an archive, instructs @command{tar} to write @var{name}
  2282. as a name record in the archive. When extracting or listing archives,
  2283. @command{tar} will only operate on archives that have a label matching
  2284. the pattern specified in @var{name}. @FIXME-xref{}
  2285. @item --listed-incremental=@var{snapshot-file}
  2286. @itemx -g @var{snapshot-file}
  2287. During a @samp{--create} operation, specifies that the archive that
  2288. @command{tar} creates is a new @acronym{GNU}-format incremental
  2289. backup, using @var{snapshot-file} to determine which files to backup.
  2290. With other operations, informs @command{tar} that the archive is in
  2291. incremental format. @FIXME-xref{}
  2292. @item --mode=@var{permissions}
  2293. When adding files to an archive, @command{tar} will use
  2294. @var{permissions} for the archive members, rather than the permissions
  2295. from the files. The program @command{chmod} and this @command{tar}
  2296. option share the same syntax for what @var{permissions} might be.
  2297. @xref{File permissions, Permissions, File permissions, fileutils,
  2298. @acronym{GNU} file utilities}. This reference also has useful
  2299. information for those not being overly familiar with the Unix
  2300. permission system.
  2301. Of course, @var{permissions} might be plainly specified as an octal number.
  2302. However, by using generic symbolic modifications to mode bits, this allows
  2303. more flexibility. For example, the value @samp{a+rw} adds read and write
  2304. permissions for everybody, while retaining executable bits on directories
  2305. or on any other file already marked as executable.
  2306. @item --multi-volume
  2307. @itemx -M
  2308. Informs @command{tar} that it should create or otherwise operate on a
  2309. multi-volume @command{tar} archive. @FIXME-xref{}
  2310. @item --new-volume-script
  2311. (see --info-script)
  2312. @item --newer=@var{date}
  2313. @itemx --after-date=@var{date}
  2314. @itemx -N
  2315. When creating an archive, @command{tar} will only add files that have changed
  2316. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2317. is taken to be the name of a file whose last-modified time specifies
  2318. the date. @FIXME-xref{}
  2319. @item --newer-mtime=@var{date}
  2320. Like @samp{--newer}, but add only files whose
  2321. contents have changed (as opposed to just @samp{--newer}, which will
  2322. also back up files for which any status information has changed).
  2323. @item --no-anchored
  2324. An exclude pattern can match any subsequence of the name's components.
  2325. @FIXME-xref{}
  2326. @item --no-ignore-case
  2327. Use case-sensitive matching when excluding files.
  2328. @FIXME-xref{}
  2329. @item --no-recursion
  2330. With this option, @command{tar} will not recurse into directories.
  2331. @FIXME-xref{}
  2332. @item --no-same-owner
  2333. @itemx -o
  2334. When extracting an archive, do not attempt to preserve the owner
  2335. specified in the @command{tar} archive. This the default behavior
  2336. for ordinary users; this option has an effect only for the superuser.
  2337. @item --no-same-permissions
  2338. When extracting an archive, subtract the user's umask from files from
  2339. the permissions specified in the archive. This is the default behavior
  2340. for ordinary users; this option has an effect only for the superuser.
  2341. @item --no-wildcards
  2342. Do not use wildcards when excluding files.
  2343. @FIXME-xref{}
  2344. @item --no-wildcards-match-slash
  2345. Wildcards do not match @samp{/} when excluding files.
  2346. @FIXME-xref{}
  2347. @item --null
  2348. When @command{tar} is using the @samp{--files-from} option, this option
  2349. instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
  2350. @command{tar} can correctly work with file names that contain newlines.
  2351. @FIXME-xref{}
  2352. @item --numeric-owner
  2353. This option will notify @command{tar} that it should use numeric user
  2354. and group IDs when creating a @command{tar} file, rather than names.
  2355. @FIXME-xref{}
  2356. @item -o
  2357. When extracting files, this option is a synonym for
  2358. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2359. restoring ownership of files being extracted.
  2360. When creating an archive, @option{-o} is a synonym for
  2361. @option{--old-archive}. This behavior is for compatibility
  2362. with previous versions of @GNUTAR{}, and will be
  2363. removed in the future releases.
  2364. @xref{Current status}, for more information.
  2365. @item --occurrence[=@var{number}]
  2366. This option can be used in conjunction with one of the subcommands
  2367. @option{--delete}, @option{--diff}, @option{--extract} or
  2368. @option{--list} when a list of files is given either on the command
  2369. line or via @option{-T} option.
  2370. This option instructs @command{tar} to process only the @var{number}th
  2371. occurrence of each named file. @var{Number} defaults to 1, so
  2372. @smallexample
  2373. tar -x -f archive.tar --occurrence filename
  2374. @end smallexample
  2375. @noindent
  2376. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2377. and will terminate without scanning to the end of the archive.
  2378. @item --old-archive
  2379. Synonym for @option{--format=v7}.
  2380. @item --one-file-system
  2381. @itemx -l
  2382. Used when creating an archive. Prevents @command{tar} from recursing into
  2383. directories that are on different file systems from the current
  2384. directory.
  2385. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2386. synonym for @option{--one-file-system}. Although such usage is still
  2387. allowed in the present version, it is @emph{strongly discouraged}.
  2388. The future versions of @GNUTAR{} will use @option{-l} as
  2389. a synonym for @option{--check-links}.
  2390. @xref{Current status}, for more information.
  2391. @item --overwrite
  2392. Overwrite existing files and directory metadata when extracting files
  2393. from an archive. @xref{Overwrite Old Files}.
  2394. @item --overwrite-dir
  2395. Overwrite the metadata of existing directories when extracting files
  2396. from an archive. @xref{Overwrite Old Files}.
  2397. @item --owner=@var{user}
  2398. Specifies that @command{tar} should use @var{user} as the owner of members
  2399. when creating archives, instead of the user associated with the source
  2400. file. @var{user} is first decoded as a user symbolic name, but if
  2401. this interpretation fails, it has to be a decimal numeric user ID.
  2402. @FIXME-xref{}
  2403. There is no value indicating a missing number, and @samp{0} usually means
  2404. @code{root}. Some people like to force @samp{0} as the value to offer in
  2405. their distributions for the owner of files, because the @code{root} user is
  2406. anonymous anyway, so that might as well be the owner of anonymous archives.
  2407. This option does not affect extraction from archives.
  2408. @item --pax-option=@var{keyword-list}
  2409. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2410. (@FIXME-xref{}). It modifies the way @command{tar} handles the
  2411. extended header keywords. @var{Keyword-list} is a comma-separated
  2412. list of keyword options, each keyword option taking one of
  2413. the following forms:
  2414. @table @asis
  2415. @item delete=@var{pattern}
  2416. When used with one of archive-creation command (@FIXME-xref{}),
  2417. this option instructs @command{tar} to omit from extended header records
  2418. that it produces any keywords matching the string @var{pattern}.
  2419. When used in extract or list mode, this option instructs tar
  2420. to ignore any keywords matching the given @var{pattern} in the extended
  2421. header records. In both cases, matching is performed using the pattern
  2422. matching notation described in @acronym{POSIX 1003.2}, 3.13 @FIXME-xref{see
  2423. man 7 glob}. For example:
  2424. @smallexample
  2425. --pax-option delete=security.*
  2426. @end smallexample
  2427. would suppress security-related information.
  2428. @item exthdr.name=@var{string}
  2429. This keyword allows user control over the name that is written into the
  2430. ustar header blocks for the extended headers. The name is obtained
  2431. from @var{string} after substituting the following meta-characters:
  2432. @multitable @columnfractions .30 .70
  2433. @item Meta-character @tab Replaced By
  2434. @item %d @tab The directory name of the file, equivalent to the
  2435. result of the @command{dirname} utility on the translated pathname.
  2436. @item %f @tab The filename of the file, equivalent to the result
  2437. of the @command{basename} utility on the translated pathname.
  2438. @item %p @tab The process ID of the @command{tar} process.
  2439. @item %% @tab A @samp{%} character.
  2440. @end multitable
  2441. Any other @samp{%} characters in @var{string} produce undefined
  2442. results.
  2443. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2444. will use the following default value:
  2445. @smallexample
  2446. %d/PaxHeaders.%p/%f
  2447. @end smallexample
  2448. @item globexthdr.name=@var{string}
  2449. This keyword allows user control over the name that is written into
  2450. the ustar header blocks for global extended header records. The name
  2451. shall will be obtained from the contents of @var{string}, after the
  2452. following character substitutions have been made:
  2453. @multitable @columnfractions .30 .70
  2454. @item Meta-character @tab Replaced By
  2455. @item %n @tab An integer that represents the
  2456. sequence number of the global extended header record in the archive,
  2457. starting at 1.
  2458. @item %p @tab The process ID of the @command{tar} process.
  2459. @item %% @tab A @samp{%} character.
  2460. @end multitable
  2461. Any other @samp{%} characters in string produce undefined results.
  2462. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2463. will use the following default value:
  2464. @smallexample
  2465. $TMPDIR/GlobalHead.%p.%n
  2466. @end smallexample
  2467. @noindent
  2468. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2469. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2470. uses @samp{/tmp}.
  2471. @item @var{keyword}=@var{value}
  2472. When used with one of archive-creation commands, these keyword/value pairs
  2473. will be included at the beginning of the archive in a global extended
  2474. header record. When used with one of archive-reading commands,
  2475. @command{tar} will behave as if it has encountered these keyword/value
  2476. pairs at the beginning of the archive in a global extended header
  2477. record.
  2478. @item @var{keyword}:=@var{value}
  2479. When used with one of archive-creation commands, these keyword/value pairs
  2480. will be included as records at the beginning of an extended header for
  2481. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2482. form except that it creates no global extended header records.
  2483. When used with one of archive-reading commands, @command{tar} will
  2484. behave as if these keyword/value pairs were included as records at the
  2485. end of each extended header; thus, they will override any global or
  2486. file-specific extended header record keywords of the same names.
  2487. For example, in the command:
  2488. @smallexample
  2489. tar --format=posix --create \
  2490. --file archive --pax-option gname:=user .
  2491. @end smallexample
  2492. the group name will be forced to a new value for all files
  2493. stored in the archive.
  2494. @end table
  2495. @item --portability
  2496. @itemx --old-archive
  2497. Synonym for @option{--format=v7}.
  2498. @item --posix
  2499. Same as @option{--format=posix}.
  2500. @item --preserve
  2501. Synonymous with specifying both @samp{--preserve-permissions} and
  2502. @samp{--same-order}. @FIXME-xref{}
  2503. @item --preserve-order
  2504. (See @samp{--same-order}; @pxref{Reading}.)
  2505. @item --preserve-permissions
  2506. @itemx --same-permissions
  2507. @itemx -p
  2508. When @command{tar} is extracting an archive, it normally subtracts the
  2509. users' umask from the permissions specified in the archive and uses
  2510. that number as the permissions to create the destination file.
  2511. Specifying this option instructs @command{tar} that it should use the
  2512. permissions directly from the archive. @xref{Writing}.
  2513. @item --read-full-records
  2514. @itemx -B
  2515. Specifies that @command{tar} should reblock its input, for reading
  2516. from pipes on systems with buggy implementations. @xref{Reading}.
  2517. @item --record-size=@var{size}
  2518. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2519. archive. @FIXME-xref{}
  2520. @item --recursion
  2521. With this option, @command{tar} recurses into directories.
  2522. @FIXME-xref{}
  2523. @item --recursive-unlink
  2524. Remove existing
  2525. directory hierarchies before extracting directories of the same name
  2526. from the archive. @xref{Writing}.
  2527. @item --remove-files
  2528. Directs @command{tar} to remove the source file from the file system after
  2529. appending it to an archive. @FIXME-xref{}
  2530. @item --rmt-command=@var{cmd}
  2531. Notifies @command{tar} that it should use @var{cmd} instead of
  2532. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2533. @item --rsh-command=@var{cmd}
  2534. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2535. devices. @FIXME-xref{}
  2536. @item --same-order
  2537. @itemx --preserve-order
  2538. @itemx -s
  2539. This option is an optimization for @command{tar} when running on machines with
  2540. small amounts of memory. It informs @command{tar} that the list of file
  2541. arguments has already been sorted to match the order of files in the
  2542. archive. @xref{Reading}.
  2543. @item --same-owner
  2544. When extracting an archive, @command{tar} will attempt to preserve the owner
  2545. specified in the @command{tar} archive with this option present.
  2546. This is the default behavior for the superuser; this option has an
  2547. effect only for ordinary users. @FIXME-xref{}
  2548. @item --same-permissions
  2549. (See @samp{--preserve-permissions}; @pxref{Writing}.)
  2550. @item --show-defaults
  2551. Displays the default options used by @command{tar} and exits
  2552. successfully. This option is intended for use in shell scripts.
  2553. Here is an example of what you can see using this option:
  2554. @smallexample
  2555. $ tar --show-defaults
  2556. --format=gnu -f- -b20
  2557. @end smallexample
  2558. @item --show-omitted-dirs
  2559. Instructs @command{tar} to mention directories its skipping over when
  2560. operating on a @command{tar} archive. @FIXME-xref{}
  2561. @item --sparse
  2562. @itemx -S
  2563. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2564. sparse files efficiently. @FIXME-xref{}
  2565. @item --starting-file=@var{name}
  2566. @itemx -K @var{name}
  2567. This option affects extraction only; @command{tar} will skip extracting
  2568. files in the archive until it finds one that matches @var{name}.
  2569. @xref{Scarce}.
  2570. @item --strip-components=@var{number}
  2571. Strip given @var{number} of leading components from file names before
  2572. extraction.@footnote{This option was called @option{--strip-path} in
  2573. version 1.14.} For example, if archive @file{archive.tar} contained
  2574. @file{/some/file/name}, then running
  2575. @smallexample
  2576. tar --extract --file archive.tar --strip-components=2
  2577. @end smallexample
  2578. @noindent
  2579. would extracted this file to file @file{name}.
  2580. @item --suffix=@var{suffix}
  2581. Alters the suffix @command{tar} uses when backing up files from the default
  2582. @samp{~}. @FIXME-xref{}
  2583. @item --tape-length=@var{num}
  2584. @itemx -L @var{num}
  2585. Specifies the length of tapes that @command{tar} is writing as being
  2586. @w{@var{num} x 1024} bytes long. @FIXME-xref{}
  2587. @item --to-stdout
  2588. @itemx -O
  2589. During extraction, @command{tar} will extract files to stdout rather
  2590. than to the file system. @xref{Writing}.
  2591. @item --totals
  2592. Displays the total number of bytes written after creating an archive.
  2593. @FIXME-xref{}
  2594. @item --touch
  2595. @itemx -m
  2596. Sets the modification time of extracted files to the extraction time,
  2597. rather than the modification time stored in the archive.
  2598. @xref{Writing}.
  2599. @item --uncompress
  2600. (See @samp{--compress}.) @FIXME-pxref{}
  2601. @item --ungzip
  2602. (See @samp{--gzip}.) @FIXME-pxref{}
  2603. @item --unlink-first
  2604. @itemx -U
  2605. Directs @command{tar} to remove the corresponding file from the file
  2606. system before extracting it from the archive. @xref{Writing}.
  2607. @item --use-compress-program=@var{prog}
  2608. Instructs @command{tar} to access the archive through @var{prog}, which is
  2609. presumed to be a compression program of some sort. @FIXME-xref{}
  2610. @item --utc
  2611. Display file modification dates in @acronym{UTC}. This option implies
  2612. @samp{--verbose}.
  2613. @item --verbose
  2614. @itemx -v
  2615. Specifies that @command{tar} should be more verbose about the operations its
  2616. performing. This option can be specified multiple times for some
  2617. operations to increase the amount of information displayed. @FIXME-xref{}
  2618. @item --verify
  2619. @itemx -W
  2620. Verifies that the archive was correctly written when creating an
  2621. archive. @FIXME-xref{}
  2622. @item --version
  2623. @command{tar} will print an informational message about what version
  2624. it is and a copyright message, some credits, and then exit.
  2625. @FIXME-xref{}
  2626. @item --volno-file=@var{file}
  2627. Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
  2628. of which volume of a multi-volume archive its working in @var{file}.
  2629. @FIXME-xref{}
  2630. @item --wildcards
  2631. Use wildcards when excluding files.
  2632. @FIXME-xref{}
  2633. @item --wildcards-match-slash
  2634. Wildcards match @samp{/} when excluding files.
  2635. @FIXME-xref{}
  2636. @end table
  2637. @node Short Option Summary
  2638. @subsection Short Options Cross Reference
  2639. Here is an alphabetized list of all of the short option forms, matching
  2640. them with the equivalent long option.
  2641. @table @kbd
  2642. @item -A
  2643. @samp{--concatenate}
  2644. @item -B
  2645. @samp{--read-full-records}
  2646. @item -C
  2647. @samp{--directory}
  2648. @item -F
  2649. @samp{--info-script}
  2650. @item -G
  2651. @samp{--incremental}
  2652. @item -K
  2653. @samp{--starting-file}
  2654. @item -L
  2655. @samp{--tape-length}
  2656. @item -M
  2657. @samp{--multi-volume}
  2658. @item -N
  2659. @samp{--newer}
  2660. @item -O
  2661. @samp{--to-stdout}
  2662. @item -P
  2663. @samp{--absolute-names}
  2664. @item -R
  2665. @samp{--block-number}
  2666. @item -S
  2667. @samp{--sparse}
  2668. @item -T
  2669. @samp{--files-from}
  2670. @item -U
  2671. @samp{--unlink-first}
  2672. @item -V
  2673. @samp{--label}
  2674. @item -W
  2675. @samp{--verify}
  2676. @item -X
  2677. @samp{--exclude-from}
  2678. @item -Z
  2679. @samp{--compress}
  2680. @item -b
  2681. @samp{--blocking-factor}
  2682. @item -c
  2683. @samp{--create}
  2684. @item -d
  2685. @samp{--compare}
  2686. @item -f
  2687. @samp{--file}
  2688. @item -g
  2689. @samp{--listed-incremental}
  2690. @item -h
  2691. @samp{--dereference}
  2692. @item -i
  2693. @samp{--ignore-zeros}
  2694. @item -j
  2695. @samp{--bzip2}
  2696. @item -k
  2697. @samp{--keep-old-files}
  2698. @item -l
  2699. @samp{--one-file-system}. Use of this short option is deprecated. It
  2700. is retained for compatibility with the earlier versions of GNU
  2701. @command{tar}, and will be changed in future releases.
  2702. @xref{Current status}, for more information.
  2703. @item -m
  2704. @samp{--touch}
  2705. @item -o
  2706. When creating --- @samp{--no-same-owner}, when extracting ---
  2707. @samp{--portability}.
  2708. The later usage is deprecated. It is retained for compatibility with
  2709. the earlier versions of @GNUTAR{}. In the future releases
  2710. @option{-o} will be equivalent to @samp{--no-same-owner} only.
  2711. @item -p
  2712. @samp{--preserve-permissions}
  2713. @item -r
  2714. @samp{--append}
  2715. @item -s
  2716. @samp{--same-order}
  2717. @item -t
  2718. @samp{--list}
  2719. @item -u
  2720. @samp{--update}
  2721. @item -v
  2722. @samp{--verbose}
  2723. @item -w
  2724. @samp{--interactive}
  2725. @item -x
  2726. @samp{--extract}
  2727. @item -z
  2728. @samp{--gzip}
  2729. @end table
  2730. @node help
  2731. @section @GNUTAR{} documentation
  2732. Being careful, the first thing is really checking that you are using
  2733. @GNUTAR{}, indeed. The @value{op-version} option
  2734. will generate a message giving confirmation that you are using
  2735. @GNUTAR{}, with the precise version of @GNUTAR{}
  2736. you are using. @command{tar} identifies itself and
  2737. prints the version number to the standard output, then immediately
  2738. exits successfully, without doing anything else, ignoring all other
  2739. options. For example, @w{@samp{tar --version}} might return:
  2740. @smallexample
  2741. tar (@acronym{GNU} tar) @value{VERSION}
  2742. @end smallexample
  2743. @noindent
  2744. The first occurrence of @samp{tar} in the result above is the program
  2745. name in the package (for example, @command{rmt} is another program),
  2746. while the second occurrence of @samp{tar} is the name of the package
  2747. itself, containing possibly many programs. The package is currently
  2748. named @samp{tar}, after the name of the main program it
  2749. contains@footnote{There are plans to merge the @command{cpio} and
  2750. @command{tar} packages into a single one which would be called
  2751. @code{paxutils}. So, who knows if, one of this days, the
  2752. @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
  2753. paxutils) 3.2}}}.
  2754. Another thing you might want to do is checking the spelling or meaning
  2755. of some particular @command{tar} option, without resorting to this
  2756. manual, for once you have carefully read it. @GNUTAR{}
  2757. has a short help feature, triggerable through the
  2758. @value{op-help} option. By using this option, @command{tar} will
  2759. print a usage message listing all available options on standard
  2760. output, then exit successfully, without doing anything else and
  2761. ignoring all other options. Even if this is only a brief summary, it
  2762. may be several screens long. So, if you are not using some kind of
  2763. scrollable window, you might prefer to use something like:
  2764. @smallexample
  2765. $ @kbd{tar --help | less}
  2766. @end smallexample
  2767. @noindent
  2768. presuming, here, that you like using @command{less} for a pager. Other
  2769. popular pagers are @command{more} and @command{pg}. If you know about some
  2770. @var{keyword} which interests you and do not want to read all the
  2771. @value{op-help} output, another common idiom is doing:
  2772. @smallexample
  2773. tar --help | grep @var{keyword}
  2774. @end smallexample
  2775. @noindent
  2776. for getting only the pertinent lines.
  2777. The perceptive reader would have noticed some contradiction in the
  2778. previous paragraphs. It is written that both @value{op-version} and
  2779. @value{op-help} print something, and have all other options ignored. In
  2780. fact, they cannot ignore each other, and one of them has to win. We do
  2781. not specify which is stronger, here; experiment if you really wonder!
  2782. The short help output is quite succinct, and you might have to get
  2783. back to the full documentation for precise points. If you are reading
  2784. this paragraph, you already have the @command{tar} manual in some
  2785. form. This manual is available in printed form, as a kind of small
  2786. book. It may printed out of the @GNUTAR{}
  2787. distribution, provided you have @TeX{} already installed somewhere,
  2788. and a laser printer around. Just configure the distribution, execute
  2789. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2790. usual way (contact your local guru to know how). If @GNUTAR{}
  2791. has been conveniently installed at your place, this
  2792. manual is also available in interactive, hypertextual form as an Info
  2793. file. Just call @w{@samp{info tar}} or, if you do not have the
  2794. @command{info} program handy, use the Info reader provided within
  2795. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2796. There is currently no @code{man} page for @GNUTAR{}.
  2797. If you observe such a @code{man} page on the system you are running,
  2798. either it does not long to @GNUTAR{}, or it has not
  2799. been produced by @acronym{GNU}. Currently, @GNUTAR{}
  2800. documentation is provided in Texinfo format only, if we
  2801. except, of course, the short result of @kbd{tar --help}.
  2802. @node verbose
  2803. @section Checking @command{tar} progress
  2804. @cindex Progress information
  2805. @cindex Status information
  2806. @cindex Information on progress and status of operations
  2807. @cindex Verbose operation
  2808. @cindex Block number where error occurred
  2809. @cindex Error message, block number of
  2810. @cindex Version of the @command{tar} program
  2811. @cindex Getting more information during the operation
  2812. @cindex Information during operation
  2813. @cindex Feedback from @command{tar}
  2814. Typically, @command{tar} performs most operations without reporting any
  2815. information to the user except error messages. When using @command{tar}
  2816. with many options, particularly ones with complicated or
  2817. difficult-to-predict behavior, it is possible to make serious mistakes.
  2818. @command{tar} provides several options that make observing @command{tar}
  2819. easier. These options cause @command{tar} to print information as it
  2820. progresses in its job, and you might want to use them just for being
  2821. more careful about what is going on, or merely for entertaining
  2822. yourself. If you have encountered a problem when operating on an
  2823. archive, however, you may need more information than just an error
  2824. message in order to solve the problem. The following options can be
  2825. helpful diagnostic tools.
  2826. Normally, the @value{op-list} command to list an archive prints just
  2827. the file names (one per line) and the other commands are silent.
  2828. When used with most operations, the @value{op-verbose} option causes
  2829. @command{tar} to print the name of each file or archive member as it
  2830. is processed. This and the other options which make @command{tar} print
  2831. status information can be useful in monitoring @command{tar}.
  2832. With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
  2833. just prints the names of the files or members as they are processed.
  2834. Using it twice causes @command{tar} to print a longer listing (reminiscent
  2835. of @samp{ls -l}) for each member. Since @value{op-list} already prints
  2836. the names of the members, @value{op-verbose} used once with @value{op-list}
  2837. causes @command{tar} to print an @samp{ls -l} type listing of the files
  2838. in the archive. The following examples both extract members with
  2839. long list output:
  2840. @smallexample
  2841. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2842. $ @kbd{tar xvvf archive.tar}
  2843. @end smallexample
  2844. Verbose output appears on the standard output except when an archive is
  2845. being written to the standard output, as with @samp{tar --create
  2846. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2847. installer let standard output be the default archive). In that case
  2848. @command{tar} writes verbose output to the standard error stream.
  2849. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2850. verbose output to @var{file} rather than to standard output or standard
  2851. error.
  2852. The @value{op-totals} option---which is only meaningful when used with
  2853. @value{op-create}---causes @command{tar} to print the total
  2854. amount written to the archive, after it has been fully created.
  2855. The @value{op-checkpoint} option prints an occasional message
  2856. as @command{tar} reads or writes the archive. In fact, it prints
  2857. a message each 10 records read or written. It is designed for
  2858. those who don't need the more detailed (and voluminous) output of
  2859. @value{op-block-number}, but do want visual confirmation that @command{tar}
  2860. is actually making forward progress.
  2861. @FIXME{There is some confusion here. It seems that -R once wrote a
  2862. message at @samp{every} record read or written.}
  2863. The @value{op-show-omitted-dirs} option, when reading an archive---with
  2864. @value{op-list} or @value{op-extract}, for example---causes a message
  2865. to be printed for each directory in the archive which is skipped.
  2866. This happens regardless of the reason for skipping: the directory might
  2867. not have been named on the command line (implicitly or explicitly),
  2868. it might be excluded by the use of the @value{op-exclude} option, or
  2869. some other reason.
  2870. If @value{op-block-number} is used, @command{tar} prints, along with
  2871. every message it would normally produce, the block number within the
  2872. archive where the message was triggered. Also, supplementary messages
  2873. are triggered when reading blocks full of NULs, or when hitting end of
  2874. file on the archive. As of now, if the archive if properly terminated
  2875. with a NUL block, the reading of the file may stop before end of file
  2876. is met, so the position of end of file will not usually show when
  2877. @value{op-block-number} is used. Note that @GNUTAR{}
  2878. drains the archive before exiting when reading the
  2879. archive from a pipe.
  2880. This option is especially useful when reading damaged archives, since
  2881. it helps pinpoint the damaged sections. It can also be used with
  2882. @value{op-list} when listing a file-system backup tape, allowing you to
  2883. choose among several backup tapes when retrieving a file later, in
  2884. favor of the tape where the file appears earliest (closest to the
  2885. front of the tape). @FIXME-xref{when the node name is set and the
  2886. backup section written.}
  2887. @node interactive
  2888. @section Asking for Confirmation During Operations
  2889. @cindex Interactive operation
  2890. Typically, @command{tar} carries out a command without stopping for
  2891. further instructions. In some situations however, you may want to
  2892. exclude some files and archive members from the operation (for instance
  2893. if disk or storage space is tight). You can do this by excluding
  2894. certain files automatically (@pxref{Choosing}), or by performing
  2895. an operation interactively, using the @value{op-interactive} option.
  2896. @command{tar} also accepts @samp{--confirmation} for this option.
  2897. When the @value{op-interactive} option is specified, before
  2898. reading, writing, or deleting files, @command{tar} first prints a message
  2899. for each such file, telling what operation it intends to take, then asks
  2900. for confirmation on the terminal. The actions which require
  2901. confirmation include adding a file to the archive, extracting a file
  2902. from the archive, deleting a file from the archive, and deleting a file
  2903. from disk. To confirm the action, you must type a line of input
  2904. beginning with @samp{y}. If your input line begins with anything other
  2905. than @samp{y}, @command{tar} skips that file.
  2906. If @command{tar} is reading the archive from the standard input,
  2907. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2908. communications.
  2909. Verbose output is normally sent to standard output, separate from
  2910. other error messages. However, if the archive is produced directly
  2911. on standard output, then verbose output is mixed with errors on
  2912. @code{stderr}. Producing the archive on standard output may be used
  2913. as a way to avoid using disk space, when the archive is soon to be
  2914. consumed by another process reading it, say. Some people felt the need
  2915. of producing an archive on stdout, still willing to segregate between
  2916. verbose output and error output. A possible approach would be using a
  2917. named pipe to receive the archive, and having the consumer process to
  2918. read from that named pipe. This has the advantage of letting standard
  2919. output free to receive verbose output, all separate from errors.
  2920. @node operations
  2921. @chapter @GNUTAR{} Operations
  2922. @menu
  2923. * Basic tar::
  2924. * Advanced tar::
  2925. * create options::
  2926. * extract options::
  2927. * backup::
  2928. * Applications::
  2929. * looking ahead::
  2930. @end menu
  2931. @node Basic tar
  2932. @section Basic @GNUTAR{} Operations
  2933. The basic @command{tar} operations, @value{op-create}, @value{op-list} and
  2934. @value{op-extract}, are currently presented and described in the tutorial
  2935. chapter of this manual. This section provides some complementary notes
  2936. for these operations.
  2937. @table @asis
  2938. @item @value{op-create}
  2939. Creating an empty archive would have some kind of elegance. One can
  2940. initialize an empty archive and later use @value{op-append} for adding
  2941. all members. Some applications would not welcome making an exception
  2942. in the way of adding the first archive member. On the other hand,
  2943. many people reported that it is dangerously too easy for @command{tar}
  2944. to destroy a magnetic tape with an empty archive@footnote{This is well
  2945. described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
  2946. Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
  2947. common errors are:
  2948. @enumerate
  2949. @item
  2950. Mistakingly using @code{create} instead of @code{extract}, when the
  2951. intent was to extract the full contents of an archive. This error
  2952. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2953. the QWERTY keyboard. Instead of being unpacked, the archive then
  2954. gets wholly destroyed. When users speak about @dfn{exploding} an
  2955. archive, they usually mean something else :-).
  2956. @item
  2957. Forgetting the argument to @code{file}, when the intent was to create
  2958. an archive with a single file in it. This error is likely because a
  2959. tired user can easily add the @kbd{f} key to the cluster of option
  2960. letters, by the mere force of habit, without realizing the full
  2961. consequence of doing so. The usual consequence is that the single
  2962. file, which was meant to be saved, is rather destroyed.
  2963. @end enumerate
  2964. So, recognizing the likelihood and the catastrophical nature of these
  2965. errors, @GNUTAR{} now takes some distance from elegance, and
  2966. cowardly refuses to create an archive when @value{op-create} option is
  2967. given, there are no arguments besides options, and @value{op-files-from}
  2968. option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
  2969. and nevertheless create an archive with nothing in it,
  2970. one may still use, as the value for the @value{op-files-from} option,
  2971. a file with no names in it, as shown in the following commands:
  2972. @smallexample
  2973. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2974. @kbd{tar cfT empty-archive.tar /dev/null}
  2975. @end smallexample
  2976. @item @value{op-extract}
  2977. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2978. @item @value{op-list}
  2979. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2980. while it used to show them as @samp{Aug 30 1996}. (One can revert to
  2981. the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
  2982. before reinstalling.) But preferably, people should get used to ISO
  2983. 8601 dates. Local American dates should be made available again with
  2984. full date localization support, once ready. In the meantime, programs
  2985. not being localizable for dates should prefer international dates,
  2986. that's really the way to go.
  2987. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2988. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2989. @end table
  2990. @node Advanced tar
  2991. @section Advanced @GNUTAR{} Operations
  2992. Now that you have learned the basics of using @GNUTAR{}, you may want
  2993. to learn about further ways in which @command{tar} can help you.
  2994. This chapter presents five, more advanced operations which you probably
  2995. won't use on a daily basis, but which serve more specialized functions.
  2996. We also explain the different styles of options and why you might want
  2997. to use one or another, or a combination of them in your @command{tar}
  2998. commands. Additionally, this chapter includes options which allow you to
  2999. define the output from @command{tar} more carefully, and provide help and
  3000. error correction in special circumstances.
  3001. @FIXME{check this after the chapter is actually revised to make sure
  3002. it still introduces the info in the chapter correctly : ).}
  3003. @menu
  3004. * Operations::
  3005. * append::
  3006. * update::
  3007. * concatenate::
  3008. * delete::
  3009. * compare::
  3010. @end menu
  3011. @node Operations
  3012. @subsection The Five Advanced @command{tar} Operations
  3013. @UNREVISED
  3014. In the last chapter, you learned about the first three operations to
  3015. @command{tar}. This chapter presents the remaining five operations to
  3016. @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
  3017. @samp{--delete}, and @samp{--compare}.
  3018. You are not likely to use these operations as frequently as those
  3019. covered in the last chapter; however, since they perform specialized
  3020. functions, they are quite useful when you do need to use them. We
  3021. will give examples using the same directory and files that you created
  3022. in the last chapter. As you may recall, the directory is called
  3023. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  3024. @samp{rock}, and the two archive files you created are
  3025. @samp{collection.tar} and @samp{music.tar}.
  3026. We will also use the archive files @samp{afiles.tar} and
  3027. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  3028. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  3029. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  3030. Unless we state otherwise, all practicing you do and examples you follow
  3031. in this chapter will take place in the @file{practice} directory that
  3032. you created in the previous chapter; see @ref{prepare for examples}.
  3033. (Below in this section, we will remind you of the state of the examples
  3034. where the last chapter left them.)
  3035. The five operations that we will cover in this chapter are:
  3036. @table @kbd
  3037. @item --append
  3038. @itemx -r
  3039. Add new entries to an archive that already exists.
  3040. @item --update
  3041. @itemx -r
  3042. Add more recent copies of archive members to the end of an archive, if
  3043. they exist.
  3044. @item --concatenate
  3045. @itemx --catenate
  3046. @itemx -A
  3047. Add one or more pre-existing archives to the end of another archive.
  3048. @item --delete
  3049. Delete items from an archive (does not work on tapes).
  3050. @item --compare
  3051. @itemx --diff
  3052. @itemx -d
  3053. Compare archive members to their counterparts in the file system.
  3054. @end table
  3055. @node append
  3056. @subsection How to Add Files to Existing Archives: @code{--append}
  3057. @UNREVISED
  3058. If you want to add files to an existing archive, you don't need to
  3059. create a new archive; you can use @value{op-append}. The archive must
  3060. already exist in order to use @samp{--append}. (A related operation
  3061. is the @samp{--update} operation; you can use this to add newer
  3062. versions of archive members to an existing archive. To learn how to
  3063. do this with @samp{--update}, @pxref{update}.)
  3064. If you use @value{op-append} to add a file that has the same name as an
  3065. archive member to an archive containing that archive member, then the
  3066. old member is not deleted. What does happen, however, is somewhat
  3067. complex. @command{tar} @emph{allows} you to have infinite number of files
  3068. with the same name. Some operations treat these same-named members no
  3069. differently than any other set of archive members: for example, if you
  3070. view an archive with @value{op-list}, you will see all of those members
  3071. listed, with their modification times, owners, etc.
  3072. Other operations don't deal with these members as perfectly as you might
  3073. prefer; if you were to use @value{op-extract} to extract the archive,
  3074. only the most recently added copy of a member with the same name as four
  3075. other members would end up in the working directory. This is because
  3076. @samp{--extract} extracts an archive in the order the members appeared
  3077. in the archive; the most recently archived members will be extracted
  3078. last. Additionally, an extracted member will @emph{replace} a file of
  3079. the same name which existed in the directory already, and @command{tar}
  3080. will not prompt you about this@footnote{Unless you give it
  3081. @option{--keep-old-files} option, or the disk copy is newer than the
  3082. the one in the archive and you invoke @command{tar} with
  3083. @option{--keep-newer-files} option}. Thus, only the most recently archived
  3084. member will end up being extracted, as it will replace the one
  3085. extracted before it, and so on.
  3086. There exists a special option that allows you to get around this
  3087. behavior and extract (or list) only a particular copy of the file.
  3088. This is @option{--occurrence} option. If you run @command{tar} with
  3089. this option, it will extract only the first copy of the file. You
  3090. may also give this option an argument specifying the number of
  3091. copy to be extracted. Thus, for example if the archive
  3092. @file{archive.tar} contained three copies of file @file{myfile}, then
  3093. the command
  3094. @smallexample
  3095. tar --extract --file archive.tar --occurrence=2 myfile
  3096. @end smallexample
  3097. @noindent
  3098. would extract only the second copy. @xref{Option Summary,---occurrence}, for the description of @value{op-occurrence} option.
  3099. @FIXME{ hag -- you might want to incorporate some of the above into the
  3100. MMwtSN node; not sure. i didn't know how to make it simpler...
  3101. There are a few ways to get around this. (maybe xref Multiple Members
  3102. with the Same Name.}
  3103. @cindex Members, replacing with other members
  3104. @cindex Replacing members with other members
  3105. If you want to replace an archive member, use @value{op-delete} to
  3106. delete the member you want to remove from the archive, , and then use
  3107. @samp{--append} to add the member you want to be in the archive. Note
  3108. that you can not change the order of the archive; the most recently
  3109. added member will still appear last. In this sense, you cannot truly
  3110. ``replace'' one member with another. (Replacing one member with another
  3111. will not work on certain types of media, such as tapes; see @ref{delete}
  3112. and @ref{Media}, for more information.)
  3113. @menu
  3114. * appending files:: Appending Files to an Archive
  3115. * multiple::
  3116. @end menu
  3117. @node appending files
  3118. @subsubsection Appending Files to an Archive
  3119. @UNREVISED
  3120. @cindex Adding files to an Archive
  3121. @cindex Appending files to an Archive
  3122. @cindex Archives, Appending files to
  3123. The simplest way to add a file to an already existing archive is the
  3124. @value{op-append} operation, which writes specified files into the
  3125. archive whether or not they are already among the archived files.
  3126. When you use @samp{--append}, you @emph{must} specify file name
  3127. arguments, as there is no default. If you specify a file that already
  3128. exists in the archive, another copy of the file will be added to the
  3129. end of the archive. As with other operations, the member names of the
  3130. newly added files will be exactly the same as their names given on the
  3131. command line. The @value{op-verbose} option will print out the names
  3132. of the files as they are written into the archive.
  3133. @samp{--append} cannot be performed on some tape drives, unfortunately,
  3134. due to deficiencies in the formats those tape drives use. The archive
  3135. must be a valid @command{tar} archive, or else the results of using this
  3136. operation will be unpredictable. @xref{Media}.
  3137. To demonstrate using @samp{--append} to add a file to an archive,
  3138. create a file called @file{rock} in the @file{practice} directory.
  3139. Make sure you are in the @file{practice} directory. Then, run the
  3140. following @command{tar} command to add @file{rock} to
  3141. @file{collection.tar}:
  3142. @smallexample
  3143. $ @kbd{tar --append --file=collection.tar rock}
  3144. @end smallexample
  3145. @noindent
  3146. If you now use the @value{op-list} operation, you will see that
  3147. @file{rock} has been added to the archive:
  3148. @smallexample
  3149. $ @kbd{tar --list --file=collection.tar}
  3150. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3151. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3152. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3153. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3154. @end smallexample
  3155. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3156. title claims it will become...}
  3157. @node multiple
  3158. @subsubsection Multiple Files with the Same Name
  3159. You can use @value{op-append} to add copies of files which have been
  3160. updated since the archive was created. (However, we do not recommend
  3161. doing this since there is another @command{tar} option called
  3162. @samp{--update}; @pxref{update} for more information. We describe this
  3163. use of @samp{--append} here for the sake of completeness.) @FIXME{is
  3164. this really a good idea, to give this whole description for something
  3165. which i believe is basically a Stupid way of doing something? certain
  3166. aspects of it show ways in which tar is more broken than i'd personally
  3167. like to admit to, specifically the last sentence. On the other hand, i
  3168. don't think it's a good idea to be saying that we explicitly don't
  3169. recommend using something, but i can't see any better way to deal with
  3170. the situation.}When you extract the archive, the older version will be
  3171. effectively lost. This works because files are extracted from an
  3172. archive in the order in which they were archived. Thus, when the
  3173. archive is extracted, a file archived later in time will replace a
  3174. file of the same name which was archived earlier, even though the older
  3175. version of the file will remain in the archive unless you delete all
  3176. versions of the file.
  3177. Supposing you change the file @file{blues} and then append the changed
  3178. version to @file{collection.tar}. As you saw above, the original
  3179. @file{blues} is in the archive @file{collection.tar}. If you change the
  3180. file and append the new version of the file to the archive, there will
  3181. be two copies in the archive. When you extract the archive, the older
  3182. version of the file will be extracted first, and then replaced by the
  3183. newer version when it is extracted.
  3184. You can append the new, changed copy of the file @file{blues} to the
  3185. archive in this way:
  3186. @smallexample
  3187. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3188. blues
  3189. @end smallexample
  3190. @noindent
  3191. Because you specified the @samp{--verbose} option, @command{tar} has
  3192. printed the name of the file being appended as it was acted on. Now
  3193. list the contents of the archive:
  3194. @smallexample
  3195. $ @kbd{tar --list --verbose --file=collection.tar}
  3196. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3197. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3198. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3199. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3200. -rw-rw-rw- me user 58 1996-10-24 18:30 blues
  3201. @end smallexample
  3202. @noindent
  3203. The newest version of @file{blues} is now at the end of the archive
  3204. (note the different creation dates and file sizes). If you extract
  3205. the archive, the older version of the file @file{blues} will be
  3206. replaced by the newer version. You can confirm this by extracting
  3207. the archive and running @samp{ls} on the directory.
  3208. If you wish to extract the first occurrence of the file @file{blues}
  3209. from the archive, use @value{op-occurrence} option, as shown in
  3210. the following example:
  3211. @smallexample
  3212. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3213. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3214. @end smallexample
  3215. @xref{Writing}, for more information on @value{op-extract} and
  3216. @xref{Option Summary, --occurrence}, for the description of
  3217. @value{op-occurrence} option.
  3218. @node update
  3219. @subsection Updating an Archive
  3220. @UNREVISED
  3221. @cindex Updating an archive
  3222. In the previous section, you learned how to use @value{op-append} to add
  3223. a file to an existing archive. A related operation is
  3224. @value{op-update}. The @samp{--update} operation updates a @command{tar}
  3225. archive by comparing the date of the specified archive members against
  3226. the date of the file with the same name. If the file has been modified
  3227. more recently than the archive member, then the newer version of the
  3228. file is added to the archive (as with @value{op-append}).
  3229. Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
  3230. The operation will fail.
  3231. @FIXME{other examples of media on which --update will fail? need to ask
  3232. charles and/or mib/thomas/dave shevett..}
  3233. Both @samp{--update} and @samp{--append} work by adding to the end
  3234. of the archive. When you extract a file from the archive, only the
  3235. version stored last will wind up in the file system, unless you use
  3236. the @value{op-backup} option. @FIXME-ref{Multiple Members with the
  3237. Same Name}
  3238. @menu
  3239. * how to update::
  3240. @end menu
  3241. @node how to update
  3242. @subsubsection How to Update an Archive Using @code{--update}
  3243. You must use file name arguments with the @value{op-update} operation.
  3244. If you don't specify any files, @command{tar} won't act on any files and
  3245. won't tell you that it didn't do anything (which may end up confusing
  3246. you).
  3247. @FIXME{note: the above parenthetical added because in fact, this
  3248. behavior just confused the author. :-) }
  3249. To see the @samp{--update} option at work, create a new file,
  3250. @file{classical}, in your practice directory, and some extra text to the
  3251. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3252. the @samp{update} operation and the @value{op-verbose} option specified,
  3253. using the names of all the files in the practice directory as file name
  3254. arguments:
  3255. @smallexample
  3256. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3257. blues
  3258. classical
  3259. $
  3260. @end smallexample
  3261. @noindent
  3262. Because we have specified verbose mode, @command{tar} prints out the names
  3263. of the files it is working on, which in this case are the names of the
  3264. files that needed to be updated. If you run @samp{tar --list} and look
  3265. at the archive, you will see @file{blues} and @file{classical} at its
  3266. end. There will be a total of two versions of the member @samp{blues};
  3267. the one at the end will be newer and larger, since you added text before
  3268. updating it.
  3269. (The reason @command{tar} does not overwrite the older file when updating
  3270. it is because writing to the middle of a section of tape is a difficult
  3271. process. Tapes are not designed to go backward. @xref{Media}, for more
  3272. information about tapes.
  3273. @value{op-update} is not suitable for performing backups for two
  3274. reasons: it does not change directory content entries, and it
  3275. lengthens the archive every time it is used. The @GNUTAR{}
  3276. options intended specifically for backups are more
  3277. efficient. If you need to run backups, please consult @ref{Backups}.
  3278. @node concatenate
  3279. @subsection Combining Archives with @code{--concatenate}
  3280. @cindex Adding archives to an archive
  3281. @cindex Concatenating Archives
  3282. Sometimes it may be convenient to add a second archive onto the end of
  3283. an archive rather than adding individual files to the archive. To add
  3284. one or more archives to the end of another archive, you should use the
  3285. @value{op-concatenate} operation.
  3286. To use @samp{--concatenate}, name the archives to be concatenated on the
  3287. command line. (Nothing happens if you don't list any.) The members,
  3288. and their member names, will be copied verbatim from those archives. If
  3289. this causes multiple members to have the same name, it does not delete
  3290. any members; all the members with the same name coexist. @FIXME-ref{For
  3291. information on how this affects reading the archive, Multiple
  3292. Members with the Same Name.}
  3293. To demonstrate how @samp{--concatenate} works, create two small archives
  3294. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3295. files from @file{practice}:
  3296. @smallexample
  3297. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3298. blues
  3299. classical
  3300. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3301. folk
  3302. jazz
  3303. @end smallexample
  3304. @noindent
  3305. If you like, You can run @samp{tar --list} to make sure the archives
  3306. contain what they are supposed to:
  3307. @smallexample
  3308. $ @kbd{tar -tvf bluesrock.tar}
  3309. -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
  3310. -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
  3311. $ @kbd{tar -tvf folkjazz.tar}
  3312. -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
  3313. -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
  3314. @end smallexample
  3315. We can concatenate these two archives with @command{tar}:
  3316. @smallexample
  3317. $ @kbd{cd ..}
  3318. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3319. @end smallexample
  3320. If you now list the contents of the @file{bluesclass.tar}, you will see
  3321. that now it also contains the archive members of @file{jazzfolk.tar}:
  3322. @smallexample
  3323. $ @kbd{tar --list --file=bluesrock.tar}
  3324. blues
  3325. rock
  3326. jazz
  3327. folk
  3328. @end smallexample
  3329. When you use @samp{--concatenate}, the source and target archives must
  3330. already exist and must have been created using compatible format
  3331. parameters. @FIXME-pxref{Matching Format Parameters}The new,
  3332. concatenated archive will be called by the same name as the first
  3333. archive listed on the command line. @FIXME{is there a way to specify a
  3334. new name?}
  3335. Like @value{op-append}, this operation cannot be performed on some
  3336. tape drives, due to deficiencies in the formats those tape drives use.
  3337. @cindex @code{concatenate} vs @command{cat}
  3338. @cindex @command{cat} vs @code{concatenate}
  3339. It may seem more intuitive to you to want or try to use @command{cat} to
  3340. concatenate two archives instead of using the @samp{--concatenate}
  3341. operation; after all, @command{cat} is the utility for combining files.
  3342. However, @command{tar} archives incorporate an end-of-file marker which
  3343. must be removed if the concatenated archives are to be read properly as
  3344. one archive. @samp{--concatenate} removes the end-of-archive marker
  3345. from the target archive before each new archive is appended. If you use
  3346. @command{cat} to combine the archives, the result will not be a valid
  3347. @command{tar} format archive. If you need to retrieve files from an
  3348. archive that was added to using the @command{cat} utility, use the
  3349. @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
  3350. information on dealing with archives improperly combined using the
  3351. @command{cat} shell utility.
  3352. @FIXME{this shouldn't go here. where should it go?} You must specify
  3353. the source archives using @value{op-file} (@value{pxref-file}). If you
  3354. do not specify the target archive, @command{tar} uses the value of the
  3355. environment variable @env{TAPE}, or, if this has not been set, the
  3356. default archive name.
  3357. @node delete
  3358. @subsection Removing Archive Members Using @samp{--delete}
  3359. @UNREVISED
  3360. @cindex Deleting files from an archive
  3361. @cindex Removing files from an archive
  3362. You can remove members from an archive by using the @value{op-delete}
  3363. option. Specify the name of the archive with @value{op-file} and then
  3364. specify the names of the members to be deleted; if you list no member
  3365. names, nothing will be deleted. The @value{op-verbose} option will
  3366. cause @command{tar} to print the names of the members as they are deleted.
  3367. As with @value{op-extract}, you must give the exact member names when
  3368. using @samp{tar --delete}. @samp{--delete} will remove all versions of
  3369. the named file from the archive. The @samp{--delete} operation can run
  3370. very slowly.
  3371. Unlike other operations, @samp{--delete} has no short form.
  3372. @cindex Tapes, using @code{--delete} and
  3373. @cindex Deleting from tape archives
  3374. This operation will rewrite the archive. You can only use
  3375. @samp{--delete} on an archive if the archive device allows you to
  3376. write to any point on the media, such as a disk; because of this, it
  3377. does not work on magnetic tapes. Do not try to delete an archive member
  3378. from a magnetic tape; the action will not succeed, and you will be
  3379. likely to scramble the archive and damage your tape. There is no safe
  3380. way (except by completely re-writing the archive) to delete files from
  3381. most kinds of magnetic tape. @xref{Media}.
  3382. To delete all versions of the file @file{blues} from the archive
  3383. @file{collection.tar} in the @file{practice} directory, make sure you
  3384. are in that directory, and then,
  3385. @smallexample
  3386. $ @kbd{tar --list --file=collection.tar}
  3387. blues
  3388. folk
  3389. jazz
  3390. rock
  3391. practice/blues
  3392. practice/folk
  3393. practice/jazz
  3394. practice/rock
  3395. practice/blues
  3396. $ @kbd{tar --delete --file=collection.tar blues}
  3397. $ @kbd{tar --list --file=collection.tar}
  3398. folk
  3399. jazz
  3400. rock
  3401. $
  3402. @end smallexample
  3403. @FIXME{I changed the order of these nodes around and haven't had a chance
  3404. to fix the above example's results, yet. I have to play with this and
  3405. follow it and see what it actually does!}
  3406. The @value{op-delete} option has been reported to work properly when
  3407. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3408. @node compare
  3409. @subsection Comparing Archive Members with the File System
  3410. @cindex Verifying the currency of an archive
  3411. @UNREVISED
  3412. The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
  3413. specified archive members against files with the same names, and then
  3414. reports differences in file size, mode, owner, modification date and
  3415. contents. You should @emph{only} specify archive member names, not file
  3416. names. If you do not name any members, then @command{tar} will compare the
  3417. entire archive. If a file is represented in the archive but does not
  3418. exist in the file system, @command{tar} reports a difference.
  3419. You have to specify the record size of the archive when modifying an
  3420. archive with a non-default record size.
  3421. @command{tar} ignores files in the file system that do not have
  3422. corresponding members in the archive.
  3423. The following example compares the archive members @file{rock},
  3424. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3425. files of the same name in the file system. (Note that there is no file,
  3426. @file{funk}; @command{tar} will report an error message.)
  3427. @smallexample
  3428. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3429. rock
  3430. blues
  3431. tar: funk not found in archive
  3432. @end smallexample
  3433. @noindent
  3434. @FIXME{what does this actually depend on? i'm making a guess,
  3435. here.}Depending on the system where you are running @command{tar} and the
  3436. version you are running, @command{tar} may have a different error message,
  3437. such as:
  3438. @smallexample
  3439. funk: does not exist
  3440. @end smallexample
  3441. @FIXME-xref{somewhere, for more information about format parameters.
  3442. Melissa says: such as "format variations"? But why? Clearly I don't
  3443. get it yet; I'll deal when I get to that section.}
  3444. The spirit behind the @value{op-compare} option is to check whether the
  3445. archive represents the current state of files on disk, more than validating
  3446. the integrity of the archive media. For this later goal, @xref{verify}.
  3447. @node create options
  3448. @section Options Used by @code{--create}
  3449. The previous chapter described the basics of how to use
  3450. @value{op-create} to create an archive from a set of files.
  3451. @xref{create}. This section described advanced options to be used with
  3452. @samp{--create}.
  3453. @menu
  3454. * Ignore Failed Read::
  3455. @end menu
  3456. @node Ignore Failed Read
  3457. @subsection Ignore Fail Read
  3458. @table @kbd
  3459. @item --ignore-failed-read
  3460. Do not exit with nonzero on unreadable files or directories.
  3461. @end table
  3462. @node extract options
  3463. @section Options Used by @code{--extract}
  3464. @UNREVISED
  3465. @FIXME{i need to get dan to go over these options with me and see if
  3466. there's a better way of organizing them.}
  3467. The previous chapter showed how to use @value{op-extract} to extract
  3468. an archive into the filesystem. Various options cause @command{tar} to
  3469. extract more information than just file contents, such as the owner,
  3470. the permissions, the modification date, and so forth. This section
  3471. presents options to be used with @samp{--extract} when certain special
  3472. considerations arise. You may review the information presented in
  3473. @ref{extract} for more basic information about the
  3474. @samp{--extract} operation.
  3475. @menu
  3476. * Reading:: Options to Help Read Archives
  3477. * Writing:: Changing How @command{tar} Writes Files
  3478. * Scarce:: Coping with Scarce Resources
  3479. @end menu
  3480. @node Reading
  3481. @subsection Options to Help Read Archives
  3482. @cindex Options when reading archives
  3483. @cindex Reading incomplete records
  3484. @cindex Records, incomplete
  3485. @cindex End-of-archive entries, ignoring
  3486. @cindex Ignoring end-of-archive entries
  3487. @cindex Large lists of file names on small machines
  3488. @cindex Small memory
  3489. @cindex Running out of space
  3490. @UNREVISED
  3491. Normally, @command{tar} will request data in full record increments from
  3492. an archive storage device. If the device cannot return a full record,
  3493. @command{tar} will report an error. However, some devices do not always
  3494. return full records, or do not require the last record of an archive to
  3495. be padded out to the next record boundary. To keep reading until you
  3496. obtain a full record, or to accept an incomplete record if it contains
  3497. an end-of-archive marker, specify the @value{op-read-full-records} option
  3498. in conjunction with the @value{op-extract} or @value{op-list} operations.
  3499. @value{xref-read-full-records}.
  3500. The @value{op-read-full-records} option is turned on by default when
  3501. @command{tar} reads an archive from standard input, or from a remote
  3502. machine. This is because on BSD Unix systems, attempting to read a
  3503. pipe returns however much happens to be in the pipe, even if it is
  3504. less than was requested. If this option were not enabled, @command{tar}
  3505. would fail as soon as it read an incomplete record from the pipe.
  3506. If you're not sure of the blocking factor of an archive, you can
  3507. read the archive by specifying @value{op-read-full-records} and
  3508. @value{op-blocking-factor}, using a blocking factor larger than what the
  3509. archive uses. This lets you avoid having to determine the blocking factor
  3510. of an archive. @value{xref-blocking-factor}.
  3511. @menu
  3512. * read full records::
  3513. * Ignore Zeros::
  3514. @end menu
  3515. @node read full records
  3516. @unnumberedsubsubsec Reading Full Records
  3517. @FIXME{need sentence or so of intro here}
  3518. @table @kbd
  3519. @item --read-full-records
  3520. @item -B
  3521. Use in conjunction with @value{op-extract} to read an archive which
  3522. contains incomplete records, or one which has a blocking factor less
  3523. than the one specified.
  3524. @end table
  3525. @node Ignore Zeros
  3526. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3527. Normally, @command{tar} stops reading when it encounters a block of zeros
  3528. between file entries (which usually indicates the end of the archive).
  3529. @value{op-ignore-zeros} allows @command{tar} to completely read an archive
  3530. which contains a block of zeros before the end (i.e.@: a damaged
  3531. archive, or one which was created by concatenating several archives
  3532. together).
  3533. The @value{op-ignore-zeros} option is turned off by default because many
  3534. versions of @command{tar} write garbage after the end-of-archive entry,
  3535. since that part of the media is never supposed to be read. @GNUTAR{}
  3536. does not write after the end of an archive, but seeks to
  3537. maintain compatiblity among archiving utilities.
  3538. @table @kbd
  3539. @item --ignore-zeros
  3540. @itemx -i
  3541. To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
  3542. encountered while reading an archive. Use in conjunction with
  3543. @value{op-extract} or @value{op-list}.
  3544. @end table
  3545. @node Writing
  3546. @subsection Changing How @command{tar} Writes Files
  3547. @cindex Overwriting old files, prevention
  3548. @cindex Protecting old files
  3549. @cindex Modification times of extracted files
  3550. @cindex Permissions of extracted files
  3551. @cindex Modes of extracted files
  3552. @cindex Writing extracted files to standard output
  3553. @cindex Standard output, writing extracted files to
  3554. @UNREVISED
  3555. @FIXME{need to mention the brand new option, --backup}
  3556. @menu
  3557. * Dealing with Old Files::
  3558. * Overwrite Old Files::
  3559. * Keep Old Files::
  3560. * Keep Newer Files::
  3561. * Unlink First::
  3562. * Recursive Unlink::
  3563. * Modification Times::
  3564. * Setting Access Permissions::
  3565. * Writing to Standard Output::
  3566. * remove files::
  3567. @end menu
  3568. @node Dealing with Old Files
  3569. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3570. When extracting files, if @command{tar} discovers that the extracted
  3571. file already exists, it normally replaces the file by removing it before
  3572. extracting it, to prevent confusion in the presence of hard or symbolic
  3573. links. (If the existing file is a symbolic link, it is removed, not
  3574. followed.) However, if a directory cannot be removed because it is
  3575. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3576. permission, etc.). The @option{--overwrite-dir} option enables this
  3577. default behavior. To be more cautious and preserve the metadata of
  3578. such a directory, use the @option{--no-overwrite-dir} option.
  3579. To be even more cautious and prevent existing files from being replaced, use
  3580. the @value{op-keep-old-files} option. It causes @command{tar} to refuse
  3581. to replace or update a file that already exists, i.e., a file with the
  3582. same name as an archive member prevents extraction of that archive
  3583. member. Instead, it reports an error.
  3584. To be more aggressive about altering existing files, use the
  3585. @value{op-overwrite} option. It causes @command{tar} to overwrite
  3586. existing files and to follow existing symbolic links when extracting.
  3587. Some people argue that @GNUTAR{} should not hesitate
  3588. to overwrite files with other files when extracting. When extracting
  3589. a @command{tar} archive, they expect to see a faithful copy of the
  3590. state of the filesystem when the archive was created. It is debatable
  3591. that this would always be a proper behavior. For example, suppose one
  3592. has an archive in which @file{usr/local} is a link to
  3593. @file{usr/local2}. Since then, maybe the site removed the link and
  3594. renamed the whole hierarchy from @file{/usr/local2} to
  3595. @file{/usr/local}. Such things happen all the time. I guess it would
  3596. not be welcome at all that @GNUTAR{} removes the
  3597. whole hierarchy just to make room for the link to be reinstated
  3598. (unless it @emph{also} simultaneously restores the full
  3599. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3600. able to remove a whole hierarchy to reestablish a symbolic link, for
  3601. example, but @emph{only if} @value{op-recursive-unlink} is specified
  3602. to allow this behavior. In any case, single files are silently
  3603. removed.
  3604. Finally, the @value{op-unlink-first} option can improve performance in
  3605. some cases by causing @command{tar} to remove files unconditionally
  3606. before extracting them.
  3607. @node Overwrite Old Files
  3608. @unnumberedsubsubsec Overwrite Old Files
  3609. @table @kbd
  3610. @item --overwrite
  3611. Overwrite existing files and directory metadata when extracting files
  3612. from an archive.
  3613. This
  3614. causes @command{tar} to write extracted files into the file system without
  3615. regard to the files already on the system; i.e., files with the same
  3616. names as archive members are overwritten when the archive is extracted.
  3617. It also causes @command{tar} to extract the ownership, permissions,
  3618. and time stamps onto any preexisting files or directories.
  3619. If the name of a corresponding file name is a symbolic link, the file
  3620. pointed to by the symbolic link will be overwritten instead of the
  3621. symbolic link itself (if this is possible). Moreover, special devices,
  3622. empty directories and even symbolic links are automatically removed if
  3623. they are in the way of extraction.
  3624. Be careful when using the @value{op-overwrite} option, particularly when
  3625. combined with the @value{op-absolute-names} option, as this combination
  3626. can change the contents, ownership or permissions of any file on your
  3627. system. Also, many systems do not take kindly to overwriting files that
  3628. are currently being executed.
  3629. @item --overwrite-dir
  3630. Overwrite the metadata of directories when extracting files from an
  3631. archive, but remove other files before extracting.
  3632. @end table
  3633. @node Keep Old Files
  3634. @unnumberedsubsubsec Keep Old Files
  3635. @table @kbd
  3636. @item --keep-old-files
  3637. @itemx -k
  3638. Do not replace existing files from archive. The
  3639. @value{op-keep-old-files} option prevents @command{tar} from replacing
  3640. existing files with files with the same name from the archive.
  3641. The @value{op-keep-old-files} option is meaningless with @value{op-list}.
  3642. Prevents @command{tar} from replacing files in the file system during
  3643. extraction.
  3644. @end table
  3645. @node Keep Newer Files
  3646. @unnumberedsubsubsec Keep Newer Files
  3647. @table @kbd
  3648. @item --keep-newer-files
  3649. Do not replace existing files that are newer than their archive
  3650. copies. This option is meaningless with @value{op-list}.
  3651. @end table
  3652. @node Unlink First
  3653. @unnumberedsubsubsec Unlink First
  3654. @table @kbd
  3655. @item --unlink-first
  3656. @itemx -U
  3657. Remove files before extracting over them.
  3658. This can make @command{tar} run a bit faster if you know in advance
  3659. that the extracted files all need to be removed. Normally this option
  3660. slows @command{tar} down slightly, so it is disabled by default.
  3661. @end table
  3662. @node Recursive Unlink
  3663. @unnumberedsubsubsec Recursive Unlink
  3664. @table @kbd
  3665. @item --recursive-unlink
  3666. When this option is specified, try removing files and directory hierarchies
  3667. before extracting over them. @emph{This is a dangerous option!}
  3668. @end table
  3669. If you specify the @value{op-recursive-unlink} option,
  3670. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3671. as far as current permissions will allow it. This could include removal
  3672. of the contents of a full directory hierarchy.
  3673. @node Modification Times
  3674. @unnumberedsubsubsec Setting Modification Times
  3675. Normally, @command{tar} sets the modification times of extracted files to
  3676. the modification times recorded for the files in the archive, but
  3677. limits the permissions of extracted files by the current @code{umask}
  3678. setting.
  3679. To set the modification times of extracted files to the time when
  3680. the files were extracted, use the @value{op-touch} option in
  3681. conjunction with @value{op-extract}.
  3682. @table @kbd
  3683. @item --touch
  3684. @itemx -m
  3685. Sets the modification time of extracted archive members to the time
  3686. they were extracted, not the time recorded for them in the archive.
  3687. Use in conjunction with @value{op-extract}.
  3688. @end table
  3689. @node Setting Access Permissions
  3690. @unnumberedsubsubsec Setting Access Permissions
  3691. To set the modes (access permissions) of extracted files to those
  3692. recorded for those files in the archive, use @samp{--same-permissions}
  3693. in conjunction with the @value{op-extract} operation. @FIXME{Should be
  3694. aliased to ignore-umask.}
  3695. @table @kbd
  3696. @item --preserve-permission
  3697. @itemx --same-permission
  3698. @itemx --ignore-umask
  3699. @itemx -p
  3700. Set modes of extracted archive members to those recorded in the
  3701. archive, instead of current umask settings. Use in conjunction with
  3702. @value{op-extract}.
  3703. @end table
  3704. @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
  3705. files together, why is this useful. is it really useful with
  3706. more than one file?}
  3707. @node Writing to Standard Output
  3708. @unnumberedsubsubsec Writing to Standard Output
  3709. To write the extracted files to the standard output, instead of
  3710. creating the files on the file system, use @value{op-to-stdout} in
  3711. conjunction with @value{op-extract}. This option is useful if you are
  3712. extracting files to send them through a pipe, and do not need to
  3713. preserve them in the file system. If you extract multiple members,
  3714. they appear on standard output concatenated, in the order they are
  3715. found in the archive.
  3716. @table @kbd
  3717. @item --to-stdout
  3718. @itemx -O
  3719. Writes files to the standard output. Used in conjunction with
  3720. @value{op-extract}. Extract files to standard output. When this option
  3721. is used, instead of creating the files specified, @command{tar} writes
  3722. the contents of the files extracted to its standard output. This may
  3723. be useful if you are only extracting the files in order to send them
  3724. through a pipe. This option is meaningless with @value{op-list}.
  3725. @end table
  3726. This can be useful, for example, if you have a tar archive containing
  3727. a big file and don't want to store the file on disk before processing
  3728. it. You can use a command like this:
  3729. @smallexample
  3730. tar -xOzf foo.tgz bigfile | process
  3731. @end smallexample
  3732. or even like this if you want to process the concatenation of the files:
  3733. @smallexample
  3734. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3735. @end smallexample
  3736. @node remove files
  3737. @unnumberedsubsubsec Removing Files
  3738. @FIXME{the various macros in the front of the manual think that this
  3739. option goes in this section. i have no idea; i only know it's nowhere
  3740. else in the book...}
  3741. @table @kbd
  3742. @item --remove-files
  3743. Remove files after adding them to the archive.
  3744. @end table
  3745. @node Scarce
  3746. @subsection Coping with Scarce Resources
  3747. @cindex Middle of the archive, starting in the
  3748. @cindex Running out of space during extraction
  3749. @cindex Disk space, running out of
  3750. @cindex Space on the disk, recovering from lack of
  3751. @UNREVISED
  3752. @menu
  3753. * Starting File::
  3754. * Same Order::
  3755. @end menu
  3756. @node Starting File
  3757. @unnumberedsubsubsec Starting File
  3758. @table @kbd
  3759. @item --starting-file=@var{name}
  3760. @itemx -K @var{name}
  3761. Starts an operation in the middle of an archive. Use in conjunction
  3762. with @value{op-extract} or @value{op-list}.
  3763. @end table
  3764. If a previous attempt to extract files failed due to lack of disk
  3765. space, you can use @value{op-starting-file} to start extracting only
  3766. after member @var{name} of the archive. This assumes, of course, that
  3767. there is now free space, or that you are now extracting into a
  3768. different file system. (You could also choose to suspend @command{tar},
  3769. remove unnecessary files from the file system, and then restart the
  3770. same @command{tar} operation. In this case, @value{op-starting-file} is
  3771. not necessary. @value{xref-incremental}, @value{xref-interactive},
  3772. and @value{ref-exclude}.)
  3773. @node Same Order
  3774. @unnumberedsubsubsec Same Order
  3775. @table @kbd
  3776. @item --same-order
  3777. @itemx --preserve-order
  3778. @itemx -s
  3779. To process large lists of file names on machines with small amounts of
  3780. memory. Use in conjunction with @value{op-compare},
  3781. @value{op-list}
  3782. or @value{op-extract}.
  3783. @end table
  3784. @FIXME{we don't need/want --preserve to exist any more (from melissa:
  3785. ie, don't want that *version* of the option to exist, or don't want
  3786. the option to exist in either version?}
  3787. @FIXME{i think this explanation is lacking.}
  3788. The @value{op-same-order} option tells @command{tar} that the list of file
  3789. names to be listed or extracted is sorted in the same order as the
  3790. files in the archive. This allows a large list of names to be used,
  3791. even on a small machine that would not otherwise be able to hold all
  3792. the names in memory at the same time. Such a sorted list can easily be
  3793. created by running @samp{tar -t} on the archive and editing its output.
  3794. This option is probably never needed on modern computer systems.
  3795. @node backup
  3796. @section Backup options
  3797. @cindex backup options
  3798. @GNUTAR{} offers options for making backups of files
  3799. before writing new versions. These options control the details of
  3800. these backups. They may apply to the archive itself before it is
  3801. created or rewritten, as well as individual extracted members. Other
  3802. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3803. and @command{mv}, for example) offer similar options.
  3804. Backup options may prove unexpectedly useful when extracting archives
  3805. containing many members having identical name, or when extracting archives
  3806. on systems having file name limitations, making different members appear
  3807. has having similar names through the side-effect of name truncation.
  3808. (This is true only if we have a good scheme for truncated backup names,
  3809. which I'm not sure at all: I suspect work is needed in this area.)
  3810. When any existing file is backed up before being overwritten by extraction,
  3811. then clashing files are automatically be renamed to be unique, and the
  3812. true name is kept for only the last file of a series of clashing files.
  3813. By using verbose mode, users may track exactly what happens.
  3814. At the detail level, some decisions are still experimental, and may
  3815. change in the future, we are waiting comments from our users. So, please
  3816. do not learn to depend blindly on the details of the backup features.
  3817. For example, currently, directories themselves are never renamed through
  3818. using these options, so, extracting a file over a directory still has
  3819. good chances to fail. Also, backup options apply to created archives,
  3820. not only to extracted members. For created archives, backups will not
  3821. be attempted when the archive is a block or character device, or when it
  3822. refers to a remote file.
  3823. For the sake of simplicity and efficiency, backups are made by renaming old
  3824. files prior to creation or extraction, and not by copying. The original
  3825. name is restored if the file creation fails. If a failure occurs after a
  3826. partial extraction of a file, both the backup and the partially extracted
  3827. file are kept.
  3828. @table @samp
  3829. @item --backup[=@var{method}]
  3830. @opindex --backup
  3831. @vindex VERSION_CONTROL
  3832. @cindex backups
  3833. Back up files that are about to be overwritten or removed.
  3834. Without this option, the original versions are destroyed.
  3835. Use @var{method} to determine the type of backups made.
  3836. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3837. environment variable. And if @env{VERSION_CONTROL} is not set,
  3838. use the @samp{existing} method.
  3839. @vindex version-control @r{Emacs variable}
  3840. This option corresponds to the Emacs variable @samp{version-control};
  3841. the same values for @var{method} are accepted as in Emacs. This option
  3842. also allows more descriptive names. The valid @var{method}s are:
  3843. @table @samp
  3844. @item t
  3845. @itemx numbered
  3846. @opindex numbered @r{backup method}
  3847. Always make numbered backups.
  3848. @item nil
  3849. @itemx existing
  3850. @opindex existing @r{backup method}
  3851. Make numbered backups of files that already have them, simple backups
  3852. of the others.
  3853. @item never
  3854. @itemx simple
  3855. @opindex simple @r{backup method}
  3856. Always make simple backups.
  3857. @end table
  3858. @item --suffix=@var{suffix}
  3859. @opindex --suffix
  3860. @cindex backup suffix
  3861. @vindex SIMPLE_BACKUP_SUFFIX
  3862. Append @var{suffix} to each backup file made with @samp{--backup}. If this
  3863. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3864. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3865. set, the default is @samp{~}, just as in Emacs.
  3866. @end table
  3867. Some people express the desire to @emph{always} use the @value{op-backup}
  3868. option, by defining some kind of alias or script. This is not as easy
  3869. as one may think, due to the fact that old style options should appear first
  3870. and consume arguments a bit unpredictably for an alias or script. But,
  3871. if you are ready to give up using old style options, you may resort to
  3872. using something like (a Bourne shell function here):
  3873. @smallexample
  3874. tar () @{ /usr/local/bin/tar --backup $*; @}
  3875. @end smallexample
  3876. @node Applications
  3877. @section Notable @command{tar} Usages
  3878. @UNREVISED
  3879. @FIXME{Using Unix file linking capability to recreate directory
  3880. structures---linking files into one subdirectory and then
  3881. @command{tar}ring that directory.}
  3882. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3883. @findex uuencode
  3884. You can easily use archive files to transport a group of files from
  3885. one system to another: put all relevant files into an archive on one
  3886. computer system, transfer the archive to another system, and extract
  3887. the contents there. The basic transfer medium might be magnetic tape,
  3888. Internet FTP, or even electronic mail (though you must encode the
  3889. archive with @command{uuencode} in order to transport it properly by
  3890. mail). Both machines do not have to use the same operating system, as
  3891. long as they both support the @command{tar} program.
  3892. For example, here is how you might copy a directory's contents from
  3893. one disk to another, while preserving the dates, modes, owners and
  3894. link-structure of all the files therein. In this case, the transfer
  3895. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3896. @smallexample
  3897. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3898. @end smallexample
  3899. @noindent
  3900. The command also works using short option forms:
  3901. @smallexample
  3902. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3903. @end smallexample
  3904. @noindent
  3905. This is one of the easiest methods to transfer a @command{tar} archive.
  3906. @node looking ahead
  3907. @section Looking Ahead: The Rest of this Manual
  3908. You have now seen how to use all eight of the operations available to
  3909. @command{tar}, and a number of the possible options. The next chapter
  3910. explains how to choose and change file and archive names, how to use
  3911. files to store names of other files which you can then call as
  3912. arguments to @command{tar} (this can help you save time if you expect to
  3913. archive the same list of files a number of times), and so forth.
  3914. @FIXME{in case it's not obvious, i'm making this up in some sense
  3915. based on my limited memory of what the next chapter *really* does. i
  3916. just wanted to flesh out this final section a little bit so i'd
  3917. remember to stick it in here. :-)}
  3918. If there are too many files to conveniently list on the command line,
  3919. you can list the names in a file, and @command{tar} will read that file.
  3920. @value{xref-files-from}.
  3921. There are various ways of causing @command{tar} to skip over some files,
  3922. and not archive them. @xref{Choosing}.
  3923. @node Backups
  3924. @chapter Performing Backups and Restoring Files
  3925. @UNREVISED
  3926. @GNUTAR{} is distributed along with the scripts
  3927. which the Free Software Foundation uses for performing backups. There
  3928. is no corresponding scripts available yet for doing restoration of
  3929. files. Even if there is a good chance those scripts may be satisfying
  3930. to you, they are not the only scripts or methods available for doing
  3931. backups and restore. You may well create your own, or use more
  3932. sophisticated packages dedicated to that purpose.
  3933. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3934. Automatic Network Disk Archiver), a backup system developed by James
  3935. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3936. This is free software, and it is available at these places:
  3937. @smallexample
  3938. http://www.cs.umd.edu/projects/amanda/amanda.html
  3939. ftp://ftp.cs.umd.edu/pub/amanda
  3940. @end smallexample
  3941. @ifclear PUBLISH
  3942. Here is a possible plan for a future documentation about the backuping
  3943. scripts which are provided within the @GNUTAR{}
  3944. distribution.
  3945. @smallexample
  3946. .* dumps
  3947. . + what are dumps
  3948. . + different levels of dumps
  3949. . - full dump = dump everything
  3950. . - level 1, level 2 dumps etc, -
  3951. A level n dump dumps everything changed since the last level
  3952. n-1 dump (?)
  3953. . + how to use scripts for dumps (ie, the concept)
  3954. . - scripts to run after editing backup specs (details)
  3955. . + Backup Specs, what is it.
  3956. . - how to customize
  3957. . - actual text of script [/sp/dump/backup-specs]
  3958. . + Problems
  3959. . - rsh doesn't work
  3960. . - rtape isn't installed
  3961. . - (others?)
  3962. . + the --incremental option of tar
  3963. . + tapes
  3964. . - write protection
  3965. . - types of media
  3966. . : different sizes and types, useful for different things
  3967. . - files and tape marks
  3968. one tape mark between files, two at end.
  3969. . - positioning the tape
  3970. MT writes two at end of write,
  3971. backspaces over one when writing again.
  3972. @end smallexample
  3973. @end ifclear
  3974. This chapter documents both the provided shell scripts and @command{tar}
  3975. options which are more specific to usage as a backup tool.
  3976. To @dfn{back up} a file system means to create archives that contain
  3977. all the files in that file system. Those archives can then be used to
  3978. restore any or all of those files (for instance if a disk crashes or a
  3979. file is accidentally deleted). File system @dfn{backups} are also
  3980. called @dfn{dumps}.
  3981. @menu
  3982. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3983. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  3984. * incremental and listed-incremental:: The Incremental Options
  3985. * Backup Levels:: Levels of Backups
  3986. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3987. * Scripted Backups:: Using the Backup Scripts
  3988. * Scripted Restoration:: Using the Restore Script
  3989. @end menu
  3990. @node Full Dumps
  3991. @section Using @command{tar} to Perform Full Dumps
  3992. @UNREVISED
  3993. @cindex full dumps
  3994. @cindex dumps, full
  3995. @cindex corrupted archives
  3996. Full dumps should only be made when no other people or programs
  3997. are modifying files in the filesystem. If files are modified while
  3998. @command{tar} is making the backup, they may not be stored properly in
  3999. the archive, in which case you won't be able to restore them if you
  4000. have to. (Files not being modified are written with no trouble, and do
  4001. not corrupt the entire archive.)
  4002. You will want to use the @value{op-label} option to give the archive a
  4003. volume label, so you can tell what this archive is even if the label
  4004. falls off the tape, or anything like that.
  4005. Unless the filesystem you are dumping is guaranteed to fit on
  4006. one volume, you will need to use the @value{op-multi-volume} option.
  4007. Make sure you have enough tapes on hand to complete the backup.
  4008. If you want to dump each filesystem separately you will need to use
  4009. the @value{op-one-file-system} option to prevent @command{tar} from crossing
  4010. filesystem boundaries when storing (sub)directories.
  4011. The @value{op-incremental} option is not needed, since this is a complete
  4012. copy of everything in the filesystem, and a full restore from this
  4013. backup would only be done onto a completely empty disk.
  4014. Unless you are in a hurry, and trust the @command{tar} program (and your
  4015. tapes), it is a good idea to use the @value{op-verify} option, to make
  4016. sure your files really made it onto the dump properly. This will
  4017. also detect cases where the file was modified while (or just after)
  4018. it was being archived. Not all media (notably cartridge tapes) are
  4019. capable of being verified, unfortunately.
  4020. @value{op-listed-incremental} take a file name argument always. If the
  4021. file doesn't exist, run a level zero dump, creating the file. If the
  4022. file exists, uses that file to see what has changed.
  4023. @value{op-incremental} @FIXME{look it up}
  4024. @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
  4025. This option should only be used when creating an incremental backup of
  4026. a filesystem. When the @value{op-incremental} option is used, @command{tar}
  4027. writes, at the beginning of the archive, an entry for each of the
  4028. directories that will be operated on. The entry for a directory
  4029. includes a list of all the files in the directory at the time the
  4030. dump was done, and a flag for each file indicating whether the file
  4031. is going to be put in the archive. This information is used when
  4032. doing a complete incremental restore.
  4033. Note that this option causes @command{tar} to create a non-standard
  4034. archive that may not be readable by non-@acronym{GNU} versions of the
  4035. @command{tar} program.
  4036. The @value{op-incremental} option means the archive is an incremental
  4037. backup. Its meaning depends on the command that it modifies.
  4038. If the @value{op-incremental} option is used with @value{op-list},
  4039. @command{tar} will list, for each directory in the archive, the list
  4040. of files in that directory at the time the archive was created. This
  4041. information is put out in a format that is not easy for humans to
  4042. read, but which is unambiguous for a program: each file name is
  4043. preceded by either a @samp{Y} if the file is present in the archive,
  4044. an @samp{N} if the file is not included in the archive, or a @samp{D}
  4045. if the file is a directory (and is included in the archive). Each
  4046. file name is terminated by a null character. The last file is
  4047. followed by an additional null and a newline to indicate the end of
  4048. the data.
  4049. If the @value{op-incremental} option is used with @value{op-extract}, then
  4050. when the entry for a directory is found, all files that currently
  4051. exist in that directory but are not listed in the archive @emph{are
  4052. deleted from the directory}.
  4053. This behavior is convenient when you are restoring a damaged file
  4054. system from a succession of incremental backups: it restores the
  4055. entire state of the file system to that which obtained when the backup
  4056. was made. If you don't use @value{op-incremental}, the file system will
  4057. probably fill up with files that shouldn't exist any more.
  4058. @value{op-listed-incremental} handle new @acronym{GNU}-format
  4059. incremental backup. This option handles new @acronym{GNU}-format
  4060. incremental backup. It has much the same effect as
  4061. @value{op-incremental}, but also the time when the dump is done and
  4062. the list of directories dumped is written to the given
  4063. @var{file}. When restoring, only files newer than the saved time are
  4064. restored, and the directory list is used to speed up operations.
  4065. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4066. used in conjunction with @value{op-create} will also cause @command{tar} to
  4067. use the file @var{file}, which contains information about the state
  4068. of the filesystem at the time of the last backup, to decide which
  4069. files to include in the archive being created. That file will then
  4070. be updated by @command{tar}. If the file @var{file} does not exist when
  4071. this option is specified, @command{tar} will create it, and include all
  4072. appropriate files in the archive.
  4073. The file, which is archive independent, contains the date it was last
  4074. modified and a list of devices, inode numbers and directory names.
  4075. @command{tar} will archive files with newer mod dates or inode change
  4076. times, and directories with an unchanged inode number and device but
  4077. a changed directory name. The file is updated after the files to
  4078. be archived are determined, but before the new archive is actually
  4079. created.
  4080. @node Inc Dumps
  4081. @section Using @command{tar} to Perform Incremental Dumps
  4082. @UNREVISED
  4083. @cindex incremental dumps
  4084. @cindex dumps, incremental
  4085. Performing incremental dumps is similar to performing full dumps,
  4086. although a few more options will usually be needed.
  4087. A standard scheme is to do a @emph{monthly} (full) dump once a month,
  4088. a @emph{weekly} dump once a week of everything since the last monthly
  4089. and a @emph{daily} every day of everything since the last (weekly or
  4090. monthly) dump.
  4091. Here is a sample script to dump the directory hierarchies @samp{/usr}
  4092. and @samp{/var}.
  4093. @smallexample
  4094. #! /bin/sh
  4095. tar --create \
  4096. --blocking-factor=126 \
  4097. --file=/dev/rmt/0 \
  4098. --label="`hostname` /usr /var `date +%Y-%m-%d`" \
  4099. --listed-incremental=/var/log/usr-var.snar \
  4100. --verbose \
  4101. /usr /var
  4102. @end smallexample
  4103. This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
  4104. store information about the previous tar dump.
  4105. The blocking factor 126 is an attempt to make the tape drive stream.
  4106. Some tape devices cannot handle 64 kB blocks or larger, and require the
  4107. block size to be a multiple of 1 kB; for these devices, 126 is the
  4108. largest blocking factor that can be used.
  4109. @node incremental and listed-incremental
  4110. @section The Incremental Options
  4111. @UNREVISED
  4112. @value{op-incremental} is used in conjunction with @value{op-create},
  4113. @value{op-extract} or @value{op-list} when backing up and restoring file
  4114. systems. An archive cannot be extracted or listed with the
  4115. @value{op-incremental} option specified unless it was created with the
  4116. option specified. This option should only be used by a script, not by
  4117. the user, and is usually disregarded in favor of
  4118. @value{op-listed-incremental}, which is described below.
  4119. @value{op-incremental} in conjunction with @value{op-create} causes
  4120. @command{tar} to write, at the beginning of the archive, an entry for
  4121. each of the directories that will be archived. The entry for a
  4122. directory includes a list of all the files in the directory at the
  4123. time the archive was created and a flag for each file indicating
  4124. whether or not the file is going to be put in the archive.
  4125. Note that this option causes @command{tar} to create a non-standard
  4126. archive that may not be readable by non-@acronym{GNU} versions of the
  4127. @command{tar} program.
  4128. @value{op-incremental} in conjunction with @value{op-extract} causes
  4129. @command{tar} to read the lists of directory contents previously stored
  4130. in the archive, @emph{delete} files in the file system that did not
  4131. exist in their directories when the archive was created, and then
  4132. extract the files in the archive.
  4133. This behavior is convenient when restoring a damaged file system from
  4134. a succession of incremental backups: it restores the entire state of
  4135. the file system to that which obtained when the backup was made. If
  4136. @value{op-incremental} isn't specified, the file system will probably
  4137. fill up with files that shouldn't exist any more.
  4138. @value{op-incremental} in conjunction with @value{op-list} causes
  4139. @command{tar} to print, for each directory in the archive, the list of
  4140. files in that directory at the time the archive was created. This
  4141. information is put out in a format that is not easy for humans to
  4142. read, but which is unambiguous for a program: each file name is
  4143. preceded by either a @samp{Y} if the file is present in the archive,
  4144. an @samp{N} if the file is not included in the archive, or a @samp{D}
  4145. if the file is a directory (and is included in the archive). Each
  4146. file name is terminated by a null character. The last file is followed
  4147. by an additional null and a newline to indicate the end of the data.
  4148. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4149. used in conjunction with @value{op-create} will also cause @command{tar}
  4150. to use the file @var{snapshot-file}, which contains information about
  4151. the state of the file system at the time of the last backup, to decide
  4152. which files to include in the archive being created. That file will
  4153. then be updated by @command{tar}. If the file @var{file} does not exist
  4154. when this option is specified, @command{tar} will create it, and include
  4155. all appropriate files in the archive.
  4156. The file @var{file}, which is archive independent, contains the date
  4157. it was last modified and a list of devices, inode numbers and
  4158. directory names. @command{tar} will archive files with newer mod dates
  4159. or inode change times, and directories with an unchanged inode number
  4160. and device but a changed directory name. The file is updated after
  4161. the files to be archived are determined, but before the new archive is
  4162. actually created.
  4163. Incremental dumps depend crucially on time stamps, so the results are
  4164. unreliable if you modify a file's time stamps during dumping (e.g.@:
  4165. with the @samp{--atime-preserve} option), or if you set the clock
  4166. backwards.
  4167. Despite it should be obvious that a device has a non-volatile value, NFS
  4168. devices have non-dependable values when an automounter gets in the picture.
  4169. This led to a great deal of spurious redumping in incremental dumps,
  4170. so it is somewhat useless to compare two NFS devices numbers over time.
  4171. So @command{tar} now considers all NFS devices as being equal when it comes
  4172. to comparing directories; this is fairly gross, but there does not seem
  4173. to be a better way to go.
  4174. @command{tar} doesn't access @var{snapshot-file} when
  4175. @value{op-create} or @value{op-list} are specified, but the
  4176. @value{op-listed-incremental} option must still be given. A
  4177. placeholder @var{snapshot-file} can be specified, e.g.,
  4178. @file{/dev/null}.
  4179. @FIXME{this section needs to be written}
  4180. @node Backup Levels
  4181. @section Levels of Backups
  4182. An archive containing all the files in the file system is called a
  4183. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4184. creating a full dump every day. This strategy, however, would waste a
  4185. substantial amount of archive media and user time, as unchanged files
  4186. are daily re-archived.
  4187. It is more efficient to do a full dump only occasionally. To back up
  4188. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4189. one} dump archives all the files that have changed since the last full
  4190. dump.
  4191. A typical dump strategy would be to perform a full dump once a week,
  4192. and a level one dump once a day. This means some versions of files
  4193. will in fact be archived more than once, but this dump strategy makes
  4194. it possible to restore a file system to within one day of accuracy by
  4195. only extracting two archives---the last weekly (full) dump and the
  4196. last daily (level one) dump. The only information lost would be in
  4197. files changed or created since the last daily backup. (Doing dumps
  4198. more than once a day is usually not worth the trouble).
  4199. @GNUTAR{} comes with scripts you can use to do full
  4200. and level-one (actually, even level-two and so on) dumps. Using
  4201. scripts (shell programs) to perform backups and restoration is a
  4202. convenient and reliable alternative to typing out file name lists
  4203. and @command{tar} commands by hand.
  4204. Before you use these scripts, you need to edit the file
  4205. @file{backup-specs}, which specifies parameters used by the backup
  4206. scripts and by the restore script. This file is usually located
  4207. in @file{/etc/backup} directory. @FIXME-xref{Script Syntax} Once the
  4208. backup parameters are set, you can perform backups or restoration by
  4209. running the appropriate script.
  4210. The name of the backup script is @code{backup}. The name of the
  4211. restore script is @code{restore}. The following sections describe
  4212. their use in detail.
  4213. @emph{Please Note:} The backup and restoration scripts are
  4214. designed to be used together. While it is possible to restore files by
  4215. hand from an archive which was created using a backup script, and to create
  4216. an archive by hand which could then be extracted using the restore script,
  4217. it is easier to use the scripts. @value{xref-incremental}, and
  4218. @value{xref-listed-incremental}, before making such an attempt.
  4219. @node Backup Parameters
  4220. @section Setting Parameters for Backups and Restoration
  4221. The file @file{backup-specs} specifies backup parameters for the
  4222. backup and restoration scripts provided with @command{tar}. You must
  4223. edit @file{backup-specs} to fit your system configuration and schedule
  4224. before using these scripts.
  4225. Syntactically, @file{backup-specs} is a shell script, containing
  4226. mainly variable assignments. However, any valid shell construct
  4227. is allowed in this file. Particularly, you may wish to define
  4228. functions within that script (e.g. see @code{RESTORE_BEGIN} below).
  4229. For more information about shell script syntax, please refer to
  4230. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4231. g_02, the definition of the Shell Command Language}. See also
  4232. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4233. The shell variables controlling behavior of @code{backup} and
  4234. @code{restore} are described in the following subsections.
  4235. @menu
  4236. * General-Purpose Variables::
  4237. * Magnetic Tape Control::
  4238. * User Hooks::
  4239. * backup-specs example:: An Example Text of @file{Backup-specs}
  4240. @end menu
  4241. @node General-Purpose Variables
  4242. @subsection General-Purpose Variables
  4243. @defvr {Backup variable} ADMINISTRATOR
  4244. The user name of the backup administrator. @code{Backup} scripts
  4245. sends a backup report to this address.
  4246. @end defvr
  4247. @defvr {Backup variable} BACKUP_HOUR
  4248. The hour at which the backups are done. This can be a number from 0
  4249. to 23, or the time specification in form @var{hours}:@var{minutes},
  4250. or the string @samp{now}.
  4251. This variable is used by @code{backup}. Its value may be overridden
  4252. using @option{--time} option (@pxref{Scripted Backups}).
  4253. @end defvr
  4254. @defvr {Backup variable} TAPE_FILE
  4255. The device @command{tar} writes the archive to. This device should be
  4256. attached to the host on which the dump scripts are run.
  4257. @end defvr
  4258. @defvr {Backup variable} BLOCKING
  4259. The blocking factor @command{tar} will use when writing the dump archive.
  4260. @value{xref-blocking-factor}.
  4261. @end defvr
  4262. @defvr {Backup variable} BACKUP_DIRS
  4263. A list of file systems to be dumped (for @code{backup}), or restored
  4264. (for @code{restore}). You can include any directory
  4265. name in the list --- subdirectories on that file system will be
  4266. included, regardless of how they may look to other networked machines.
  4267. Subdirectories on other file systems will be ignored.
  4268. The host name specifies which host to run @command{tar} on, and should
  4269. normally be the host that actually contains the file system. However,
  4270. the host machine must have @GNUTAR{} installed, and
  4271. must be able to access the directory containing the backup scripts and
  4272. their support files using the same file name that is used on the
  4273. machine where the scripts are run (ie. what @command{pwd} will print
  4274. when in that directory on that machine). If the host that contains
  4275. the file system does not have this capability, you can specify another
  4276. host as long as it can access the file system through NFS.
  4277. If the list of file systems is very long you may wish to put it
  4278. in a separate file. This file is usually named
  4279. @file{/etc/backup/dirs}, but this name may be overridden in
  4280. @file{backup-specs} using @code{DIRLIST} variable.
  4281. @end defvr
  4282. @defvr {Backup variable} DIRLIST
  4283. A path to the file containing the list of the filesystems to backup
  4284. or restore. By default it is @file{/etc/backup/dirs}.
  4285. @end defvr
  4286. @defvr {Backup variable} BACKUP_FILES
  4287. A list of individual files to be dumped (for @code{backup}), or restored
  4288. (for @code{restore}). These should be accessible from the machine on
  4289. which the backup script is run.
  4290. If the list of file systems is very long you may wish to store it
  4291. in a separate file. This file is usually named
  4292. @file{/etc/backup/files}, but this name may be overridden in
  4293. @file{backup-specs} using @code{FILELIST} variable.
  4294. @end defvr
  4295. @defvr {Backup variable} FILELIST
  4296. A path to the file containing the list of the individual files to backup
  4297. or restore. By default it is @file{/etc/backup/files}.
  4298. @end defvr
  4299. @defvr {Backup variable} RSH
  4300. Path to @code{rsh} binary or its equivalent. You may wish to
  4301. set it to @code{ssh}, to improve security. In this case you will have
  4302. to use public key authentication.
  4303. @end defvr
  4304. @defvr {Backup variable} RSH_COMMAND
  4305. Path to rsh binary on remote mashines. This will be passed via
  4306. @option{--rsh-command} option to the remote invocation of @GNUTAR{}.
  4307. @end defvr
  4308. @defvr {Backup variable} VOLNO_FILE
  4309. Name of temporary file to hold volume numbers. This needs to be accessible
  4310. by all the machines which have filesystems to be dumped.
  4311. @end defvr
  4312. @defvr {Backup variable} XLIST
  4313. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4314. located on the remote machine and containing the list of files to
  4315. be excluded from the backup. Exclude file lists are searched in
  4316. /etc/tar-backup directory. A common use for exclude file lists
  4317. is to exclude files containing security-sensitive information
  4318. (e.g. @file{/etc/shadow} from backups).
  4319. This variable affects only @code{backup}.
  4320. @end defvr
  4321. @defvr {Backup variable} SLEEP_TIME
  4322. Time to sleep between dumps of any two successive filesystems
  4323. This variable affects only @code{backup}.
  4324. @end defvr
  4325. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4326. Script to be run when it's time to insert a new tape in for the next
  4327. volume. Administrators may want to tailor this script for their site.
  4328. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4329. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4330. the console.
  4331. @end defvr
  4332. @defvr {Backup variable} SLEEP_MESSAGE
  4333. Message to display on the terminal while waiting for dump time. Usually
  4334. this will just be some literal text.
  4335. @end defvr
  4336. @defvr {Backup variable} TAR
  4337. Pathname of the @GNUTAR{} executable. If this is not set, backup
  4338. scripts will search @command{tar} in the current shell path.
  4339. @end defvr
  4340. @node Magnetic Tape Control
  4341. @subsection Magnetic Tape Control
  4342. Backup scripts access tape device using special @dfn{hook functions}.
  4343. These functions take a single argument -- the name of the tape
  4344. device. Their names are kept in the following variables:
  4345. @defvr {Backup variable} MT_BEGIN
  4346. The name of @dfn{begin} function. This function is called before
  4347. accessing the drive. By default it retensions the tape:
  4348. @smallexample
  4349. MT_BEGIN=mt_begin
  4350. mt_begin() @{
  4351. mt -f "$1" retension
  4352. @}
  4353. @end smallexample
  4354. @end defvr
  4355. @defvr {Backup variable} MT_REWIND
  4356. The name of @dfn{rewind} function. The default definition is as
  4357. follows:
  4358. @smallexample
  4359. MT_REWIND=mt_rewind
  4360. mt_rewind() @{
  4361. mt -f "$1" rewind
  4362. @}
  4363. @end smallexample
  4364. @end defvr
  4365. @defvr {Backup variable} MT_OFFLINE
  4366. The name of the function switching the tape off line. By default
  4367. it is defined as follows:
  4368. @smallexample
  4369. MT_OFFLINE=mt_offline
  4370. mt_offline() @{
  4371. mt -f "$1" offl
  4372. @}
  4373. @end smallexample
  4374. @end defvr
  4375. @defvr {Backup variable} MT_STATUS
  4376. The name of the function used to obtain the status of the archive device,
  4377. including error count. Default definition:
  4378. @smallexample
  4379. MT_STATUS=mt_status
  4380. mt_status() @{
  4381. mt -f "$1" status
  4382. @}
  4383. @end smallexample
  4384. @end defvr
  4385. @node User Hooks
  4386. @subsection User Hooks
  4387. @dfn{User hooks} are shell functions executed before and after
  4388. each @command{tar} invocation. Thus, there are @dfn{backup
  4389. hooks}, which are executed before and after dumping each file
  4390. system, and @dfn{restore hooks}, executed before and
  4391. after restoring a file system. Each user hook is a shell function
  4392. taking four arguments:
  4393. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4394. Its arguments are:
  4395. @table @var
  4396. @item level
  4397. Current backup or restore level.
  4398. @item host
  4399. Name or IP address of the host machine being dumped or restored.
  4400. @item fs
  4401. Full path name to the filesystem being dumped or restored.
  4402. @item fsname
  4403. Filesystem name with directory separators replaced with colons. This
  4404. is useful e.g. for creating unique files.
  4405. @end table
  4406. @end deffn
  4407. Following variables keep the names of user hook functions
  4408. @defvr {Backup variable} DUMP_BEGIN
  4409. Dump begin function. It is executed before dumping the filesystem.
  4410. @end defvr
  4411. @defvr {Backup variable} DUMP_END
  4412. Executed after dumping the filesystem.
  4413. @end defvr
  4414. @defvr {Backup variable} RESTORE_BEGIN
  4415. Executed before restoring the filesystem.
  4416. @end defvr
  4417. @defvr {Backup variable} RESTORE_END
  4418. Executed after restoring the filesystem.
  4419. @end defvr
  4420. @node backup-specs example
  4421. @subsection An Example Text of @file{Backup-specs}
  4422. The following is an example of @file{backup-specs}:
  4423. @smallexample
  4424. # site-specific parameters for file system backup.
  4425. ADMINISTRATOR=friedman
  4426. BACKUP_HOUR=1
  4427. TAPE_FILE=/dev/nrsmt0
  4428. # Use @code{ssh} instead of the less secure @code{rsh}
  4429. RSH=/usr/bin/ssh
  4430. RSH_COMMAND=/usr/bin/ssh
  4431. # Override MT_STATUS function:
  4432. my_status() @{
  4433. mts -t $TAPE_FILE
  4434. @}
  4435. MT_STATUS=my_status
  4436. # Disable MT_OFFLINE function
  4437. MT_OFFLINE=:
  4438. BLOCKING=124
  4439. BACKUP_DIRS="
  4440. albert:/fs/fsf
  4441. apple-gunkies:/gd
  4442. albert:/fs/gd2
  4443. albert:/fs/gp
  4444. geech:/usr/jla
  4445. churchy:/usr/roland
  4446. albert:/
  4447. albert:/usr
  4448. apple-gunkies:/
  4449. apple-gunkies:/usr
  4450. gnu:/hack
  4451. gnu:/u
  4452. apple-gunkies:/com/mailer/gnu
  4453. apple-gunkies:/com/archive/gnu"
  4454. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4455. @end smallexample
  4456. @node Scripted Backups
  4457. @section Using the Backup Scripts
  4458. The syntax for running a backup script is:
  4459. @smallexample
  4460. backup --level=@var{level} --time=@var{time}
  4461. @end smallexample
  4462. The @option{level} option requests the dump level. Thus, to produce
  4463. a full dump, specify @code{--level=0} (this is the default, so
  4464. @option{--level} may be omitted if its value is @code{0}).
  4465. @footnote{For backward compatibility, the @code{backup} will also
  4466. try to deduce the requested dump level from the name of the
  4467. script itself. If the name consists of a string @samp{level-}
  4468. followed by a single decimal digit, that digit is taken as
  4469. the dump level number. Thus, you may create a link from @code{backup}
  4470. to @code{level-1} and then run @code{level-1} whenever you need to
  4471. create a level one dump.}
  4472. The @option{--time} option determines when should the backup be
  4473. run. @var{Time} may take three forms:
  4474. @table @asis
  4475. @item @var{hh}:@var{mm}
  4476. The dump must be run at @var{hh} hours @var{mm} minutes.
  4477. @item @var{hh}
  4478. The dump must be run at @var{hh} hours
  4479. @item now
  4480. The dump must be run immediately.
  4481. @end table
  4482. You should start a script with a tape or disk mounted. Once you
  4483. start a script, it prompts you for new tapes or disks as it
  4484. needs them. Media volumes don't have to correspond to archive
  4485. files --- a multi-volume archive can be started in the middle of a
  4486. tape that already contains the end of another multi-volume archive.
  4487. The @code{restore} script prompts for media by its archive volume,
  4488. so to avoid an error message you should keep track of which tape
  4489. (or disk) contains which volume of the archive (@pxref{Scripted
  4490. Restoration}).
  4491. The backup scripts write two files on the file system. The first is a
  4492. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4493. to store and retrieve information about which files were dumped. This
  4494. file is not meant to be read by humans, and should not be deleted by
  4495. them. @FIXME-xref{incremental and listed-incremental, for a more
  4496. detailed explanation of this file.}
  4497. The second file is a log file containing the names of the file systems
  4498. and files dumped, what time the backup was made, and any error
  4499. messages that were generated, as well as how much space was left in
  4500. the media volume after the last volume of the archive was written.
  4501. You should check this log file after every backup. The file name is
  4502. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4503. represents current date, and @var{n} represents current dump level number.
  4504. The script also prints the name of each system being dumped to the
  4505. standard output.
  4506. Following is the full list of options accepted by @code{backup}
  4507. script:
  4508. @table @option
  4509. @item -l @var{level}
  4510. @itemx --level=@var{level}
  4511. Do backup level @var{level} (default 0).
  4512. @item -f
  4513. @itemx --force
  4514. Force backup even if today's log file already exists.
  4515. @item -v[@var{level}]
  4516. @itemx --verbose[=@var{level}]
  4517. Set verbosity level. The higher the level is, the more debugging
  4518. information will be output during execution. Devault @var{level}
  4519. is 100, which means the highest debugging level.
  4520. @item -t @var{start-time}
  4521. @itemx --time=@var{start-time}
  4522. Wait till @var{time}, then do backup.
  4523. @item -h
  4524. @itemx --help
  4525. Display short help message and exit.
  4526. @item -L
  4527. @itemx --license
  4528. Display program license and exit.
  4529. @item -V
  4530. @itemx --version
  4531. Display program version and exit.
  4532. @end table
  4533. @node Scripted Restoration
  4534. @section Using the Restore Script
  4535. To restore files that were archived using a scripted backup, use the
  4536. @code{restore} script. Its usage is quite straightforward. In the
  4537. simplest form, invoke @code{restore --all}, it will
  4538. then restore all the filesystems and files specified in
  4539. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4540. You may select the filesystems (and/or files) to restore by
  4541. giving @code{restore} list of @dfn{patterns} in its command
  4542. line. For example, running
  4543. @smallexample
  4544. restore 'albert:*'
  4545. @end smallexample
  4546. @noindent
  4547. will restore all filesystems on the machine @samp{albert}. A more
  4548. complicated example:
  4549. @smallexample
  4550. restore 'albert:*' '*:/var'
  4551. @end smallexample
  4552. @noindent
  4553. This command will restore all filesystems on the machine @samp{albert}
  4554. as well as @file{/var} filesystem on all machines.
  4555. By default @code{restore} will start restoring files from the lowest
  4556. available dump level (usually zero) and will continue through
  4557. all available dump levels. There may be situations where such a
  4558. thorough restore is not necessary. For example, you may wish to
  4559. restore only files from the recent level one backup. To do so,
  4560. use @option{--level} option, as shown in the example below:
  4561. @smallexample
  4562. restore --level=1
  4563. @end smallexample
  4564. The full list of options accepted by @code{restore} follows:
  4565. @table @option
  4566. @item -a
  4567. @itemx --all
  4568. Restore all filesystems and files specified in @file{backup-specs}
  4569. @item -l @var{level}
  4570. @itemx --level=@var{level}
  4571. Start restoring from the given backup level, instead of the default 0.
  4572. @item -v[@var{level}]
  4573. @itemx --verbose[=@var{level}]
  4574. Set verbosity level. The higher the level is, the more debugging
  4575. information will be output during execution. Devault @var{level}
  4576. is 100, which means the highest debugging level.
  4577. @item -h
  4578. @itemx --help
  4579. Display short help message and exit.
  4580. @item -L
  4581. @itemx --license
  4582. Display program license and exit.
  4583. @item -V
  4584. @itemx --version
  4585. Display program version and exit.
  4586. @end table
  4587. You should start the restore script with the media containing the
  4588. first volume of the archive mounted. The script will prompt for other
  4589. volumes as they are needed. If the archive is on tape, you don't need
  4590. to rewind the tape to to its beginning---if the tape head is
  4591. positioned past the beginning of the archive, the script will rewind
  4592. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4593. positioning.}
  4594. @quotation
  4595. @strong{Warning:} The script will delete files from the active file
  4596. system if they were not in the file system when the archive was made.
  4597. @end quotation
  4598. @value{xref-incremental}, and @value{ref-listed-incremental},
  4599. for an explanation of how the script makes that determination.
  4600. @node Choosing
  4601. @chapter Choosing Files and Names for @command{tar}
  4602. @UNREVISED
  4603. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4604. Certain options to @command{tar} enable you to specify a name for your
  4605. archive. Other options let you decide which files to include or exclude
  4606. from the archive, based on when or whether files were modified, whether
  4607. the file names do or don't match specified patterns, or whether files
  4608. are in specified directories.
  4609. @menu
  4610. * file:: Choosing the Archive's Name
  4611. * Selecting Archive Members::
  4612. * files:: Reading Names from a File
  4613. * exclude:: Excluding Some Files
  4614. * Wildcards::
  4615. * after:: Operating Only on New Files
  4616. * recurse:: Descending into Directories
  4617. * one:: Crossing Filesystem Boundaries
  4618. @end menu
  4619. @node file
  4620. @section Choosing and Naming Archive Files
  4621. @cindex Naming an archive
  4622. @cindex Archive Name
  4623. @cindex Directing output
  4624. @cindex Choosing an archive file
  4625. @cindex Where is the archive?
  4626. @UNREVISED
  4627. @FIXME{should the title of this section actually be, "naming an
  4628. archive"?}
  4629. By default, @command{tar} uses an archive file name that was compiled when
  4630. it was built on the system; usually this name refers to some physical
  4631. tape drive on the machine. However, the person who installed @command{tar}
  4632. on the system may not set the default to a meaningful value as far as
  4633. most users are concerned. As a result, you will usually want to tell
  4634. @command{tar} where to find (or create) the archive. The @value{op-file}
  4635. option allows you to either specify or name a file to use as the archive
  4636. instead of the default archive file location.
  4637. @table @kbd
  4638. @item --file=@var{archive-name}
  4639. @itemx -f @var{archive-name}
  4640. Name the archive to create or operate on. Use in conjunction with
  4641. any operation.
  4642. @end table
  4643. For example, in this @command{tar} command,
  4644. @smallexample
  4645. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4646. @end smallexample
  4647. @noindent
  4648. @file{collection.tar} is the name of the archive. It must directly
  4649. follow the @samp{-f} option, since whatever directly follows @samp{-f}
  4650. @emph{will} end up naming the archive. If you neglect to specify an
  4651. archive name, you may end up overwriting a file in the working directory
  4652. with the archive you create since @command{tar} will use this file's name
  4653. for the archive name.
  4654. An archive can be saved as a file in the file system, sent through a
  4655. pipe or over a network, or written to an I/O device such as a tape,
  4656. floppy disk, or CD write drive.
  4657. @cindex Writing new archives
  4658. @cindex Archive creation
  4659. If you do not name the archive, @command{tar} uses the value of the
  4660. environment variable @env{TAPE} as the file name for the archive. If
  4661. that is not available, @command{tar} uses a default, compiled-in archive
  4662. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4663. @command{tar} always needs an archive name.
  4664. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4665. archive from standard input (when listing or extracting files), or
  4666. writes it to standard output (when creating an archive). If you use
  4667. @file{-} as an @var{archive-name} when modifying an archive,
  4668. @command{tar} reads the original archive from its standard input and
  4669. writes the entire new archive to its standard output.
  4670. @FIXME{might want a different example here; this is already used in
  4671. "notable tar usages".}
  4672. @smallexample
  4673. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4674. @end smallexample
  4675. @FIXME{help!}
  4676. @cindex Standard input and output
  4677. @cindex tar to standard input and output
  4678. To specify an archive file on a device attached to a remote machine,
  4679. use the following:
  4680. @smallexample
  4681. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4682. @end smallexample
  4683. @noindent
  4684. @command{tar} will complete the remote connection, if possible, and
  4685. prompt you for a username and password. If you use
  4686. @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4687. will complete the remote connection, if possible, using your username
  4688. as the username on the remote machine.
  4689. If the archive file name includes a colon (@samp{:}), then it is assumed
  4690. to be a file on another machine. If the archive file is
  4691. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4692. host @var{host}. The remote host is accessed using the @command{rsh}
  4693. program, with a username of @var{user}. If the username is omitted
  4694. (along with the @samp{@@} sign), then your user name will be used.
  4695. (This is the normal @command{rsh} behavior.) It is necessary for the
  4696. remote machine, in addition to permitting your @command{rsh} access, to
  4697. have the @file{rmt} program installed (This command is included in
  4698. the @GNUTAR{} distribution and by default is installed under
  4699. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4700. installation prefix). If you need to use a file whose name includes a
  4701. colon, then the remote tape drive behavior
  4702. can be inhibited by using the @value{op-force-local} option.
  4703. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4704. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4705. into what came before it well enough <<i moved it now, is it better
  4706. here?>>. bob also comments that if Amanda isn't free software, we
  4707. shouldn't mention it..}
  4708. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4709. tries to minimize input and output operations. The
  4710. Amanda backup system, when used with @GNUTAR{}, has
  4711. an initial sizing pass which uses this feature.
  4712. @node Selecting Archive Members
  4713. @section Selecting Archive Members
  4714. @cindex Specifying files to act on
  4715. @cindex Specifying archive members
  4716. @dfn{File Name arguments} specify which files in the file system
  4717. @command{tar} operates on, when creating or adding to an archive, or which
  4718. archive members @command{tar} operates on, when reading or deleting from
  4719. an archive. @xref{Operations}.
  4720. To specify file names, you can include them as the last arguments on
  4721. the command line, as follows:
  4722. @smallexample
  4723. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4724. @end smallexample
  4725. If you specify a directory name as a file name argument, all the files
  4726. in that directory are operated on by @command{tar}.
  4727. If you do not specify files when @command{tar} is invoked with
  4728. @value{op-create}, @command{tar} operates on all the non-directory files in
  4729. the working directory. If you specify either @value{op-list} or
  4730. @value{op-extract}, @command{tar} operates on all the archive members in the
  4731. archive. If you specify any operation other than one of these three,
  4732. @command{tar} does nothing.
  4733. By default, @command{tar} takes file names from the command line. However,
  4734. there are other ways to specify file or member names, or to modify the
  4735. manner in which @command{tar} selects the files or members upon which to
  4736. operate. @FIXME{add xref here}In general, these methods work both for
  4737. specifying the names of files and archive members.
  4738. @node files
  4739. @section Reading Names from a File
  4740. @UNREVISED
  4741. @cindex Reading file names from a file
  4742. @cindex Lists of file names
  4743. @cindex File Name arguments, alternatives
  4744. Instead of giving the names of files or archive members on the command
  4745. line, you can put the names into a file, and then use the
  4746. @value{op-files-from} option to @command{tar}. Give the name of the file
  4747. which contains the list of files to include as the argument to
  4748. @samp{--files-from}. In the list, the file names should be separated by
  4749. newlines. You will frequently use this option when you have generated
  4750. the list of files to archive with the @command{find} utility.
  4751. @table @kbd
  4752. @item --files-from=@var{file name}
  4753. @itemx -T @var{file name}
  4754. Get names to extract or create from file @var{file name}.
  4755. @end table
  4756. If you give a single dash as a file name for @samp{--files-from}, (i.e.,
  4757. you specify either @samp{--files-from=-} or @samp{-T -}), then the file
  4758. names are read from standard input.
  4759. Unless you are running @command{tar} with @samp{--create}, you can not use
  4760. both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
  4761. command.
  4762. @FIXME{add bob's example, from his message on 2-10-97}
  4763. The following example shows how to use @command{find} to generate a list of
  4764. files smaller than 400K in length and put that list into a file
  4765. called @file{small-files}. You can then use the @samp{-T} option to
  4766. @command{tar} to specify the files from that file, @file{small-files}, to
  4767. create the archive @file{little.tgz}. (The @samp{-z} option to
  4768. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4769. more information.)
  4770. @smallexample
  4771. $ @kbd{find . -size -400 -print > small-files}
  4772. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4773. @end smallexample
  4774. @noindent
  4775. @FIXME{say more here to conclude the example/section?}
  4776. @menu
  4777. * nul::
  4778. @end menu
  4779. @node nul
  4780. @subsection @kbd{NUL} Terminated File Names
  4781. @cindex File names, terminated by @kbd{NUL}
  4782. @cindex @kbd{NUL} terminated file names
  4783. The @value{op-null} option causes @value{op-files-from} to read file
  4784. names terminated by a @code{NUL} instead of a newline, so files whose
  4785. names contain newlines can be archived using @samp{--files-from}.
  4786. @table @kbd
  4787. @item --null
  4788. Only consider @kbd{NUL} terminated file names, instead of files that
  4789. terminate in a newline.
  4790. @end table
  4791. The @samp{--null} option is just like the one in @acronym{GNU}
  4792. @command{xargs} and @command{cpio}, and is useful with the
  4793. @samp{-print0} predicate of @acronym{GNU} @command{find}. In
  4794. @command{tar}, @samp{--null} also causes @value{op-directory} options
  4795. to be treated as file names to archive, in case there are any files
  4796. out there called @file{-C}.
  4797. This example shows how to use @command{find} to generate a list of files
  4798. larger than 800K in length and put that list into a file called
  4799. @file{long-files}. The @samp{-print0} option to @command{find} just just
  4800. like @samp{-print}, except that it separates files with a @kbd{NUL}
  4801. rather than with a newline. You can then run @command{tar} with both the
  4802. @samp{--null} and @samp{-T} options to specify that @command{tar} get the
  4803. files from that file, @file{long-files}, to create the archive
  4804. @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
  4805. @command{tar} to recognize the @kbd{NUL} separator between files.
  4806. @smallexample
  4807. $ @kbd{find . -size +800 -print0 > long-files}
  4808. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4809. @end smallexample
  4810. @FIXME{say anything else here to conclude the section?}
  4811. @node exclude
  4812. @section Excluding Some Files
  4813. @cindex File names, excluding files by
  4814. @cindex Excluding files by name and pattern
  4815. @cindex Excluding files by file system
  4816. @UNREVISED
  4817. To avoid operating on files whose names match a particular pattern,
  4818. use the @value{op-exclude} or @value{op-exclude-from} options.
  4819. @table @kbd
  4820. @item --exclude=@var{pattern}
  4821. Causes @command{tar} to ignore files that match the @var{pattern}.
  4822. @end table
  4823. @findex exclude
  4824. The @value{op-exclude} option prevents any file or member whose name
  4825. matches the shell wildcard (@var{pattern}) from being operated on.
  4826. For example, to create an archive with all the contents of the directory
  4827. @file{src} except for files whose names end in @file{.o}, use the
  4828. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4829. You may give multiple @samp{--exclude} options.
  4830. @table @kbd
  4831. @item --exclude-from=@var{file}
  4832. @itemx -X @var{file}
  4833. Causes @command{tar} to ignore files that match the patterns listed in
  4834. @var{file}.
  4835. @end table
  4836. @findex exclude-from
  4837. Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
  4838. list of patterns, one per line, from @var{file}; @command{tar} will
  4839. ignore files matching those patterns. Thus if @command{tar} is
  4840. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4841. single line @file{*.o}, no files whose names end in @file{.o} will be
  4842. added to the archive.
  4843. @FIXME{do the exclude options files need to have stuff separated by
  4844. newlines the same as the files-from option does?}
  4845. @menu
  4846. * controlling pattern-patching with exclude::
  4847. * problems with exclude::
  4848. @end menu
  4849. @node controlling pattern-patching with exclude
  4850. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4851. Normally, a pattern matches a name if an initial subsequence of the
  4852. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4853. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4854. and wildcards can match @samp{/}.
  4855. Other than optionally stripping leading @samp{/} from names
  4856. (@pxref{absolute}), patterns and names are used as-is. For
  4857. example, trailing @samp{/} is not trimmed from a user-specified name
  4858. before deciding whether to exclude it.
  4859. However, this matching procedure can be altered by the options listed
  4860. below. These options accumulate. For example:
  4861. @smallexample
  4862. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4863. @end smallexample
  4864. ignores case when excluding @samp{makefile}, but not when excluding
  4865. @samp{readme}.
  4866. @table @option
  4867. @item --anchored
  4868. @itemx --no-anchored
  4869. If anchored, a pattern must match an initial subsequence
  4870. of the name's components. Otherwise, the pattern can match any
  4871. subsequence. Default is @option{--no-anchored}.
  4872. @item --ignore-case
  4873. @itemx --no-ignore-case
  4874. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4875. When not ignoring case (the default), matching is case-sensitive.
  4876. @item --wildcards
  4877. @itemx --no-wildcards
  4878. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4879. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4880. Otherwise, none of these characters are special, and patterns must match
  4881. names literally.
  4882. @item --wildcards-match-slash
  4883. @itemx --no-wildcards-match-slash
  4884. When wildcards match slash (the default), a wildcard like @samp{*} in
  4885. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4886. matched only by @samp{/}.
  4887. @end table
  4888. The @option{--recursion} and @option{--no-recursion} options
  4889. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4890. recursion is in effect, a pattern excludes a name if it matches any of
  4891. the name's parent directories.
  4892. @node problems with exclude
  4893. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4894. Some users find @samp{exclude} options confusing. Here are some common
  4895. pitfalls:
  4896. @itemize @bullet
  4897. @item
  4898. The main operating mode of @command{tar} does not act on a path name
  4899. explicitly listed on the command line if one of its file name
  4900. components is excluded. In the example above, if
  4901. you create an archive and exclude files that end with @samp{*.o}, but
  4902. explicitly name the file @samp{dir.o/foo} after all the options have been
  4903. listed, @samp{dir.o/foo} will be excluded from the archive.
  4904. @item
  4905. You can sometimes confuse the meanings of @value{op-exclude} and
  4906. @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
  4907. to be excluded are given as a pattern on the command line. Use
  4908. @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
  4909. file which contains a list of patterns, one per line; each of these
  4910. patterns can exclude zero, one, or many files.
  4911. @item
  4912. When you use @value{op-exclude}, be sure to quote the @var{pattern}
  4913. parameter, so @GNUTAR{} sees wildcard characters
  4914. like @samp{*}. If you do not do this, the shell might expand the
  4915. @samp{*} itself using files at hand, so @command{tar} might receive a
  4916. list of files instead of one pattern, or none at all, making the
  4917. command somewhat illegal. This might not correspond to what you want.
  4918. For example, write:
  4919. @smallexample
  4920. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4921. @end smallexample
  4922. @noindent
  4923. rather than:
  4924. @smallexample
  4925. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4926. @end smallexample
  4927. @item
  4928. You must use use shell syntax, or globbing, rather than @code{regexp}
  4929. syntax, when using exclude options in @command{tar}. If you try to use
  4930. @code{regexp} syntax to describe files to be excluded, your command
  4931. might fail.
  4932. @item
  4933. In earlier versions of @command{tar}, what is now the
  4934. @samp{--exclude-from=@var{file-of-patterns}} option was called
  4935. @samp{--exclude=@var{pattern}} instead. Now,
  4936. @samp{--exclude=@var{pattern}} applies to patterns listed on the command
  4937. line and @samp{--exclude-from=@var{file-of-patterns}} applies to
  4938. patterns listed in a file.
  4939. @end itemize
  4940. @node Wildcards
  4941. @section Wildcards Patterns and Matching
  4942. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  4943. @samp{*} or @samp{?} for example, are replaced and expanded into all
  4944. existing files matching the given pattern. However, @command{tar} often
  4945. uses wildcard patterns for matching (or globbing) archive members instead
  4946. of actual files in the filesystem. Wildcard patterns are also used for
  4947. verifying volume labels of @command{tar} archives. This section has the
  4948. purpose of explaining wildcard syntax for @command{tar}.
  4949. @FIXME{the next few paragraphs need work.}
  4950. A @var{pattern} should be written according to shell syntax, using wildcard
  4951. characters to effect globbing. Most characters in the pattern stand
  4952. for themselves in the matched string, and case is significant: @samp{a}
  4953. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  4954. pattern matches any single character in the matched string. The character
  4955. @samp{*} in the pattern matches zero, one, or more single characters in
  4956. the matched string. The character @samp{\} says to take the following
  4957. character of the pattern @emph{literally}; it is useful when one needs to
  4958. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  4959. The character @samp{[}, up to the matching @samp{]}, introduces a character
  4960. class. A @dfn{character class} is a list of acceptable characters
  4961. for the next single character of the matched string. For example,
  4962. @samp{[abcde]} would match any of the first five letters of the alphabet.
  4963. Note that within a character class, all of the ``special characters''
  4964. listed above other than @samp{\} lose their special meaning; for example,
  4965. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  4966. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  4967. the characters @samp{-} and @samp{]} must either come @emph{first} or
  4968. @emph{last} in a character class.)
  4969. @cindex Excluding characters from a character class
  4970. @cindex Character class, excluding characters from
  4971. If the first character of the class after the opening @samp{[}
  4972. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  4973. Rather than listing character to match, it lists those characters which
  4974. are @emph{forbidden} as the next single character of the matched string.
  4975. Other characters of the class stand for themselves. The special
  4976. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  4977. letters, is meant to represent all characters between @var{a} and
  4978. @var{e}, inclusive.
  4979. @FIXME{need to add a sentence or so here to make this clear for those
  4980. who don't have dan around.}
  4981. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  4982. special for wildcard matches. However, if a pattern completely matches
  4983. a directory prefix of a matched string, then it matches the full matched
  4984. string: excluding a directory also excludes all the files beneath it.
  4985. @node after
  4986. @section Operating Only on New Files
  4987. @cindex Excluding file by age
  4988. @cindex Modification time, excluding files by
  4989. @cindex Age, excluding files by
  4990. @UNREVISED
  4991. The @value{op-after-date} option causes @command{tar} to only work on files
  4992. whose modification or inode-changed times are newer than the @var{date}
  4993. given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
  4994. be a file name; the last-modified time of that file is used as the date.
  4995. If you use this option when creating or appending to an archive,
  4996. the archive will only include new files. If you use @samp{--after-date}
  4997. when extracting an archive, @command{tar} will only extract files newer
  4998. than the @var{date} you specify.
  4999. If you only want @command{tar} to make the date comparison based on
  5000. modification of the actual contents of the file (rather than inode
  5001. changes), then use the @value{op-newer-mtime} option.
  5002. You may use these options with any operation. Note that these options
  5003. differ from the @value{op-update} operation in that they allow you to
  5004. specify a particular date against which @command{tar} can compare when
  5005. deciding whether or not to archive the files.
  5006. @table @kbd
  5007. @item --after-date=@var{date}
  5008. @itemx --newer=@var{date}
  5009. @itemx -N @var{date}
  5010. Only store files newer than @var{date}.
  5011. Acts on files only if their modification or inode-changed times are
  5012. later than @var{date}. Use in conjunction with any operation.
  5013. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5014. name; the last-modified time of that file is used as the date.
  5015. @item --newer-mtime=@var{date}
  5016. Acts like @value{op-after-date}, but only looks at modification times.
  5017. @end table
  5018. These options limit @command{tar} to only operating on files which have
  5019. been modified after the date specified. A file is considered to have
  5020. changed if the contents have been modified, or if the owner,
  5021. permissions, and so forth, have been changed. (For more information on
  5022. how to specify a date, see @ref{Date input formats}; remember that the
  5023. entire date argument must be quoted if it contains any spaces.)
  5024. Gurus would say that @value{op-after-date} tests both the @code{mtime}
  5025. (time the contents of the file were last modified) and @code{ctime}
  5026. (time the file's status was last changed: owner, permissions, etc)
  5027. fields, while @value{op-newer-mtime} tests only @code{mtime} field.
  5028. To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
  5029. @code{ctime} and processes the file if either one is more recent than
  5030. @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
  5031. disregards @code{ctime}. Neither uses @code{atime} (the last time the
  5032. contents of the file were looked at).
  5033. Date specifiers can have embedded spaces. Because of this, you may need
  5034. to quote date arguments to keep the shell from parsing them as separate
  5035. arguments.
  5036. @FIXME{Need example of --newer-mtime with quoted argument.}
  5037. @quotation
  5038. @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
  5039. should not be used for incremental backups. Some files (such as those
  5040. in renamed directories) are not selected properly by these options.
  5041. @xref{incremental and listed-incremental}.
  5042. @end quotation
  5043. @noindent
  5044. @FIXME{which tells -- need to fill this in!}
  5045. @node recurse
  5046. @section Descending into Directories
  5047. @cindex Avoiding recursion in directories
  5048. @cindex Descending directories, avoiding
  5049. @cindex Directories, avoiding recursion
  5050. @cindex Recursion in directories, avoiding
  5051. @UNREVISED
  5052. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5053. @FIXME{show dan bob's comments, from 2-10-97}
  5054. Usually, @command{tar} will recursively explore all directories (either
  5055. those given on the command line or through the @value{op-files-from}
  5056. option) for the various files they contain. However, you may not always
  5057. want @command{tar} to act this way.
  5058. The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
  5059. into specified directories. If you specify @samp{--no-recursion}, you can
  5060. use the @command{find} utility for hunting through levels of directories to
  5061. construct a list of file names which you could then pass to @command{tar}.
  5062. @command{find} allows you to be more selective when choosing which files to
  5063. archive; see @ref{files} for more information on using @command{find} with
  5064. @command{tar}, or look.
  5065. @table @kbd
  5066. @item --no-recursion
  5067. Prevents @command{tar} from recursively descending directories.
  5068. @item --recursion
  5069. Requires @command{tar} to recursively descend directories.
  5070. This is the default.
  5071. @end table
  5072. When you use @samp{--no-recursion}, @GNUTAR{} grabs
  5073. directory entries themselves, but does not descend on them
  5074. recursively. Many people use @command{find} for locating files they
  5075. want to back up, and since @command{tar} @emph{usually} recursively
  5076. descends on directories, they have to use the @samp{@w{! -d}} option
  5077. to @command{find} @FIXME{needs more explanation or a cite to another
  5078. info file}as they usually do not want all the files in a directory.
  5079. They then use the @value{op-files-from} option to archive the files
  5080. located via @command{find}.
  5081. The problem when restoring files archived in this manner is that the
  5082. directories themselves are not in the archive; so the
  5083. @value{op-same-permissions} option does not affect them---while users
  5084. might really like it to. Specifying @value{op-no-recursion} is a way to
  5085. tell @command{tar} to grab only the directory entries given to it, adding
  5086. no new files on its own.
  5087. The @value{op-no-recursion} option also applies when extracting: it
  5088. causes @command{tar} to extract only the matched directory entries, not
  5089. the files under those directories.
  5090. The @value{op-no-recursion} option also affects how exclude patterns
  5091. are interpreted (@pxref{controlling pattern-patching with exclude}).
  5092. The @option{--no-recursion} and @option{--recursion} options apply to
  5093. later options and operands, and can be overridden by later occurrences
  5094. of @option{--no-recursion} and @option{--recursion}. For example:
  5095. @smallexample
  5096. $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
  5097. @end smallexample
  5098. @noindent
  5099. creates an archive with one entry for @file{grape}, and the recursive
  5100. contents of @file{grape/concord}, but no entries under @file{grape}
  5101. other than @file{grape/concord}.
  5102. @node one
  5103. @section Crossing Filesystem Boundaries
  5104. @cindex File system boundaries, not crossing
  5105. @UNREVISED
  5106. @command{tar} will normally automatically cross file system boundaries in
  5107. order to archive files which are part of a directory tree. You can
  5108. change this behavior by running @command{tar} and specifying
  5109. @value{op-one-file-system}. This option only affects files that are
  5110. archived because they are in a directory that is being archived;
  5111. @command{tar} will still archive files explicitly named on the command line
  5112. or through @value{op-files-from}, regardless of where they reside.
  5113. @table @kbd
  5114. @item --one-file-system
  5115. @itemx -l
  5116. Prevents @command{tar} from crossing file system boundaries when
  5117. archiving. Use in conjunction with any write operation.
  5118. @end table
  5119. The @samp{--one-file-system} option causes @command{tar} to modify its
  5120. normal behavior in archiving the contents of directories. If a file in
  5121. a directory is not on the same filesystem as the directory itself, then
  5122. @command{tar} will not archive that file. If the file is a directory
  5123. itself, @command{tar} will not archive anything beneath it; in other words,
  5124. @command{tar} will not cross mount points.
  5125. It is reported that using this option, the mount point is is archived,
  5126. but nothing under it.
  5127. This option is useful for making full or incremental archival backups of
  5128. a file system. If this option is used in conjunction with
  5129. @value{op-verbose}, files that are excluded are mentioned by name on the
  5130. standard error.
  5131. @menu
  5132. * directory:: Changing Directory
  5133. * absolute:: Absolute File Names
  5134. @end menu
  5135. @node directory
  5136. @subsection Changing the Working Directory
  5137. @FIXME{need to read over this node now for continuity; i've switched
  5138. things around some.}
  5139. @cindex Changing directory mid-stream
  5140. @cindex Directory, changing mid-stream
  5141. @cindex Working directory, specifying
  5142. @UNREVISED
  5143. To change the working directory in the middle of a list of file names,
  5144. either on the command line or in a file specified using
  5145. @value{op-files-from}, use @value{op-directory}. This will change the
  5146. working directory to the directory @var{directory} after that point in
  5147. the list.
  5148. @table @kbd
  5149. @item --directory=@var{directory}
  5150. @itemx -C @var{directory}
  5151. Changes the working directory in the middle of a command line.
  5152. @end table
  5153. For example,
  5154. @smallexample
  5155. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5156. @end smallexample
  5157. @noindent
  5158. will place the files @file{grape} and @file{prune} from the current
  5159. directory into the archive @file{jams.tar}, followed by the file
  5160. @file{cherry} from the directory @file{food}. This option is especially
  5161. useful when you have several widely separated files that you want to
  5162. store in the same archive.
  5163. Note that the file @file{cherry} is recorded in the archive under the
  5164. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5165. archive will contain three files that all appear to have come from the
  5166. same directory; if the archive is extracted with plain @samp{tar
  5167. --extract}, all three files will be written in the current directory.
  5168. Contrast this with the command,
  5169. @smallexample
  5170. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5171. @end smallexample
  5172. @noindent
  5173. which records the third file in the archive under the name
  5174. @file{red/cherry} so that, if the archive is extracted using
  5175. @samp{tar --extract}, the third file will be written in a subdirectory
  5176. named @file{orange-colored}.
  5177. You can use the @samp{--directory} option to make the archive
  5178. independent of the original name of the directory holding the files.
  5179. The following command places the files @file{/etc/passwd},
  5180. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5181. @file{foo.tar}:
  5182. @smallexample
  5183. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5184. @end smallexample
  5185. @noindent
  5186. However, the names of the archive members will be exactly what they were
  5187. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5188. They will not appear to be related by file name to the original
  5189. directories where those files were located.
  5190. Note that @samp{--directory} options are interpreted consecutively. If
  5191. @samp{--directory} specifies a relative file name, it is interpreted
  5192. relative to the then current directory, which might not be the same as
  5193. the original current working directory of @command{tar}, due to a previous
  5194. @samp{--directory} option.
  5195. @FIXME{dan: does this mean that you *can* use the short option form, but
  5196. you can *not* use the long option form with --files-from? or is this
  5197. totally screwed?}
  5198. When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
  5199. options in the file list. Unfortunately, you cannot put
  5200. @samp{--directory} options in the file list. (This interpretation can
  5201. be disabled by using the @value{op-null} option.)
  5202. @node absolute
  5203. @subsection Absolute File Names
  5204. @UNREVISED
  5205. @table @kbd
  5206. @item -P
  5207. @itemx --absolute-names
  5208. Do not strip leading slashes from file names, and permit file names
  5209. containing a @file{..} file name component.
  5210. @end table
  5211. By default, @GNUTAR{} drops a leading @samp{/} on
  5212. input or output, and complains about file names containing a @file{..}
  5213. component. This option turns off this behavior.
  5214. When @command{tar} extracts archive members from an archive, it strips any
  5215. leading slashes (@samp{/}) from the member name. This causes absolute
  5216. member names in the archive to be treated as relative file names. This
  5217. allows you to have such members extracted wherever you want, instead of
  5218. being restricted to extracting the member in the exact directory named
  5219. in the archive. For example, if the archive member has the name
  5220. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5221. really @file{etc/passwd}.
  5222. File names containing @file{..} can cause problems when extracting, so
  5223. @command{tar} normally warns you about such files when creating an
  5224. archive, and rejects attempts to extracts such files.
  5225. Other @command{tar} programs do not do this. As a result, if you
  5226. create an archive whose member names start with a slash, they will be
  5227. difficult for other people with a non-@GNUTAR{}
  5228. program to use. Therefore, @GNUTAR{} also strips
  5229. leading slashes from member names when putting members into the
  5230. archive. For example, if you ask @command{tar} to add the file
  5231. @file{/bin/ls} to an archive, it will do so, but the member name will
  5232. be @file{bin/ls}.
  5233. If you use the @value{op-absolute-names} option, @command{tar} will do
  5234. none of these transformations.
  5235. To archive or extract files relative to the root directory, specify
  5236. the @value{op-absolute-names} option.
  5237. Normally, @command{tar} acts on files relative to the working
  5238. directory---ignoring superior directory names when archiving, and
  5239. ignoring leading slashes when extracting.
  5240. When you specify @value{op-absolute-names}, @command{tar} stores file names
  5241. including all superior directory names, and preserves leading slashes.
  5242. If you only invoked @command{tar} from the root directory you would never
  5243. need the @value{op-absolute-names} option, but using this option may be
  5244. more convenient than switching to root.
  5245. @FIXME{Should be an example in the tutorial/wizardry section using this
  5246. to transfer files between systems.}
  5247. @FIXME{Is write access an issue?}
  5248. @table @kbd
  5249. @item --absolute-names
  5250. Preserves full file names (including superior directory names) when
  5251. archiving files. Preserves leading slash when extracting files.
  5252. @end table
  5253. @FIXME{this is still horrible; need to talk with dan on monday.}
  5254. @command{tar} prints out a message about removing the @samp{/} from
  5255. file names. This message appears once per @GNUTAR{}
  5256. invocation. It represents something which ought to be told; ignoring
  5257. what it means can cause very serious surprises, later.
  5258. Some people, nevertheless, do not want to see this message. Wanting to
  5259. play really dangerously, one may of course redirect @command{tar} standard
  5260. error to the sink. For example, under @command{sh}:
  5261. @smallexample
  5262. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5263. @end smallexample
  5264. @noindent
  5265. Another solution, both nicer and simpler, would be to change to
  5266. the @file{/} directory first, and then avoid absolute notation.
  5267. For example:
  5268. @smallexample
  5269. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5270. $ @kbd{tar -c -f archive.tar -C / home}
  5271. @end smallexample
  5272. @include getdate.texi
  5273. @node Formats
  5274. @chapter Controlling the Archive Format
  5275. Due to historical reasons, there are several formats of tar archives.
  5276. All of them are based on the same principles, but have some subtle
  5277. differences that often make them incompatible with each other.
  5278. GNU tar is able to create and handle archives in a variety of formats.
  5279. The most frequently used formats are (in alphabetical order):
  5280. @table @asis
  5281. @item gnu
  5282. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5283. from an early @acronym{POSIX} standard, adding some improvements such as
  5284. sparse file handling and incremental archives. Unfortunately these
  5285. features were implemented in a way incompatible with other archive
  5286. formats.
  5287. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5288. length.
  5289. @item oldgnu
  5290. Format used by @GNUTAR{} of versions prior to 1.12.
  5291. @item v7
  5292. Archive format, compatible with the V7 implementation of tar. This
  5293. format imposes a number of limitations. The most important of them
  5294. are:
  5295. @enumerate
  5296. @item The maximum length of a file name is limited to 99 characters.
  5297. @item The maximum length of a symbolic link is limited to 99 characters.
  5298. @item It is impossible to store special files (block and character
  5299. devices, fifos etc.)
  5300. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5301. octal)
  5302. @item V7 archives do not contain symbolic ownership information (user
  5303. and group name of the file owner).
  5304. @end enumerate
  5305. This format has traditionally been used by Automake when producing
  5306. Makefiles. This practice will change in the future, in the meantime,
  5307. however this means that projects containing filenames more than 99
  5308. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5309. Automake prior to 1.9.
  5310. @item ustar
  5311. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5312. symbolic ownership information. It is also able to store
  5313. special files. However, it imposes several restrictions as well:
  5314. @enumerate
  5315. @item The maximum length of a file name is limited to 256 characters,
  5316. provided that the filename can be split at directory separator in
  5317. two parts, first of them being at most 155 bytes long. So, in most
  5318. cases the maximum file name length will be shorter than 256
  5319. characters.
  5320. @item The maximum length of a symbolic link name is limited to
  5321. 100 characters.
  5322. @item Maximum size of a file the archive is able to accomodate
  5323. is 8GB
  5324. @item Maximum value of UID/GID is 2097151.
  5325. @item Maximum number of bits in device major and minor numbers is 21.
  5326. @end enumerate
  5327. @item star
  5328. Format used by J@"org Schilling @command{star}
  5329. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5330. currently does not produce them.
  5331. @item posix
  5332. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5333. most flexible and feature-rich format. It does not impose any
  5334. restrictions on file sizes or filename lengths. This format is quite
  5335. recent, so not all tar implementations are able to handle it properly.
  5336. However, this format is designed in such a way that any tar
  5337. implementation able to read @samp{ustar} archives will be able to read
  5338. most @samp{posix} archives as well, with the only exception that any
  5339. additional information (such as long file names etc.) will in such
  5340. case be extracted as plain text files along with the files it refers to.
  5341. This archive format will be the default format for future versions
  5342. of @GNUTAR{}.
  5343. @end table
  5344. The following table summarizes the limitations of each of these
  5345. formats:
  5346. @multitable @columnfractions .10 .20 .20 .20 .20
  5347. @item Format @tab UID @tab File Size @tab Path Name @tab Devn
  5348. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5349. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5350. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5351. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5352. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5353. @end multitable
  5354. The default format for @GNUTAR{} is defined at compilation
  5355. time. You may check it by running @command{tar --help}, and examining
  5356. the last lines of its output. Usually, @GNUTAR{} is configured
  5357. to create archives in @samp{gnu} format, however, future version will
  5358. switch to @samp{posix}.
  5359. @menu
  5360. * Portability:: Making @command{tar} Archives More Portable
  5361. * Compression:: Using Less Space through Compression
  5362. * Attributes:: Handling File Attributes
  5363. * Standard:: The Standard Format
  5364. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5365. * cpio:: Comparison of @command{tar} and @command{cpio}
  5366. @end menu
  5367. @node Portability
  5368. @section Making @command{tar} Archives More Portable
  5369. Creating a @command{tar} archive on a particular system that is meant to be
  5370. useful later on many other machines and with other versions of @command{tar}
  5371. is more challenging than you might think. @command{tar} archive formats
  5372. have been evolving since the first versions of Unix. Many such formats
  5373. are around, and are not always compatible with each other. This section
  5374. discusses a few problems, and gives some advice about making @command{tar}
  5375. archives more portable.
  5376. One golden rule is simplicity. For example, limit your @command{tar}
  5377. archives to contain only regular files and directories, avoiding
  5378. other kind of special files. Do not attempt to save sparse files or
  5379. contiguous files as such. Let's discuss a few more problems, in turn.
  5380. @menu
  5381. * Portable Names:: Portable Names
  5382. * dereference:: Symbolic Links
  5383. * old:: Old V7 Archives
  5384. * ustar:: Ustar Archives
  5385. * gnu:: GNU and old GNU format archives.
  5386. * posix:: @acronym{POSIX} archives
  5387. * Checksumming:: Checksumming Problems
  5388. * Large or Negative Values:: Large files, negative time stamps, etc.
  5389. @end menu
  5390. @node Portable Names
  5391. @subsection Portable Names
  5392. Use portable file and member names. A name is portable if it contains
  5393. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5394. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5395. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5396. old Unix hosts, limit your file name components to 14 characters or
  5397. less.
  5398. If you intend to have your @command{tar} archives to be read under
  5399. MSDOS, you should not rely on case distinction for file names, and you
  5400. might use the @acronym{GNU} @command{doschk} program for helping you
  5401. further diagnosing illegal MSDOS names, which are even more limited
  5402. than System V's.
  5403. @node dereference
  5404. @subsection Symbolic Links
  5405. @cindex File names, using symbolic links
  5406. @cindex Symbolic link as file name
  5407. Normally, when @command{tar} archives a symbolic link, it writes a
  5408. block to the archive naming the target of the link. In that way, the
  5409. @command{tar} archive is a faithful record of the filesystem contents.
  5410. @value{op-dereference} is used with @value{op-create}, and causes
  5411. @command{tar} to archive the files symbolic links point to, instead of
  5412. the links themselves. When this option is used, when @command{tar}
  5413. encounters a symbolic link, it will archive the linked-to file,
  5414. instead of simply recording the presence of a symbolic link.
  5415. The name under which the file is stored in the file system is not
  5416. recorded in the archive. To record both the symbolic link name and
  5417. the file name in the system, archive the file under both names. If
  5418. all links were recorded automatically by @command{tar}, an extracted file
  5419. might be linked to a file name that no longer exists in the file
  5420. system.
  5421. If a linked-to file is encountered again by @command{tar} while creating
  5422. the same archive, an entire second copy of it will be stored. (This
  5423. @emph{might} be considered a bug.)
  5424. So, for portable archives, do not archive symbolic links as such,
  5425. and use @value{op-dereference}: many systems do not support
  5426. symbolic links, and moreover, your distribution might be unusable if
  5427. it contains unresolved symbolic links.
  5428. @node old
  5429. @subsection Old V7 Archives
  5430. @cindex Format, old style
  5431. @cindex Old style format
  5432. @cindex Old style archives
  5433. Certain old versions of @command{tar} cannot handle additional
  5434. information recorded by newer @command{tar} programs. To create an
  5435. archive in V7 format (not ANSI), which can be read by these old
  5436. versions, specify the @value{op-format-v7} option in
  5437. conjunction with the @value{op-create} (@command{tar} also
  5438. accepts @samp{--portability} or @samp{op-old-archive} for this
  5439. option). When you specify it,
  5440. @command{tar} leaves out information about directories, pipes, fifos,
  5441. contiguous files, and device files, and specifies file ownership by
  5442. group and user IDs instead of group and user names.
  5443. When updating an archive, do not use @value{op-format-v7}
  5444. unless the archive was created using this option.
  5445. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5446. @command{tar} program without serious trouble, so this option should
  5447. seldom be needed. On the other hand, most modern @command{tar}s are
  5448. able to read old format archives, so it might be safer for you to
  5449. always use @value{op-format-v7} for your distributions.
  5450. @node ustar
  5451. @subsection Ustar Archive Format
  5452. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5453. @code{ustar}. Although it is more flexible than the V7 format, it
  5454. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5455. description of @code{ustar} format). Along with V7 format,
  5456. @code{ustar} format is a good choice for archives intended to be read
  5457. with other implementations of @command{tar}.
  5458. To create archive in @code{ustar} format, use @value{op-format-ustar}
  5459. option in conjunction with the @value{op-create}.
  5460. @node gnu
  5461. @subsection @acronym{GNU} and old @GNUTAR{} format
  5462. @GNUTAR{} was based on an early draft of the
  5463. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5464. @command{tar}, such as the support for file names longer than 100
  5465. characters, use portions of the @command{tar} header record which were
  5466. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5467. @acronym{POSIX} have allocated the same parts of the header record for
  5468. other purposes. As a result, @GNUTAR{} format is
  5469. incompatible with the current @acronym{POSIX} specification, and with
  5470. @command{tar} programs that follow it.
  5471. In the majority of cases, @command{tar} will be configured to create
  5472. this format by default. This will change in the future releases, since
  5473. we plan to make @samp{posix} format the default.
  5474. To force creation a @GNUTAR{} archive, use option
  5475. @value{op-format-gnu}.
  5476. Some @command{tar} options are currently basing on @GNUTAR{}
  5477. format, and can therefore be used only with @samp{gnu}
  5478. or @samp{oldgnu} archive formats. The list of such options follows:
  5479. @itemize @bullet
  5480. @item @value{op-label}, when used with @value{op-create}.
  5481. @item @value{op-incremental}
  5482. @item @value{op-multi-volume}
  5483. @end itemize
  5484. These options will be re-implemented for the @samp{posix} archive
  5485. format in the future.
  5486. @node posix
  5487. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5488. The version @value{VERSION} of @GNUTAR{} is able
  5489. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5490. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5491. was given @value{op-format-posix} option.
  5492. Notice, that currently @acronym{GNU} extensions are not
  5493. allowed with this format. Following is the list of options that
  5494. cannot be used with @value{op-format-posix}:
  5495. @itemize @bullet
  5496. @item @value{op-label}, when used with @value{op-create}.
  5497. @item @value{op-incremental}
  5498. @item @value{op-multi-volume}
  5499. @end itemize
  5500. This restriction will disappear in the future versions.
  5501. @node Checksumming
  5502. @subsection Checksumming Problems
  5503. SunOS and HP-UX @command{tar} fail to accept archives created using
  5504. @GNUTAR{} and containing non-ASCII file names, that
  5505. is, file names having characters with the eight bit set, because they
  5506. use signed checksums, while @GNUTAR{} uses unsigned
  5507. checksums while creating archives, as per @acronym{POSIX} standards. On
  5508. reading, @GNUTAR{} computes both checksums and
  5509. accept any. It is somewhat worrying that a lot of people may go
  5510. around doing backup of their files using faulty (or at least
  5511. non-standard) software, not learning about it until it's time to
  5512. restore their missing files with an incompatible file extractor, or
  5513. vice versa.
  5514. @GNUTAR{} compute checksums both ways, and accept
  5515. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5516. wrong checksums. @GNUTAR{} produces the standard
  5517. checksum, however, raising incompatibilities with Sun. That is to
  5518. say, @GNUTAR{} has not been modified to
  5519. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5520. I've been told that more recent Sun @command{tar} now read standard
  5521. archives, so maybe Sun did a similar patch, after all?
  5522. The story seems to be that when Sun first imported @command{tar}
  5523. sources on their system, they recompiled it without realizing that
  5524. the checksums were computed differently, because of a change in
  5525. the default signing of @code{char}'s in their compiler. So they
  5526. started computing checksums wrongly. When they later realized their
  5527. mistake, they merely decided to stay compatible with it, and with
  5528. themselves afterwards. Presumably, but I do not really know, HP-UX
  5529. has chosen that their @command{tar} archives to be compatible with Sun's.
  5530. The current standards do not favor Sun @command{tar} format. In any
  5531. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5532. a @command{tar} able to read the good archives they receive.
  5533. @node Large or Negative Values
  5534. @subsection Large or Negative Values
  5535. @cindex large values
  5536. @cindex future time stamps
  5537. @cindex negative time stamps
  5538. @acronym{POSIX} @command{tar} format uses fixed-sized unsigned octal strings
  5539. to represent numeric values. User and group IDs and device major and
  5540. minor numbers have unsigned 21-bit representations, and file sizes and
  5541. times have unsigned 33-bit representations. @GNUTAR{}
  5542. generates @acronym{POSIX} representations when possible, but for values
  5543. outside the @acronym{POSIX} range it generates two's-complement base-256
  5544. strings: uids, gids, and device numbers have signed 57-bit
  5545. representations, and file sizes and times have signed 89-bit
  5546. representations. These representations are an extension to @acronym{POSIX}
  5547. @command{tar} format, so they are not universally portable.
  5548. The most common portability problems with out-of-range numeric values
  5549. are large files and future or negative time stamps.
  5550. Portable archives should avoid members of 8 GB or larger, as @acronym{POSIX}
  5551. @command{tar} format cannot represent them.
  5552. Portable archives should avoid time stamps from the future. @acronym{POSIX}
  5553. @command{tar} format can represent time stamps in the range 1970-01-01
  5554. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5555. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5556. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5557. portable archives must avoid these time stamps for many years to come.
  5558. Portable archives should also avoid time stamps before 1970. These time
  5559. stamps are a common @acronym{POSIX} extension but their @code{time_t}
  5560. representations are negative. Many traditional @command{tar}
  5561. implementations generate a two's complement representation for negative
  5562. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5563. generate archives that are not portable to hosts with differing
  5564. @code{time_t} representations. @GNUTAR{} recognizes this
  5565. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5566. it issues a warning, as these time stamps are nonstandard and unportable.
  5567. @node Compression
  5568. @section Using Less Space through Compression
  5569. @menu
  5570. * gzip:: Creating and Reading Compressed Archives
  5571. * sparse:: Archiving Sparse Files
  5572. @end menu
  5573. @node gzip
  5574. @subsection Creating and Reading Compressed Archives
  5575. @cindex Compressed archives
  5576. @cindex Storing archives in compressed format
  5577. @UNREVISED
  5578. @table @kbd
  5579. @item -z
  5580. @itemx --gzip
  5581. @itemx --ungzip
  5582. Filter the archive through @command{gzip}.
  5583. @end table
  5584. @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
  5585. format parameters must be taken into consideration when modifying an
  5586. archive.@FIXME{???} Compressed archives cannot be modified.
  5587. You can use @samp{--gzip} and @samp{--gunzip} on physical devices
  5588. (tape drives, etc.) and remote files as well as on normal files; data
  5589. to or from such devices or remote files is reblocked by another copy
  5590. of the @command{tar} program to enforce the specified (or default) record
  5591. size. The default compression parameters are used; if you need to
  5592. override them, avoid the @value{op-gzip} option and run @command{gzip}
  5593. explicitly. (Or set the @env{GZIP} environment variable.)
  5594. The @value{op-gzip} option does not work with the @value{op-multi-volume}
  5595. option, or with the @value{op-update}, @value{op-append},
  5596. @value{op-concatenate}, or @value{op-delete} operations.
  5597. It is not exact to say that @GNUTAR{} is to work in concert
  5598. with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
  5599. possible that @command{tar} and @command{gzip} be done with a single call,
  5600. like in:
  5601. @smallexample
  5602. $ @kbd{tar cfz archive.tar.gz subdir}
  5603. @end smallexample
  5604. @noindent
  5605. to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
  5606. can do:
  5607. @smallexample
  5608. $ @kbd{tar xfz archive.tar.gz}
  5609. @end smallexample
  5610. @noindent
  5611. to explode and unpack.
  5612. The difference is that the whole archive is compressed. With
  5613. @command{zip}, archive members are archived individually. @command{tar}'s
  5614. method yields better compression. On the other hand, one can view the
  5615. contents of a @command{zip} archive without having to decompress it. As
  5616. for the @command{tar} and @command{gzip} tandem, you need to decompress the
  5617. archive to see its contents. However, this may be done without needing
  5618. disk space, by using pipes internally:
  5619. @smallexample
  5620. $ @kbd{tar tfz archive.tar.gz}
  5621. @end smallexample
  5622. @cindex corrupted archives
  5623. About corrupted compressed archives: @command{gzip}'ed files have no
  5624. redundancy, for maximum compression. The adaptive nature of the
  5625. compression scheme means that the compression tables are implicitly
  5626. spread all over the archive. If you lose a few blocks, the dynamic
  5627. construction of the compression tables becomes unsynchronized, and there
  5628. is little chance that you could recover later in the archive.
  5629. There are pending suggestions for having a per-volume or per-file
  5630. compression in @GNUTAR{}. This would allow for viewing the
  5631. contents without decompression, and for resynchronizing decompression at
  5632. every volume or file, in case of corrupted archives. Doing so, we might
  5633. lose some compressibility. But this would have make recovering easier.
  5634. So, there are pros and cons. We'll see!
  5635. @table @kbd
  5636. @item -j
  5637. @itemx --bzip2
  5638. Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
  5639. @item -Z
  5640. @itemx --compress
  5641. @itemx --uncompress
  5642. Filter the archive through @command{compress}. Otherwise like
  5643. @value{op-gzip}.
  5644. @item --use-compress-program=@var{prog}
  5645. Filter through @var{prog} (must accept @samp{-d}).
  5646. @end table
  5647. @value{op-compress} stores an archive in compressed format. This
  5648. option is useful in saving time over networks and space in pipes, and
  5649. when storage space is at a premium. @value{op-compress} causes
  5650. @command{tar} to compress when writing the archive, or to uncompress when
  5651. reading the archive.
  5652. To perform compression and uncompression on the archive, @command{tar}
  5653. runs the @command{compress} utility. @command{tar} uses the default
  5654. compression parameters; if you need to override them, avoid the
  5655. @value{op-compress} option and run the @command{compress} utility
  5656. explicitly. It is useful to be able to call the @command{compress}
  5657. utility from within @command{tar} because the @command{compress} utility by
  5658. itself cannot access remote tape drives.
  5659. The @value{op-compress} option will not work in conjunction with the
  5660. @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
  5661. and @value{op-delete} operations. @xref{Operations}, for
  5662. more information on these operations.
  5663. If there is no compress utility available, @command{tar} will report an error.
  5664. @strong{Please note} that the @command{compress} program may be covered by
  5665. a patent, and therefore we recommend you stop using it.
  5666. @value{op-bzip2} acts like @value{op-compress}, except that it uses
  5667. the @code{bzip2} utility.
  5668. @table @kbd
  5669. @item --compress
  5670. @itemx --uncompress
  5671. @itemx -z
  5672. @itemx -Z
  5673. When this option is specified, @command{tar} will compress (when
  5674. writing an archive), or uncompress (when reading an archive). Used in
  5675. conjunction with the @value{op-create}, @value{op-extract},
  5676. @value{op-list} and @value{op-compare} operations.
  5677. @end table
  5678. You can have archives be compressed by using the @value{op-gzip} option.
  5679. This will arrange for @command{tar} to use the @command{gzip} program to be
  5680. used to compress or uncompress the archive wren writing or reading it.
  5681. To use the older, obsolete, @command{compress} program, use the
  5682. @value{op-compress} option. The @acronym{GNU} Project recommends you not use
  5683. @command{compress}, because there is a patent covering the algorithm it
  5684. uses. You could be sued for patent infringement merely by running
  5685. @command{compress}.
  5686. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5687. to do it now. I would like to use @value{op-gzip}, but I'd also like
  5688. the output to be fed through a program like @acronym{GNU}
  5689. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5690. to use :-)), basically adding ECC protection on top of compression.
  5691. It seems as if this should be quite easy to do, but I can't work out
  5692. exactly how to go about it. Of course, I can pipe the standard output
  5693. of @command{tar} through @command{ecc}, but then I lose (though I
  5694. haven't started using it yet, I confess) the ability to have
  5695. @command{tar} use @command{rmt} for it's I/O (I think).
  5696. I think the most straightforward thing would be to let me specify a
  5697. general set of filters outboard of compression (preferably ordered,
  5698. so the order can be automatically reversed on input operations, and
  5699. with the options they require specifiable), but beggars shouldn't be
  5700. choosers and anything you decide on would be fine with me.
  5701. By the way, I like @command{ecc} but if (as the comments say) it can't
  5702. deal with loss of block sync, I'm tempted to throw some time at adding
  5703. that capability. Supposing I were to actually do such a thing and
  5704. get it (apparently) working, do you accept contributed changes to
  5705. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5706. Isn't that exactly the role of the @value{op-use-compress-prog} option?
  5707. I never tried it myself, but I suspect you may want to write a
  5708. @var{prog} script or program able to filter stdin to stdout to
  5709. way you want. It should recognize the @samp{-d} option, for when
  5710. extraction is needed rather than creation.
  5711. It has been reported that if one writes compressed data (through the
  5712. @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
  5713. the DLT compression mode, the data will actually get bigger and one will
  5714. end up with less space on the tape.}
  5715. @node sparse
  5716. @subsection Archiving Sparse Files
  5717. @cindex Sparse Files
  5718. @UNREVISED
  5719. @table @kbd
  5720. @item -S
  5721. @itemx --sparse
  5722. Handle sparse files efficiently.
  5723. @end table
  5724. This option causes all files to be put in the archive to be tested for
  5725. sparseness, and handled specially if they are. The @value{op-sparse}
  5726. option is useful when many @code{dbm} files, for example, are being
  5727. backed up. Using this option dramatically decreases the amount of
  5728. space needed to store such a file.
  5729. In later versions, this option may be removed, and the testing and
  5730. treatment of sparse files may be done automatically with any special
  5731. @acronym{GNU} options. For now, it is an option needing to be specified on
  5732. the command line with the creation or updating of an archive.
  5733. Files in the filesystem occasionally have ``holes.'' A hole in a file
  5734. is a section of the file's contents which was never written. The
  5735. contents of a hole read as all zeros. On many operating systems,
  5736. actual disk storage is not allocated for holes, but they are counted
  5737. in the length of the file. If you archive such a file, @command{tar}
  5738. could create an archive longer than the original. To have @command{tar}
  5739. attempt to recognize the holes in a file, use @value{op-sparse}. When
  5740. you use the @value{op-sparse} option, then, for any file using less
  5741. disk space than would be expected from its length, @command{tar} searches
  5742. the file for consecutive stretches of zeros. It then records in the
  5743. archive for the file where the consecutive stretches of zeros are, and
  5744. only archives the ``real contents'' of the file. On extraction (using
  5745. @value{op-sparse} is not needed on extraction) any such files have
  5746. holes created wherever the continuous stretches of zeros were found.
  5747. Thus, if you use @value{op-sparse}, @command{tar} archives won't take
  5748. more space than the original.
  5749. A file is sparse if it contains blocks of zeros whose existence is
  5750. recorded, but that have no space allocated on disk. When you specify
  5751. the @value{op-sparse} option in conjunction with the @value{op-create}
  5752. operation, @command{tar} tests all files for sparseness while archiving.
  5753. If @command{tar} finds a file to be sparse, it uses a sparse representation of
  5754. the file in the archive. @value{xref-create}, for more information
  5755. about creating archives.
  5756. @value{op-sparse} is useful when archiving files, such as dbm files,
  5757. likely to contain many nulls. This option dramatically
  5758. decreases the amount of space needed to store such an archive.
  5759. @quotation
  5760. @strong{Please Note:} Always use @value{op-sparse} when performing file
  5761. system backups, to avoid archiving the expanded forms of files stored
  5762. sparsely in the system.
  5763. Even if your system has no sparse files currently, some may be
  5764. created in the future. If you use @value{op-sparse} while making file
  5765. system backups as a matter of course, you can be assured the archive
  5766. will never take more space on the media than the files take on disk
  5767. (otherwise, archiving a disk filled with sparse files might take
  5768. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5769. @end quotation
  5770. @command{tar} ignores the @value{op-sparse} option when reading an archive.
  5771. @table @kbd
  5772. @item --sparse
  5773. @itemx -S
  5774. Files stored sparsely in the file system are represented sparsely in
  5775. the archive. Use in conjunction with write operations.
  5776. @end table
  5777. However, users should be well aware that at archive creation time,
  5778. @GNUTAR{} still has to read whole disk file to
  5779. locate the @dfn{holes}, and so, even if sparse files use little space
  5780. on disk and in the archive, they may sometimes require inordinate
  5781. amount of time for reading and examining all-zero blocks of a file.
  5782. Although it works, it's painfully slow for a large (sparse) file, even
  5783. though the resulting tar archive may be small. (One user reports that
  5784. dumping a @file{core} file of over 400 megabytes, but with only about
  5785. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5786. ELC, with full CPU utilization.)
  5787. This reading is required in all cases and is not related to the fact
  5788. the @value{op-sparse} option is used or not, so by merely @emph{not}
  5789. using the option, you are not saving time@footnote{Well! We should say
  5790. the whole truth, here. When @value{op-sparse} is selected while creating
  5791. an archive, the current @command{tar} algorithm requires sparse files to be
  5792. read twice, not once. We hope to develop a new archive format for saving
  5793. sparse files in which one pass will be sufficient.}.
  5794. Programs like @command{dump} do not have to read the entire file; by
  5795. examining the file system directly, they can determine in advance
  5796. exactly where the holes are and thus avoid reading through them. The
  5797. only data it need read are the actual allocated data blocks.
  5798. @GNUTAR{} uses a more portable and straightforward
  5799. archiving approach, it would be fairly difficult that it does
  5800. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5801. 1990-12-10:
  5802. @quotation
  5803. What I did say is that you cannot tell the difference between a hole and an
  5804. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5805. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5806. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5807. to name one that does?), they may also care where the holes are (I have
  5808. no examples of this one either, but it's equally imaginable).
  5809. I conclude from this that good archivers are not portable. One can
  5810. arguably conclude that if you want a portable program, you can in good
  5811. conscience restore files with as many holes as possible, since you can't
  5812. get it right.
  5813. @end quotation
  5814. @node Attributes
  5815. @section Handling File Attributes
  5816. @UNREVISED
  5817. When @command{tar} reads files, this causes them to have the access
  5818. times updated. To have @command{tar} attempt to set the access times
  5819. back to what they were before they were read, use the
  5820. @value{op-atime-preserve} option.
  5821. Handling of file attributes
  5822. @table @kbd
  5823. @item --atime-preserve
  5824. Preserve access times on files that are read.
  5825. This doesn't work for files that
  5826. you don't own, unless you're root, and it doesn't interact with
  5827. incremental dumps nicely (@pxref{Backups}), and it can set access or
  5828. modification times incorrectly if other programs access the file while
  5829. @command{tar} is running; but it is good enough for some purposes.
  5830. @item -m
  5831. @itemx --touch
  5832. Do not extract file modified time.
  5833. When this option is used, @command{tar} leaves the modification times
  5834. of the files it extracts as the time when the files were extracted,
  5835. instead of setting it to the time recorded in the archive.
  5836. This option is meaningless with @value{op-list}.
  5837. @item --same-owner
  5838. Create extracted files with the same ownership they have in the
  5839. archive.
  5840. This is the default behavior for the superuser,
  5841. so this option is meaningful only for non-root users, when @command{tar}
  5842. is executed on those systems able to give files away. This is
  5843. considered as a security flaw by many people, at least because it
  5844. makes quite difficult to correctly account users for the disk space
  5845. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5846. files are easily and silently lost when files are given away.
  5847. When writing an archive, @command{tar} writes the user id and user name
  5848. separately. If it can't find a user name (because the user id is not
  5849. in @file{/etc/passwd}), then it does not write one. When restoring,
  5850. and doing a @code{chmod} like when you use @value{op-same-permissions},
  5851. @FIXME{same-owner?}it tries to look the name (if one was written)
  5852. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5853. stored in the archive instead.
  5854. @item --no-same-owner
  5855. @itemx -o
  5856. Do not attempt to restore ownership when extracting. This is the
  5857. default behavior for ordinary users, so this option has an effect
  5858. only for the superuser.
  5859. @item --numeric-owner
  5860. The @value{op-numeric-owner} option allows (ANSI) archives to be written
  5861. without user/group name information or such information to be ignored
  5862. when extracting. It effectively disables the generation and/or use
  5863. of user/group name information. This option forces extraction using
  5864. the numeric ids from the archive, ignoring the names.
  5865. This is useful in certain circumstances, when restoring a backup from
  5866. an emergency floppy with different passwd/group files for example.
  5867. It is otherwise impossible to extract files with the right ownerships
  5868. if the password file in use during the extraction does not match the
  5869. one belonging to the filesystem(s) being extracted. This occurs,
  5870. for example, if you are restoring your files after a major crash and
  5871. had booted from an emergency floppy with no password file or put your
  5872. disk into another machine to do the restore.
  5873. The numeric ids are @emph{always} saved into @command{tar} archives.
  5874. The identifying names are added at create time when provided by the
  5875. system, unless @value{op-old-archive} is used. Numeric ids could be
  5876. used when moving archives between a collection of machines using
  5877. a centralized management for attribution of numeric ids to users
  5878. and groups. This is often made through using the NIS capabilities.
  5879. When making a @command{tar} file for distribution to other sites, it
  5880. is sometimes cleaner to use a single owner for all files in the
  5881. distribution, and nicer to specify the write permission bits of the
  5882. files as stored in the archive independently of their actual value on
  5883. the file system. The way to prepare a clean distribution is usually
  5884. to have some Makefile rule creating a directory, copying all needed
  5885. files in that directory, then setting ownership and permissions as
  5886. wanted (there are a lot of possible schemes), and only then making a
  5887. @command{tar} archive out of this directory, before cleaning
  5888. everything out. Of course, we could add a lot of options to
  5889. @GNUTAR{} for fine tuning permissions and ownership.
  5890. This is not the good way, I think. @GNUTAR{} is
  5891. already crowded with options and moreover, the approach just explained
  5892. gives you a great deal of control already.
  5893. @item -p
  5894. @itemx --same-permissions
  5895. @itemx --preserve-permissions
  5896. Extract all protection information.
  5897. This option causes @command{tar} to set the modes (access permissions) of
  5898. extracted files exactly as recorded in the archive. If this option
  5899. is not used, the current @code{umask} setting limits the permissions
  5900. on extracted files.
  5901. This option is meaningless with @value{op-list}.
  5902. @item --preserve
  5903. Same as both @value{op-same-permissions} and @value{op-same-order}.
  5904. The @value{op-preserve} option has no equivalent short option name.
  5905. It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
  5906. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  5907. @end table
  5908. @node Standard
  5909. @section Basic Tar Format
  5910. @UNREVISED
  5911. While an archive may contain many files, the archive itself is a
  5912. single ordinary file. Like any other file, an archive file can be
  5913. written to a storage device such as a tape or disk, sent through a
  5914. pipe or over a network, saved on the active file system, or even
  5915. stored in another archive. An archive file is not easy to read or
  5916. manipulate without using the @command{tar} utility or Tar mode in
  5917. @acronym{GNU} Emacs.
  5918. Physically, an archive consists of a series of file entries terminated
  5919. by an end-of-archive entry, which consists of two 512 blocks of zero
  5920. bytes. A file
  5921. entry usually describes one of the files in the archive (an
  5922. @dfn{archive member}), and consists of a file header and the contents
  5923. of the file. File headers contain file names and statistics, checksum
  5924. information which @command{tar} uses to detect file corruption, and
  5925. information about file types.
  5926. Archives are permitted to have more than one member with the same
  5927. member name. One way this situation can occur is if more than one
  5928. version of a file has been stored in the archive. For information
  5929. about adding new versions of a file to an archive, see @ref{update}.
  5930. @FIXME-xref{To learn more about having more than one archive member with the
  5931. same name, see -backup node, when it's written.}
  5932. In addition to entries describing archive members, an archive may
  5933. contain entries which @command{tar} itself uses to store information.
  5934. @value{xref-label}, for an example of such an archive entry.
  5935. A @command{tar} archive file contains a series of blocks. Each block
  5936. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  5937. of as being on magnetic tape, other media are often used.
  5938. Each file archived is represented by a header block which describes
  5939. the file, followed by zero or more blocks which give the contents
  5940. of the file. At the end of the archive file there are two 512-byte blocks
  5941. filled with binary zeros as an end-of-file marker. A reasonable system
  5942. should write such end-of-file marker at the end of an archive, but
  5943. must not assume that such a block exists when reading an archive. In
  5944. particular @GNUTAR{} always issues a warning if it does not encounter it.
  5945. The blocks may be @dfn{blocked} for physical I/O operations.
  5946. Each record of @var{n} blocks (where @var{n} is set by the
  5947. @value{op-blocking-factor} option to @command{tar}) is written with a single
  5948. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  5949. such a write is a single record. When writing an archive,
  5950. the last record of blocks should be written at the full size, with
  5951. blocks after the zero block containing all zeros. When reading
  5952. an archive, a reasonable system should properly handle an archive
  5953. whose last record is shorter than the rest, or which contains garbage
  5954. records after a zero block.
  5955. The header block is defined in C as follows. In the @GNUTAR{}
  5956. distribution, this is part of file @file{src/tar.h}:
  5957. @smallexample
  5958. @include header.texi
  5959. @end smallexample
  5960. All characters in header blocks are represented by using 8-bit
  5961. characters in the local variant of ASCII. Each field within the
  5962. structure is contiguous; that is, there is no padding used within
  5963. the structure. Each character on the archive medium is stored
  5964. contiguously.
  5965. Bytes representing the contents of files (after the header block
  5966. of each file) are not translated in any way and are not constrained
  5967. to represent characters in any character set. The @command{tar} format
  5968. does not distinguish text files from binary files, and no translation
  5969. of file contents is performed.
  5970. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  5971. @code{gname} are null-terminated character strings. All other fields
  5972. are zero-filled octal numbers in ASCII. Each numeric field of width
  5973. @var{w} contains @var{w} minus 1 digits, and a null.
  5974. The @code{name} field is the file name of the file, with directory names
  5975. (if any) preceding the file name, separated by slashes.
  5976. @FIXME{how big a name before field overflows?}
  5977. The @code{mode} field provides nine bits specifying file permissions
  5978. and three bits to specify the Set UID, Set GID, and Save Text
  5979. (@dfn{sticky}) modes. Values for these bits are defined above.
  5980. When special permissions are required to create a file with a given
  5981. mode, and the user restoring files from the archive does not hold such
  5982. permissions, the mode bit(s) specifying those special permissions
  5983. are ignored. Modes which are not supported by the operating system
  5984. restoring files from the archive will be ignored. Unsupported modes
  5985. should be faked up when creating or updating an archive; e.g.@: the
  5986. group permission could be copied from the @emph{other} permission.
  5987. The @code{uid} and @code{gid} fields are the numeric user and group
  5988. ID of the file owners, respectively. If the operating system does
  5989. not support numeric user or group IDs, these fields should be ignored.
  5990. The @code{size} field is the size of the file in bytes; linked files
  5991. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  5992. particular the @value{op-incremental} option.}
  5993. The @code{mtime} field is the modification time of the file at the time
  5994. it was archived. It is the ASCII representation of the octal value of
  5995. the last time the file was modified, represented as an integer number of
  5996. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  5997. The @code{chksum} field is the ASCII representation of the octal value
  5998. of the simple sum of all bytes in the header block. Each 8-bit
  5999. byte in the header is added to an unsigned integer, initialized to
  6000. zero, the precision of which shall be no less than seventeen bits.
  6001. When calculating the checksum, the @code{chksum} field is treated as
  6002. if it were all blanks.
  6003. The @code{typeflag} field specifies the type of file archived. If a
  6004. particular implementation does not recognize or permit the specified
  6005. type, the file will be extracted as if it were a regular file. As this
  6006. action occurs, @command{tar} issues a warning to the standard error.
  6007. The @code{atime} and @code{ctime} fields are used in making incremental
  6008. backups; they store, respectively, the particular file's access time
  6009. and last inode-change time.
  6010. The @code{offset} is used by the @value{op-multi-volume} option, when
  6011. making a multi-volume archive. The offset is number of bytes into
  6012. the file that we need to restart at to continue the file on the next
  6013. tape, i.e., where we store the location that a continued file is
  6014. continued at.
  6015. The following fields were added to deal with sparse files. A file
  6016. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6017. represented as zeros, i.e., no useful data. A test to see if a file
  6018. is sparse is to look at the number blocks allocated for it versus the
  6019. number of characters in the file; if there are fewer blocks allocated
  6020. for the file than would normally be allocated for a file of that
  6021. size, then the file is sparse. This is the method @command{tar} uses to
  6022. detect a sparse file, and once such a file is detected, it is treated
  6023. differently from non-sparse files.
  6024. Sparse files are often @code{dbm} files, or other database-type files
  6025. which have data at some points and emptiness in the greater part of
  6026. the file. Such files can appear to be very large when an @samp{ls
  6027. -l} is done on them, when in truth, there may be a very small amount
  6028. of important data contained in the file. It is thus undesirable
  6029. to have @command{tar} think that it must back up this entire file, as
  6030. great quantities of room are wasted on empty blocks, which can lead
  6031. to running out of room on a tape far earlier than is necessary.
  6032. Thus, sparse files are dealt with so that these empty blocks are
  6033. not written to the tape. Instead, what is written to the tape is a
  6034. description, of sorts, of the sparse file: where the holes are, how
  6035. big the holes are, and how much data is found at the end of the hole.
  6036. This way, the file takes up potentially far less room on the tape,
  6037. and when the file is extracted later on, it will look exactly the way
  6038. it looked beforehand. The following is a description of the fields
  6039. used to handle a sparse file:
  6040. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6041. sparse} contains two 12-character strings which represent an offset
  6042. into the file and a number of bytes to be written at that offset.
  6043. The offset is absolute, and not relative to the offset in preceding
  6044. array element.
  6045. The header can hold four of these @code{struct sparse} at the moment;
  6046. if more are needed, they are not stored in the header.
  6047. The @code{isextended} flag is set when an @code{extended_header}
  6048. is needed to deal with a file. Note that this means that this flag
  6049. can only be set when dealing with a sparse file, and it is only set
  6050. in the event that the description of the file will not fit in the
  6051. allotted room for sparse structures in the header. In other words,
  6052. an extended_header is needed.
  6053. The @code{extended_header} structure is used for sparse files which
  6054. need more sparse structures than can fit in the header. The header can
  6055. fit 4 such structures; if more are needed, the flag @code{isextended}
  6056. gets set and the next block is an @code{extended_header}.
  6057. Each @code{extended_header} structure contains an array of 21
  6058. sparse structures, along with a similar @code{isextended} flag
  6059. that the header had. There can be an indeterminate number of such
  6060. @code{extended_header}s to describe a sparse file.
  6061. @table @asis
  6062. @item @code{REGTYPE}
  6063. @itemx @code{AREGTYPE}
  6064. These flags represent a regular file. In order to be compatible
  6065. with older versions of @command{tar}, a @code{typeflag} value of
  6066. @code{AREGTYPE} should be silently recognized as a regular file.
  6067. New archives should be created using @code{REGTYPE}. Also, for
  6068. backward compatibility, @command{tar} treats a regular file whose name
  6069. ends with a slash as a directory.
  6070. @item @code{LNKTYPE}
  6071. This flag represents a file linked to another file, of any type,
  6072. previously archived. Such files are identified in Unix by each
  6073. file having the same device and inode number. The linked-to name is
  6074. specified in the @code{linkname} field with a trailing null.
  6075. @item @code{SYMTYPE}
  6076. This represents a symbolic link to another file. The linked-to name
  6077. is specified in the @code{linkname} field with a trailing null.
  6078. @item @code{CHRTYPE}
  6079. @itemx @code{BLKTYPE}
  6080. These represent character special files and block special files
  6081. respectively. In this case the @code{devmajor} and @code{devminor}
  6082. fields will contain the major and minor device numbers respectively.
  6083. Operating systems may map the device specifications to their own
  6084. local specification, or may ignore the entry.
  6085. @item @code{DIRTYPE}
  6086. This flag specifies a directory or sub-directory. The directory
  6087. name in the @code{name} field should end with a slash. On systems where
  6088. disk allocation is performed on a directory basis, the @code{size} field
  6089. will contain the maximum number of bytes (which may be rounded to
  6090. the nearest disk block allocation unit) which the directory may
  6091. hold. A @code{size} field of zero indicates no such limiting. Systems
  6092. which do not support limiting in this manner should ignore the
  6093. @code{size} field.
  6094. @item @code{FIFOTYPE}
  6095. This specifies a FIFO special file. Note that the archiving of a
  6096. FIFO file archives the existence of this file and not its contents.
  6097. @item @code{CONTTYPE}
  6098. This specifies a contiguous file, which is the same as a normal
  6099. file except that, in operating systems which support it, all its
  6100. space is allocated contiguously on the disk. Operating systems
  6101. which do not allow contiguous allocation should silently treat this
  6102. type as a normal file.
  6103. @item @code{A} @dots{} @code{Z}
  6104. These are reserved for custom implementations. Some of these are
  6105. used in the @acronym{GNU} modified format, as described below.
  6106. @end table
  6107. Other values are reserved for specification in future revisions of
  6108. the P1003 standard, and should not be used by any @command{tar} program.
  6109. The @code{magic} field indicates that this archive was output in
  6110. the P1003 archive format. If this field contains @code{TMAGIC},
  6111. the @code{uname} and @code{gname} fields will contain the ASCII
  6112. representation of the owner and group of the file respectively.
  6113. If found, the user and group IDs are used rather than the values in
  6114. the @code{uid} and @code{gid} fields.
  6115. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6116. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6117. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6118. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6119. @node Extensions
  6120. @section @acronym{GNU} Extensions to the Archive Format
  6121. @UNREVISED
  6122. The @acronym{GNU} format uses additional file types to describe new types of
  6123. files in an archive. These are listed below.
  6124. @table @code
  6125. @item GNUTYPE_DUMPDIR
  6126. @itemx 'D'
  6127. This represents a directory and a list of files created by the
  6128. @value{op-incremental} option. The @code{size} field gives the total
  6129. size of the associated list of files. Each file name is preceded by
  6130. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6131. (The file is a directory, or is not stored in the archive.) Each file
  6132. name is terminated by a null. There is an additional null after the
  6133. last file name.
  6134. @item GNUTYPE_MULTIVOL
  6135. @itemx 'M'
  6136. This represents a file continued from another volume of a multi-volume
  6137. archive created with the @value{op-multi-volume} option. The original
  6138. type of the file is not given here. The @code{size} field gives the
  6139. maximum size of this piece of the file (assuming the volume does
  6140. not end before the file is written out). The @code{offset} field
  6141. gives the offset from the beginning of the file where this part of
  6142. the file begins. Thus @code{size} plus @code{offset} should equal
  6143. the original size of the file.
  6144. @item GNUTYPE_SPARSE
  6145. @itemx 'S'
  6146. This flag indicates that we are dealing with a sparse file. Note
  6147. that archiving a sparse file requires special operations to find
  6148. holes in the file, which mark the positions of these holes, along
  6149. with the number of bytes of data to be found after the hole.
  6150. @item GNUTYPE_VOLHDR
  6151. @itemx 'V'
  6152. This file type is used to mark the volume header that was given with
  6153. the @value{op-label} option when the archive was created. The @code{name}
  6154. field contains the @code{name} given after the @value{op-label} option.
  6155. The @code{size} field is zero. Only the first file in each volume
  6156. of an archive should have this type.
  6157. @end table
  6158. You may have trouble reading a @acronym{GNU} format archive on a
  6159. non-@acronym{GNU} system if the options @value{op-incremental},
  6160. @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
  6161. used when writing the archive. In general, if @command{tar} does not
  6162. use the @acronym{GNU}-added fields of the header, other versions of
  6163. @command{tar} should be able to read the archive. Otherwise, the
  6164. @command{tar} program will give an error, the most likely one being a
  6165. checksum error.
  6166. @node cpio
  6167. @section Comparison of @command{tar} and @command{cpio}
  6168. @UNREVISED
  6169. @FIXME{Reorganize the following material}
  6170. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6171. pathname lengths. The binary and old ASCII formats have a max path
  6172. length of 256, and the new ASCII and CRC ASCII formats have a max
  6173. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6174. with arbitrary pathname lengths, but other @command{cpio} implementations
  6175. may crash unexplainedly trying to read them.
  6176. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6177. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6178. in System V prior to SVR4, and some vendors may have added symlinks
  6179. to their system without enhancing @command{cpio} to know about them.
  6180. Others may have enhanced it in a way other than the way I did it
  6181. at Sun, and which was adopted by AT&T (and which is, I think, also
  6182. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6183. into a later BSD release---I think I gave them my changes).
  6184. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6185. can handle @command{tar} format input, and write it on output, and it
  6186. probably handles symbolic links. They may not have bothered doing
  6187. anything to enhance @command{tar} as a result.)
  6188. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6189. @command{tar} comes with V7, System III, System V, and BSD source;
  6190. @command{cpio} comes only with System III, System V, and later BSD
  6191. (4.3-tahoe and later).
  6192. @command{tar}'s way of handling multiple hard links to a file can handle
  6193. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6194. @command{cpio}s way requires you to play some games (in its "binary"
  6195. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6196. they're 18 bits---it would have to play games with the "file system ID"
  6197. field of the header to make sure that the file system ID/i-number pairs
  6198. of different files were always different), and I don't know which
  6199. @command{cpio}s, if any, play those games. Those that don't might get
  6200. confused and think two files are the same file when they're not, and
  6201. make hard links between them.
  6202. @command{tar}s way of handling multiple hard links to a file places only
  6203. one copy of the link on the tape, but the name attached to that copy
  6204. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6205. way puts one copy for every link, but you can retrieve it using any
  6206. of the names.
  6207. @quotation
  6208. What type of check sum (if any) is used, and how is this calculated.
  6209. @end quotation
  6210. See the attached manual pages for @command{tar} and @command{cpio} format.
  6211. @command{tar} uses a checksum which is the sum of all the bytes in the
  6212. @command{tar} header for a file; @command{cpio} uses no checksum.
  6213. @quotation
  6214. If anyone knows why @command{cpio} was made when @command{tar} was present
  6215. at the unix scene,
  6216. @end quotation
  6217. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6218. generally-available version of UNIX had @command{tar} at the time. I don't
  6219. know whether any version that was generally available @emph{within AT&T}
  6220. had @command{tar}, or, if so, whether the people within AT&T who did
  6221. @command{cpio} knew about it.
  6222. On restore, if there is a corruption on a tape @command{tar} will stop at
  6223. that point, while @command{cpio} will skip over it and try to restore the
  6224. rest of the files.
  6225. The main difference is just in the command syntax and header format.
  6226. @command{tar} is a little more tape-oriented in that everything is blocked
  6227. to start on a record boundary.
  6228. @quotation
  6229. Is there any differences between the ability to recover crashed
  6230. archives between the two of them. (Is there any chance of recovering
  6231. crashed archives at all.)
  6232. @end quotation
  6233. Theoretically it should be easier under @command{tar} since the blocking
  6234. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6235. However, modern @command{cpio}'s and variations have an option to just
  6236. search for the next file header after an error with a reasonable chance
  6237. of resyncing. However, lots of tape driver software won't allow you to
  6238. continue past a media error which should be the only reason for getting
  6239. out of sync unless a file changed sizes while you were writing the
  6240. archive.
  6241. @quotation
  6242. If anyone knows why @command{cpio} was made when @command{tar} was present
  6243. at the unix scene, please tell me about this too.
  6244. @end quotation
  6245. Probably because it is more media efficient (by not blocking everything
  6246. and using only the space needed for the headers where @command{tar}
  6247. always uses 512 bytes per file header) and it knows how to archive
  6248. special files.
  6249. You might want to look at the freely available alternatives. The
  6250. major ones are @command{afio}, @GNUTAR{}, and
  6251. @command{pax}, each of which have their own extensions with some
  6252. backwards compatibility.
  6253. Sparse files were @command{tar}red as sparse files (which you can
  6254. easily test, because the resulting archive gets smaller, and
  6255. @acronym{GNU} @command{cpio} can no longer read it).
  6256. @node Media
  6257. @chapter Tapes and Other Archive Media
  6258. @UNREVISED
  6259. A few special cases about tape handling warrant more detailed
  6260. description. These special cases are discussed below.
  6261. Many complexities surround the use of @command{tar} on tape drives. Since
  6262. the creation and manipulation of archives located on magnetic tape was
  6263. the original purpose of @command{tar}, it contains many features making
  6264. such manipulation easier.
  6265. Archives are usually written on dismountable media---tape cartridges,
  6266. mag tapes, or floppy disks.
  6267. The amount of data a tape or disk holds depends not only on its size,
  6268. but also on how it is formatted. A 2400 foot long reel of mag tape
  6269. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6270. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6271. Magnetic media are re-usable---once the archive on a tape is no longer
  6272. needed, the archive can be erased and the tape or disk used over.
  6273. Media quality does deteriorate with use, however. Most tapes or disks
  6274. should be discarded when they begin to produce data errors. EXABYTE
  6275. tape cartridges should be discarded when they generate an @dfn{error
  6276. count} (number of non-usable bits) of more than 10k.
  6277. Magnetic media are written and erased using magnetic fields, and
  6278. should be protected from such fields to avoid damage to stored data.
  6279. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6280. not a good idea.
  6281. @menu
  6282. * Device:: Device selection and switching
  6283. * Remote Tape Server::
  6284. * Common Problems and Solutions::
  6285. * Blocking:: Blocking
  6286. * Many:: Many archives on one tape
  6287. * Using Multiple Tapes:: Using Multiple Tapes
  6288. * label:: Including a Label in the Archive
  6289. * verify::
  6290. * Write Protection::
  6291. @end menu
  6292. @node Device
  6293. @section Device Selection and Switching
  6294. @UNREVISED
  6295. @table @kbd
  6296. @item -f [@var{hostname}:]@var{file}
  6297. @itemx --file=[@var{hostname}:]@var{file}
  6298. Use archive file or device @var{file} on @var{hostname}.
  6299. @end table
  6300. This option is used to specify the file name of the archive @command{tar}
  6301. works on.
  6302. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6303. input (when listing or extracting), or writes it to standard output
  6304. (when creating). If the @samp{-} file name is given when updating an
  6305. archive, @command{tar} will read the original archive from its standard
  6306. input, and will write the entire new archive to its standard output.
  6307. If the file name contains a @samp{:}, it is interpreted as
  6308. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6309. sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
  6310. either case, @command{tar} will invoke the command @command{rsh} (or
  6311. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6312. machine. If you give an alternate login name, it will be given to the
  6313. @command{rsh}.
  6314. Naturally, the remote machine must have an executable
  6315. @command{/usr/libexec/rmt}. This program is free software from the
  6316. University of California, and a copy of the source code can be found
  6317. with the sources for @command{tar}; it's compiled and installed by default.
  6318. The exact path to this utility is determined when configuring the package.
  6319. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6320. your installation prefix. This location may also be overridden at
  6321. runtime by using @value{op-rmt-command} option (@xref{Option Summary,
  6322. ---rmt-command}, for detailed description of this option. @xref{Remote
  6323. Tape Server}, for the description of @command{rmt} command).
  6324. If this option is not given, but the environment variable @env{TAPE}
  6325. is set, its value is used; otherwise, old versions of @command{tar}
  6326. used a default archive name (which was picked when @command{tar} was
  6327. compiled). The default is normally set up to be the @dfn{first} tape
  6328. drive or other transportable I/O medium on the system.
  6329. Starting with version 1.11.5, @GNUTAR{} uses
  6330. standard input and standard output as the default device, and I will
  6331. not try anymore supporting automatic device detection at installation
  6332. time. This was failing really in too many cases, it was hopeless.
  6333. This is now completely left to the installer to override standard
  6334. input and standard output for default device, if this seems
  6335. preferable. Further, I think @emph{most} actual usages of
  6336. @command{tar} are done with pipes or disks, not really tapes,
  6337. cartridges or diskettes.
  6338. Some users think that using standard input and output is running
  6339. after trouble. This could lead to a nasty surprise on your screen if
  6340. you forget to specify an output file name---especially if you are going
  6341. through a network or terminal server capable of buffering large amounts
  6342. of output. We had so many bug reports in that area of configuring
  6343. default tapes automatically, and so many contradicting requests, that
  6344. we finally consider the problem to be portably intractable. We could
  6345. of course use something like @samp{/dev/tape} as a default, but this
  6346. is @emph{also} running after various kind of trouble, going from hung
  6347. processes to accidental destruction of real tapes. After having seen
  6348. all this mess, using standard input and output as a default really
  6349. sounds like the only clean choice left, and a very useful one too.
  6350. @GNUTAR{} reads and writes archive in records, I
  6351. suspect this is the main reason why block devices are preferred over
  6352. character devices. Most probably, block devices are more efficient
  6353. too. The installer could also check for @samp{DEFTAPE} in
  6354. @file{<sys/mtio.h>}.
  6355. @table @kbd
  6356. @item --force-local
  6357. Archive file is local even if it contains a colon.
  6358. @item --rsh-command=@var{command}
  6359. Use remote @var{command} instead of @command{rsh}. This option exists
  6360. so that people who use something other than the standard @command{rsh}
  6361. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6362. When this command is not used, the shell command found when
  6363. the @command{tar} program was installed is used instead. This is
  6364. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6365. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6366. The installer may have overridden this by defining the environment
  6367. variable @env{RSH} @emph{at installation time}.
  6368. @item -[0-7][lmh]
  6369. Specify drive and density.
  6370. @item -M
  6371. @itemx --multi-volume
  6372. Create/list/extract multi-volume archive.
  6373. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6374. that may be larger than will fit on the medium used to hold it.
  6375. @xref{Multi-Volume Archives}.
  6376. @item -L @var{num}
  6377. @itemx --tape-length=@var{num}
  6378. Change tape after writing @var{num} x 1024 bytes.
  6379. This option might be useful when your tape drivers do not properly
  6380. detect end of physical tapes. By being slightly conservative on the
  6381. maximum tape length, you might avoid the problem entirely.
  6382. @item -F @var{file}
  6383. @itemx --info-script=@var{file}
  6384. @itemx --new-volume-script=@var{file}
  6385. Execute @file{file} at end of each tape. If @file{file} exits with
  6386. nonzero status, exit. This implies @value{op-multi-volume}.
  6387. @end table
  6388. @node Remote Tape Server
  6389. @section The Remote Tape Server
  6390. @cindex remote tape drive
  6391. @pindex rmt
  6392. In order to access the tape drive on a remote machine, @command{tar}
  6393. uses the remote tape server written at the University of California at
  6394. Berkeley. The remote tape server must be installed as
  6395. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6396. want to use. @command{tar} calls @command{rmt} by running an
  6397. @command{rsh} or @command{remsh} to the remote machine, optionally
  6398. using a different login name if one is supplied.
  6399. A copy of the source for the remote tape server is provided. It is
  6400. Copyright @copyright{} 1983 by the Regents of the University of
  6401. California, but can be freely distributed. It is compiled and
  6402. installed by default.
  6403. @cindex absolute file names
  6404. Unless you use the @value{op-absolute-names} option, @GNUTAR{}
  6405. will not allow you to create an archive that contains
  6406. absolute file names (a file name beginning with @samp{/}.) If you try,
  6407. @command{tar} will automatically remove the leading @samp{/} from the
  6408. file names it stores in the archive. It will also type a warning
  6409. message telling you what it is doing.
  6410. When reading an archive that was created with a different
  6411. @command{tar} program, @GNUTAR{} automatically
  6412. extracts entries in the archive which have absolute file names as if
  6413. the file names were not absolute. This is an important feature. A
  6414. visitor here once gave a @command{tar} tape to an operator to restore;
  6415. the operator used Sun @command{tar} instead of @GNUTAR{},
  6416. and the result was that it replaced large portions of
  6417. our @file{/bin} and friends with versions from the tape; needless to
  6418. say, we were unhappy about having to recover the file system from
  6419. backup tapes.
  6420. For example, if the archive contained a file @file{/usr/bin/computoy},
  6421. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6422. relative to the current directory. If you want to extract the files in
  6423. an archive to the same absolute names that they had when the archive
  6424. was created, you should do a @samp{cd /} before extracting the files
  6425. from the archive, or you should either use the @value{op-absolute-names}
  6426. option, or use the command @samp{tar -C / @dots{}}.
  6427. @cindex Ultrix 3.1 and write failure
  6428. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6429. can claim that a short write near the end of a tape succeeded,
  6430. when it actually failed. This will result in the -M option not
  6431. working correctly. The best workaround at the moment is to use a
  6432. significantly larger blocking factor than the default 20.
  6433. In order to update an archive, @command{tar} must be able to backspace the
  6434. archive in order to reread or rewrite a record that was just read (or
  6435. written). This is currently possible only on two kinds of files: normal
  6436. disk files (or any other file that can be backspaced with @samp{lseek}),
  6437. and industry-standard 9-track magnetic tape (or any other kind of tape
  6438. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6439. This means that the @value{op-append}, @value{op-update},
  6440. @value{op-concatenate}, and @value{op-delete} commands will not work on any
  6441. other kind of file. Some media simply cannot be backspaced, which
  6442. means these commands and options will never be able to work on them.
  6443. These non-backspacing media include pipes and cartridge tape drives.
  6444. Some other media can be backspaced, and @command{tar} will work on them
  6445. once @command{tar} is modified to do so.
  6446. Archives created with the @value{op-multi-volume}, @value{op-label}, and
  6447. @value{op-incremental} options may not be readable by other version
  6448. of @command{tar}. In particular, restoring a file that was split over
  6449. a volume boundary will require some careful work with @command{dd}, if
  6450. it can be done at all. Other versions of @command{tar} may also create
  6451. an empty file whose name is that of the volume header. Some versions
  6452. of @command{tar} may create normal files instead of directories archived
  6453. with the @value{op-incremental} option.
  6454. @node Common Problems and Solutions
  6455. @section Some Common Problems and their Solutions
  6456. @ifclear PUBLISH
  6457. @format
  6458. errors from system:
  6459. permission denied
  6460. no such file or directory
  6461. not owner
  6462. errors from @command{tar}:
  6463. directory checksum error
  6464. header format error
  6465. errors from media/system:
  6466. i/o error
  6467. device busy
  6468. @end format
  6469. @end ifclear
  6470. @node Blocking
  6471. @section Blocking
  6472. @UNREVISED
  6473. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6474. is also confusing to the expert reader. On the other hand, readers
  6475. who are new to the field have a fresh mind, and they may safely skip
  6476. the next two paragraphs, as the remainder of this manual uses those
  6477. two terms in a quite consistent way.
  6478. John Gilmore, the writer of the public domain @command{tar} from which
  6479. @GNUTAR{} was originally derived, wrote (June 1995):
  6480. @quotation
  6481. The nomenclature of tape drives comes from IBM, where I believe
  6482. they were invented for the IBM 650 or so. On IBM mainframes, what
  6483. is recorded on tape are tape blocks. The logical organization of
  6484. data is into records. There are various ways of putting records into
  6485. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6486. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6487. to a block), @code{VB} (variable size records, @var{n} to a block),
  6488. @code{VSB} (variable spanned blocked: variable sized records that can
  6489. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6490. parameter specified this to the operating system.
  6491. The Unix man page on @command{tar} was totally confused about this.
  6492. When I wrote @code{PD TAR}, I used the historically correct terminology
  6493. (@command{tar} writes data records, which are grouped into blocks).
  6494. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6495. here), and now Fran@,{c}ois has migrated that terminology back
  6496. into the source code too.
  6497. @end quotation
  6498. The term @dfn{physical block} means the basic transfer chunk from or
  6499. to a device, after which reading or writing may stop without anything
  6500. being lost. In this manual, the term @dfn{block} usually refers to
  6501. a disk physical block, @emph{assuming} that each disk block is 512
  6502. bytes in length. It is true that some disk devices have different
  6503. physical blocks, but @command{tar} ignore these differences in its own
  6504. format, which is meant to be portable, so a @command{tar} block is always
  6505. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6506. The term @dfn{logical block} often represents the basic chunk of
  6507. allocation of many disk blocks as a single entity, which the operating
  6508. system treats somewhat atomically; this concept is only barely used
  6509. in @GNUTAR{}.
  6510. The term @dfn{physical record} is another way to speak of a physical
  6511. block, those two terms are somewhat interchangeable. In this manual,
  6512. the term @dfn{record} usually refers to a tape physical block,
  6513. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6514. It is true that archives may be put on disk or used with pipes,
  6515. but nevertheless, @command{tar} tries to read and write the archive one
  6516. @dfn{record} at a time, whatever the medium in use. One record is made
  6517. up of an integral number of blocks, and this operation of putting many
  6518. disk blocks into a single tape block is called @dfn{reblocking}, or
  6519. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6520. the logical organization of many characters into something meaningful
  6521. to the application. The term @dfn{unit record} describes a small set
  6522. of characters which are transmitted whole to or by the application,
  6523. and often refers to a line of text. Those two last terms are unrelated
  6524. to what we call a @dfn{record} in @GNUTAR{}.
  6525. When writing to tapes, @command{tar} writes the contents of the archive
  6526. in chunks known as @dfn{records}. To change the default blocking
  6527. factor, use the @value{op-blocking-factor} option. Each record will
  6528. then be composed of @var{512-size} blocks. (Each @command{tar} block is
  6529. 512 bytes. @xref{Standard}.) Each file written to the archive uses
  6530. at least one full record. As a result, using a larger record size
  6531. can result in more wasted space for small files. On the other hand, a
  6532. larger record size can often be read and written much more efficiently.
  6533. Further complicating the problem is that some tape drives ignore the
  6534. blocking entirely. For these, a larger record size can still improve
  6535. performance (because the software layers above the tape drive still
  6536. honor the blocking), but not as dramatically as on tape drives that
  6537. honor blocking.
  6538. When reading an archive, @command{tar} can usually figure out the
  6539. record size on itself. When this is the case, and a non-standard
  6540. record size was used when the archive was created, @command{tar} will
  6541. print a message about a non-standard blocking factor, and then operate
  6542. normally. On some tape devices, however, @command{tar} cannot figure
  6543. out the record size itself. On most of those, you can specify a
  6544. blocking factor (with @value{op-blocking-factor}) larger than the
  6545. actual blocking factor, and then use the @value{op-read-full-records}
  6546. option. (If you specify a blocking factor with
  6547. @value{op-blocking-factor} and don't use the
  6548. @value{op-read-full-records} option, then @command{tar} will not
  6549. attempt to figure out the recording size itself.) On some devices,
  6550. you must always specify the record size exactly with
  6551. @value{op-blocking-factor} when reading, because @command{tar} cannot
  6552. figure it out. In any case, use @value{op-list} before doing any
  6553. extractions to see whether @command{tar} is reading the archive
  6554. correctly.
  6555. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6556. putting them into records is to put a whole number of them (one or
  6557. more) into each record. @command{tar} records are all the same size;
  6558. at the end of the file there's a block containing all zeros, which
  6559. is how you tell that the remainder of the last record(s) are garbage.
  6560. In a standard @command{tar} file (no options), the block size is 512
  6561. and the record size is 10240, for a blocking factor of 20. What the
  6562. @value{op-blocking-factor} option does is sets the blocking factor,
  6563. changing the record size while leaving the block size at 512 bytes.
  6564. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6565. most tape drives these days prefer much bigger records in order to
  6566. stream and not waste tape. When writing tapes for myself, some tend
  6567. to use a factor of the order of 2048, say, giving a record size of
  6568. around one megabyte.
  6569. If you use a blocking factor larger than 20, older @command{tar}
  6570. programs might not be able to read the archive, so we recommend this
  6571. as a limit to use in practice. @GNUTAR{}, however,
  6572. will support arbitrarily large record sizes, limited only by the
  6573. amount of virtual memory or the physical characteristics of the tape
  6574. device.
  6575. @menu
  6576. * Format Variations:: Format Variations
  6577. * Blocking Factor:: The Blocking Factor of an Archive
  6578. @end menu
  6579. @node Format Variations
  6580. @subsection Format Variations
  6581. @cindex Format Parameters
  6582. @cindex Format Options
  6583. @cindex Options, archive format specifying
  6584. @cindex Options, format specifying
  6585. @UNREVISED
  6586. Format parameters specify how an archive is written on the archive
  6587. media. The best choice of format parameters will vary depending on
  6588. the type and number of files being archived, and on the media used to
  6589. store the archive.
  6590. To specify format parameters when accessing or creating an archive,
  6591. you can use the options described in the following sections.
  6592. If you do not specify any format parameters, @command{tar} uses
  6593. default parameters. You cannot modify a compressed archive.
  6594. If you create an archive with the @value{op-blocking-factor} option
  6595. specified (@value{pxref-blocking-factor}), you must specify that
  6596. blocking-factor when operating on the archive. @xref{Formats}, for other
  6597. examples of format parameter considerations.
  6598. @node Blocking Factor
  6599. @subsection The Blocking Factor of an Archive
  6600. @cindex Blocking Factor
  6601. @cindex Record Size
  6602. @cindex Number of blocks per record
  6603. @cindex Number of bytes per record
  6604. @cindex Bytes per record
  6605. @cindex Blocks per record
  6606. @UNREVISED
  6607. The data in an archive is grouped into blocks, which are 512 bytes.
  6608. Blocks are read and written in whole number multiples called
  6609. @dfn{records}. The number of blocks in a record (ie. the size of a
  6610. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6611. The @value{op-blocking-factor} option specifies the blocking factor of
  6612. an archive. The default blocking factor is typically 20 (ie.@:
  6613. 10240 bytes), but can be specified at installation. To find out
  6614. the blocking factor of an existing archive, use @samp{tar --list
  6615. --file=@var{archive-name}}. This may not work on some devices.
  6616. Records are separated by gaps, which waste space on the archive media.
  6617. If you are archiving on magnetic tape, using a larger blocking factor
  6618. (and therefore larger records) provides faster throughput and allows you
  6619. to fit more data on a tape (because there are fewer gaps). If you are
  6620. archiving on cartridge, a very large blocking factor (say 126 or more)
  6621. greatly increases performance. A smaller blocking factor, on the other
  6622. hand, may be useful when archiving small files, to avoid archiving lots
  6623. of nulls as @command{tar} fills out the archive to the end of the record.
  6624. In general, the ideal record size depends on the size of the
  6625. inter-record gaps on the tape you are using, and the average size of the
  6626. files you are archiving. @xref{create}, for information on
  6627. writing archives.
  6628. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6629. Archives with blocking factors larger than 20 cannot be read
  6630. by very old versions of @command{tar}, or by some newer versions
  6631. of @command{tar} running on old machines with small address spaces.
  6632. With @GNUTAR{}, the blocking factor of an archive is limited
  6633. only by the maximum record size of the device containing the archive,
  6634. or by the amount of available virtual memory.
  6635. Also, on some systems, not using adequate blocking factors, as sometimes
  6636. imposed by the device drivers, may yield unexpected diagnostics. For
  6637. example, this has been reported:
  6638. @smallexample
  6639. Cannot write to /dev/dlt: Invalid argument
  6640. @end smallexample
  6641. @noindent
  6642. In such cases, it sometimes happen that the @command{tar} bundled by
  6643. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6644. requires an explicit specification for the block size,
  6645. which it cannot guess. This yields some people to consider
  6646. @GNUTAR{} is misbehaving, because by comparison,
  6647. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6648. for example, might resolve the problem.
  6649. If you use a non-default blocking factor when you create an archive, you
  6650. must specify the same blocking factor when you modify that archive. Some
  6651. archive devices will also require you to specify the blocking factor when
  6652. reading that archive, however this is not typically the case. Usually, you
  6653. can use @value{op-list} without specifying a blocking factor---@command{tar}
  6654. reports a non-default record size and then lists the archive members as
  6655. it would normally. To extract files from an archive with a non-standard
  6656. blocking factor (particularly if you're not sure what the blocking factor
  6657. is), you can usually use the @value{op-read-full-records} option while
  6658. specifying a blocking factor larger then the blocking factor of the archive
  6659. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6660. @xref{list}, for more information on the @value{op-list}
  6661. operation. @xref{Reading}, for a more detailed explanation of that option.
  6662. @table @kbd
  6663. @item --blocking-factor=@var{number}
  6664. @itemx -b @var{number}
  6665. Specifies the blocking factor of an archive. Can be used with any
  6666. operation, but is usually not necessary with @value{op-list}.
  6667. @end table
  6668. Device blocking
  6669. @table @kbd
  6670. @item -b @var{blocks}
  6671. @itemx --blocking-factor=@var{blocks}
  6672. Set record size to @math{@var{blocks} * 512} bytes.
  6673. This option is used to specify a @dfn{blocking factor} for the archive.
  6674. When reading or writing the archive, @command{tar}, will do reads and writes
  6675. of the archive in records of @math{@var{block}*512} bytes. This is true
  6676. even when the archive is compressed. Some devices requires that all
  6677. write operations be a multiple of a certain size, and so, @command{tar}
  6678. pads the archive out to the next record boundary.
  6679. The default blocking factor is set when @command{tar} is compiled, and is
  6680. typically 20. Blocking factors larger than 20 cannot be read by very
  6681. old versions of @command{tar}, or by some newer versions of @command{tar}
  6682. running on old machines with small address spaces.
  6683. With a magnetic tape, larger records give faster throughput and fit
  6684. more data on a tape (because there are fewer inter-record gaps).
  6685. If the archive is in a disk file or a pipe, you may want to specify
  6686. a smaller blocking factor, since a large one will result in a large
  6687. number of null bytes at the end of the archive.
  6688. When writing cartridge or other streaming tapes, a much larger
  6689. blocking factor (say 126 or more) will greatly increase performance.
  6690. However, you must specify the same blocking factor when reading or
  6691. updating the archive.
  6692. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6693. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6694. seems to disappear. Id est, we are using block size of 112 right
  6695. now, and we haven't had the problem since we switched@dots{}
  6696. With @GNUTAR{} the blocking factor is limited only
  6697. by the maximum record size of the device containing the archive, or by
  6698. the amount of available virtual memory.
  6699. However, deblocking or reblocking is virtually avoided in a special
  6700. case which often occurs in practice, but which requires all the
  6701. following conditions to be simultaneously true:
  6702. @itemize @bullet
  6703. @item
  6704. the archive is subject to a compression option,
  6705. @item
  6706. the archive is not handled through standard input or output, nor
  6707. redirected nor piped,
  6708. @item
  6709. the archive is directly handled to a local disk, instead of any special
  6710. device,
  6711. @item
  6712. @value{op-blocking-factor} is not explicitly specified on the @command{tar}
  6713. invocation.
  6714. @end itemize
  6715. If the output goes directly to a local disk, and not through
  6716. stdout, then the last write is not extended to a full record size.
  6717. Otherwise, reblocking occurs. Here are a few other remarks on this
  6718. topic:
  6719. @itemize @bullet
  6720. @item
  6721. @command{gzip} will complain about trailing garbage if asked to
  6722. uncompress a compressed archive on tape, there is an option to turn
  6723. the message off, but it breaks the regularity of simply having to use
  6724. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6725. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6726. Gailly, by sending a copy of this message to him.
  6727. @item
  6728. @command{compress} does not show this problem, but as Jean-loup pointed
  6729. out to Michael, @samp{compress -d} silently adds garbage after
  6730. the result of decompression, which tar ignores because it already
  6731. recognized its end-of-file indicator. So this bug may be safely
  6732. ignored.
  6733. @item
  6734. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6735. but will still return an exit status of 2 which tar reports in turn.
  6736. @command{tar} might ignore the exit status returned, but I hate doing
  6737. that, as it weakens the protection @command{tar} offers users against
  6738. other possible problems at decompression time. If @command{gzip} was
  6739. silently skipping trailing zeros @emph{and} also avoiding setting the
  6740. exit status in this innocuous case, that would solve this situation.
  6741. @item
  6742. @command{tar} should become more solid at not stopping to read a pipe at
  6743. the first null block encountered. This inelegantly breaks the pipe.
  6744. @command{tar} should rather drain the pipe out before exiting itself.
  6745. @end itemize
  6746. @item -i
  6747. @itemx --ignore-zeros
  6748. Ignore blocks of zeros in archive (means EOF).
  6749. The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
  6750. of zeros in the archive. Normally a block of zeros indicates the
  6751. end of the archive, but when reading a damaged archive, or one which
  6752. was created by concatenating several archives together, this option
  6753. allows @command{tar} to read the entire archive. This option is not on
  6754. by default because many versions of @command{tar} write garbage after
  6755. the zeroed blocks.
  6756. Note that this option causes @command{tar} to read to the end of the
  6757. archive file, which may sometimes avoid problems when multiple files
  6758. are stored on a single physical tape.
  6759. @item -B
  6760. @itemx --read-full-records
  6761. Reblock as we read (for reading 4.2BSD pipes).
  6762. If @value{op-read-full-records} is used, @command{tar} will not panic if an
  6763. attempt to read a record from the archive does not return a full record.
  6764. Instead, @command{tar} will keep reading until it has obtained a full
  6765. record.
  6766. This option is turned on by default when @command{tar} is reading
  6767. an archive from standard input, or from a remote machine. This is
  6768. because on BSD Unix systems, a read of a pipe will return however
  6769. much happens to be in the pipe, even if it is less than @command{tar}
  6770. requested. If this option was not used, @command{tar} would fail as
  6771. soon as it read an incomplete record from the pipe.
  6772. This option is also useful with the commands for updating an archive.
  6773. @end table
  6774. Tape blocking
  6775. @FIXME{Appropriate options should be moved here from elsewhere.}
  6776. @cindex blocking factor
  6777. @cindex tape blocking
  6778. When handling various tapes or cartridges, you have to take care of
  6779. selecting a proper blocking, that is, the number of disk blocks you
  6780. put together as a single tape block on the tape, without intervening
  6781. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6782. with no information on it, used for decelerating the tape to a
  6783. full stop, and for later regaining the reading or writing speed.
  6784. When the tape driver starts reading a record, the record has to
  6785. be read whole without stopping, as a tape gap is needed to stop the
  6786. tape motion without loosing information.
  6787. @cindex Exabyte blocking
  6788. @cindex DAT blocking
  6789. Using higher blocking (putting more disk blocks per tape block) will use
  6790. the tape more efficiently as there will be less tape gaps. But reading
  6791. such tapes may be more difficult for the system, as more memory will be
  6792. required to receive at once the whole record. Further, if there is a
  6793. reading error on a huge record, this is less likely that the system will
  6794. succeed in recovering the information. So, blocking should not be too
  6795. low, nor it should be too high. @command{tar} uses by default a blocking of
  6796. 20 for historical reasons, and it does not really matter when reading or
  6797. writing to disk. Current tape technology would easily accommodate higher
  6798. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6799. We were told that for some DLT drives, the blocking should be a multiple
  6800. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6801. Other manufacturers may use different recommendations for the same tapes.
  6802. This might also depends of the buffering techniques used inside modern
  6803. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6804. Others request blocking to be some exponent of two.
  6805. So, there is no fixed rule for blocking. But blocking at read time
  6806. should ideally be the same as blocking used at write time. At one place
  6807. I know, with a wide variety of equipment, they found it best to use a
  6808. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6809. I was also told that, for recycled tapes, prior erasure (by the same
  6810. drive unit that will be used to create the archives) sometimes lowers
  6811. the error rates observed at rewriting time.
  6812. I might also use @samp{--number-blocks} instead of
  6813. @samp{--block-number}, so @samp{--block} will then expand to
  6814. @samp{--blocking-factor} unambiguously.
  6815. @node Many
  6816. @section Many Archives on One Tape
  6817. @FIXME{Appropriate options should be moved here from elsewhere.}
  6818. @findex ntape @r{device}
  6819. Most tape devices have two entries in the @file{/dev} directory, or
  6820. entries that come in pairs, which differ only in the minor number for
  6821. this device. Let's take for example @file{/dev/tape}, which often
  6822. points to the only or usual tape device of a given system. There might
  6823. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6824. name is the @emph{rewinding} version of the device, while the name
  6825. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6826. device.
  6827. A rewinding tape device will bring back the tape to its beginning point
  6828. automatically when this device is opened or closed. Since @command{tar}
  6829. opens the archive file before using it and closes it afterwards, this
  6830. means that a simple:
  6831. @smallexample
  6832. $ @kbd{tar cf /dev/tape @var{directory}}
  6833. @end smallexample
  6834. @noindent
  6835. will reposition the tape to its beginning both prior and after saving
  6836. @var{directory} contents to it, thus erasing prior tape contents and
  6837. making it so that any subsequent write operation will destroy what has
  6838. just been saved.
  6839. @cindex tape positioning
  6840. So, a rewinding device is normally meant to hold one and only one file.
  6841. If you want to put more than one @command{tar} archive on a given tape, you
  6842. will need to avoid using the rewinding version of the tape device. You
  6843. will also have to pay special attention to tape positioning. Errors in
  6844. positioning may overwrite the valuable data already on your tape. Many
  6845. people, burnt by past experiences, will only use rewinding devices and
  6846. limit themselves to one file per tape, precisely to avoid the risk of
  6847. such errors. Be fully aware that writing at the wrong position on a
  6848. tape loses all information past this point and most probably until the
  6849. end of the tape, and this destroyed information @emph{cannot} be
  6850. recovered.
  6851. To save @var{directory-1} as a first archive at the beginning of a
  6852. tape, and leave that tape ready for a second archive, you should use:
  6853. @smallexample
  6854. $ @kbd{mt -f /dev/nrtape rewind}
  6855. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6856. @end smallexample
  6857. @cindex tape marks
  6858. @dfn{Tape marks} are special magnetic patterns written on the tape
  6859. media, which are later recognizable by the reading hardware. These
  6860. marks are used after each file, when there are many on a single tape.
  6861. An empty file (that is to say, two tape marks in a row) signal the
  6862. logical end of the tape, after which no file exist. Usually,
  6863. non-rewinding tape device drivers will react to the close request issued
  6864. by @command{tar} by first writing two tape marks after your archive, and by
  6865. backspacing over one of these. So, if you remove the tape at that time
  6866. from the tape drive, it is properly terminated. But if you write
  6867. another file at the current position, the second tape mark will be
  6868. erased by the new information, leaving only one tape mark between files.
  6869. So, you may now save @var{directory-2} as a second archive after the
  6870. first on the same tape by issuing the command:
  6871. @smallexample
  6872. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  6873. @end smallexample
  6874. @noindent
  6875. and so on for all the archives you want to put on the same tape.
  6876. Another usual case is that you do not write all the archives the same
  6877. day, and you need to remove and store the tape between two archive
  6878. sessions. In general, you must remember how many files are already
  6879. saved on your tape. Suppose your tape already has 16 files on it, and
  6880. that you are ready to write the 17th. You have to take care of skipping
  6881. the first 16 tape marks before saving @var{directory-17}, say, by using
  6882. these commands:
  6883. @smallexample
  6884. $ @kbd{mt -f /dev/nrtape rewind}
  6885. $ @kbd{mt -f /dev/nrtape fsf 16}
  6886. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  6887. @end smallexample
  6888. In all the previous examples, we put aside blocking considerations, but
  6889. you should do the proper things for that as well. @xref{Blocking}.
  6890. @menu
  6891. * Tape Positioning:: Tape Positions and Tape Marks
  6892. * mt:: The @command{mt} Utility
  6893. @end menu
  6894. @node Tape Positioning
  6895. @subsection Tape Positions and Tape Marks
  6896. @UNREVISED
  6897. Just as archives can store more than one file from the file system,
  6898. tapes can store more than one archive file. To keep track of where
  6899. archive files (or any other type of file stored on tape) begin and
  6900. end, tape archive devices write magnetic @dfn{tape marks} on the
  6901. archive media. Tape drives write one tape mark between files,
  6902. two at the end of all the file entries.
  6903. If you think of data as a series of records "rrrr"'s, and tape marks as
  6904. "*"'s, a tape might look like the following:
  6905. @smallexample
  6906. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  6907. @end smallexample
  6908. Tape devices read and write tapes using a read/write @dfn{tape
  6909. head}---a physical part of the device which can only access one
  6910. point on the tape at a time. When you use @command{tar} to read or
  6911. write archive data from a tape device, the device will begin reading
  6912. or writing from wherever on the tape the tape head happens to be,
  6913. regardless of which archive or what part of the archive the tape
  6914. head is on. Before writing an archive, you should make sure that no
  6915. data on the tape will be overwritten (unless it is no longer needed).
  6916. Before reading an archive, you should make sure the tape head is at
  6917. the beginning of the archive you want to read. (The @code{restore}
  6918. script will find the archive automatically. @FIXME-xref{Scripted Restoration}@xref{mt}, for
  6919. an explanation of the tape moving utility.
  6920. If you want to add new archive file entries to a tape, you should
  6921. advance the tape to the end of the existing file entries, backspace
  6922. over the last tape mark, and write the new archive file. If you were
  6923. to add two archives to the example above, the tape might look like the
  6924. following:
  6925. @smallexample
  6926. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  6927. @end smallexample
  6928. @node mt
  6929. @subsection The @command{mt} Utility
  6930. @UNREVISED
  6931. @FIXME{Is it true that this only works on non-block devices?
  6932. should explain the difference, (fixed or variable).}
  6933. @value{xref-blocking-factor}.
  6934. You can use the @command{mt} utility to advance or rewind a tape past a
  6935. specified number of archive files on the tape. This will allow you
  6936. to move to the beginning of an archive before extracting or reading
  6937. it, or to the end of all the archives before writing a new one.
  6938. @FIXME{Why isn't there an "advance 'til you find two tape marks
  6939. together"?}
  6940. The syntax of the @command{mt} command is:
  6941. @smallexample
  6942. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  6943. @end smallexample
  6944. where @var{tapename} is the name of the tape device, @var{number} is
  6945. the number of times an operation is performed (with a default of one),
  6946. and @var{operation} is one of the following:
  6947. @FIXME{is there any use for record operations?}
  6948. @table @kbd
  6949. @item eof
  6950. @itemx weof
  6951. Writes @var{number} tape marks at the current position on the tape.
  6952. @item fsf
  6953. Moves tape position forward @var{number} files.
  6954. @item bsf
  6955. Moves tape position back @var{number} files.
  6956. @item rewind
  6957. Rewinds the tape. (Ignores @var{number}).
  6958. @item offline
  6959. @itemx rewoff1
  6960. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  6961. @item status
  6962. Prints status information about the tape unit.
  6963. @end table
  6964. @FIXME{Is there a better way to frob the spacing on the list?}
  6965. If you don't specify a @var{tapename}, @command{mt} uses the environment
  6966. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  6967. @file{/dev/rmt12}.
  6968. @command{mt} returns a 0 exit status when the operation(s) were
  6969. successful, 1 if the command was unrecognized, and 2 if an operation
  6970. failed.
  6971. @FIXME{New node on how to find an archive?}
  6972. If you use @value{op-extract} with the @value{op-label} option specified,
  6973. @command{tar} will read an archive label (the tape head has to be positioned
  6974. on it) and print an error if the archive label doesn't match the
  6975. @var{archive-name} specified. @var{archive-name} can be any regular
  6976. expression. If the labels match, @command{tar} extracts the archive.
  6977. @value{xref-label}.
  6978. @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
  6979. references}@samp{tar --list --label} will cause @command{tar} to print the
  6980. label.
  6981. @FIXME{Program to list all the labels on a tape?}
  6982. @node Using Multiple Tapes
  6983. @section Using Multiple Tapes
  6984. @UNREVISED
  6985. Often you might want to write a large archive, one larger than will fit
  6986. on the actual tape you are using. In such a case, you can run multiple
  6987. @command{tar} commands, but this can be inconvenient, particularly if you
  6988. are using options like @value{op-exclude} or dumping entire filesystems.
  6989. Therefore, @command{tar} supports multiple tapes automatically.
  6990. Use @value{op-multi-volume} on the command line, and then @command{tar} will,
  6991. when it reaches the end of the tape, prompt for another tape, and
  6992. continue the archive. Each tape will have an independent archive, and
  6993. can be read without needing the other. (As an exception to this, the
  6994. file that @command{tar} was archiving when it ran out of tape will usually
  6995. be split between the two archives; in this case you need to extract from
  6996. the first archive, using @value{op-multi-volume}, and then put in the
  6997. second tape when prompted, so @command{tar} can restore both halves of the
  6998. file.)
  6999. @GNUTAR{} multi-volume archives do not use a truly
  7000. portable format. You need @GNUTAR{} at both end to
  7001. process them properly.
  7002. When prompting for a new tape, @command{tar} accepts any of the following
  7003. responses:
  7004. @table @kbd
  7005. @item ?
  7006. Request @command{tar} to explain possible responses
  7007. @item q
  7008. Request @command{tar} to exit immediately.
  7009. @item n @var{file name}
  7010. Request @command{tar} to write the next volume on the file @var{file name}.
  7011. @item !
  7012. Request @command{tar} to run a subshell.
  7013. @item y
  7014. Request @command{tar} to begin writing the next volume.
  7015. @end table
  7016. (You should only type @samp{y} after you have changed the tape;
  7017. otherwise @command{tar} will write over the volume it just finished.)
  7018. If you want more elaborate behavior than this, give @command{tar} the
  7019. @value{op-info-script} option. The file @var{script-name} is expected
  7020. to be a program (or shell script) to be run instead of the normal
  7021. prompting procedure. If the program fails, @command{tar} exits;
  7022. otherwise, @command{tar} begins writing the next volume. The behavior
  7023. of the
  7024. @samp{n} response to the normal tape-change prompt is not available
  7025. if you use @value{op-info-script}.
  7026. The method @command{tar} uses to detect end of tape is not perfect, and
  7027. fails on some operating systems or on some devices. You can use the
  7028. @value{op-tape-length} option if @command{tar} can't detect the end of the
  7029. tape itself. This option selects @value{op-multi-volume} automatically.
  7030. The @var{size} argument should then be the usable size of the tape.
  7031. But for many devices, and floppy disks in particular, this option is
  7032. never required for real, as far as we know.
  7033. The volume number used by @command{tar} in its tape-change prompt
  7034. can be changed; if you give the @value{op-volno-file} option, then
  7035. @var{file-of-number} should be an unexisting file to be created, or else,
  7036. a file already containing a decimal number. That number will be used
  7037. as the volume number of the first volume written. When @command{tar} is
  7038. finished, it will rewrite the file with the now-current volume number.
  7039. (This does not change the volume number written on a tape label, as
  7040. per @value{ref-label}, it @emph{only} affects the number used in
  7041. the prompt.)
  7042. If you want @command{tar} to cycle through a series of tape drives, then
  7043. you can use the @samp{n} response to the tape-change prompt. This is
  7044. error prone, however, and doesn't work at all with @value{op-info-script}.
  7045. Therefore, if you give @command{tar} multiple @value{op-file} options, then
  7046. the specified files will be used, in sequence, as the successive volumes
  7047. of the archive. Only when the first one in the sequence needs to be
  7048. used again will @command{tar} prompt for a tape change (or run the info
  7049. script).
  7050. Multi-volume archives
  7051. With @value{op-multi-volume}, @command{tar} will not abort when it cannot
  7052. read or write any more data. Instead, it will ask you to prepare a new
  7053. volume. If the archive is on a magnetic tape, you should change tapes
  7054. now; if the archive is on a floppy disk, you should change disks, etc.
  7055. Each volume of a multi-volume archive is an independent @command{tar}
  7056. archive, complete in itself. For example, you can list or extract any
  7057. volume alone; just don't specify @value{op-multi-volume}. However, if one
  7058. file in the archive is split across volumes, the only way to extract
  7059. it successfully is with a multi-volume extract command @samp{--extract
  7060. --multi-volume} (@samp{-xM}) starting on or before the volume where
  7061. the file begins.
  7062. For example, let's presume someone has two tape drives on a system
  7063. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7064. to switch to the second drive when it needs to write the
  7065. second tape, and then back to the first tape, etc., just do either of:
  7066. @smallexample
  7067. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7068. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7069. @end smallexample
  7070. @menu
  7071. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7072. * Tape Files:: Tape Files
  7073. @end menu
  7074. @node Multi-Volume Archives
  7075. @subsection Archives Longer than One Tape or Disk
  7076. @cindex Multi-volume archives
  7077. @UNREVISED
  7078. To create an archive that is larger than will fit on a single unit of
  7079. the media, use the @value{op-multi-volume} option in conjunction with
  7080. the @value{op-create} option (@pxref{create}). A
  7081. @dfn{multi-volume} archive can be manipulated like any other archive
  7082. (provided the @value{op-multi-volume} option is specified), but is
  7083. stored on more than one tape or disk.
  7084. When you specify @value{op-multi-volume}, @command{tar} does not report an
  7085. error when it comes to the end of an archive volume (when reading), or
  7086. the end of the media (when writing). Instead, it prompts you to load
  7087. a new storage volume. If the archive is on a magnetic tape, you
  7088. should change tapes when you see the prompt; if the archive is on a
  7089. floppy disk, you should change disks; etc.
  7090. You can read each individual volume of a multi-volume archive as if it
  7091. were an archive by itself. For example, to list the contents of one
  7092. volume, use @value{op-list}, without @value{op-multi-volume} specified.
  7093. To extract an archive member from one volume (assuming it is described
  7094. that volume), use @value{op-extract}, again without
  7095. @value{op-multi-volume}.
  7096. If an archive member is split across volumes (ie. its entry begins on
  7097. one volume of the media and ends on another), you need to specify
  7098. @value{op-multi-volume} to extract it successfully. In this case, you
  7099. should load the volume where the archive member starts, and use
  7100. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7101. volumes as it needs them. @xref{extracting archives}, for more
  7102. information about extracting archives.
  7103. @value{op-info-script} is like @value{op-multi-volume}, except that
  7104. @command{tar} does not prompt you directly to change media volumes when
  7105. a volume is full---instead, @command{tar} runs commands you have stored
  7106. in @var{script-name}. For example, this option can be used to eject
  7107. cassettes, or to broadcast messages such as @samp{Someone please come
  7108. change my tape} when performing unattended backups. When @var{script-name}
  7109. is done, @command{tar} will assume that the media has been changed.
  7110. Multi-volume archives can be modified like any other archive. To add
  7111. files to a multi-volume archive, you need to only mount the last
  7112. volume of the archive media (and new volumes, if needed). For all
  7113. other operations, you need to use the entire archive.
  7114. If a multi-volume archive was labeled using @value{op-label}
  7115. (@value{pxref-label}) when it was created, @command{tar} will not
  7116. automatically label volumes which are added later. To label subsequent
  7117. volumes, specify @value{op-label} again in conjunction with the
  7118. @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
  7119. @cindex Labeling multi-volume archives
  7120. @FIXME{example}
  7121. @FIXME{There should be a sample program here, including an exit
  7122. before end. Is the exit status even checked in tar? :-(}
  7123. @table @kbd
  7124. @item --multi-volume
  7125. @itemx -M
  7126. Creates a multi-volume archive, when used in conjunction with
  7127. @value{op-create}. To perform any other operation on a multi-volume
  7128. archive, specify @value{op-multi-volume} in conjunction with that
  7129. operation.
  7130. @item --info-script=@var{program-file}
  7131. @itemx -F @var{program-file}
  7132. Creates a multi-volume archive via a script. Used in conjunction with
  7133. @value{op-create}.
  7134. @end table
  7135. Beware that there is @emph{no} real standard about the proper way, for
  7136. a @command{tar} archive, to span volume boundaries. If you have a
  7137. multi-volume created by some vendor's @command{tar}, there is almost
  7138. no chance you could read all the volumes with @GNUTAR{}.
  7139. The converse is also true: you may not expect
  7140. multi-volume archives created by @GNUTAR{} to be
  7141. fully recovered by vendor's @command{tar}. Since there is little
  7142. chance that, in mixed system configurations, some vendor's
  7143. @command{tar} will work on another vendor's machine, and there is a
  7144. great chance that @GNUTAR{} will work on most of
  7145. them, your best bet is to install @GNUTAR{} on all
  7146. machines between which you know exchange of files is possible.
  7147. @node Tape Files
  7148. @subsection Tape Files
  7149. @UNREVISED
  7150. To give the archive a name which will be recorded in it, use the
  7151. @value{op-label} option. This will write a special block identifying
  7152. @var{volume-label} as the name of the archive to the front of the archive
  7153. which will be displayed when the archive is listed with @value{op-list}.
  7154. If you are creating a multi-volume archive with
  7155. @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
  7156. volume label will have
  7157. @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
  7158. the number of the volume of the archive. (If you use the @value{op-label}
  7159. option when reading an archive, it checks to make sure the label on the
  7160. tape matches the one you give. @value{xref-label}.
  7161. When @command{tar} writes an archive to tape, it creates a single
  7162. tape file. If multiple archives are written to the same tape, one
  7163. after the other, they each get written as separate tape files. When
  7164. extracting, it is necessary to position the tape at the right place
  7165. before running @command{tar}. To do this, use the @command{mt} command.
  7166. For more information on the @command{mt} command and on the organization
  7167. of tapes into a sequence of tape files, see @ref{mt}.
  7168. People seem to often do:
  7169. @smallexample
  7170. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7171. @end smallexample
  7172. or such, for pushing a common date in all volumes or an archive set.
  7173. @node label
  7174. @section Including a Label in the Archive
  7175. @cindex Labeling an archive
  7176. @cindex Labels on the archive media
  7177. @UNREVISED
  7178. @table @kbd
  7179. @item -V @var{name}
  7180. @itemx --label=@var{name}
  7181. Create archive with volume name @var{name}.
  7182. @end table
  7183. This option causes @command{tar} to write out a @dfn{volume header} at
  7184. the beginning of the archive. If @value{op-multi-volume} is used, each
  7185. volume of the archive will have a volume header of @samp{@var{name}
  7186. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7187. next, and so on.
  7188. @FIXME{Should the arg to --label be a quoted string?? No.}
  7189. To avoid problems caused by misplaced paper labels on the archive
  7190. media, you can include a @dfn{label} entry---an archive member which
  7191. contains the name of the archive---in the archive itself. Use the
  7192. @value{op-label} option in conjunction with the @value{op-create} operation
  7193. to include a label entry in the archive as it is being created.
  7194. If you create an archive using both @value{op-label} and
  7195. @value{op-multi-volume}, each volume of the archive will have an
  7196. archive label of the form @samp{@var{archive-label} Volume @var{n}},
  7197. where @var{n} is 1 for the first volume, 2 for the next, and so on.
  7198. @FIXME-xref{Multi-Volume Archives, for information on creating multiple
  7199. volume archives.}
  7200. If you list or extract an archive using @value{op-label}, @command{tar} will
  7201. print an error if the archive label doesn't match the @var{archive-label}
  7202. specified, and will then not list nor extract the archive. In those cases,
  7203. @var{archive-label} argument is interpreted as a globbing-style pattern
  7204. which must match the actual magnetic volume label. @xref{exclude}, for
  7205. a precise description of how match is attempted@footnote{Previous versions
  7206. of @command{tar} used full regular expression matching, or before that, only
  7207. exact string matching, instead of wildcard matchers. We decided for the
  7208. sake of simplicity to use a uniform matching device through @command{tar}.}.
  7209. If the switch @value{op-multi-volume} is being used, the volume label
  7210. matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
  7211. if the initial match fails, before giving up. Since the volume numbering
  7212. is automatically added in labels at creation time, it sounded logical to
  7213. equally help the user taking care of it when the archive is being read.
  7214. The @value{op-label} was once called @samp{--volume}, but is not available
  7215. under that name anymore.
  7216. To find out an archive's label entry (or to find out if an archive has
  7217. a label at all), use @samp{tar --list --verbose}. @command{tar} will
  7218. print the label first, and then print archive member information, as
  7219. in the example below:
  7220. @smallexample
  7221. $ @kbd{tar --verbose --list --file=iamanarchive}
  7222. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7223. -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  7224. @end smallexample
  7225. @table @kbd
  7226. @item --label=@var{archive-label}
  7227. @itemx -V @var{archive-label}
  7228. Includes an @dfn{archive-label} at the beginning of the archive when
  7229. the archive is being created, when used in conjunction with the
  7230. @value{op-create} option. Checks to make sure the archive label
  7231. matches the one specified (when used in conjunction with the
  7232. @value{op-extract} option.
  7233. @end table
  7234. To get a common information on all tapes of a series, use the
  7235. @value{op-label} option. For having this information different in each
  7236. series created through a single script used on a regular basis, just
  7237. manage to get some date string as part of the label. For example:
  7238. @smallexample
  7239. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7240. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7241. --volume="Daily backup for `date +%Y-%m-%d`"}
  7242. @end smallexample
  7243. Also note that each label has its own date and time, which corresponds
  7244. to when @GNUTAR{} initially attempted to write it,
  7245. often soon after the operator launches @command{tar} or types the
  7246. carriage return telling that the next tape is ready. Comparing date
  7247. labels does give an idea of tape throughput only if the delays for
  7248. rewinding tapes and the operator switching them were negligible, which
  7249. is usually not the case.
  7250. @FIXME{was --volume}
  7251. @node verify
  7252. @section Verifying Data as It is Stored
  7253. @cindex Verifying a write operation
  7254. @cindex Double-checking a write operation
  7255. @table @kbd
  7256. @item -W
  7257. @itemx --verify
  7258. Attempt to verify the archive after writing.
  7259. @end table
  7260. This option causes @command{tar} to verify the archive after writing it.
  7261. Each volume is checked after it is written, and any discrepancies
  7262. are recorded on the standard error output.
  7263. Verification requires that the archive be on a back-space-able medium.
  7264. This means pipes, some cartridge tape drives, and some other devices
  7265. cannot be verified.
  7266. You can insure the accuracy of an archive by comparing files in the
  7267. system with archive members. @command{tar} can compare an archive to the
  7268. file system as the archive is being written, to verify a write
  7269. operation, or can compare a previously written archive, to insure that
  7270. it is up to date.
  7271. To check for discrepancies in an archive immediately after it is
  7272. written, use the @value{op-verify} option in conjunction with
  7273. the @value{op-create} operation. When this option is
  7274. specified, @command{tar} checks archive members against their counterparts
  7275. in the file system, and reports discrepancies on the standard error.
  7276. To verify an archive, you must be able to read it from before the end
  7277. of the last written entry. This option is useful for detecting data
  7278. errors on some tapes. Archives written to pipes, some cartridge tape
  7279. drives, and some other devices cannot be verified.
  7280. One can explicitly compare an already made archive with the file system
  7281. by using the @value{op-compare} option, instead of using the more automatic
  7282. @value{op-verify} option. @value{xref-compare}.
  7283. Note that these two options have a slightly different intent. The
  7284. @value{op-compare} option how identical are the logical contents of some
  7285. archive with what is on your disks, while the @value{op-verify} option is
  7286. really for checking if the physical contents agree and if the recording
  7287. media itself is of dependable quality. So, for the @value{op-verify}
  7288. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7289. the archive, while it lets the speed optimization undisturbed for the
  7290. @value{op-compare} option. If you nevertheless use @value{op-compare} for
  7291. media verification, you may have to defeat the in-memory cache yourself,
  7292. maybe by opening and reclosing the door latch of your recording unit,
  7293. forcing some doubt in your operating system about the fact this is really
  7294. the same volume as the one just written or read.
  7295. The @value{op-verify} option would not be necessary if drivers were indeed
  7296. able to detect dependably all write failures. This sometimes require many
  7297. magnetic heads, some able to read after the writes occurred. One would
  7298. not say that drivers unable to detect all cases are necessarily flawed,
  7299. as long as programming is concerned.
  7300. The @value{op-verify} option will not work in conjunction with the
  7301. @value{op-multi-volume} option or the @value{op-append},
  7302. @value{op-update} and @value{op-delete} operations. @xref{Operations},
  7303. for more information on these operations.
  7304. Also, since @command{tar} normally strips leading @samp{/} from file
  7305. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7306. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7307. @file{/}, as @command{tar} uses the archive's relative member names
  7308. (e.g., @file{etc/motd}) when verifying the archive.
  7309. @node Write Protection
  7310. @section Write Protection
  7311. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7312. be @dfn{write protected}, to protect data on them from being changed.
  7313. Once an archive is written, you should write protect the media to prevent
  7314. the archive from being accidentally overwritten or deleted. (This will
  7315. protect the archive from being changed with a tape or floppy drive---it
  7316. will not protect it from magnet fields or other physical hazards).
  7317. The write protection device itself is usually an integral part of the
  7318. physical media, and can be a two position (write enabled/write
  7319. disabled) switch, a notch which can be popped out or covered, a ring
  7320. which can be removed from the center of a tape reel, or some other
  7321. changeable feature.
  7322. @node Free Software Needs Free Documentation
  7323. @appendix Free Software Needs Free Documentation
  7324. @include freemanuals.texi
  7325. @node Copying This Manual
  7326. @appendix Copying This Manual
  7327. @menu
  7328. * GNU Free Documentation License:: License for copying this manual
  7329. @end menu
  7330. @include fdl.texi
  7331. @node Index
  7332. @appendix Index
  7333. @printindex cp
  7334. @summarycontents
  7335. @contents
  7336. @bye
  7337. @c Local variables:
  7338. @c texinfo-column-for-description: 32
  7339. @c End: