tar.texi 343 KB

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