tar.texi 332 KB

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