4
0

tar.texi 344 KB

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