tar.texi 351 KB

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