123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585 |
- \input texinfo
- comment %**start of header
- include version.texi
- value{VERSION}
- finalout
- c %**end of header
- c 1. Pay attention to UNREVISED{}s
- c 2.1. Run 'make check-options' to make sure all options are properly
- c 2.2. Run 'make master-menu' (see comment before the master menu).
- include value.texi
- defcodeindex kw
- syncodeindex fn cp
- syncodeindex pg cp
- syncodeindex kw cp
- acronym{GNU}
- value{VERSION},
- copyright{} 1992, 1994--1997, 1999--2001, 2003--2013 Free
- Software Foundation, Inc.
- end quotation
- dircategory Archiving
- end direntry
- direntry
- * tar: (tar)tar invocation. Invoking
- end direntry
- acronym{GNU}
- titlepage
- acronym{GNU} tar: an archiver tool
- value{RENDITION} value{UPDATED}
- page
- insertcopying
- ifnottex
- top
- insertcopying
- cindex archiving files
- The first part of this master menu lists the major nodes in this Info
- document. The rest of the menu lists all the lower level nodes.
- c The master menu goes here.
- c NOTE: To update it from within Emacs, make sure mastermenu.el is
- c To update it from the command line, run
- c make master-menu
- detailmenu
- --- The Detailed Node Listing ---
- Introduction
- * Book Contents:: What this Book Contains
- * Definitions:: Some Definitions
- * What tar Does:: What
- command{tar} Archives are Named
- * Authors::
- command{tar}
- * assumptions::
- * stylistic conventions::
- * basic tar options:: Basic
- GNUTAR{}
- * Synopsis::
- * using tar options::
- * Styles::
- * All Options::
- * help::
- * defaults::
- * verbose::
- * checkpoints::
- * warnings::
- * interactive::
- The Three Option Styles
- * Long Options:: Long Option Style
- * Short Options:: Short Option Style
- * Old Options:: Old Option Style
- * Mixing:: Mixing Option Styles
- All
- GNUTAR{} Operations
- * Basic tar::
- * Advanced tar::
- * create options::
- * extract options::
- * backup::
- * Applications::
- * looking ahead::
- Advanced
- option{--append}
- * appending files:: Appending Files to an Archive
- * multiple::
- Updating an Archive
- * how to update::
- Options Used by
- option{--extract}
- * Reading:: Options to Help Read Archives
- * Writing:: Changing How
- command{tar} Writes Files
- * Dealing with Old Files::
- * Overwrite Old Files::
- * Keep Old Files::
- * Keep Newer Files::
- * Unlink First::
- * Recursive Unlink::
- * Data Modification Times::
- * Setting Access Permissions::
- * Directory Modification Times and Permissions::
- * Writing to Standard Output::
- * Writing to an External Program::
- * remove files::
- Coping with Scarce Resources
- * Starting File::
- * Same Order::
- Performing Backups and Restoring Files
- * Full Dumps:: Using
- command{tar} to Perform Incremental Dumps
- * Backup Levels:: Levels of Backups
- * Backup Parameters:: Setting Parameters for Backups and Restoration
- * Scripted Backups:: Using the Backup Scripts
- * Scripted Restoration:: Using the Restore Script
- Setting Parameters for Backups and Restoration
- * General-Purpose Variables::
- * Magnetic Tape Control::
- * User Hooks::
- * backup-specs example:: An Example Text of
- command{tar}
- * file:: Choosing the Archive's Name
- * Selecting Archive Members::
- * files:: Reading Names from a File
- * exclude:: Excluding Some Files
- * wildcards:: Wildcards Patterns and Matching
- * quoting styles:: Ways of Quoting Special Characters in Names
- * transform:: Modifying File and Member Names
- * after:: Operating Only on New Files
- * recurse:: Descending into Directories
- * one:: Crossing File System Boundaries
- Reading Names from a File
- * nul::
- Excluding Some Files
- * problems with exclude::
- Wildcards Patterns and Matching
- * controlling pattern-matching::
- Crossing File System Boundaries
- * directory:: Changing Directory
- * absolute:: Absolute File Names
- Date input formats
- * General date syntax:: Common rules.
- * Calendar date items:: 19 Dec 1994.
- * Time of day items:: 9:20pm.
- * Time zone items:: sc{pdt},
- command{tar} Archives More Portable
- * cpio:: Comparison of command{cpio}
- Using Less Space through Compression
- * gzip:: Creating and Reading Compressed Archives
- * sparse:: Archiving Sparse Files
- Creating and Reading Compressed Archives
- * lbzip2:: Using lbzip2 with
- command{tar} Archives More Portable
- * Portable Names:: Portable Names
- * dereference:: Symbolic Links
- * hard links:: Hard Links
- * old:: Old V7 Archives
- * ustar:: Ustar Archives
- * gnu:: GNU and old GNU format archives.
- * posix::
- command{tar} Implementations
- acronym{POSIX}
- command{tar} Implementations
- * Split Recovery:: Members Split Between Volumes
- * Sparse Recovery:: Sparse Members
- Tapes and Other Archive Media
- * Device:: Device selection and switching
- * Remote Tape Server::
- * Common Problems and Solutions::
- * Blocking:: Blocking
- * Many:: Many archives on one tape
- * Using Multiple Tapes:: Using Multiple Tapes
- * label:: Including a Label in the Archive
- * verify::
- * Write Protection::
- Blocking
- * Format Variations:: Format Variations
- * Blocking Factor:: The Blocking Factor of an Archive
- Many Archives on One Tape
- * Tape Positioning:: Tape Positions and Tape Marks
- * mt:: The
- acronym{GNU} Extensions to the Archive Format
- * Sparse Formats:: Storing Sparse Files
- * Snapshot Files::
- * Dumpdir::
- Storing Sparse Files
- * Old GNU Format::
- * PAX 0:: PAX Format, Versions 0.0 and 0.1
- * PAX 1:: PAX Format, Version 1.0
- Genfile
- * Generate Mode:: File Generation Mode.
- * Status Mode:: File Status Mode.
- * Exec Mode:: Synchronous Execution mode.
- Copying This Manual
- * GNU Free Documentation License:: License for copying this manual
- end menu
- chapter Introduction
- dfn{archives} which are actually collections of
- many other files; the program provides users with an organized and
- systematic method for controlling a large amount of data.
- The name ``tar'' originally came from the phrase ``Tape ARchive'', but
- archives need not (and these days, typically do not) reside on tapes.
- command{tar} Does
- * Naming tar Archives:: How
- GNUTAR{} Authors
- * Reports:: Reporting bugs or suggestions
- node Book Contents
- GNUTAR{}
- and its documentation, and where you should send bug reports
- or comments.
- The second chapter is a tutorial (
- command{tar}. It is
- meant to be self-contained, not requiring any reading from subsequent
- chapters to make sense. It moves from topic to topic in a logical,
- progressive order, building on information already explained.
- Although the tutorial is paced and structured to allow beginners to
- learn how to use
- samp{create}, samp{extract}) as well as
- two frequently used options (samp{verbose}). The other
- chapters do not refer to the tutorial frequently; however, if a section
- discusses something which is a complex variant of a basic concept, there
- may be a cross-reference to that basic concept. (The entire book,
- including the tutorial, assumes that the reader understands some basic
- concepts of using a Unix-type operating system;
- command{tar} options and option syntax.
- The other chapters are meant to be used as a reference. Each chapter
- presents everything that needs to be said about a specific topic.
- One of the chapters (
- acronym{GNU} manuals, and is mostly self-contained.
- In addition, one section of this manual (
- command{tar} sources.
- In general, we give both long and short (abbreviated) option names
- at least once in each section where the relevant option is covered, so
- that novice readers will become familiar with both styles. (A few
- options have no short versions, and the relevant sections will
- indicate this.)
- section Some Definitions
- cindex tar archive
- The command{tar}
- archives. An
- command{tar}
- to
- cindex member
- cindex file name
- dfn{members}. Within this
- manual, we use the term
- command{ls},
- dfn{member} to refer only to the members of an archive. Similarly, a
- dfn{member name} is the name of an archive member within the
- archive.
- cindex unpacking
- The term
- dfn{extracting the
- archive}. The term
- dfn{list} the members in a given archive
- (this is often thought of as ``printing'' them to the standard output,
- or the command line), or
- command{tar}.
- section What
- cindex tar
- The command{tar}
- archives, as well as various other kinds of manipulation. For example,
- you can use
- command{tar} archives were used to store files conveniently on
- magnetic tape. The name
- code{t}ape command{tar} can
- direct its output to available devices, files, or other programs (using
- pipes).
- command{tar} archives in many ways. We want to stress a few
- of them: storage, backup, and transportation.
- table
- item Storage
- Often,
- acronym{GNU} Project distributes its software bundled into
- command{tar} archive. Even when the basic transfer
- mechanism can keep track of names, as FTP can, the nuisance of handling
- multiple files, directories, and multiple links makes
- command{tar} can be used to move archives in
- all dimensions, even time!)
- command{tar} is capable of preserving
- file information and directory structure,
- GNUTAR{} has special features that allow it to be
- used to make incremental and full dumps of all the files in a
- file system.
- end table
- section How
- command{tar} archives are given names ending with
- command{tar} to operate properly,
- but this manual follows that convention in order to accustom readers to
- it and to make examples more clear.
- cindex entry
- command{tar} archives as ``
- command{tar}, this causes no difficulty. However, in
- this manual, we consistently refer to ``archives'' and ``archive
- members'' to make learning to use
- node Authors
- GNUTAR{} Authors
- acronym{GNU} enhancements were
- written by Jay Fenlason, then Joy Kendall, and the whole package has
- been further maintained by Thomas Bushnell, n/BSG, Fran
- command{tar} is a collective work, and owes much to
- all those people who reported problems, offered solutions and other
- insights, or shared their thoughts and suggestions. An impressive, yet
- partial list of those contributors can be found in the
- GNUTAR{} distribution.
- FIXME{History is more important, and surely more interesting, than
- actual names. Quoting names without history would be meaningless. FP}
- Jay Fenlason put together a draft of a
- GNUTAR{}.
- Fran
- value{VERSION} were edited
- by the current maintainer, Sergey Poznyakoff.
- For version 1.12, Daniel Hagerty contributed a great deal of technical
- consulting. In particular, he is the primary author of
- GNUTAR{} was put on CVS at savannah.gnu.org
- (see
- GNUTAR{} is being maintained by Paul Eggert, Sergey
- Poznyakoff and Jeff Bailey.
- Support for
- node Reports
- cindex bug reports
- file{bug-targnu.org}.
- When reporting a bug, please be sure to include as much detail as
- possible, in order to reproduce it.
- node Tutorial
- command{tar}
- This chapter guides you through some basic examples of three
- option{--create}, option{--extract}. If
- you already know how to use some other version of
- command{tar} works.
- command{tar} Operations and Options
- * frequent operations::
- * Two Frequent Options::
- * create:: How to Create Archives
- * list:: How to List Archives
- * extract:: How to Extract Members from an Archive
- * going further::
- node assumptions
- command{tar}
- slowly. At the same time, we will try to cover all the basic aspects of
- these three operations. In order to accomplish both of these tasks, we
- have made certain assumptions about your knowledge before reading this
- manual, and the hardware you will be using:
- bullet
- pxref{Definitions}). In addition, you should understand something
- about how Unix-type operating systems work, and you should know how to
- use some basic utilities. For example, you should know how to create,
- list, copy, rename, edit, and delete files and directories; how to
- change between directories; and how to figure out where you are in the
- file system. You should have some basic understanding of directory
- structure and how files are named according to which directory they are
- in. You should understand concepts such as standard output and standard
- input, what various definitions of the term
- FIXME{and what else?}
- command{tar} commands in. When we show file names,
- we will assume that those names are relative to your home directory.
- For example, my home directory is
- file{practice}.
- xref{Media}, for complete information on using
- FIXME{this is a cop out. need to add some simple tape drive info.}
- node stylistic conventions
- samp{$} represents a typical shell prompt. It
- precedes lines you should type; to make this more clear, those lines are
- shown in
- code{this font}, or
- sometimes
- c When we have lines which are too long to be
- node basic tar options
- command{tar} Operations and Options
- command{tar} fall into one of two classes:
- operations, and options.
- Some arguments fall into a class called
- command{tar};
- you may
- dfn{operating modes}. You are in a particular operating mode when you
- have specified the operation which specifies it; there are eight
- operations in total, and thus there are eight operating modes.
- The other arguments fall into the class known as
- command{tar} at
- that time). Some options are used so frequently, and are so useful for
- helping you type commands more carefully that they are effectively
- ``required''. We will discuss them in this chapter.
- You can write most of the
- GNUTAR{} for compatibility with Unix
- pxref{Old Options}), and we discuss
- the other two styles of writing options (
- pxref{Short Options}).
- In the examples and in the text of this tutorial, we usually use the
- long forms of operations and options; but the ``short'' forms produce
- the same result and can make typing long
- smallexample
- end smallexample
- smallexample
- end smallexample
- smallexample
- end smallexample
- ref{Advanced tar}. In
- discussions in the text, when we name an option by its long form, we
- also give the corresponding short option in parentheses.
- The term, ``option'', can be confusing at times, since ``operations''
- are often lumped in with the actual,
- command{tar}
- users often refer to these by shorthand terms such as, ``short and long
- options''. This term assumes that the ``operations'' are included, also.
- Context will help you determine which definition of ``options'' to use.
- Similarly, the term ``command'' can be confusing, as it is often used in
- two different ways. People sometimes refer to
- command{tar}
- command{tar} what to do --- including the operation, options,
- and any arguments (file names, pipes, other commands, etc.). However,
- you will also sometimes hear the term ``the
- command{tar}
- node frequent operations
- table
- item --create
- command{tar} archive.
- itemx -t
- List the contents of an archive.
- itemx -x
- Extract one or more members from an archive.
- node Two Frequent Options
- command{tar} in the three operating modes listed
- previously, you also need to understand how to use two of the options to
- option{--file} (which takes an archive file as an argument)
- and emph{required} to specify
- either of these options when you run
- menu
- * file tutorial::
- * verbose tutorial::
- * help tutorial::
- node file tutorial
- option{--file} Option
- option
- item --file=
- itemx -f
- end table
- You can specify an argument for the var{archive-name}} (var{archive-name}}) option whenever you
- use
- command{tar} will work on.
- command{tar} will examine
- the environment variable
- command{tar} will use the
- default archive, determined at compile time. Usually it is
- standard output or some physical tape drive attached to your machine
- (you can verify what the default is by running
- pxref{defaults}). If there is no tape drive
- attached, or the default is not meaningful, then
- smallexample
- tar: can't open /dev/rmt8 : No such device or address
- tar: can't open /dev/rsmt0 : I/O error
- noindent
- To avoid confusion, we recommend that you always specify an archive file
- name by using var{archive-name}} (var{archive-name}}) when writing your
- option{--file=option{-f
- ref{file}.
- unnumberedsubsec The
- table
- xopindex{verbose, introduced}
- itemx -v
- Show the files being worked on as
- end table
- option{-v}) shows details about the results of running
- command{tar} as
- it writes files into the archive, you can use the
- option{--verbose} at all times; when you are more accustomed to
- option{--verbose} at times to help make something
- clear, and we will give many examples both using and not using
- option{--verbose} on the command line increases the
- verbosity level by one, so if you need more details on the output,
- specify it twice.
- When reading archives (option{--extract},
- command{tar} by default prints only the names of
- the members being extracted. Using
- command{ls} style member listing.
- In contrast, when writing archives (option{--append},
- command{tar} does not print file names by
- default. So, a single
- option{--verbose} options
- enable the full listing.
- For example, to create an archive in verbose mode:
- kbd{tar -cvf afiles.tar apple angst aspic}
- apple
- angst
- aspic
- noindent
- Creating the same archive with the verbosity level 2 could give:
- kbd{tar -cvvf afiles.tar apple angst aspic}
- -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
- -rw-r--r-- gray/staff 11481 2006-06-09 12:06 angst
- -rw-r--r-- gray/staff 23152 2006-06-09 12:06 aspic
- noindent
- This works equally well using short or long forms of options. Using
- long forms, you would simply write out the mnemonic form of the option
- twice, like this:
- kbd{tar --create --verbose --verbose
- end smallexample
- w{
- anchor{verbose member listing}
- The full output consists of six fields:
- bullet
- command{ls -l} output (
- item Owner name and group separated by a slash character.
- If these data are not available (for example, when listing a
- acronym{ID} values are printed instead.
- item File modification date in ISO 8601 format.
- item File name.
- If the name contains any special characters (white space, newlines,
- etc.) these are displayed in an unambiguous form using so called
- ref{quoting styles}.
- Depending on the file type, the name can be followed by some
- additional information, described in the following table:
- samp
- var{link-name}
- The file or archive member is a
- var{link-name} is the name of file it links to.
- var{link-name}
- The file or archive member is a var{link-name} is
- the name of file it links to.
- item --Long Name--
- The archive member is an old GNU format long name. You will normally
- not encounter this.
- dfn{volume header} (
- item --Continued at byte
- pxref{Using Multiple Tapes}). This archive member is a continuation
- from the previous volume. The number
- item unknown file type
- var{c} is the type character from
- the archive header. If you encounter such a message, it means that
- either your archive contains proprietary member types
- end table
- smallexample
- end group
- smallexample
- node help tutorial
- option{--help} Option
- option
- item --help
- The command{tar} prints out a very brief list of
- all operations and option available for the current version of
- end table
- section How to Create Archives
- cindex Creation of the archive
- command{tar} is option{-c}), which
- you use to create a
- option{--create} first because, in order to learn about the other
- operations, you will find it useful to have an archive available to
- practice on.
- To make this easier, in this section you will first create a directory
- containing three files. Then, we will show you how to create an
- file{blues}, file{jazz}. The archive is called
- option{--create}
- in
- command{tar} works.
- end menu
- subsection Preparing a Practice Directory for Examples
- To follow along with this and future examples, create a new directory
- called file{blues},
- file{jazz}. The files can contain any information you like:
- ideally, they should contain information which relates to their names,
- and be of different lengths. Our examples assume that
- command{cd} to the directory named file{practice}
- is now your emph{Please note}: Although
- the full file name of this directory is
- var{homedir}/practice}, in our examples we will refer to
- this directory as var{homedir} is presumed.)
- In general, you should check that the files to be archived exist where
- you think they do (in the working directory) by running
- samp{collection.tar}), or that you don't care about its contents.
- Whenever you use command{tar} will erase the current
- contents of the file named by var{archive-name}} (var{archive-name}}) if it exists.
- pxref{backup}, for the
- information on how to do so). To add files to an existing archive,
- you need to use a different option, such as option{-r}); see
- node Creating the archive
- xopindex{create, introduced}
- To place the files file{folk}, and
- file{collection.tar}, use the following command:
- kbd{tar --create --file=collection.tar blues folk jazz}
- emph{when using long
- option forms}. You could also say:
- kbd{tar blues --create folk --file=collection.tar jazz}
- noindent
- However, you can see that this order is harder to understand; this is
- why we will list the arguments in the order that makes the commands
- easiest to understand (and we encourage you to do the same when you use
- option{--file=emph{one} argument.
- If you substituted any other string of characters for
- xref{short create}, for more information on this.
- In this example, you type the command as shown above:
- file{collection.tar}), and
- file{blues},
- file{jazz}, are now members of the archive,
- dfn{file name arguments} to the
- xref{Choosing}, for the detailed discussion on these.) Now that they are
- in the archive, they are called
- pxref{Definitions,members}).
- When you create an archive, you
- GNUTAR{} will complain.
- If you now list the contents of the working directory (
- smallexample
- blues folk jazz collection.tar
- noindent
- Creating the archive
- command{tar} will not
- run and will prompt you for one. If you don't name any files,
- emph{Caution}: Do not attempt to use option{-c}) to add files to
- an existing archive; it will delete the archive and write a new one.
- Use option{-r}) instead.
- node create verbose
- option{--create} with
- xopindex{create, using with
- xopindex{verbose, using with
- option{--verbose} (
- command{tar} will list the files it is acting on as it is working. In
- verbose mode, the
- smallexample
- $
- end smallexample
- This example is just like the example we showed which did not use
- command{tar} generated the remaining
- end iftex
- end ifinfo
- In the rest of the examples in this chapter, we will frequently use
- command{tar} responses that
- you would otherwise not see, and which are important for you to
- understand.
- subsection Short Forms with
- option{--create} (
- command{tar}, and you will use it countless times.
- Eventually, you will probably want to use abbreviated (or ``short'')
- forms of options. A full discussion of the three different forms that
- options can take appears in
- option{--verbose} (
- smallexample
- $
- end smallexample
- FIXME{i don't like how this is worded:} One difference between using
- short and long option forms is that, although the exact placement of
- arguments following options is no more specific when using short forms,
- it is easier to become confused and make a mistake when using short
- forms. For example, suppose you attempted the above example in the
- following way:
- kbd{tar -cfv collection.tar blues folk jazz}
- noindent
- In this case, file{v},
- containing the files file{folk}, and
- samp{v} is the closest ``file name'' to the
- command{tar} will try
- to add a file called file{v} archive file;
- if the file command{tar} will
- report an error indicating that this file does not exist. If the file
- command{tar} will add this file to the archive.
- Because the command{tar} will not
- run under
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- option{-f}, but doing that could sacrifice
- valuable data.
- For this reason, we recommend that you pay very careful attention to
- the order of options and placement of file and archive names,
- especially when using short option forms. Not having the option name
- written out mnemonically can affect how well you remember which option
- does what, and therefore where different names have to be placed.
- subsection Archiving Directories
- cindex Directories, Archiving
- You can archive a directory by specifying its directory name as a
- file name argument to
- smallexample
- $
- end smallexample
- file{practice},
- i.e., your home directory. Once in the superior directory, you can
- specify the subdirectory,
- file{practice} in the new archive file
- smallexample
- $
- end smallexample
- command{tar} should output:
- end smallexample
- Note that the archive thus created is not in the subdirectory
- command{tar} was invoked. Before trying to archive a
- directory from its superior directory, you should make sure you have
- write access to the superior directory itself, not only the directory
- you are trying archive with
- command{tar} from the root directory;
- file{collection.tar}, the original archive file, has itself
- been archived.
- file{music.tar} is
- extracted, the archive file
- command{tar} a command such as
- kbd{tar --create --file=foo.tar .}
- noindent
- samp{tar: ./foo.tar is the archive; not
- dumped}. This happens because
- file{foo.tar} in the current directory before putting any files into
- it. Then, when
- file{.} to the archive, it notices that the file
- file{foo.tar}, and skips
- it. (It makes no sense to put an archive into itself.)
- emph{Please
- note:} Other implementations of
- GNUTAR{}. In general, it is wise to always place the archive outside
- of the directory being dumped.)
- section How to List Archives
- option{--list}
- (
- file{collection.tar} that you created in the last section with the
- command,
- kbd{tar --list --file=collection.tar}
- noindent
- The output of
- smallexample
- blues
- folk
- jazz
- noindent
- The archive
- smallexample
- ./birds
- baboon
- ./box
- noindent
- Be sure to use a var{archive-name}} (
- var{archive-name}}) option just as with
- option{-c}) to specify the name of the archive.
- option{--verbose}}
- option{--list}}
- If you use the option{-v}) option with
- command{tar} will print out a listing
- reminiscent of samp{ls -l}}, showing owner, file size, and so
- forth. This output is described in detail in
- option{--verbose} (
- smallexample
- $
- end smallexample
- anchor{listing member and file names}
- It is important to notice that the output of
- kbd{tar
- --create --verbose} while creating the archive. It is because
- xref{absolute}, for more information). In other
- words, in verbose mode dfn{file names} when creating
- an archive and
- smallexample
- kbd{tar --create --verbose --file archive /etc/mail}
- tar: Removing leading '/' from member names
- /etc/mail/
- /etc/mail/sendmail.cf
- /etc/mail/aliases
- $
- end group
- opindex show-stored-names
- This default behavior can sometimes be inconvenient. You can force
- option{--show-stored-names} option.
- option
- emph{file}) names when creating the archive.
- cindex File name arguments, using
- xopindex{list, using with file name arguments}
- You can specify one or more individual member names as arguments when
- using command{tar} will only list the
- names of members you identify. For example, kbd{tar --list
- --file=afiles.tar apple}} would only print
- command{tar} preserves file names, these must be specified as
- they appear in the archive (i.e., relative to the directory from which
- the archive was created). Therefore, it is essential when specifying
- member names to
- w{
- samp{tar: birds: Not found in archive},
- because there is no member named
- file{./birds}. While the names file{./birds} name
- the same file,
- w{
- file{baboon}, because this exact member name is in the archive file
- dfn{globbing patterns}, for example:
- kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
- noindent
- will list all members whose name contains xref{wildcards},
- for a detailed discussion of globbing patterns and related
- menu
- * list dir::
- node list dir
- option{--list} (
- option{--verbose} (
- file{practice}, in
- the archive file
- smallexample
- $
- end smallexample
- smallexample
- drwxrwxrwx myself/user 0 1990-05-31 21:49 practice/
- -rw-r--r-- myself/user 42 1990-05-21 13:29 practice/blues
- -rw-r--r-- myself/user 62 1990-05-23 10:55 practice/folk
- -rw-r--r-- myself/user 40 1990-05-21 13:30 practice/jazz
- -rw-r--r-- myself/user 10240 1990-05-31 21:49 practice/collection.tar
- command{tar} acts on
- all the files (including sub-directories) in that directory.
- section How to Extract Members from an Archive
- cindex Retrieving files from an archive
- opindex extract
- Creating an archive is only half the job---there is no point in storing
- files in an archive if you can't retrieve them. The act of retrieving
- members from an archive so they can be used and manipulated as
- unarchived files again is called
- option{--extract} (
- option{-x}) operation. As with
- option{--file} (
- option{--extract}, you can extract an entire archive, or specific
- files. The files can be directories containing other files, or not. As
- with option{-c}) and option{-t}), you may use the short or the
- long form of the operation without affecting the performance.
- end menu
- subsection Extracting an Entire Archive
- To extract an entire archive, specify the archive file name only, with
- no individual file names as arguments. For example,
- kbd{tar -xvf collection.tar}
- noindent
- produces this:
- end smallexample
- subsection Extracting Specific Files
- To extract specific archive members, give their exact member names as
- arguments, as printed by option{-t}). If you had
- mistakenly deleted one of the files you had placed in the archive
- file{blues}), you can extract it
- from the archive without changing the archive's structure. Its
- contents will be identical to the original file
- file{practice} directory, and list the
- files in the directory. Now, delete the file,
- file{blues} from the archive file
- smallexample
- $
- end smallexample
- file{blues} has been restored, with its original permissions, data
- modification times, and owner.
- code{umask} is compatible with original
- permissions.} (These parameters will be identical to those which
- the file had when you originally placed it in the archive; any changes
- you may have made before deleting the file from the file system,
- however, will
- samp{collection.tar}, is the same as it was before you
- extracted command{tar} with
- option{-t}).
- Remember that as with other operations, specifying the exact member
- name is important. kbd{tar --extract --file=bfiles.tar birds}}
- will fail, because there is no member named
- file{./birds}, you must specify kbd{tar
- --extract --file=bfiles.tar ./birds}}. If you don't remember the
- exact member names, use option{-t}) option
- (
- dfn{globbing pattern}. For example, to extract from
- samp{b}, no matter their
- directory prefix, you could type:
- kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
- noindent
- Here, command{tar} to treat
- command line arguments as globbing patterns and
- samp{/}
- delimiter. The use of globbing patterns is discussed in detail in
- option{--to-stdout} (pxref{Writing to Standard
- Output}).
- If you give the option{--extract}
- will print the names of the archive members as it extracts them.
- subsection Extracting Files that are Directories
- Extracting directories which are members of an archive is similar to
- extracting other files. The main difference to be aware of is that if
- the extracted directory has the same name as any directory already in
- the working directory, then files in the extracted directory will be
- placed into the directory of the same name. Likewise, if there are
- files in the pre-existing directory with the same names as the members
- which you extract, the files from the extracted archive will replace
- the files already in the working directory (and possible
- subdirectories). This will happen regardless of whether or not the
- files in the working directory were more recent than those extracted
- (there exist, however, special options that alter this behavior
- command{tar} will create the directory.
- We can demonstrate how to use
- file{practice} directory if you
- weren't there, and remove the files file{jazz}. Then,
- go back to the parent directory and extract the archive
- file{music.tar}. To extract only the files you deleted, use the
- following command:
- kbd{tar -xvf music.tar practice/folk practice/jazz}
- practice/folk
- practice/jazz
- noindent
- If you were to specify two option{-v}) options,
- smallexample
- $
- end smallexample
- file{practice} as part of the
- file names of each of the files by archiving the
- file{practice}, you must give
- node extracting untrusted archives
- file{untrusted.tar} came from somewhere else on the
- Internet, and you don't necessarily trust its contents, you can
- extract it as follows:
- kbd{mkdir newdir}
- $
- kbd{tar -xvf ../untrusted.tar}
- option{--list} (
- option{--verbose} (
- node failing commands
- smallexample
- $
- end smallexample
- smallexample
- tar: folk: Not found in archive
- tar: jazz: Not found in archive
- noindent
- This is because these files were not originally
- file{..}, where the archive is located; they were in the
- smallexample
- $
- end smallexample
- noindent
- Likewise, if you try to use this command,
- kbd{tar -tvf music.tar folk jazz}
- noindent
- you would get a similar response. Members with those names are not in the
- archive. You must use the correct member names, or wildcards, in order
- to extract the files from the archive.
- If you have forgotten the correct names of the files in the archive,
- use kbd{tar --list --verbose}} to list them correctly.
- node going further
- UNREVISED
- node tar invocation
- GNUTAR{}
- This chapter is about how one invokes the
- pxref{Synopsis}). There are
- numerous options, and many styles for writing them. One mandatory
- option specifies the operation
- pxref{Operation Summary}), other options are meant to detail how
- this operation should be performed (
- pxref{Styles}). On the other hand, operations and options
- are fully described elsewhere, in other chapters. Here, you will find
- only synthetic descriptions for operations and options, together with
- pointers to other parts of the
- command{tar} or else, they globally alter the amount of feedback the user
- receives about what is going on. These are the
- option{--version} (option{--verbose} (
- option{--interactive} options (
- menu
- * Synopsis::
- * using tar options::
- * Styles::
- * All Options:: All
- command{tar} progress.
- * checkpoints:: Checkpoints.
- * warnings:: Controlling Warning Messages.
- * interactive:: Asking for Confirmation During Operations.
- * external:: Running External Commands.
- node Synopsis
- command{tar}
- The
- smallexample
- var{option}var{name}]
- kbd{tar dots{} [dots{} [dots{} [dots{}}
- command{tar} to store files in an archive, to extract them from
- an archive, and to do other types of archive manipulation. The primary
- argument to dfn{operation}, specifies
- which action to take. The other arguments to
- dfn{options}, which change the way
- command{tar} is to act on.
- You can actually type in arguments in any order, even if in this manual
- the options always precede the other arguments, to make examples easier
- to understand. Further, the option stating the main operation mode
- (the
- var{name} in the synopsis above is interpreted as an archive member
- name when the main command is one of
- option{--diff}, option{--delete},
- option{--get}, option{--list} (
- option{--update} (
- option{--list}. For option{-r}) and
- option{-c}), these
- command{tar} command.
- command{tar} will make all file names relative
- (by removing leading slashes when archiving or restoring files),
- unless you specify otherwise (using the
- xref{absolute}, for more information about
- command{tar} acts recursively on all the files and directories
- beneath that directory. For example, the name
- command{tar}.
- The distinction between file names and archive member names is especially
- important when shell globbing is used, and sometimes a source of confusion
- for newcomers.
- command{tar} itself may glob on archive members, so when
- needed, you must ensure that wildcard characters reach
- samp{*}
- or
- var{name}s are often specified on the command line, they
- can also be read from a text file in the file system, using the
- var{file-of-names}} (var{file-of-names}}) option.
- If you don't use any file name arguments, option{-r}),
- option{--concatenate} (
- option{-A}) will do nothing, while option{-c})
- will usually yield a diagnostic and inhibit
- command{tar} (
- option{--extract}, option{--update})
- will act on the entire contents of the archive.
- cindex exit status
- GNUTAR{} may fail for
- many reasons. Some reasons correspond to bad usage, that is, when the
- command{tar} has completed all its work. Some errors are such that
- it would be not meaningful, or at least risky, to continue processing:
- code{stderr}, after a line stating the nature of the error.
- Possible exit codes of
- table
- item 0
- item 1
- option{--compare}
- (option{-d}) command line option, this means that
- some files in the archive differ from their disk counterparts
- (option{--create},
- option{--update} option, this exit code means
- that some files were changed while being archived and so the resulting
- archive does not contain the exact copy of the file set.
- samp{Fatal error}. This means that some fatal, unrecoverable error
- occurred.
- command{tar} has invoked a subprocess and that subprocess exited with a
- nonzero exit code,
- command{tar} was given some
- compression option (
- command{rmt} failure during backup to the
- remote device (
- node using tar options
- command{tar} Options
- command{tar} program by
- specifying one, and only one operation as an argument to the
- ref{frequent operations} and
- command{tar}'s performance by running
- option{--verbose}
- (
- dfn{options} are arguments to
- pxref{All Options}.)
- anchor{TAR_OPTIONS}
- The
- code{TAR_OPTIONS} is command{tar} behaves as
- if the two options option{--unlink-first} had been
- specified before any explicit options. Option specifications are
- separated by whitespace. A backslash escapes the next character, so it
- can be used to specify an option containing whitespace or a backslash.
- Note that
- option{-T} and
- var{name}s,
- while the second does not require an argument and is another way to
- write option{-t}).
- In addition to the eight operations, there are many options to
- FIXME{menu at end of this node. need to think of an actual outline
- for this chapter; probably do that after stuff from chapter 4 is
- incorporated.}
- section The Three Option Styles
- There are three styles for writing operations and options to the command
- line invoking
- command{tar}. These styles will be
- presented below, from the most recent to the oldest.
- Some options must take an argumentoption{--file}
- (
- command{tar} will use a
- default, but this can be confusing; thus, we recommend that you always
- supply a specific archive file name.}. Where you
- emph{may} take an argument. Such options may have at
- most long and short forms, they do not have old style equivalent. The
- rules for specifying an argument for such options are stricter than
- those for specifying mandatory arguments. Please, pay special
- attention to them.
- end menu
- subsection Long Option Style
- cindex options, long style
- cindex options, mnemonic names
- Each option has at least one dfn{mnemonic}) name starting with two
- dashes in a row, e.g.,
- option{--compare} and
- option{--cre} can be used in place of
- samp{cre}. (One way to find
- this out is by trying it and seeing what happens; if a particular
- abbreviation could represent more than one option,
- samp{tar --help}
- to see a list of options. Be aware that if you run
- command{tar} will perform the command as ordered.)
- Long options are meant to be obvious and easy to remember, and their
- meanings are generally easier to discern than those of their
- corresponding short options (see below). For example:
- kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
- noindent
- gives a fairly good set of hints about what the command does, even
- for those not fully acquainted with
- cindex arguments to long options
- option{--file} option (which
- tells the name of the
- file{archive.tar} as argument by using any of the following notations:
- option{--file archive.tar}.
- cindex long options with optional arguments
- In contrast, optional arguments must always be introduced using
- an equal sign. For example, the
- option{--backup=
- node Short Options
- cindex short options
- cindex options, traditional
- Most options also have a
- option{-t}
- (which is equivalent to
- cindex arguments to short options
- w{
- option{-farchive.tar} instead of using
- option{--file=
- w{var{archive-name}}} denote the option which indicates a
- specific archive, here named
- cindex optional arguments to short options
- emph{without any intervening
- white space characters}.
- Short options' letters may be clumped together, but you are not
- required to do this (as compared to old options; see below). When
- short options are clumped as a set, use one (single) dash for them
- all, e.g., samp{
- footnote{Clustering many
- options, the last of which has an argument, is a rather opaque way to
- write options. Some wonder if code{getopt} should not
- even be made helpful enough for considering such usages as invalid.}.
- When the options are separated, the argument for each option which requires
- an argument directly follows that option, as is usual for Unix programs.
- For example:
- kbd{tar -c -v -b 20 -f /dev/rmt0}
- node Old Options
- cindex options, old style
- cindex option syntax, traditional
- As far as we know, all acronym{GNU} and
- non-dfn{old options}: that is, if the first
- argument does not start with
- GNUTAR{} supports old options not only for historical
- reasons, but also because many people are used to them. If the first
- argument does not start with a dash, you are announcing the old option
- style instead of the short option style; old options are decoded
- differently.
- Like short options, old options are single letters. However, old options
- must be written together as a single clumped set, without spaces separating
- them or dashes preceding them. This set
- of letters must be the first to appear on the command line, after the
- samp{t} is
- the same as the short option
- option{--list}. So for example, the command samp{tar
- cv}} specifies the option option{-c}.
- cindex old options with mandatory arguments
- When options that need arguments are given together with the command,
- all the associated arguments follow, in the same order as the options.
- Thus, the example given previously could also be written in the old
- style as follows:
- kbd{tar cvbf 20 /dev/rmt0}
- noindent
- Here, option{-b} and
- option{-f}.
- The old style syntax can make it difficult to match
- option letters with their corresponding arguments, and is often
- confusing. In the command samp{tar cvbf 20 /dev/rmt0}}, for example,
- option{-b},
- option{-f}, and
- w{
- command{tar} options can surprise even experienced
- users. For example, the two commands:
- kbd{tar cfz archive.tar.gz file}
- end smallexample
- file{archive.tar.gz} as
- the value for option samp{z}. The
- second example, however, uses
- samp{f} --- probably not what was intended.
- This second example could be corrected in many ways, among which the
- following are equivalent:
- kbd{tar -czf archive.tar.gz file}
- kbd{tar cf archive.tar.gz -z file}
- node Mixing
- cindex options, mixing different styles
- All three styles may be intermixed in a single
- footnote{Before
- command{tar} command. However,
- old style options must be introduced as the first arguments only,
- following the rule for old options (old options must appear directly
- after the
- smallexample
- kbd{tar --create -f archive.tar}
- kbd{tar --file=archive.tar --create}
- kbd{tar -c --file=archive.tar}
- kbd{tar -c -farchive.tar}
- kbd{tar -cfarchive.tar}
- kbd{tar -f archive.tar -c}
- kbd{tar -farchive.tar -c}
- kbd{tar c -f archive.tar}
- kbd{tar cf archive.tar}
- kbd{tar f archive.tar -c}
- end smallexample
- On the other hand, the following commands are
- smallexample
- kbd{tar -fc archive.tar}
- kbd{tar -farchive.tarc}
- end smallexample
- command{tar} archive would be a file named
- samp{c}, samp{archive.tarc},
- respectively. The first two examples also specify a single non-option,
- samp{archive.tar}. The last
- example contains only old style option letters (repeating option
- samp{.},
- samp{i}), with no argument value.
- node All Options
- command{tar} Options
- The coming manual sections contain an alphabetical listing of all
- command{tar} commands in scripts.
- end menu
- subsection Operations
- option
- item --append
- xref{append}.
- item --catenate
- option{--concatenate}.
- opsummary{compare}
- itemx -d
- Compares archive members with their counterparts in the file
- system, and reports differences in file size, mode, owner,
- modification date and contents.
- opsummary{concatenate}
- itemx -A
- Appends other
- xref{concatenate}.
- item --create
- command{tar} archive.
- opsummary{delete}
- xref{delete}.
- item --diff
- option{--compare}.
- opsummary{extract}
- itemx -x
- Extracts members from the archive into the file system.
- opsummary{get}
- itemx -x
- Same as xref{extract}.
- item --list
- xref{list}.
- item --update
- xref{update}.
- node Option Summary
- command{tar} Options
- option
- item --absolute-names
- command{tar} strips an initial
- command{tar}
- treats names specially if they have initial
- samp{..}. This option disables that behavior.
- opsummary{after-date}
- option{--newer},
- opsummary{anchored}
- xref{controlling pattern-matching}.
- item --atime-preserve
- itemx --atime-preserve=system
- Attempt to preserve the access time of files when reading them. This
- option currently is effective only on files that you own, unless you
- have superuser privileges.
- command{tar} to restore the
- data modification time too, so this option may also cause problems if
- other programs are writing the file at the same time (
- option{--atime-preserve=system} avoids changing time stamps on files,
- without interfering with time stamp updates
- caused by other programs, so it works better with incremental backups.
- However, it requires a special
- command{tar} knows that it does not work, and if you use
- command{tar} complains and
- exits right away. But other times
- option{--atime-preserve} with no operand defaults to
- option{--atime-preserve=system} improves.
- If your operating or file system does not support
- -system}, you might be able to preserve access
- times reliably by using the
- samp{noatime} mount option
- available on some systems. However, mounting typically requires
- superuser privileges and can be a pain to manage.
- item --auto-compress
- option{--create} operation, enables automatic compressed
- format recognition based on the archive suffix. The effect of this
- option is cancelled by xref{gzip}.
- item --backup=
- command{tar} will
- back them up using simple or numbered backups, depending upon
- xref{backup}.
- item --block-number
- command{tar} prints error messages for read errors
- with the block number in the archive file.
- opsummary{blocking-factor}
- var{blocking}
- var{blocking}
- Sets the blocking factor var{blocking} x 512 bytes per
- record.
- opsummary{bzip2}
- itemx -j
- This option tells
- code{bzip2}.
- opsummary{check-device}
- xref{device numbers},
- for a detailed description.
- item --checkpoint[=
- command{tar} to print periodic checkpoint
- messages as it reads through the archive. It is intended for when you
- want a visual indication that
- option{--verbose} output. You can also instruct
- option{--checkpoint-action} below. For a detailed description, see
- opsummary{checkpoint-action}
- var{action}
- Instruct
- xref{checkpoints},
- for a complete description.
- The
- table
- item bell
- Produce an audible bell on the console.
- itemx .
- Print a single dot on the standard listing stream.
- item echo=
- var{string} on the standard error. Before output, the string
- is subject to meta-character expansion.
- var{command}
- Execute the given
- item sleep=
- var{time} seconds.
- var{string}
- Output file{/dev/tty}).
- option{--checkpoint-action} options can be specified. The
- supplied actions will be executed in order of their appearance in the
- command line.
- Using option{--checkpoint}
- assumes default checkpoint frequency of one checkpoint per 10 records.
- item --check-links
- command{tar} will check the number of links
- dumped for each processed file. If this number does not match the
- total number of hard links for the file, a warning message will be
- output GNUTAR{} understood
- option{--one-file-system}. The current semantics, which
- complies to UNIX98, was introduced with version
- 1.15.91.
- xref{hard links}.
- opsummary{uncompress}
- itemx --uncompress
- command{tar} will use the
- xref{gzip}.
- item --confirmation
- (See xref{interactive}.
- item --delay-directory-restore
- Delay setting modification times and permissions of extracted
- directories until the end of extraction.
- opsummary{dereference}
- itemx -h
- When reading or writing a file to be archived,
- xref{dereference}.
- item --directory=
- itemx -C
- command{tar} will change its current directory
- to
- xref{directory}.
- item --exclude=
- command{tar} will skip files that match
- xref{exclude}.
- item --exclude-backups
- Exclude backup and lock files.
- opsummary{exclude-from}
- var{file}
- var{file}
- Similar to command{tar} will use the list of
- patterns in the file xref{exclude}.
- item --exclude-caches
- Exclude from dump any directory containing a valid cache directory
- tag file, but still dump the directory node and the tag file itself.
- opsummary{exclude-caches-under}
- xref{exclude}.
- item --exclude-caches-all
- Exclude from dump any directory containing a valid cache directory
- tag file.
- opsummary{exclude-tag}
- var{file}
- Exclude from dump any directory containing file named
- var{file} itself.
- opsummary{exclude-tag-under}
- var{file}
- Exclude from dump the contents of any directory containing file
- named xref{exclude,,
- exclude-tag-under}.
- item --exclude-tag-all=
- var{file}.
- opsummary{exclude-vcs}
- xref{exclude,,exclude-vcs}.
- item --file=
- itemx -f
- command{tar} will use the file command{tar} archive it
- performs operations on, rather than
- xref{file tutorial}.
- item --files-from=
- itemx -T
- command{tar} will use the contents of
- xref{files}.
- item --force-local
- Forces option{--file}
- as a local file, even if it looks like a remote tape drive name.
- opsummary{format}
- var{format}
- var{format}
- Selects output archive format.
- table
- item v7
- Creates an archive that is compatible with Unix V7
- item oldgnu
- Creates an archive that is compatible with GNU
- item gnu
- Creates archive in GNU tar 1.13 format. Basically it is the same as
- item ustar
- Creates a
- item posix
- Creates a
- end table
- opsummary{full-time}
- command{tar} to print file times to their full
- resolution. Usually this means 1-second resolution, but that depends
- on the underlying file system. The
- option{--verbose} option, e.g., when listing
- or extracting archives:
- kbd{tar -t -v --full-time -f archive.tar}
- noindent
- or, when creating an archive:
- kbd{tar -c -vv --full-time -f archive.tar .}
- option{--verbose} twice to get a detailed output (
- opsummary{group}
- var{group}
- Files added to the acronym{ID} of
- var{group} can specify a
- symbolic name, or a numeric
- var{name}:xref{override}.
- Also see the comments for the var{user}} option.
- opsummary{gunzip}
- item --gzip
- itemx --ungzip
- command{tar} to read or write archives through
- command{tar} to directly operate on several
- kinds of compressed archives transparently.
- opsummary{hard-dereference}
- xref{hard links}.
- item --help
- command{tar} will print out a short message summarizing the operations and
- options to xref{help}.
- item --ignore-case
- Ignore case when matching member or file names with
- patterns.
- opsummary{ignore-command-error}
- xref{Writing to an External Program}.
- item --ignore-failed-read
- Do not exit unsuccessfully merely because an unreadable file was encountered.
- opsummary{ignore-zeros}
- itemx -i
- With this option,
- xref{Reading}.
- item --incremental
- command{tar} that it is working with an old
- xref{Incremental Dumps},
- for a detailed discussion of incremental archives.
- item --index-file=
- var{file} instead of to standard output.
- opsummary{new-volume-script}
- var{command}
- var{command}
- var{command}
- When var{command} is run
- at the end of each tape. If it exits with nonzero status,
- xref{info-script}, for a detailed
- discussion of this feature.
- item --interactive
- itemx -w
- Specifies that
- xref{interactive}.
- item --keep-directory-symlink
- This option changes the behavior of tar when it encounters a symlink
- with the same name as the directory that it is about to extract. By
- default, in this case tar would first remove the symlink and then
- proceed extracting the directory.
- The
- opsummary{keep-newer-files}
- opsummary{keep-old-files}
- itemx -k
- Do not overwrite existing files when extracting files from an
- archive. Return error if such files exist. See also
- xref{Keep Old Files}.
- item --label=
- itemx -V
- command{tar} to write
- command{tar} will only operate on archives that have a label matching
- the pattern specified in xref{Tape Files}.
- item --level=
- var{n}. As of
- value{VERSION}, the option
- var{n} are
- effectively ignored.
- option{--listed-incremental} option.
- opsummary{listed-incremental}
- var{snapshot-file}
- var{snapshot-file}
- During a
- command{tar} creates is a new
- var{snapshot-file} to determine which files to backup.
- With other operations, informs
- xref{Incremental Dumps}.
- item --lzip
- This option tells
- command{lzip}.
- opsummary{lzma}
- command{tar} to read or write archives through
- xref{gzip}.
- command{tar} to read or write archives through
- xref{gzip}.
- item --mode=
- command{tar} will use
- var{permissions} can be specified either as an octal
- number or as symbolic permissions, like with
- xref{override}.
- item --mtime=
- command{tar} will use
- var{date} can be
- either a textual date representation (
- samp{/} or
- xref{override}.
- item --multi-volume
- command{tar} that it should create or otherwise operate on a
- multi-volume xref{Using Multiple Tapes}.
- item --new-volume-script
- (see
- opsummary{newer}
- var{date}
- var{date}
- command{tar} will only add files that have changed
- since var{date} begins with samp{.}, it
- is taken to be the name of a file whose data modification time specifies
- the date.
- opsummary{newer-mtime}
- var{date}
- Like
- option{--newer}, which will
- also back up files for which any status information has
- changed).
- opsummary{no-anchored}
- xref{controlling pattern-matching}.
- item --no-auto-compress
- Disables automatic compressed format recognition based on the archive
- suffix. xref{gzip}.
- item --no-check-device
- Do not check device numbers when creating a list of modified files
- for incremental archiving.
- opsummary{no-delay-directory-restore}
- xref{Directory Modification Times and Permissions}.
- item --no-ignore-case
- Use case-sensitive matching.
- opsummary{no-ignore-command-error}
- xref{Writing to an External Program}.
- item --no-null
- If the
- option{--files-from}
- options will expect their file lists to be newline-terminated.
- item --no-overwrite-dir
- Preserve metadata of existing directories when extracting files
- from an archive.
- opsummary{no-quote-chars}
- var{string}
- Remove characters listed in
- option{--quote-chars} option
- (
- opsummary{no-recursion}
- command{tar} will not recurse into directories.
- opsummary{no-same-owner}
- itemx -o
- When extracting an archive, do not attempt to preserve the owner
- specified in the
- opsummary{no-same-permissions}
- opsummary{no-seek}
- command{tar} determines automatically whether
- the archive can be seeked or not. Use this option to disable this
- mechanism.
- item --no-unquote
- Treat all input file or member names literally, do not interpret
- escape sequences.
- opsummary{no-wildcards}
- xref{controlling pattern-matching}.
- item --no-wildcards-match-slash
- Wildcards do not match
- xref{controlling pattern-matching}.
- item --null
- When option{--files-from} option, this option
- instructs acronym{NUL}, so
- xref{nul}.
- item --numeric-owner
- This option will notify
- command{tar} file, rather than names.
- item -o
- The function of this option depends on the action
- option{-o} is a synonym for
- command{tar} from
- restoring ownership of files being extracted.
- When creating an archive, it is a synonym for
- GNUTAR{}, and will be
- removed in future releases.
- opsummary{occurrence}
- var{number}]
- This option can be used in conjunction with one of the subcommands
- option{--diff},
- option{--list} when a list of files is given either on the command
- line or via
- command{tar} to process only the
- var{Number} defaults to 1, so
- end smallexample
- file{filename} from
- opsummary{old-archive}
- option{--format=v7}.
- item --one-file-system
- Used when creating an archive. Prevents
- opsummary{one-top-level}
- command{tar} to create a new directory beneath the extraction directory
- (or the one passed to
- option{--transform} and
- samp{.tar}, samp{.tbz},
- samp{.tgz}, samp{.txz}.
- item --overwrite
- Overwrite existing files and directory metadata when extracting files
- from an archive.
- opsummary{overwrite-dir}
- xref{Overwrite Old Files}.
- item --owner=
- command{tar} should use
- var{user} can specify a symbolic name, or a numeric
- var{name}:
- xref{override}.
- This option does not affect extraction from archives.
- item --pax-option=
- acronym{POSIX.1-2001}
- format (command{tar} handles the
- extended header keywords.
- xref{PAX keywords}, for a detailed
- discussion.
- item --portability
- option{--format=v7}.
- item --posix
- Same as
- opsummary{preserve}
- option{--preserve-permissions} and
- xref{Setting Access Permissions}.
- item --preserve-order
- (See pxref{Reading}.)
- opsummary{same-permissions}
- itemx --same-permissions
- command{tar} is extracting an archive, it normally subtracts the
- users' umask from the permissions specified in the archive and uses
- that number as the permissions to create the destination file.
- Specifying this option instructs
- xref{Setting Access Permissions}.
- item --quote-chars=
- var{string}, even if the selected
- quoting style would not quote them (
- opsummary{quoting-style}
- var{style}
- Set quoting style to use when printing member and file names
- (var{style} values are:
- code{shell}, code{c},
- code{locale}, and
- code{escape}, unless overridden while configuring the
- package.
- item --read-full-records
- command{tar} should reblock its input, for reading
- from pipes on systems with buggy implementations.
- opsummary{record-size}
- var{size}[
- command{tar} to use
- dfn{size suffix}, e.g.
- xref{size-suffixes},
- for a list of valid suffixes.
- opsummary{recursion}
- command{tar} recurses into directories (default).
- opsummary{recursive-unlink}
- xref{Recursive Unlink}.
- item --remove-files
- Directs
- xref{remove files}.
- item --restrict
- Disable use of some potentially harmful
- pxref{Using Multiple Tapes}).
- item --rmt-command=
- command{tar} that it should use
- file{/usr/libexec/rmt} (
- opsummary{rsh-command}
- var{cmd}
- Notifies var{cmd} to communicate with remote
- devices.
- opsummary{same-order}
- itemx --preserve-order
- command{tar} when running on machines with
- small amounts of memory. It informs
- xref{Reading}.
- item --same-owner
- When extracting an archive,
- command{tar} archive with this option present.
- This is the default behavior for the superuser; this option has an
- effect only for ordinary users.
- opsummary{same-permissions}
- option{--preserve-permissions};
- opsummary{seek}
- itemx -n
- Assume that the archive media supports seeks to arbitrary
- locations. Usually
- option{--list} or
- opsummary{show-defaults}
- command{tar} and exits
- successfully. This option is intended for use in shell scripts.
- Here is an example of what you can see using this option:
- kbd{tar --show-defaults}
- --format=gnu -f- -b20 --quoting-style=escape
- --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
- noindent
- Notice, that this option outputs only one line. The example output
- above has been split to fit page boundaries.
- opsummary{show-omitted-dirs}
- command{tar} to mention the directories it is skipping when
- operating on a xref{show-omitted-dirs}.
- item --show-snapshot-field-ranges
- Displays the range of values allowed by this version of
- xref{Snapshot Files}.
- opsummary{show-stored-names}
- itemx --show-stored-names
- Display file or member names after applying any transformations
- (
- command{tar} to list the
- member names stored in the archive, as opposed to the actual file
- names.
- opsummary{skip-old-files}
- xref{Keep Old Files}.
- This option differs from
- option{--warning=existing-file} option can be used together with
- this option to produce warning messages about existing old files
- (
- opsummary{sparse}
- itemx -S
- Invokes a
- xref{sparse}.
- item --sparse-version=
- dfn{format version} to use when archiving sparse
- files. Implies xref{sparse}. For the description
- of the supported sparse formats,
- opsummary{starting-file}
- var{name}
- var{name}
- This option affects extraction only;
- var{name}.
- opsummary{strip-components}
- var{number}
- Strip given
- file{archive.tar} contained
- smallexample
- tar --extract --file archive.tar --strip-components=2
- noindent
- would extract this file to file
- opsummary{suffix}
- var{suffix}
- Alters the suffix
- samp{~}.
- opsummary{tape-length}
- var{num}[
- itemx -L var{suf}]
- Specifies the length of tapes that
- w{var{suf} is given, it
- specifies a multiplicative factor to be used instead of 1024. For
- example, xref{size-suffixes}, for a
- list of allowed suffixes.
- opsummary{test-label}
- xref{--test-label option}.
- item --to-command=
- command{tar} will pipe extracted files to the
- standard input of xref{Writing to an External Program}.
- item --to-stdout
- command{tar} will extract files to stdout rather
- than to the file system.
- opsummary{totals}
- var{signo}]
- Displays the total number of bytes transferred when processing an
- archive. If an argument is given, these data are displayed on
- request, when signal command{tar}.
- opsummary{touch}
- itemx -m
- Sets the data modification time of extracted files to the extraction time,
- rather than the data modification time stored in the archive.
- opsummary{transform}
- item --transform=
- itemx --xform=
- command{sed} replacement expression
- smallexample
- $
- end smallexample
- file{archive} files from the current working directory,
- replacing initial samp{usr/}. For the detailed
- discussion,
- option{--show-transformed-names} option
- (
- opsummary{uncompress}
- option{--compress},
- opsummary{ungzip}
- option{--gzip},
- opsummary{unlink-first}
- itemx -U
- Directs
- xref{Unlink First}.
- item --unquote
- Enable unquoting input file or member names (default).
- opsummary{use-compress-program}
- var{prog}
- var{prog}
- Instructs var{prog}, which is
- presumed to be a compression program of some sort.
- opsummary{utc}
- acronym{UTC}. This option implies
- opsummary{verbose}
- itemx -v
- Specifies that
- xref{verbose}.
- item --verify
- xref{verify}.
- item --version
- Print information about the program's name, version, origin and legal
- status, all on standard output, and then exit successfully.
- opsummary{volno-file}
- var{file}
- Used in conjunction with command{tar} will
- keep track of which volume of a multi-volume archive it is working in
- xref{volno-file}.
- item --warning=
- var{keyword}. The
- messages are suppressed if samp{no-}.
- opsummary{wildcards}
- xref{controlling pattern-matching}.
- item --wildcards-match-slash
- Wildcards match
- xref{controlling pattern-matching}.
- item --xz
- command{xz} for compressing or decompressing the archives.
- end table
- subsection Short Options Cross Reference
- Here is an alphabetized list of all of the short option forms, matching
- them with the equivalent long option.
- columnfractions 0.20 0.80
- tab Reference
- tab
- item -B ref{--read-full-records}.
- tab
- item -F ref{--info-script}.
- tab
- item -J ref{--xz}.
- tab
- item -L ref{--tape-length}.
- tab
- item -N ref{--newer}.
- tab
- item -P ref{--absolute-names}.
- tab
- item -S ref{--sparse}.
- tab
- item -U ref{--unlink-first}.
- tab
- item -W ref{--verify}.
- tab
- item -Z ref{--compress}.
- tab
- item -c ref{--create}.
- tab
- item -f ref{--file}.
- tab
- item -h ref{--dereference}.
- tab
- item -j ref{--bzip2}.
- tab
- item -l ref{--check-links}.
- tab
- item -o ref{--no-same-owner}, when extracting ---
- GNUTAR{}. In future releases
- option{--no-same-owner} only.
- tab
- item -r ref{--append}.
- tab
- item -t ref{--list}.
- tab
- item -v ref{--verbose}.
- tab
- item -x ref{--extract}.
- tab
- end multitable
- section
- cindex Getting program version number
- cindex Version of the
- GNUTAR{}, indeed. The
- command{tar} to print information about its name, version,
- origin and legal status, all on standard output, and then exit
- successfully. For example, samp{tar --version}} might print:
- value{VERSION}
- Copyright (C) 2013 Free Software Foundation, Inc.
- License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
- This is free software: you are free to change and redistribute it.
- There is NO WARRANTY, to the extent permitted by law.
- Written by John Gilmore and Jay Fenlason.
- noindent
- The first occurrence of
- command{rmt} is another program),
- while the second occurrence of
- samp{tar}, after the name of the main program it
- containscommand{cpio} and
- code{paxutils}. So, who knows if, one of this days, the
- w{acronym{GNU}
- paxutils) 3.2}}.}.
- cindex Listing all
- xopindex{help, introduction}
- Another thing you might want to do is checking the spelling or meaning
- of some particular
- GNUTAR{}
- has a short help feature, triggerable through the
- command{tar} will
- print a usage message listing all available options on standard
- output, then exit successfully, without doing anything else and
- ignoring all other options. Even if this is only a brief summary, it
- may be several screens long. So, if you are not using some kind of
- scrollable window, you might prefer to use something like:
- kbd{tar --help | less}
- noindent
- presuming, here, that you like using
- command{more} and
- var{keyword} which interests you and do not want to read all the
- smallexample
- tar --help | grep
- end smallexample
- command{tar} options have long description lines and the above
- command will list only the first of them.
- The exact look of the option summary displayed by
- xref{Configuring Help Summary}, for a detailed description.
- kbd{tar
- --usage} may be a better choice. This will display a terse list of
- command{tar} manual in some
- form. This manual is available in a variety of forms from
- GNUTAR{}
- distribution, provided you have
- w{file{doc/tar.dvi} the
- usual way (contact your local guru to know how). If
- w{
- command{info} program handy, use the Info reader provided within
- samp{tar} from the main Info menu.
- There is currently no GNUTAR{}.
- If you observe such a
- GNUTAR{}, or it has not
- been produced by
- kbd{tar --help} output to a man page, using
- GNUTAR{} is this Texinfo documentation.
- section Obtaining
- opindex show-defaults
- option{--show-defaults} option. This will output the
- values in the form of
- smallexample
- kbd{tar --show-defaults}
- --format=gnu -f- -b20 --quoting-style=escape
- --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
- end smallexample
- noindent
- The above output shows that this version of
- samp{gnu} archive format (
- option{--file} option has been given
- (
- pxref{Blocking Factor}). It also shows the default locations where
- command{rmt} and
- node verbose
- command{tar} progress
- Typically,
- command{tar}
- with many options, particularly ones with complicated or
- difficult-to-predict behavior, it is possible to make serious mistakes.
- command{tar}
- easier. These options cause
- cindex Verbose operation
- option{--list} (
- option{--verbose}
- (command{tar} to print the name of each
- file or archive member as it is processed. This and the other options
- which make
- command{tar}.
- With option{--extract},
- command{tar} to print a longer listing
- (
- option{--list} already prints the names of the members,
- option{--list} causes
- samp{ls -l} type listing of the files in the archive.
- The following examples both extract members with long list output:
- kbd{tar --extract --file=archive.tar --verbose --verbose}
- $
- end smallexample
- Verbose output appears on the standard output except when an archive is
- being written to the standard output, as with
- samp{tar cvf -}, or even
- command{tar} writes verbose output to the standard error stream.
- If var{file}} is specified,
- var{file} rather than to standard output or standard
- error.
- cindex Obtaining total status information
- option{--totals} option causes
- smallexample
- kbd{tar -c -f archive.tar --totals /home}
- Total bytes written: 7924664320 (7.4GiB, 85MiB/s)
- end smallexample
- When reading an archive, this option displays the number of bytes
- read:
- group
- $
- end group
- option{--totals} option
- displays both numbers plus number of bytes removed from the archive:
- group
- $
- end group
- option{--totals} is used with an argument, this argument is
- interpreted as a symbolic name of a signal, upon delivery of which the
- statistics is to be printed:
- option
- var{signo}
- Print statistics upon delivery of signal
- code{SIGHUP}, code{SIGINT},
- code{SIGUSR2}. Shortened names without
- end table
- Both forms of
- kbd{tar -x --totals --totals=USR1} instructs
- code{SIGUSR1}.
- cindex Progress information
- The
- command{tar} reads or writes the archive. It is designed for
- those who don't need the more detailed (and voluminous) output of
- option{-R}), but do want visual confirmation
- that
- smallexample
- $
- end smallexample
- This example shows the default checkpoint message used by
- samp{.} at each checkpoint
- option{--checkpoint=
- xref{checkpoints, dot}.}. For example:
- kbd{tar -c --checkpoint=.1000} /var
- ...
- option{--checkpoint} option provides a flexible mechanism for
- executing arbitrary actions upon hitting checkpoints, see the next
- section (
- opindex show-omitted-dirs
- option{--show-omitted-dirs} option, when reading an archive---with
- option{--extract}, for example---causes a message
- to be printed for each directory in the archive which is skipped.
- This happens regardless of the reason for skipping: the directory might
- not have been named on the command line (implicitly or explicitly),
- it might be excluded by the use of the
- var{pattern}} option, or some other reason.
- cindex Block number where error occurred
- option{--block-number} (command{tar} prints, along with
- every message it would normally produce, the block number within the
- archive where the message was triggered. Also, supplementary messages
- are triggered when reading blocks full of NULs, or when hitting end of
- file on the archive. As of now, if the archive is properly terminated
- with a NUL block, the reading of the file may stop before end of file
- is met, so the position of end of file will not usually show when
- option{-R}) is used. Note that
- cindex Error message, block number of
- This option is especially useful when reading damaged archives, since
- it helps pinpoint the damaged sections. It can also be used with
- option{-t}) when listing a file-system backup tape, allowing you to
- choose among several backup tapes when retrieving a file later, in
- favor of the tape where the file appears earliest (closest to the
- front of the tape).
- node checkpoints
- cindex checkpoints, defined
- opindex checkpoint-action
- A var{n}th record to
- the archive (a var{n}th record
- from the archive (a
- table
- xopindex{checkpoint, defined}
- var{n}]
- Schedule checkpoints before writing or reading each
- var{n} is 10.
- dfn{actions} can be executed at each checkpoint.
- These actions include: pausing, displaying textual messages, and
- executing arbitrary external programs. Actions are defined using
- the
- table
- xopindex{checkpoint-action, defined}
- var{action}
- Execute an
- end table
- code{echo}, checkpoint action
- The simplest value of samp{echo}. It instructs
- acronym{POSIX} locale) var{n}}, for write
- checkpoints, and var{n}}, for read checkpoints.
- Here,
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- The
- smallexample
- --checkpoint-action="echo=Hit %s checkpoint #%u"
- samp{%s} and
- dfn{format specifiers}. The
- dfn{type} of the checkpoint:
- samp{read} (or a corresponding translated version in locales other
- than samp{%u} specifier is replaced with
- the ordinal number of the checkpoint. Thus, the above example could
- produce the following output when used with the
- smallexample
- tar: Hit write checkpoint #10
- tar: Hit write checkpoint #20
- tar: Hit write checkpoint #30
- table
- item %s
- Print type of the checkpoint (samp{read}).
- item %}T
- Print number of bytes transferred so far and approximate transfer
- speed. Optional arguments supply prefixes to be used before number
- of bytes read, written and deleted, correspondingly. If absent,
- they default to samp{W},
- samp{%}T} means to print corresponding
- statistics without any prefixes. Any surplus arguments, if present,
- are silently ignored.
- kbd{tar --delete -f f.tar --checkpoint-action=echo="#%u: %T" main.c}
- tar: #1: R: 0 (0B, 0B/s),W: 0 (0B, 0B/s),D: 0
- tar: #2: R: 10240 (10KiB, 19MiB/s),W: 0 (0B, 0B/s),D: 10240
- noindent
- See also the
- item %var{fmt}
- var{fmt} as format for
- pxref{strftime, strftime,,strftime(3), strftime(3) man page}). The
- {}} part is optional. If not present, the default
- format is
- item %var{n}
- var{n}th column. If the
- {}} part is omitted, the current screen width
- is assumed.
- var{c}
- This is a shortcut for {%Y-%m-%d %H:%M:%S{read,wrote
- samp{ttyout} action (see below).
- dfn{unquoting}, during which the backslash
- acronym{ASCII} characters
- (
- smallexample
- --checkpoint-action='echo=\aHit %s checkpoint #%u'
- cindex
- samp{bell}. It is not equivalent to
- samp{bell} sends the bell directly to the console (
- samp{echo='\a'} sends it to the standard error.
- code{ttyout}, checkpoint action
- The var{string}} action outputs
- file{/dev/tty}, so it can be used even if the standard output is
- redirected elsewhere. The
- samp{echo} action. In contrast to the latter,
- command{tar} executable name to the
- string, nor does it output a newline after it. For example, the
- following action will print the checkpoint message at the same screen
- line, overwriting any previous message:
- end smallexample
- samp{%*} specifier to clear out any eventual
- remains of the prior output line. As as more complex example,
- consider this:
- {%Y-%m-%d %H:%M:%S
- end smallexample
- cindex
- samp{dot} (or
- command{tar} to print a single dot on the standard listing
- stream, e.g.:
- kbd{tar -c --checkpoint=1000 --checkpoint-action=dot} /var
- ...
- GNUTAR{} versions, this action can
- be abbreviated by placing a dot in front of the checkpoint frequency,
- as shown in the previous section.
- code{totals}, checkpoint action
- The
- option{--totals} option (samp{%T} format
- specifier of the samp{ttyout} action.
- code{sleep}, checkpoint action
- Yet another action, command{tar} for a specified
- amount of seconds. The following example will stop for 30 seconds at each
- checkpoint:
- kbd{tar -c --checkpoint=1000 --checkpoint-action=sleep=30}
- anchor{checkpoint exec}
- code{exec}, checkpoint action
- Finally, the
- smallexample
- $
- end smallexample
- The supplied command can be any valid command invocation, with or
- without additional command line arguments. If it does contain
- arguments, don't forget to quote it to prevent it from being split by
- the shell.
- command{tar}'s environment plus the
- following variables:
- env
- item TAR_VERSION
- vrindex TAR_ARCHIVE, checkpoint script environment
- command{tar} is processing.
- item TAR_BLOCKING_FACTOR
- Current blocking factor (
- vrindex TAR_CHECKPOINT, checkpoint script environment
- vrindex TAR_SUBCOMMAND, checkpoint script environment
- command{tar} is executing.
- vrindex TAR_FORMAT, checkpoint script environment
- xref{Formats}, for a complete
- list of archive format names.
- smallexample
- end smallexample
- command{tar}.
- Any number of actions can be defined, by supplying several
- file{/sbin/cpoint} script:
- group
- $
- end group
- option{--checkpoint-action} can be used without
- node warnings
- GNUTAR{} notices
- some conditions that are not exactly errors, but which the user
- should be aware of. When this happens,
- dfn{warning message} describing the condition. Warning messages
- are output to the standard error and they do not affect the exit
- code of
- xopindex{warning, explained}
- table
- item --warning=
- var{keyword}.
- If samp{no-}, such messages are
- suppressed. Otherwise, they are enabled.
- Multiple
- var{keyword} along with the
- warning messages they control.
- subheading Keywords controlling
- table
- kwindex all
- kwindex none
- kwindex filename-with-nuls
- samp{file name read contains nul character}, warning message
- samp{%s: file name read contains nul character}
- cindex
- item alone-zero-block
- end table
- command{tar --create}
- asis
- cindex
- item cachedir
- kwindex file-shrank
- samp{File shrank by %s bytes}, warning message
- samp{%s: File shrank by %s bytes; padding with zeros}
- cindex
- item xdev
- kwindex file-ignored
- samp{Unknown file type; file ignored}, warning message
- samp{socket ignored}, warning message
- samp{door ignored}, warning message
- samp{%s: Unknown file type; file ignored}
- samp{%s: socket ignored}
- samp{%s: door ignored}
- cindex
- item file-unchanged
- kwindex ignore-archive
- samp{file is the archive; not dumped}, warning message
- cindex
- item ignore-archive
- kwindex file-removed
- samp{File removed before we read it}, warning message
- samp{%s: File removed before we read it}
- cindex
- item file-changed
- end table
- command{tar --extract}
- asis
- cindex
- cindex
- item timestamp
- *
- kwindex contiguous-cast
- samp{Extracting contiguous files as regular files}, warning message
- samp{Extracting contiguous files as regular files}
- cindex
- item symlink-cast
- kwindex unknown-cast
- samp{Unknown file type '%c', extracted as normal file}, warning message
- samp{%s: Unknown file type '%c', extracted as normal file}
- cindex
- item ignore-newer
- kwindex unknown-keyword
- samp{Ignoring unknown extended header keyword '%s'}, warning message
- samp{Ignoring unknown extended header keyword '%s'}
- item decompress-program
- Controls verbose description of failures occurring when trying to run
- alternative decompressor programs (
- option{--verbose} is used). A common example of what you can get
- when using this warning is:
- kbd{tar --warning=decompress-program -x -f archive.Z}
- tar (child): cannot run compress: No such file or directory
- tar (child): trying gzip
- command{tar} first tried to decompress
- command{compress}, and, when that
- failed, switched to
- kwindex record-size
- samp{Record size = %lu blocks}, warning message
- samp{Record size = %lu blocks}
- subheading Keywords controlling incremental extraction:
- asis
- cindex
- cindex
- item rename-directory
- *
- kwindex new-directory
- samp{%s: Directory is new}, warning message
- samp{%s: Directory is new}
- cindex
- item xdev
- kwindex bad-dumpdir
- samp{Malformed dumpdir: 'X' never used}, warning message
- samp{Malformed dumpdir: 'X' never used}
- node interactive
- cindex Interactive operation
- Typically,
- pxref{Choosing}), or by performing
- an operation interactively, using the option{-w}) option.
- option{--confirmation} for this option.
- option{--interactive} (
- command{tar} first prints a message
- for each such file, telling what operation it intends to take, then asks
- for confirmation on the terminal. The actions which require
- confirmation include adding a file to the archive, extracting a file
- from the archive, deleting a file from the archive, and deleting a file
- from disk. To confirm the action, you must type a line of input
- beginning with
- samp{y},
- command{tar} is reading the archive from the standard input,
- file{/dev/tty} to support the interactive
- communications.
- Verbose output is normally sent to standard output, separate from
- other error messages. However, if the archive is produced directly
- on standard output, then verbose output is mixed with errors on
- node external
- GNUTAR{} operations imply running external commands that you
- supply on the command line. One of such operations is checkpointing,
- described above (
- option{-I} option, which allows you to supply the
- program to use for compressing or decompressing the archive
- (
- command{tar} first splits the
- supplied command into words much like the shell does. It then treats
- the first word as the name of the program or the shell script to execute
- and the rest of words as its command line arguments. The program,
- unless given as an absolute file name, is searched in the shell's
- option{--checkpoint-action=exec} option, defines the
- smallexample
- $
- end smallexample
- command{tar}.
- chapter
- menu
- * Basic tar::
- * Advanced tar::
- * create options::
- * extract options::
- * backup::
- * Applications::
- * looking ahead::
- node Basic tar
- GNUTAR{} Operations
- The basic option{--create} (
- option{--list} (option{--extract} (
- option{-x}), are currently presented and described in the tutorial
- chapter of this manual. This section provides some complementary notes
- for these operations.
- option
- item --create
- option{--append}
- (
- command{tar} to destroy a magnetic tape with
- an empty archivecite{Unix-haters
- Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
- Books, ISBN 1-56884-203-1.}. The two most common errors are:
- item
- Mistakingly using code{extract}, when the
- intent was to extract the full contents of an archive. This error
- is likely: keys kbd{x} are right next to each other on
- the QWERTY keyboard. Instead of being unpacked, the archive then
- gets wholly destroyed. When users speak about
- item
- Forgetting the argument to
- kbd{f} key to the cluster of option
- letters, by the mere force of habit, without realizing the full
- consequence of doing so. The usual consequence is that the single
- file, which was meant to be saved, is rather destroyed.
- GNUTAR{} now takes some distance from elegance, and
- cowardly refuses to create an archive when
- option{--files-from} (emph{not} used. To get
- around the cautiousness of
- option{--files-from} option, a file with no names in it, as shown in
- the following commands:
- kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
- end smallexample
- item --extract
- itemx -x
- A socket is stored, within a
- item option{-t})
- samp{1996-08-30},
- while it used to show them as
- url{http://www.cl.cam.ac.uk//iso-time.html} if you
- are curious, it contains a detailed explanation of the ISO 8601 standard.
- node Advanced tar
- GNUTAR{} Operations
- Now that you have learned the basics of using
- command{tar} can help you.
- This chapter presents five, more advanced operations which you probably
- won't use on a daily basis, but which serve more specialized functions.
- We also explain the different styles of options and why you might want
- to use one or another, or a combination of them in your
- command{tar} more carefully, and provide help and
- error correction in special circumstances.
- menu
- * Operations::
- * append::
- * update::
- * concatenate::
- * delete::
- * compare::
- node Operations
- command{tar} Operations
- command{tar}. This chapter presents the remaining five operations to
- option{--append}, option{--concatenate},
- option{--compare}.
- You are not likely to use these operations as frequently as those
- covered in the last chapter; however, since they perform specialized
- functions, they are quite useful when you do need to use them. We
- will give examples using the same directory and files that you created
- in the last chapter. As you may recall, the directory is called
- samp{jazz}, samp{folk},
- and the two archive files you created are
- samp{music.tar}.
- We will also use the archive files
- samp{bfiles.tar}. The archive samp{apple},
- samp{aspic};
- samp{./birds}, samp{./box}.
- Unless we state otherwise, all practicing you do and examples you follow
- in this chapter will take place in the
- ref{prepare for examples}.
- (Below in this section, we will remind you of the state of the examples
- where the last chapter left them.)
- The five operations that we will cover in this chapter are:
- option
- itemx -r
- Add new entries to an archive that already exists.
- itemx -u
- Add more recent copies of archive members to the end of an archive, if
- they exist.
- itemx --catenate
- item --delete
- Delete items from an archive (does not work on tapes).
- itemx --diff
- end table
- subsection How to Add Files to Existing Archives:
- cindex appending files to existing archive
- option{--append} (
- option{--append}. (A
- related operation is the
- option{--update},
- option{--append} to add a file that has the same name as an
- archive member to an archive containing that archive member, then the
- old member is not deleted. What does happen, however, is somewhat
- complex. emph{allows} you to have infinite number of files
- with the same name. Some operations treat these same-named members no
- differently than any other set of archive members: for example, if you
- view an archive with option{-t}), you will see all
- of those members listed, with their data modification times, owners, etc.
- Other operations don't deal with these members as perfectly as you might
- prefer; if you were to use
- option{--extract} extracts an archive in the order the members appeared
- in the archive; the most recently archived members will be extracted
- last. Additionally, an extracted member will
- command{tar}
- will not prompt you about this
- option{--keep-old-files} (or
- command{tar} with
- cindex extracting
- xopindex{occurrence, described}
- There exists a special option that allows you to get around this
- behavior and extract (or list) only a particular copy of the file.
- This is command{tar} with
- this option, it will extract only the first copy of the file. You
- may also give this option an argument specifying the number of
- copy to be extracted. Thus, for example if the archive
- file{myfile}, then
- the command
- end smallexample
- xref{Option
- Summary,---occurrence}, for the description of
- FIXME{ hag -- you might want to incorporate some of the above into the
- MMwtSN node; not sure. i didn't know how to make it simpler...
- There are a few ways to get around this. Xref to Multiple Members
- with the Same Name, maybe.}
- cindex Replacing members with other members
- option{--delete} to
- delete the member you want to remove from the archive, and then use
- ref{delete}
- and
- menu
- * appending files:: Appending Files to an Archive
- * multiple::
- node appending files
- cindex Adding files to an Archive
- cindex Archives, Appending files to
- option{--append} (
- option{--append}, you
- option{--verbose} (
- option{--append} cannot be performed on some tape drives, unfortunately,
- due to deficiencies in the formats those tape drives use. The archive
- must be a valid
- xref{Media}.
- To demonstrate using
- file{rock} in the
- file{practice} directory. Then, run the
- following file{rock} to
- smallexample
- $
- end smallexample
- option{--list} (
- file{rock} has been added to the archive:
- kbd{tar --list --file=collection.tar}
- -rw-r--r-- me/user 28 1996-10-18 16:31 jazz
- -rw-r--r-- me/user 21 1996-09-23 16:44 blues
- -rw-r--r-- me/user 20 1996-09-23 16:44 folk
- -rw-r--r-- me/user 20 1996-09-23 16:44 rock
- node multiple
- cindex members, multiple
- option{--append} (
- command{tar}
- option called xref{update}, for more information.
- We describe this use of
- file{blues} and then append the changed
- version to
- file{blues} is in the archive
- file{blues} to the
- archive in this way:
- kbd{tar --append --verbose --file=collection.tar blues}
- blues
- noindent
- Because you specified the command{tar} has
- printed the name of the file being appended as it was acted on. Now
- list the contents of the archive:
- kbd{tar --list --verbose --file=collection.tar}
- -rw-r--r-- me/user 28 1996-10-18 16:31 jazz
- -rw-r--r-- me/user 21 1996-09-23 16:44 blues
- -rw-r--r-- me/user 20 1996-09-23 16:44 folk
- -rw-r--r-- me/user 20 1996-09-23 16:44 rock
- -rw-r--r-- me/user 58 1996-10-24 18:30 blues
- noindent
- The newest version of
- file{blues} will be
- replaced by the newer version. You can confirm this by extracting
- the archive and running
- file{blues}
- from the archive, use
- smallexample
- $
- end smallexample
- option{--extract} and
- see
- option{--occurrence} option.
- subsection Updating an Archive
- opindex update
- In the previous section, you learned how to use
- option{--update} (option{--update} operation
- updates a
- option{--append}).
- Unfortunately, you cannot use
- FIXME{other examples of media on which --update will fail? need to ask
- charles and/or mib/thomas/dave shevett..}
- Both option{--append} work by adding to the end
- of the archive. When you extract a file from the archive, only the
- version stored last will wind up in the file system, unless you use
- the xref{multiple}, for a detailed discussion.
- end menu
- subsubsection How to Update an Archive Using
- opindex update
- You must use file name arguments with the
- option{-u}) operation. If you don't specify any files,
- c note: the above parenthetical added because in fact, this
- option{--update} option at work, create a new file,
- file{blues}, using any text editor. Then invoke
- samp{update} operation and the option{-v})
- option specified, using the names of all the files in the
- smallexample
- $
- end smallexample
- command{tar} prints out the names
- of the files it is working on, which in this case are the names of the
- files that needed to be updated. If you run
- file{blues} and
- samp{blues};
- the one at the end will be newer and larger, since you added text before
- updating it.
- The reason
- xref{Media}, for more
- information about tapes.
- option{-u}) is not suitable for performing backups for two
- reasons: it does not change directory content entries, and it
- lengthens the archive every time it is used. The
- ref{Backups}.
- subsection Combining Archives with
- cindex Adding archives to an archive
- opindex concatenate
- c option{-A} described
- Sometimes it may be convenient to add a second archive onto the end of
- an archive rather than adding individual files to the archive. To add
- one or more archives to the end of another archive, you should use the
- option{--catenate},
- option{--concatenate}, give the first archive with
- footnote{This can cause multiple members to have the same name. For
- information on how this affects reading the archive, see
- option{--file} option. As usual, if you omit
- command{tar} will use the value of the environment
- variable
- FIXME{There is no way to specify a new name...}
- To demonstrate how
- file{bluesrock.tar} and
- file{practice}:
- kbd{tar -cvf bluesrock.tar blues rock}
- blues
- rock
- $
- end smallexample
- samp{tar --list} to make sure the archives
- contain what they are supposed to:
- kbd{tar -tvf bluesrock.tar}
- -rw-r--r-- melissa/user 105 1997-01-21 19:42 blues
- -rw-r--r-- melissa/user 33 1997-01-20 15:34 rock
- $
- end smallexample
- We can concatenate these two archives with
- smallexample
- $
- kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
- file{bluesrock.tar}, you will see
- that now it also contains the archive members of
- smallexample
- $
- end smallexample
- When you use
- command{tar} does not check whether the
- archives it concatenates have compatible formats, it does not
- even check if the files are really tar archives.
- Like option{-r}), this operation cannot be performed on some
- tape drives, due to deficiencies in the formats those tape drives use.
- code{concatenate} vs
- cindex code{concatenate}
- It may seem more intuitive to you to want or try to use
- option{--concatenate}
- operation; after all,
- command{tar} archives incorporate an end-of-file marker which
- must be removed if the concatenated archives are to be read properly as
- one archive.
- command{cat} to combine the archives, the result will not be a valid
- command{cat} utility, use the
- option{-i}) option.
- command{cat} shell utility.
- subsection Removing Archive Members Using
- cindex Deleting files from an archive
- opindex delete
- You can remove members from an archive by using the
- option{--file}
- (
- option{--verbose} option will cause
- option{--extract}, you
- must give the exact member names when using
- option{--delete} will remove all versions of the named file from the
- archive. The
- option{--delete} has no short form.
- option{--delete} and
- option{--delete} on an archive if the archive device allows you to
- write to any point on the media, such as a disk; because of this, it
- does not work on magnetic tapes. Do not try to delete an archive member
- from a magnetic tape; the action will not succeed, and you will be
- likely to scramble the archive and damage your tape. There is no safe
- way (except by completely re-writing the archive) to delete files from
- most kinds of magnetic tape.
- file{blues} from the archive
- file{practice} directory, make sure you
- are in that directory, and then,
- kbd{tar --list --file=collection.tar}
- blues
- folk
- jazz
- rock
- $
- kbd{tar --list --file=collection.tar}
- folk
- jazz
- rock
- FIXME{Check if the above listing is actually produced after running
- all the examples on collection.tar.}
- The
- command{tar} acts as a filter from code{stdout}.
- subsection Comparing Archive Members with the File System
- opindex compare
- The option{-d}), or
- emph{only} specify archive member names, not file
- names. If you do not name any members, then
- command{tar} reports a difference.
- You have to specify the record size of the archive when modifying an
- archive with a non-default record size.
- file{rock},
- file{funk} in the archive
- file{funk};
- smallexample
- $
- end smallexample
- The spirit behind the option{--diff},
- ref{verify}.
- section Options Used by
- xopindex{create, additional options}
- The previous chapter described the basics of how to use
- option{-c}) to create an archive from a set of files.
- option{--create}.
- end menu
- subsection Overriding File Metadata
- As described above, a
- dfn{metadata}, such as modification time, mode and ownership of
- the file.
- ref{PAX keywords}, for additional ways of controlling
- metadata, stored in the archive.
- option
- item --mode=
- command{tar} will use
- var{permissions} can be specified either as an octal
- number or as symbolic permissions, like with
- xref{File permissions, Permissions, File
- permissions, fileutils,
- samp{a+rw} adds read and write
- permissions for everybody, while retaining executable bits on directories
- or on any other file already marked as executable:
- kbd{tar -c -f archive.tar --mode='a+rw' .}
- item --mtime=
- opindex mtime
- When adding files to an archive, var{date} as
- the modification time of members when creating archives, instead of
- their actual modification times. The argument
- pxref{Date input formats}) or a name of an existing file, starting
- with samp{.}. In the latter case, the modification time
- of that file will be used.
- The following example will set the modification date to 00:00:00,
- January 1, 1970:
- kbd{tar -c -f archive.tar --mtime='1970-01-01' .}
- noindent
- When used with pxref{verbose tutorial})
- option{--mtime} options. If the two dates differ,
- smallexample
- $
- dots{}
- item --owner=
- opindex owner
- Specifies that var{user} as the owner of members
- when creating archives, instead of the user associated with the source
- file.
- If
- var{name}:var{name} specifies the user
- name and a nonempty
- acronym{ID}. If
- samp{0} usually means
- samp{0} as the value to offer in
- their distributions for the owner of files, because the
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- var{group}
- command{tar} archive will have a group var{group},
- rather than the group from the source file. As with
- var{group} can be an existing group symbolic name, or a
- decimal numeric group var{name}:
- end table
- subsection Ignore Fail Read
- option
- opindex ignore-failed-read
- Do not exit with nonzero on unreadable files or directories.
- node extract options
- option{--extract}
- option{--extract}
- option{--extract} to extract
- an archive into the file system. Various options cause
- option{--extract} when certain special
- considerations arise. You may review the information presented in
- option{--extract} operation.
- command{tar} Writes Files
- * Scarce:: Coping with Scarce Resources
- node Reading
- cindex Options when reading archives
- cindex Records, incomplete
- command{tar} will request data in full record increments from
- an archive storage device. If the device cannot return a full record,
- option{--read-full-records} (
- option{--extract} or
- xref{Blocking}.
- The option{-B}) option is turned on by default when
- acronym{BSD} Unix systems, attempting to read a
- pipe returns however much happens to be in the pipe, even if it is
- less than was requested. If this option were not enabled,
- option{--read-full-records} (
- option{--blocking-factor=option{-b
- xref{Blocking Factor}.
- end menu
- unnumberedsubsubsec Reading Full Records
- table
- opindex read-full-records
- item -B
- Use in conjunction with option{--get},
- end table
- unnumberedsubsubsec Ignoring Blocks of Zeros
- cindex Ignoring end-of-archive blocks
- command{tar} stops reading when it encounters a block of zeros
- between file entries (which usually indicates the end of the archive).
- option{-i}) allows
- option{--ignore-zeros} (
- command{tar} write garbage after the end-of-archive entry,
- since that part of the media is never supposed to be read.
- table
- item --ignore-zeros
- option{--extract} or
- end table
- subsection Changing How
- UNREVISED
- menu
- * Dealing with Old Files::
- * Overwrite Old Files::
- * Keep Old Files::
- * Keep Newer Files::
- * Unlink First::
- * Recursive Unlink::
- * Data Modification Times::
- * Setting Access Permissions::
- * Directory Modification Times and Permissions::
- * Writing to Standard Output::
- * Writing to an External Program::
- * remove files::
- node Dealing with Old Files
- xopindex{overwrite-dir, introduced}
- When extracting files, if
- command{tar} normally overwrites its metadata (ownership,
- permission, etc.). The
- option{--no-overwrite-dir} option.
- xopindex{keep-old-files, introduced}
- To be even more cautious and prevent existing files from being replaced, use
- the option{-k}) option. It causes
- example
- $
- kbd{tar -x -k -f archive.tar}
- tar: blues: Cannot open: File exists
- tar: Exiting with failure status due to previous errors
- xopindex{skip-old-files, introduced}
- If you wish to preserve old files untouched, but don't want
- option{--skip-old-files} option. This option causes
- xopindex{overwrite, introduced}
- To be more aggressive about altering existing files, use the
- command{tar} to overwrite
- existing files and to follow existing symbolic links when extracting.
- GNUTAR{} should not hesitate
- to overwrite files with other files when extracting. When extracting
- a
- file{usr/local} is a link to
- file{/usr/local2} to
- GNUTAR{} removes the
- whole hierarchy just to make room for the link to be reinstated
- (unless it
- file{/usr/local2}, of course!)
- emph{only if}
- xopindex{unlink-first, introduced}
- Finally, the option{-U}) option can improve performance in
- some cases by causing
- node Overwrite Old Files
- table
- opindex overwrite
- command{tar} to write extracted files into the file system without
- regard to the files already on the system; i.e., files with the same
- names as archive members are overwritten when the archive is extracted.
- It also causes
- option{--overwrite} option, particularly when
- combined with the option{-P}) option, as this combination
- can change the contents, ownership or permissions of any file on your
- system. Also, many systems do not take kindly to overwriting files that
- are currently being executed.
- item --overwrite-dir
- Overwrite the metadata of directories when extracting files from an
- archive, but remove other files before extracting.
- node Keep Old Files
- GNUTAR{} provides two options to control its actions in a situation
- when it is about to extract a file which already exists on disk.
- option
- item --keep-old-files
- command{tar} issues an error message. Upon end of
- extraction, pxref{exit status}).
- command{tar} exit status.
- Additional verbosity can be obtained using
- pxref{warnings}).
- node Keep Newer Files
- table
- opindex keep-newer-files
- option{--list} (
- end table
- unnumberedsubsubsec Unlink First
- option
- item --unlink-first
- command{tar} run a bit faster if you know in advance
- that the extracted files all need to be removed. Normally this option
- slows
- end table
- unnumberedsubsubsec Recursive Unlink
- option
- item --recursive-unlink
- When this option is specified, try removing files and directory hierarchies
- before extracting over them.
- end table
- If you specify the
- command{tar} removes
- node Data Modification Times
- cindex Data modification times of extracted files
- command{tar} sets the data modification times of extracted
- files to the corresponding times recorded for the files in the archive, but
- limits the permissions of extracted files by the current
- option{--touch} (
- option{--extract} (option{-x}).
- option
- item --touch
- option{--extract} (option{-x}).
- node Setting Access Permissions
- cindex Permissions of extracted files
- option{--same-permissions}
- in conjunction with the option{--get},
- table
- opindex preserve-permissions
- item --preserve-permissions
- c
- itemx -p
- Set modes of extracted archive members to those recorded in the
- archive, instead of current umask settings. Use in conjunction with
- option{--get},
- end table
- unnumberedsubsubsec Directory Modification Times and Permissions
- After successfully extracting a file member,
- command{tar} will almost certainly
- extract files into that directory and this will cause the directory
- modification time to be updated. Moreover, restoring that directory
- permissions may not permit file creation within it. Thus, restoring
- directory permissions and modification times must be delayed at least
- until all files have been extracted into that directory.
- GNUTAR{} checks if the
- directory prefix of this file contains the remembered directory. If
- it does not, the program assumes that all files have been extracted
- into that directory, restores its modification time and permissions
- and removes its entry from the internal list. This approach allows
- to correctly restore directory meta-information in the majority of
- cases, while keeping memory requirements sufficiently small. It is
- based on the fact, that most
- pxref{Incremental Dumps}). The member order in
- an incremental archive is reversed: first all directory members are
- stored, followed by other (non-directory) members. So, when extracting
- from incremental archives,
- GNUTAR{}
- automatically detects archives in incremental format.
- There may be cases, when such processing is required for normal archives
- too. Consider the following example:
- group
- $
- end group
- file{bar}
- file{foo}
- were already extracted and will therefore restore its timestamp and
- permission bits. However, after extracting
- option{--delay-directory-restore} command line option:
- option
- item --delay-directory-restore
- Delays restoring of the modification times and permissions of extracted
- directories until the end of extraction. This way, correct
- meta-information is restored even if the archive has unusual member
- ordering.
- item --no-delay-directory-restore
- Cancel the effect of the previous
- option{--delay-directory-restore} in
- pxref{TAR_OPTIONS}) and wish to
- temporarily disable it.
- node Writing to Standard Output
- cindex Writing extracted files to standard output
- option{--to-stdout} (
- option{--extract} (option{-x}). This option is useful if you are
- extracting files to send them through a pipe, and do not need to
- preserve them in the file system. If you extract multiple members,
- they appear on standard output concatenated, in the order they are
- found in the archive.
- option
- item --to-stdout
- option{--extract} (option{-x}). When this option is
- used, instead of creating the files specified,
- option{--list}
- (
- end table
- This can be useful, for example, if you have a tar archive containing
- a big file and don't want to store the file on disk before processing
- it. You can use a command like this:
- end smallexample
- or even like this if you want to process the concatenation of the files:
- end smallexample
- However,
- node Writing to an External Program
- command{tar} to send the contents of each extracted
- file to the standard input of an external program:
- option
- item --to-command=
- var{command}. When this option is used, instead of creating the
- files specified, var{command} and pipes the
- contents of the files to its standard output. The
- ref{external, Running External Commands},
- for more detail).
- Notice, that
- end table
- The command can obtain the information about the file it processes
- from the following environment variables:
- env
- item TAR_FILETYPE
- Type of the file. It is a single letter with the following meaning:
- columnfractions 0.10 0.90
- tab Regular file
- tab Directory
- tab Symbolic link
- tab Hard link
- tab Block device
- tab Character device
- vrindex TAR_MODE, to-command environment
- vrindex TAR_FILENAME, to-command environment
- vrindex TAR_REALNAME, to-command environment
- vrindex TAR_UNAME, to-command environment
- vrindex TAR_GNAME, to-command environment
- vrindex TAR_ATIME, to-command environment
- vrindex TAR_MTIME, to-command environment
- vrindex TAR_CTIME, to-command environment
- vrindex TAR_SIZE, to-command environment
- vrindex TAR_UID, to-command environment
- vrindex TAR_GID, to-command environment
- end table
- Additionally, the following variables contain information about
- tar mode and the archive being processed:
- env
- item TAR_VERSION
- vrindex TAR_ARCHIVE, to-command environment
- command{tar} is processing.
- item TAR_BLOCKING_FACTOR
- Current blocking factor (
- vrindex TAR_VOLUME, to-command environment
- command{tar} is processing.
- item TAR_FORMAT
- Format of the archive being processed.
- end table
- These variables are defined prior to executing the command, so you can
- pass them as arguments, if you prefer. For example, if the command
- smallexample
- $
- end smallexample
- command{tar}.
- If command{tar} will print
- an error message similar to the following:
- end smallexample
- Here,
- option{--ignore-command-error}:
- option
- item --ignore-command-error
- Ignore exit codes of subprocesses. Notice that if the program
- exits on signal or otherwise terminates abnormally, the error message
- will be printed even if this option is used.
- item --no-ignore-command-error
- Cancel the effect of any previous
- option{--ignore-command-error} in
- pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
- node remove files
- FIXME{The section is too terse. Something more to add? An example,
- maybe?}
- option
- item --remove-files
- Remove files after adding them to the archive.
- node Scarce
- UNREVISED
- cindex Running out of space
- end menu
- unnumberedsubsubsec Starting File
- option
- item --starting-file=
- itemx -K
- option{--extract} (option{-x}) or option{-t}).
- cindex Middle of the archive, starting in the
- If a previous attempt to extract files failed due to lack of disk
- space, you can use var{name}} (
- var{name}}) to start extracting only after member
- command{tar}, remove unnecessary files from
- the file system, and then resume the same
- option{--starting-file} is not necessary.) See also
- ref{exclude}.
- unnumberedsubsubsec Same Order
- option
- opindex same-order
- item --same-order
- itemx -s
- To process large lists of file names on machines with small amounts of
- memory. Use in conjunction with option{--diff},
- option{--list} (option{--extract}
- (option{-x}).
- option{--same-order} (option{-s}) option tells
- samp{tar -t} on the archive and editing its output.
- This option is probably never needed on modern computer systems.
- section Backup options
- GNUTAR{} offers options for making backups of files
- before writing new versions. These options control the details of
- these backups. They may apply to the archive itself before it is
- created or rewritten, as well as individual extracted members. Other
- command{cp}, command{ln},
- and
- FIXME{This is true only if we have a good scheme for truncated backup names,
- which I'm not sure at all: I suspect work is needed in this area.}
- When any existing file is backed up before being overwritten by extraction,
- then clashing files are automatically be renamed to be unique, and the
- true name is kept for only the last file of a series of clashing files.
- By using verbose mode, users may track exactly what happens.
- At the detail level, some decisions are still experimental, and may
- change in the future, we are waiting comments from our users. So, please
- do not learn to depend blindly on the details of the backup features.
- For example, currently, directories themselves are never renamed through
- using these options, so, extracting a file over a directory still has
- good chances to fail. Also, backup options apply to created archives,
- not only to extracted members. For created archives, backups will not
- be attempted when the archive is a block or character device, or when it
- refers to a remote file.
- For the sake of simplicity and efficiency, backups are made by renaming old
- files prior to creation or extraction, and not by copying. The original
- name is restored if the file creation fails. If a failure occurs after a
- partial extraction of a file, both the backup and the partially extracted
- file are kept.
- samp
- var{method}]
- vindex VERSION_CONTROL
- var{method} to determine the type of backups made.
- If env{VERSION_CONTROL}
- environment variable. And if
- samp{existing} method.
- r{Emacs variable}
- This option corresponds to the Emacs variable
- var{method} are accepted as in Emacs. This option
- also allows more descriptive names. The valid
- table
- item t
- cindex numbered
- item nil
- cindex existing
- item never
- cindex simple
- end table
- var{suffix}
- cindex backup suffix
- var{suffix} to each backup file made with
- env{SIMPLE_BACKUP_SUFFIX}
- environment variable is used. And if
- samp{~}, just as in Emacs.
- node Applications
- command{tar} Usages
- FIXME{Using Unix file linking capability to recreate directory
- structures---linking files into one subdirectory and then
- FIXME{Nice hairy example using absolute-names, newer, etc.}
- command{uuencode} in order to transport it properly by
- mail). Both machines do not have to use the same operating system, as
- long as they both support the
- dfn{pipe}:
- kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
- noindent
- You can avoid subshells by using
- smallexample
- $
- end smallexample
- smallexample
- kbd{(cd sourcedir; tar --create --file=- . ) \
- | (cd targetdir; tar --extract --file=-)}
- end smallexample
- smallexample
- kbd{tar --directory sourcedir --create --file=- . \
- | tar --directory targetdir --extract --file=-}
- end smallexample
- command{tar} archive.
- section Looking Ahead: The Rest of this Manual
- You have now seen how to use all eight of the operations available to
- command{tar} (this can help you save time if you expect to
- archive the same list of files a number of times), and so forth.
- command{tar} will read that file.
- command{tar} to skip over some files,
- and not archive them.
- node Backups
- cindex backups
- code{Amanda} (The Advanced Maryland
- Automatic Network Disk Archiver), a backup system developed by James
- da Silva
- uref{http://www.amanda.org}.
- GNUTAR{}
- distribution.
- bullet
- itemize
- item what are dumps
-
- itemize +
-
- item level 1, level 2 dumps etc
- A level
- var{n}-1 dump (?)
-
- item how to use scripts for dumps (ie, the concept)
-
- item scripts to run after editing backup specs (details)
-
- item Backup Specs, what is it.
-
- item how to customize
-
- end itemize
-
- itemize +
-
- item rtape isn't installed
-
- end itemize
- option{--incremental} option of tar
-
- itemize +
-
- item types of media, different sizes and types, useful for different things
-
- item positioning the tape
- MT writes two at end of write,
- backspaces over one when writing again.
-
- end itemize
- command{tar}
- options which are more specific to usage as a backup tool.
- To
- dfn{backups} are also
- called
- menu
- * Full Dumps:: Using
- command{tar} to Perform Incremental Dumps
- * Backup Levels:: Levels of Backups
- * Backup Parameters:: Setting Parameters for Backups and Restoration
- * Scripted Backups:: Using the Backup Scripts
- * Scripted Restoration:: Using the Restore Script
- node Full Dumps
- command{tar} to Perform Full Dumps
- cindex full dumps
- cindex corrupted archives
- Full dumps should only be made when no other people or programs
- are modifying files in the file system. If files are modified while
- option{--label=
- option{-V
- option{--multi-volume} (
- option{--one-file-system} option to prevent
- option{--incremental} (pxref{Incremental Dumps})
- option is not needed, since this is a complete copy of everything in
- the file system, and a full restore from this backup would only be
- done onto a completely
- empty disk.
- Unless you are in a hurry, and trust the
- option{--verify} (
- node Incremental Dumps
- command{tar} to Perform Incremental Dumps
- GNUTAR{} archive that
- stores additional metadata so that exact state of the file system
- can be restored when extracting the archive.
- option{--listed-incremental=option{-g
- option{--incremental} (
- xopindex{listed-incremental, described}
- The option
- dfn{snapshot file}. The purpose of this file is to help
- determine which files have been changed, added or deleted since the
- last backup, so that the next incremental backup will contain only
- modified files. The name of the snapshot file is given as an argument
- to the option:
- option
- var{file}
- var{file}
- Handle incremental backups with snapshot data in
- end table
- To create an incremental backup, you would use
- option{--create}
- (
- smallexample
- $
- end smallexample
- This will create in
- file{/usr} file system, storing additional metadata in the file
- dfn{level 0 backup};
- please see the next section for more on backup levels.
- Otherwise, if the file
- file{/usr/doc/old} and create
- directory
- smallexample
- $
- end smallexample
- Some time later you create another incremental backup. You will
- then see:
- kbd{tar --create \
- --file=archive.2.tar \
- --listed-incremental=/var/log/usr.snar \
- /usr}
- tar: usr/local/db: Directory is new
- usr/local/db/
- usr/local/db/data
- usr/local/db/index
- noindent
- The created archive
- dfn{level 1 backup}. Notice
- that
- samp{level 1} backups, it is necessary to
- create a working copy of the snapshot file before running
- smallexample
- $
- kbd{tar --create \
- --file=archive.2.tar \
- --listed-incremental=/var/log/usr.snar-1 \
- /usr}
- anchor{--level=0}
- samp{level 0} backups either by removing the snapshot
- file before running
- option{--level=0} option, e.g.:
- kbd{tar --create \
- --file=archive.2.tar \
- --listed-incremental=/var/log/usr.snar-0 \
- --level=0 \
- /usr}
- option{--atime-preserve=replace} option), or if you set the clock
- backwards.
- cindex Device numbers, using in incremental backups
- Metadata stored in snapshot files include device numbers, which,
- obviously are supposed to be non-volatile values. However, it turns
- out that
- acronym{NFS} devices numbers over time. The solution implemented
- currently is to consider all
- acronym{NFS}, there are a number of cases where
- relying on device numbers can cause spurious redumping of unmodified
- files. For example, this occurs when archiving
- option{--no-check-device} option:
- option
- item --no-check-device
- Do not rely on device numbers when preparing a list of changed files
- for an incremental dump.
- item --check-device
- Use device numbers when preparing a list of changed files
- for an incremental dump. This is the default behavior. The purpose
- of this option is to undo the effect of the
- env{TAR_OPTIONS} environment variable
- (
- end table
- There is also another way to cope with changing device numbers. It is
- described in detail in
- command{tar} extensions and may
- not be readable by non-command{tar} program.
- option{--extract}}
- option{--listed-incremental}}
- To extract from the incremental dumps, use
- option{--extract}
- option (command{tar} does
- not need to access snapshot file, since all the data necessary for
- extraction are stored in the archive itself. So, when extracting, you
- can give whatever argument to
- option{--listed-incremental=/dev/null}.
- Alternatively, you can use
- option{--incremental} (
- option{--listed-incremental} when listing or
- extracting incremental backups (for more information regarding this
- option,
- GNUTAR{} attempts to
- restore the exact state the file system had when the archive was
- created. In particular, it will
- file{/usr}
- file system, one would do
- option{-P} option (
- smallexample
- $
- kbd{tar --extract \
- --listed-incremental=/dev/null \
- --file archive.2.tar}
- option{--list}
- (
- option{--listed-incremental} or
- option{--verbose} options
- option{--verbose} options were selected to avoid breaking usual
- verbose listing output (
- xopindex{incremental, using with
- xopindex{listed-incremental, using with
- xopindex{list, using with
- xopindex{list, using with
- GNUTAR{} up to 1.15.1 used to dump verbatim binary
- contents of the DUMPDIR header (with terminating nulls) when
- option{--listed-incremental} option was
- given, no matter what the verbosity level. This behavior, and,
- especially, the binary output it produced were considered inconvenient
- and were changed in version 1.16.}:
- kbd{tar --list --incremental --verbose --verbose archive.tar}
- smallexample
- var{file}
- noindent
- where samp{Y}
- if the file is present in the archive,
- samp{D} if the file is a directory (and
- is included in the archive).
- anchor{incremental-op}The option option{-G})
- gives the same behavior as
- option{--list} and
- option{--create} option, it creates an incremental archive without
- creating snapshot file. Thus, it is impossible to create several
- levels of incremental backups with
- node Backup Levels
- dfn{full backup} or
- dfn{incremental dumps}. A
- GNUTAR{} comes with scripts you can use to do full
- and level-one (actually, even level-two and so on) dumps. Using
- scripts (shell programs) to perform backups and restoration is a
- convenient and reliable alternative to typing out file name lists
- and
- file{backup-specs}, which specifies parameters used by the backup
- scripts and by the restore script. This file is usually located
- in xref{Backup Parameters}, for its
- detailed description. Once the backup parameters are set, you can
- perform backups or restoration by running the appropriate script.
- The name of the backup script is
- code{restore}. The following sections describe
- their use in detail.
- xref{Incremental Dumps}, before
- making such an attempt.
- section Setting Parameters for Backups and Restoration
- The file
- command{tar}. You must
- edit
- file{backup-specs} is a shell script, containing
- mainly variable assignments. However, any valid shell construct
- is allowed in this file. Particularly, you may wish to define
- functions within that script (e.g., see
- url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
- g_02, the definition of the Shell Command Language}. See also
- code{backup} and
- menu
- * General-Purpose Variables::
- * Magnetic Tape Control::
- * User Hooks::
- * backup-specs example:: An Example Text of
- end menu
- subsection General-Purpose Variables
- code{Backup} scripts
- sends a backup report to this address.
- defvr {Backup variable} BACKUP_HOUR
- The hour at which the backups are done. This can be a number from 0
- to 23, or the time specification in form var{minutes},
- or the string
- code{backup}. Its value may be overridden
- using pxref{Scripted Backups}).
- defvr {Backup variable} TAPE_FILE
- The device var{TAPE_FILE}
- is a remote archive (
- command{mt} is able to access remote devices. If
- pxref{RSH}) is set,
- command{mt}.
- defvr {Backup variable} BLOCKING
- The blocking factor
- xref{Blocking Factor}.
- defvr {Backup variable} BACKUP_DIRS
- A list of file systems to be dumped (for
- code{restore}). You can include any directory
- name in the list --- subdirectories on that file system will be
- included, regardless of how they may look to other networked machines.
- Subdirectories on other file systems will be ignored.
- The host name specifies which host to run
- GNUTAR{} installed, and
- must be able to access the directory containing the backup scripts and
- their support files using the same file name that is used on the
- machine where the scripts are run (i.e., what
- acronym{NFS}.
- If the list of file systems is very long you may wish to put it
- in a separate file. This file is usually named
- file{backup-specs} using
- end defvr
- file{/etc/backup/dirs}.
- defvr {Backup variable} BACKUP_FILES
- A list of individual files to be dumped (for
- code{restore}). These should be accessible from the machine on
- which the backup script is run.
- If the list of individual files is very long you may wish to store it
- in a separate file. This file is usually named
- file{backup-specs} using
- end defvr
- file{/etc/backup/files}.
- defvr {Backup variable} MT
- Full file name of
- end defvr
- anchor{RSH}
- Full file name of
- code{ssh}, to improve security. In this case you will have
- to use public key authentication.
- defvr {Backup variable} RSH_COMMAND
- Full file name of
- option{--rsh-command} option to the remote invocation
- of
- end defvr
- end defvr
- dfn{exclude file list}. An
- file{/etc/shadow} from backups).
- This variable affects only
- end defvr
- code{backup}.
- defvr {Backup variable} DUMP_REMIND_SCRIPT
- Script to be run when it's time to insert a new tape in for the next
- volume. Administrators may want to tailor this script for their site.
- If this variable isn't set,
- ref{change volume prompt}.
- defvr {Backup variable} SLEEP_MESSAGE
- Message to display on the terminal while waiting for dump time. Usually
- this will just be some literal text.
- defvr {Backup variable} TAR
- Full file name of the
- command{tar} in the current shell path.
- node Magnetic Tape Control
- dfn{hook functions}.
- These functions take a single argument --- the name of the tape
- device. Their names are kept in the following variables:
- dfn{begin} function. This function is called before
- accessing the drive. By default it retensions the tape:
- {
- mt -f "$1" retension
- end smallexample
- defvr {Backup variable} MT_REWIND
- The name of
- smallexample
- MT_REWIND=mt_rewind
- mt_rewind()
- }
- end defvr
- smallexample
- MT_OFFLINE=mt_offline
- mt_offline()
- }
- end defvr
- smallexample
- MT_STATUS=mt_status
- mt_status()
- }
- end defvr
- subsection User Hooks
- command{tar} invocation. Thus, there are
- dfn{restore hooks}, executed before and
- after restoring a file system. Each user hook is a shell function
- taking four arguments:
- var{level} var{fs}
- table
- item level
- Current backup or restore level.
- item fs
- Full file name of the file system being dumped or restored.
- end table
- defvr {Backup variable} DUMP_BEGIN
- Dump begin function. It is executed before dumping the file system.
- defvr {Backup variable} DUMP_END
- Executed after dumping the file system.
- defvr {Backup variable} RESTORE_BEGIN
- Executed before restoring the file system.
- defvr {Backup variable} RESTORE_END
- Executed after restoring the file system.
- node backup-specs example
- file{Backup-specs}
- The following is an example of
- smallexample
- # site-specific parameters for file system backup.
- ADMINISTRATOR=friedman
- BACKUP_HOUR=1
- TAPE_FILE=/dev/nrsmt0
- # Use code{rsh}
- RSH=/usr/bin/ssh
- RSH_COMMAND=/usr/bin/ssh
- # Override MT_STATUS function:
- my_status()
- }
- MT_STATUS=my_status
- # Disable MT_OFFLINE function
- MT_OFFLINE=:
- BLOCKING=124
- BACKUP_DIRS="
- albert:/fs/fsf
- apple-gunkies:/gd
- albert:/fs/gd2
- albert:/fs/gp
- geech:/usr/jla
- churchy:/usr/roland
- albert:/
- albert:/usr
- apple-gunkies:/
- apple-gunkies:/usr
- gnu:/hack
- gnu:/u
- apple-gunkies:/com/mailer/gnu
- apple-gunkies:/com/archive/gnu"
- BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
- node Scripted Backups
- smallexample
- backup --level=var{time}
- option{--level} option requests the dump level. Thus, to produce
- a full dump, specify
- option{--level} may be omitted if its value is
- footnote{For backward compatibility, the
- samp{level-}
- followed by a single decimal digit, that digit is taken as
- the dump level number. Thus, you may create a link from
- code{level-1} and then run
- option{--time} option determines when should the backup be
- run.
- table
- item var{mm}
- The dump must be run at var{mm} minutes.
- var{hh}
- The dump must be run at
- item now
- The dump must be run immediately.
- code{restore} script prompts for media by its archive volume,
- so to avoid an error message you should keep track of which tape
- (or disk) contains which volume of the archive (
- file{/etc/tar-backup/}, which is used by the scripts
- to store and retrieve information about which files were dumped. This
- file is not meant to be read by humans, and should not be deleted by
- them.
- file{log-var{n}}, where
- var{n} represents current dump level number.
- The script also prints the name of each system being dumped to the
- standard output.
- Following is the full list of options accepted by
- table
- item -l
- itemx --level=
- var{level} (default 0).
- itemx --force
- Force backup even if today's log file already exists.
- var{level}]
- var{level}]
- Set verbosity level. The higher the level is, the more debugging
- information will be output during execution. Default
- item -t
- itemx --time=
- var{time}, then do backup.
- itemx --help
- Display short help message and exit.
- itemx --version
- Display information about the program's name, version, origin and legal
- status, all on standard output, and then exit successfully.
- node Scripted Restoration
- code{restore} script. Its usage is quite straightforward. In the
- simplest form, invoke
- file{backup-specs} (
- code{restore} a list of
- smallexample
- restore 'albert:*'
- noindent
- will restore all file systems on the machine
- smallexample
- restore 'albert:*' '*:/var'
- noindent
- This command will restore all file systems on the machine
- file{/var} file system on all machines.
- By default
- option{--level} option, as shown in the example below:
- end smallexample
- The full list of options accepted by
- table
- item -a
- file{backup-specs}.
- var{level}
- var{level}
- Start restoring from the given backup level, instead of the default 0.
- var{level}]
- var{level}]
- Set verbosity level. The higher the level is, the more debugging
- information will be output during execution. Default
- item -h
- item -V
- end table
- You should start the restore script with the media containing the
- first volume of the archive mounted. The script will prompt for other
- volumes as they are needed. If the archive is on tape, you don't need
- to rewind the tape to to its beginning---if the tape head is
- positioned past the beginning of the archive, the script will rewind
- the tape as needed.
- quotation
- end quotation
- node Choosing
- command{tar}
- Certain options to
- menu
- * file:: Choosing the Archive's Name
- * Selecting Archive Members::
- * files:: Reading Names from a File
- * exclude:: Excluding Some Files
- * wildcards:: Wildcards Patterns and Matching
- * quoting styles:: Ways of Quoting Special Characters in Names
- * transform:: Modifying File and Member Names
- * after:: Operating Only on New Files
- * recurse:: Descending into Directories
- * one:: Crossing File System Boundaries
- node file
- cindex Naming an archive
- cindex Choosing an archive file
- opindex file
- By default,
- command{tar}
- on the system may not have set the default to a meaningful value as far as
- most users are concerned. As a result, you will usually want to tell
- option{--file=option{-f
- table
- xopindex{file, short description}
- var{archive-name}
- var{archive-name}
- Name the archive to create or operate on. Use in conjunction with
- any operation.
- command{tar} command,
- kbd{tar -cvf collection.tar blues folk jazz}
- noindent
- option{-f} option, since whatever directly follows
- emph{will} end up naming the archive. If you neglect to specify an
- archive name, you may end up overwriting a file in the working directory
- with the archive you create since
- cindex Writing new archives
- command{tar} uses the value of the
- environment variable
- command{tar} uses a default, compiled-in archive
- name, usually that for tape unit zero (i.e.,
- cindex Standard input and output
- file{-} as an command{tar} reads the
- archive from standard input (when listing or extracting files), or
- writes it to standard output (when creating an archive). If you use
- var{archive-name} when modifying an archive,
- file{sourcedir} to
- smallexample
- $
- end smallexample
- The
- smallexample
- $
- end smallexample
- In both examples above, the leftmost
- file{sourcedir} to the standard output, while the
- rightmost one reads this archive from its standard input and
- extracts it. The
- cindex Remote devices
- anchor{remote-dev}
- To specify an archive file on a device attached to a remote machine,
- use the following:
- kbd{--file=var{dev}/
- end smallexample
- command{tar} will set up the remote connection, if possible, and
- prompt you for a username and password. If you use
- var{hostname}:/var{file-name}},
- cindex Local and remote archives
- samp{:}), then it is assumed
- to be a file on another machine. If the archive file is
- var{user}var{file}}, then
- var{host}. The remote host is accessed using the
- var{user}. If the username is omitted
- (along with the
- command{rsh} behavior.) It is necessary for the
- remote machine, in addition to permitting your
- file{rmt} program installed (this command is included in
- the
- file{var{prefix} means your
- installation prefix). If you need to use a file whose name includes a
- colon, then the remote tape drive behavior
- can be inhibited by using the
- file{/dev/null},
- GNUTAR{}, has an initial sizing pass which
- uses this feature.
- section Selecting Archive Members
- cindex Specifying archive members
- command{tar} operates on, when creating or adding to an archive, or which
- archive members
- xref{Operations}.
- To specify file names, you can include them as the last arguments on
- the command line, as follows:
- kbd{tar} var{option1} dots{}] [var{file name-2}
- end smallexample
- If a file name begins with dash (
- option{--add-file} option to prevent it from being treated as an
- option.
- GNUTAR{} attempts to
- dfn{escape sequences} according to the following
- table:
- columnfractions 0.20 0.60
- tab Replaced with
- tab Audible bell (
- item \b acronym{ASCII} 8)
- tab Form feed (
- item \n acronym{ASCII} 10)
- tab Carriage return (
- item \t acronym{ASCII} 9)
- tab Vertical tabulation (
- item \? acronym{ASCII} 127
- var{n} acronym{ASCII} var{n} should be an octal number
- of up to 3 digits)
- table
- opindex unquote
- opindex no-unquote
- end table
- If you specify a directory name as a file name argument, all the files
- in that directory are operated on by
- command{tar} behavior differs depending
- on the operation mode as described below:
- When option{--create} (
- command{tar} will stop immediately, reporting the following:
- group
- $
- end group
- option{--list} (
- option{--extract} (option{-x}),
- option{--diff} option, tar will compare the archive with
- the contents of the current working directory.
- If you specify any other operation,
- command{tar} takes file names from the command line. However,
- there are other ways to specify file or member names, or to modify the
- manner in which
- node files
- cindex Reading file names from a file
- cindex File Name arguments, alternatives
- command{find}, using with
- option{--files-from=option{-T
- command{tar}. Give the name of the
- file which contains the list of files to include as the argument to
- command{find} utility.
- option
- item --files-from=
- itemx -T
- var{file-name}.
- option{--files-from}, (i.e.,
- you specify either code{-T -}), then the file
- names are read from standard input.
- Unless you are running option{--create}, you can not use
- both code{--file=-} (
- option{-T} options can be given in the command line.
- The following example shows how to use
- file{small-files}. You can then use the
- command{tar} to specify the files from that file,
- file{little.tgz}. (The
- command{tar} compresses the archive with pxref{gzip} for
- more information.)
- kbd{find . -size -400 -print > small-files}
- $
- end smallexample
- option{-T} option, any file name beginning
- with command{tar} option and is
- processed accordinglyGNUTAR{} up to 1.15.1
- recognized only
- option{-C} option:
- group
- $
- kbd{tar -c -f foo.tar --files-from list}
- end smallexample
- command{tar} will first switch to
- file{passwd} and
- file{/lib} directory and will archive
- the file file{foo.tar} will
- contain:
- group
- $
- end group
- opindex add-file
- If you happen to have a file whose name starts with
- option{--add-file} option to prevent it from
- being recognized as an option. For example:
- menu
- * nul::
- node nul
- code{NUL}-Terminated File Names
- code{NUL}
- code{NUL}-terminated file names
- The
- option{--files-from=option{-T
- code{NUL} instead of a newline, so
- files whose names contain newlines can be archived using
- table
- xopindex{null, described}
- code{NUL}-terminated file names, instead of files that
- terminate in a newline.
- item --no-null
- Undo the effect of any previous
- end table
- The acronym{GNU}
- command{cpio}, and is useful with the
- acronym{GNU}
- command{tar},
- command{find} to generate a list of files
- larger than 800K in length and put that list into a file called
- option{-print0} option to
- option{-print}, except that it separates files with a
- command{tar} with both the
- option{-T} options to specify that
- file{long-files}, to create the archive
- option{--null} option to
- command{tar} to recognize the
- smallexample
- $
- kbd{tar -c -v --null --files-from=long-files --file=big.tar}
- option{--no-null} option can be used if you need to read both
- file{flist} is a newline-terminated file, then the
- following command can be used to combine it with the above command:
- group
- $
- end group
- GNUTAR is tries to automatically detect
- option{--null} option. In this case
- option{--null} were
- actually given:
- group
- $
- end group
- option{-T} options will assume
- newline termination. Of course, the null autodetection applies
- to these eventual surplus
- node exclude
- cindex File names, excluding files by
- cindex Excluding files by file system
- opindex exclude-from
- To avoid operating on files whose names match a particular pattern,
- use the option{--exclude-from} options.
- option
- item --exclude=
- command{tar} to ignore files that match the
- end table
- option{--exclude=
- var{pattern}) from
- being operated on.
- For example, to create an archive with all the contents of the directory
- file{.o}, use the
- command
- option{--exclude} options.
- option
- item --exclude-from=
- itemx -X
- command{tar} to ignore files that match the patterns listed in
- end table
- option{--exclude-from} option to read a
- list of patterns, one per line, from command{tar} will
- ignore files matching those patterns. Thus if
- w{file{foo} contains a
- single line file{.o} will be
- added to the archive.
- Notice, that lines from
- table
- cindex version control system, excluding files
- cindex SCCS, excluding files
- cindex CVS, excluding files
- cindex git, excluding files
- cindex Arch, excluding files
- cindex Darcs, excluding files
- item --exclude-vcs
- Exclude files and directories used by following version control
- systems: samp{RCS}, samp{SVN},
- samp{Bazaar}, samp{Darcs}.
- As of version
- itemize
- item
- item
- item
- item
- item
- item
- item
- item
- item {arch
- item
- item
- item
- item
- item
- item
- item
- item
- item
- item
- end itemize
- item --exclude-backups
- Exclude backup and lock files. This option causes exclusion of files
- that match the following shell globbing patterns:
- asis
- item *~
- end table
- findex exclude-caches
- When creating an archive, the
- command{tar} to exclude all directories that contain a
- file{CACHEDIR.TAG} and having a standard header
- specified in
- samp{exclude-caches} options, each providing a different
- exclusion semantics:
- option
- item --exclude-caches
- Do not archive the contents of the directory, but archive the
- directory itself and the
- opindex exclude-caches-under
- file{CACHEDIR.TAG} file, archive only the directory itself.
- item --exclude-caches-all
- Omit directories containing
- end table
- option{--exclude-tag}, provides a generalization of
- this concept. It takes a single argument, a file name to look for.
- Any directory that contains this file will be excluded from the dump.
- Similarly to
- table
- opindex exclude-tag
- var{file}
- Do not dump the contents of the directory, but dump the
- directory itself and the
- opindex exclude-tag-under
- var{file}
- Do not dump the contents of the directory, nor the
- opindex exclude-tag-all
- var{file}
- Omit directories containing
- end table
- Multiple
- smallexample
- kbd{find dir}
- dir
- dir/blues
- dir/jazz
- dir/folk
- dir/folk/tagfile
- dir/folk/sanjuan
- dir/folk/trote
- end smallexample
- The
- smallexample
- $
- end smallexample
- Both the
- option{--exclude-tag-under} option will exclude
- smallexample
- $
- end smallexample
- Finally, using file{dir/folk}
- directory entirely:
- kbd{tar -cf archive.tar --exclude-tag-all=tagfile -v dir}
- dir/
- dir/blues
- dir/jazz
- ./tar: dir/folk/: contains a cache directory tag tagfile;
- directory not dumped
- menu
- * problems with exclude::
- node problems with exclude
- code{exclude} Options
- samp{exclude} options confusing. Here are some common
- pitfalls:
- bullet
- command{tar} does not act on a file name
- explicitly listed on the command line, if one of its file name
- components is excluded. In the example above, if
- you create an archive and exclude files that end with
- samp{dir.o/foo} after all the options have been
- listed,
- item
- You can sometimes confuse the meanings of
- option{--exclude-from}. Be careful: use
- option{--exclude-from} to introduce the name of a file which contains
- a list of patterns, one per line; each of these patterns can exclude
- zero, one, or many files.
- option{--exclude=
- var{pattern} parameter, so
- samp{*}. If you do not do this, the shell might expand the
- command{tar} might receive a
- list of files instead of one pattern, or none at all, making the
- command somewhat illegal. This might not correspond to what you want.
- For example, write:
- kbd{tar -c -f var{directory}}
- noindent
- rather than:
- emph{Wrong!}
- $ var{archive.tar} --exclude *.o
- end smallexample
- code{regexp}
- syntax, when using exclude options in
- code{regexp} syntax to describe files to be excluded, your command
- might fail.
- FIXME{The change in semantics must have occurred before 1.11,
- so I doubt if it is worth mentioning at all. Anyway, should at
- least specify in which version the semantics changed.}
- In earlier versions of
- option{--exclude-from} option was called
- option{--exclude} applies to patterns listed on the command
- line and
- end itemize
- section Wildcards Patterns and Matching
- dfn{wildcard} characters,
- samp{?} for example, are replaced and expanded into all
- existing files matching the given pattern.
- command{tar} archives. This section has the
- purpose of explaining wildcard syntax for
- FIXME{the next few paragraphs need work.}
- A
- samp{a}
- will match only samp{A}. The character
- samp{*} in the pattern matches zero, one, or more single characters in
- the matched string. The character
- emph{literally}; it is useful when one needs to
- match the samp{*}, samp{\} characters, themselves.
- The character samp{]}, introduces a character
- class. A
- samp{[abcde]} would match any of the first five letters of the alphabet.
- Note that within a character class, all of the ``special characters''
- listed above other than
- samp{[-\\[*?]]} would match any of the characters, samp{\},
- samp{*}, samp{]}. (Due to parsing constraints,
- the characters samp{]} must either come
- emph{last} in a character class.)
- cindex Character class, excluding characters from
- If the first character of the class after the opening
- samp{!} or
- emph{forbidden} as the next single character of the matched string.
- Other characters of the class stand for themselves. The special
- construction var{a}-
- var{a} and
- FIXME{need to add a sentence or so here to make this clear for those
- who don't have dan around.}
- Periods (samp{/}) are not considered
- special for wildcard matches. However, if a pattern completely matches
- a directory prefix of a matched string, then it matches the full matched
- string: thus, excluding a directory also excludes all the files beneath it.
- end menu
- unnumberedsubsec Controlling Pattern-Matching
- For the purposes of this section, we call
- option{--exclude} and
- dfn{inclusion members} those
- member names that were given in the command line or read from the file
- specified with
- option{--diff}, option{--list},
- option{--create} and
- emph{files}, not archive members.
- By default, inclusion members are compared with archive members
- literally GNUTAR{} versions used
- globbing for inclusion members, which contradicted to UNIX98
- specification and was not documented.
- smallexample
- kbd{tar tf foo.tar}
- a.c
- b.c
- a.txt
- [remarks]
- #
- kbd{tar -xf foo.tar -v '[remarks]'}
- [remarks]
- #
- kbd{tar -xf foo.tar -v --exclude '*.c'}
- a.txt
- [remarks]
- end smallexample
- This behavior can be altered by using the following options:
- option
- item --wildcards
- Treat all member names as wildcards.
- item --no-wildcards
- Treat all member names as literal strings.
- samp{.c}, you can use:
- kbd{tar -xf foo.tar -v --wildcards '*.c'}
- a.c
- b.c
- noindent
- Notice quoting of the pattern to prevent the shell from interpreting
- it.
- The effect of
- option{--no-wildcards}. This can be used to pass part of
- the command line arguments verbatim and other part as globbing
- patterns. For example, the following invocation:
- kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
- noindent
- instructs file{foo.tar} all files whose
- names end in file{[remarks]}.
- Normally, a pattern matches a name if an initial subsequence of the
- name's components matches the pattern, where samp{?}, and
- samp{\} escapes wildcards,
- and wildcards can match
- samp{/} from names
- (
- samp{/} is not trimmed from a user-specified name
- before deciding whether to exclude it.
- However, this matching procedure can be altered by the options listed
- below. These options accumulate. For example:
- end smallexample
- samp{makefile}, but not when excluding
- table
- opindex anchored
- item --anchored
- option{--no-anchored} for exclusion members
- and
- opindex ignore-case
- item --ignore-case
- opindex wildcards-match-slash
- item --wildcards-match-slash
- samp{*} in the pattern can match a
- samp{/} is matched only by
- end table
- The option{--no-recursion} options
- (
- multitable
- headitem Members
- item Inclusion option{--no-wildcards --anchored --no-wildcards-match-slash}
- tab
- end multitable
- section Quoting Member Names
- When displaying member names,
- dfn{name
- quoting}. The characters in question are:
- bullet
- anchor{escape sequences}
- columnfractions 0.20 0.10 0.60
- tab tab Character name
- tab 7
- item \b tab Backspace
- tab 12
- item \n tab New line
- tab 13
- item \t tab Horizontal tabulation
- tab 11
- end multitable
- acronym{ASCII} 32)
- samp{'} and
- item Backslash (
- end itemize
- The exact way
- dfn{quoting style}. The default quoting style, called
- samp{Character} in the
- above table, a space is printed as samp{\\}.
- option{--quoting-style} option:
- option
- var{style}
- var{style} argument are:
- literal, shell, shell-always, c, escape, locale, clocale.
- file{arch.tar}
- containing the following members:
- group
- # 1. Contains horizontal tabulation character.
- a tab
- # 2. Contains newline character
- a
- newline
- # 3. Contains a space
- a space
- # 4. Contains double quotes
- a"double"quote
- # 5. Contains single quotes
- a'single'quote
- # 6. Contains a backslash character:
- a\backslash
- end smallexample
- Here is how usual
- smallexample
- kbd{ls}
- a\ttab
- a\nnewline
- a\ space
- a"double"quote
- a'single'quote
- a\\backslash
- end smallexample
- Quoting styles:
- samp
- smallexample
- kbd{tar tf arch.tar --quoting-style=literal}
- ./
- ./a space
- ./a'single'quote
- ./a"double"quote
- ./a\backslash
- ./a tab
- ./a
- newline
- end smallexample
- samp{\t} and
- samp{\t} and
- samp{\'}. If a name contains any quoted
- characters, it is enclosed in single quotes. In particular, if a name
- contains single quotes, it is printed as several single-quoted strings:
- group
- $
- end group
- item shell-always
- Same as
- smallexample
- kbd{tar tf arch.tar --quoting-style=shell-always}
- './'
- './a space'
- './a'\''single'\''quote'
- './a"double"quote'
- './a\backslash'
- './a tab'
- './a
- newline'
- end smallexample
- samp{\"},
- backslash characters are represented as @samp{\\}. Single quotes and
- spaces are not quoted:
- @smallexample
- @group
- $ @kbd{tar tf arch.tar --quoting-style=c}
- "./"
- "./a space"
- "./a'single'quote"
- "./a\"double\"quote"
- "./a\\backslash"
- "./a\ttab"
- "./a\nnewline"
- end smallexample
- samp{\ } and a backslash as
- smallexample
- kbd{tar tf arch.tar --quoting-style=escape}
- ./
- ./a space
- ./a'single'quote
- ./a"double"quote
- ./a\\backslash
- ./a\ttab
- ./a\nnewline
- end smallexample
- samp{'} as left and as right
- quotation marks. Any occurrences of the right quotation mark in a
- name are escaped with
- smallexample
- kbd{tar tf arch.tar --quoting-style=locale}
- './'
- './a space'
- './a\'single\'quote'
- './a"double"quote'
- './a\\backslash'
- './a\ttab'
- './a\nnewline'
- end smallexample
- samp{locale}, but
- smallexample
- kbd{tar tf arch.tar --quoting-style=clocale}
- "./"
- "./a space"
- "./a'single'quote"
- "./a\"double\"quote"
- "./a\\backslash"
- "./a\ttab"
- "./a\nnewline"
- end smallexample
- table
- item --quote-chars=
- var{string}, even if the selected
- quoting style would not quote them.
- samp{escape} quoting (compare with the usual
- escape listing above):
- group
- $
- end group
- table
- item --no-quote-chars=
- var{string} from the list of quoted
- characters set by the previous
- end table
- This option is particularly useful if you have added
- env{TAR_OPTIONS} (
- option{--no-quote-chars} does
- node transform
- command{Tar} archives contain detailed information about files stored
- in them and full file names are part of that information. When
- storing a file to an archive, its file name is recorded in it,
- along with the actual file contents. When restoring from an archive,
- a file is created on disk with exactly the same name as that stored
- in the archive. In the majority of cases this is the desired behavior
- of a file archiver. However, there are some cases when it is not.
- First of all, it is often unsafe to extract archive members with
- absolute file names or those that begin with a GNUTAR{}
- takes special precautions when extracting such names and provides a
- special option for handling them, which is described in
- GNUTAR{} provides several options for these needs.
- option
- item --strip-components=
- var{number} of leading components from file names before
- extraction.
- file{/usr} hierarchy to
- a tar archive named
- file{usr/include/stdlib.h}, which you wish to extract to
- the current working directory. To do so, you type:
- kbd{tar -xf usr.tar --strip=2 usr/include/stdlib.h}
- option{--strip=2} instructs
- file{usr/} and
- option{--verbose} (
- command{tar} provides a special option for
- altering this behavior:
- table
- opindex show-transformed-names
- end table
- smallexample
- kbd{tar -xf usr.tar -v --strip=2 usr/include/stdlib.h}
- usr/include/stdlib.h
- $
- end group
- file{stdlib.h} is extracted to the
- current working directory,
- smallexample
- $ var{n}}
- noindent
- it is often advisable to run
- kbd{tar -t -v --show-transformed --strip=
- end smallexample
- GNUTAR{} provides a general-purpose transformation option:
- option
- opindex xform
- var{expression}
- var{expression}
- Modify file names using supplied
- end table
- var{expression} is a
- smallexample
- s/var{replace}/[
- end smallexample
- var{regexp} is a var{replace} is a
- replacement for each file name part that matches
- var{regexp} and
- ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}.
- Any delimiter can be used in lieu of
- smallexample
- end group
- var{regex} contains
- slashes. For example, it is more convenient to write
- code{s/\//-/}.
- As in
- var{flags} are:
- samp
- emph{all} matches to the
- item i
- Use case-insensitive matching.
- var{regexp} is an pxref{Extended
- regexps, Extended regular expressions, Extended regular expressions,
- sed, GNU sed}).
- var{number}
- Only replace the var{regexp}.
- Note: the
- samp{g} and GNUTAR{}
- follows the GNU
- var{number}th, and then match and replace all matches from the
- end table
- In addition, several
- table
- item r
- Apply transformation to regular archive members.
- item s
- Apply transformation to symbolic link targets.
- item h
- Apply transformation to hard link targets.
- end table
- Default is
- samp{flags=} statement
- in the transform expression. The flags set this way remain in force
- until next
- smallexample
- --transform 'flags=S;s|^|/usr/local/|'
- option{--transform} usage:
- item Extract file{usr/local/}:
- kbd{tar --transform='s,usr/,usr/local/,' -x -f arch.tar}
- item Strip two leading directory components (equivalent to
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- file{/prefix/} to each file name:
- kbd{tar --transform 's,^,/prefix/,' -x -f arch.tar}
- item Archive the samp{/usr/local}
- to each archive member:
- kbd{tar --transform 's,^,/usr/local/,S' -c -f arch.tar /lib}
- end enumerate
- Notice the use of flags in the last example. The
- smallexample
- $
- end smallexample
- Using the expression
- samp{/usr/local} to both regular archive members and to link
- targets. In this case,
- smallexample
- /usr/local/lib/libc.so.6 -> /usr/local/libc-2.3.2.so
- samp{S} flag
- is used, which excludes symbolic link targets from filename
- transformations. The result is:
- kbd{tar --transform 's,^,/usr/local/,S', -c -v -f arch.tar \
- --show-transformed /lib}
- drwxr-xr-x root/root 0 2008-07-08 16:20 /usr/local/lib/
- -rwxr-xr-x root/root 1250840 2008-05-25 07:44 /usr/local/lib/libc-2.3.2.so
- lrwxrwxrwx root/root 0 2008-06-24 17:12 /usr/local/lib/libc.so.6 \
- -> libc-2.3.2.so
- option{--strip-components},
- GNUTAR{} operation mode. For example, the following command
- adds files to the archive while replacing the leading
- file{var/}:
- kbd{tar -cf arch.tar --transform='s,^usr/,var/,' /}
- option{--transform} effect we suggest using
- smallexample
- $
- end smallexample
- If both option{--transform} are used
- together, then
- option{--transform} options in a single command
- line as you want. The specified expressions will then be applied in
- order of their appearance. For example, the following two invocations
- are equivalent:
- kbd{tar -cf arch.tar --transform='s,/usr/var,/var/' \
- --transform='s,/usr/local,/usr/,'}
- $
- end smallexample
- section Operating Only on New Files
- cindex Data Modification time, excluding files by
- cindex Age, excluding files by
- The var{date}} (var{date}},
- var{date}}) option causes
- var{date} given. If samp{/} or
- option{--after-date} when extracting an archive,
- var{date} you specify.
- If you only want
- option{--newer-mtime=
- cindex --after-date and --update compared
- option{--update} (
- command{tar} can
- compare when deciding whether or not to archive the files.
- option
- opindex newer
- var{date}
- var{date}
- var{date}
- Only store files newer than
- var{date}. Use in conjunction with any operation.
- If samp{/} or
- opindex newer-mtime
- var{date}
- Acts like
- end table
- These options limit
- ref{Date input formats}; remember that the
- entire date argument must be quoted if it contains any spaces.)
- Gurus would say that
- code{mtime}, the time the contents of the file
- were last modified) and the status change time (
- :)
- fields, while code{mtime}
- field.
- To be precise, emph{both}
- code{ctime} and processes the file if either one is more recent than
- option{--newer-mtime} only checks
- code{ctime}. Neither does it use
- smallexample
- $
- end smallexample
- When any of these options is used with the option
- pxref{verbose tutorial})
- command{tar} will
- print a warning saying what date it will use. This is to help user
- ensure he is using the right date. For example:
- group
- $
- end group
- quotation
- option{--after-date} and
- xref{Incremental Dumps},
- for proper way of creating incremental backups.
- node recurse
- cindex Avoiding recursion in directories
- cindex Directories, avoiding recursion
- command{tar} will recursively explore all directories (either
- those given on the command line or through the
- command{tar} to act this way.
- cindex command{tar}
- The command{tar}'s recursive descent
- into specified directories. If you specify
- command{find} (
- command{tar}.
- ref{files}, for more information on using
- command{tar}.
- option
- command{tar} from recursively descending directories.
- item --recursion
- Requires
- end table
- When you use GNUTAR{} grabs
- directory entries themselves, but does not descend on them
- recursively. Many people use
- command{tar}
- samp{
- command{find} invocation (
- option{--files-from} option to archive
- the files located via
- option{--same-permissions} (
- option{-p}) option does not affect them---while users might really
- like it to. Specifying
- command{tar} to grab only the directory entries given to it, adding
- no new files on its own. To summarize, if you use
- smallexample
- kbd{find var{tests} | \
- tar -cf
- end group
- option{--no-recursion} option also applies when extracting: it
- causes
- option{--no-recursion} option also affects how globbing patterns
- are interpreted (
- option{--no-recursion} and
- option{--no-recursion} and
- smallexample
- $
- end smallexample
- file{grape}, and the recursive
- contents of file{grape}
- other than
- node one
- cindex File system boundaries, not crossing
- command{tar} and specifying
- command{tar} will still archive files explicitly named on the command line
- or through
- table
- opindex one-file-system
- command{tar} from crossing file system boundaries when
- archiving. Use in conjunction with any write operation.
- option{--one-file-system} option causes
- command{tar} will not archive that file. If the file is a directory
- itself,
- command{tar} will not cross mount points.
- This option is useful for making full or incremental archival backups of
- a file system. If this option is used in conjunction with
- option{-v}), files that are excluded are
- mentioned by name on the standard error.
- end menu
- subsection Changing the Working Directory
- cindex Changing directory mid-stream
- cindex Working directory, specifying
- To change the working directory in the middle of a list of file names,
- either on the command line or in a file specified using
- option{-T}), use option{-C}).
- This will change the working directory to the specified directory
- after that point in the list.
- option
- item --directory=
- itemx -C
- end table
- For example,
- kbd{tar -c -f jams.tar grape prune -C food cherry}
- noindent
- will place the files file{prune} from the current
- directory into the archive
- file{cherry} from the directory
- file{cherry} is recorded in the archive under the
- precise name emph{not}
- samp{tar
- --extract}, all three files will be written in the current directory.
- Contrast this with the command,
- kbd{tar -c -f jams.tar grape prune -C food red/cherry}
- noindent
- which records the third file in the archive under the name
- samp{tar --extract}, the third file will be written in a subdirectory
- named
- option{--directory} option to make the archive
- independent of the original name of the directory holding the files.
- The following command places the files
- file{/etc/hosts}, and
- file{foo.tar}:
- kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
- noindent
- However, the names of the archive members will be exactly what they were
- on the command line: file{hosts}, and
- option{--directory} options are interpreted consecutively. If
- command{tar}, due to a previous
- option{--files-from} (
- command{tar} options (including
- smallexample
- end group
- noindent
- To use it, you would invoke
- smallexample
- $
- end smallexample
- The interpretation of
- option{--null} option.
- subsection Absolute File Names
- cindex file names, absolute
- By default, samp{/} on
- input or output, and complains about file names containing a
- table
- opindex absolute-names
- itemx -P
- Do not strip leading slashes from file names, and permit file names
- containing a
- end table
- When
- samp{/}) from the member name. This causes absolute
- member names in the archive to be treated as relative file names. This
- allows you to have such members extracted wherever you want, instead of
- being restricted to extracting the member in the exact directory named
- in the archive. For example, if the archive member has the name
- command{tar} will extract it as if the name were
- really
- file{..} can cause problems when extracting, so
- command{tar} programs do not do this. As a result, if you
- create an archive whose member names start with a slash, they will be
- difficult for other people with a non-
- GNUTAR{} also strips
- leading slashes from member names when putting members into the
- archive. For example, if you ask
- file{/bin/ls} to an archive, it will do so, but the member name will
- be footnote{A side effect of this is that when
- option{--verbose} the resulting output
- is not, generally speaking, the same as the one you'd get running
- xref{listing member and file names},
- for the information on how to handle this case.}.
- Symbolic links containing samp{/} can also cause
- problems when extracting, so
- option{--absolute-names} (
- command{tar} will do none of these transformations.
- To archive or extract files relative to the root directory, specify
- the option{-P}) option.
- Normally,
- option{--absolute-names} (
- command{tar} stores file names including all superior directory
- names, and preserves leading slashes. If you only invoked
- option{--absolute-names} option, but using this option
- may be more convenient than switching to root.
- table
- item --absolute-names
- Preserves full file names (including superior directory names) when
- archiving and extracting files.
- command{tar} prints out a message about removing the
- GNUTAR{}
- invocation. It represents something which ought to be told; ignoring
- what it means can cause very serious surprises, later.
- Some people, nevertheless, do not want to see this message. Wanting to
- play really dangerously, one may of course redirect
- command{sh}:
- kbd{tar -c -f archive.tar /home 2> /dev/null}
- noindent
- Another solution, both nicer and simpler, would be to change to
- the
- smallexample
- $
- end smallexample
- include parse-datetime.texi
- chapter Controlling the Archive Format
- table
- item gnu
- Format used by
- acronym{POSIX} standard, adding some improvements such as
- sparse file handling and incremental archives. Unfortunately these
- features were implemented in a way incompatible with other archive
- formats.
- Archives in
- item oldgnu
- Format used by
- item v7
- Archive format, compatible with the V7 implementation of tar. This
- format imposes a number of limitations. The most important of them
- are:
- item The maximum length of a file name is limited to 99 characters.
- item It is impossible to store special files (block and character
- devices, fifos etc.)
- acronym{ID} is limited to 2097151 (7777777
- octal)
- end enumerate
- This format has traditionally been used by Automake when producing
- Makefiles. This practice will change in the future, in the meantime,
- however this means that projects containing file names more than 99
- characters long will not be able to use value{VERSION} and
- Automake prior to 1.9.
- acronym{POSIX.1-1988} specification. It stores
- symbolic ownership information. It is also able to store
- special files. However, it imposes several restrictions as well:
- item The maximum length of a file name is limited to 256 characters,
- provided that the file name can be split at a directory separator in
- two parts, first of them being at most 155 bytes long. So, in most
- cases the maximum file name length will be shorter than 256
- characters.
- item Maximum size of a file the archive is able to accommodate
- is 8GB
- item Maximum number of bits in device major and minor numbers is 21.
- item star
- Format used by Jcommand{star}
- implementation. samp{star} archives but
- currently does not produce them.
- acronym{POSIX.1-2001} specification. This is the
- most flexible and feature-rich format. It does not impose any
- restrictions on file sizes or file name lengths. This format is quite
- recent, so not all tar implementations are able to handle it properly.
- However, this format is designed in such a way that any tar
- implementation able to read
- samp{posix} archives as well, with the only exception that any
- additional information (such as long file names etc.) will in such
- case be extracted as plain text files along with the files it refers to.
- This archive format will be the default format for future versions
- of
- end table
- The following table summarizes the limitations of each of these
- formats:
- columnfractions .10 .20 .20 .20 .20
- tab UID tab File Name
- item gnu tab Unlimited tab 63
- tab 1.8e19 tab Unlimited
- item v7 tab 8GB tab n/a
- tab 2097151 tab 256
- item posix tab Unlimited tab Unlimited
- GNUTAR{} is defined at compilation
- time. You may check it by running
- GNUTAR{} is configured
- to create archives in
- samp{posix}.
- command{tar} Archives More Portable
- * cpio:: Comparison of command{cpio}
- node Compression
- menu
- * gzip:: Creating and Reading Compressed Archives
- * sparse:: Archiving Sparse Files
- node gzip
- cindex Compressed archives
- cindex gzip
- cindex lzip
- cindex lzop
- GNUTAR{} is able to create and read compressed archives. It supports
- a wide variety of compression programs, namely:
- command{bzip2}, command{lzma},
- command{xz} and traditional
- footnote{It also had patent problems in the past.}.
- Creating a compressed archive is simple: you just specify a
- option{-z} (
- command{gzip} compressed archive,
- option{--bzip2}) to create a
- option{--lzip} to create an
- option{-J} (asis{XZ} archive,
- asis{LZMA} compressed
- archive, asis{LSOP} archive, and
- option{--compress}) to use
- smallexample
- $
- end smallexample
- You can also let
- option{--auto-compress} (
- command{bzip2} for
- compression:
- kbd{tar caf archive.tar.bz2 .}
- noindent
- whereas the following one will use
- smallexample
- $
- end smallexample
- For a complete list of file name suffixes recognized by
- ref{auto-compress}.
- Reading compressed archive is even simpler: you don't need to specify
- any additional options as
- smallexample
- # List the compressed archive
- $
- kbd{tar xf archive.tar.gz}
- dfn{signatures}, a
- special byte sequences in the beginning of file, that are specific for
- certain compression formats. If this approach fails,
- pxref{auto-compress}, for a list of recognized suffixes).
- cindex alternative decompression programs
- Some compression programs are able to handle different compression
- formats.
- command{compress} is
- not installed, command{gzip}. As of
- version
- footnote{To verbosely trace the decompressor selection, use the
- pxref{warnings,decompress-program}).}:
- columnfractions 0.3 0.3 0.3
- tab Main decompressor
- item compress tab gzip
- tab lzma
- item bzip2 tab lbzip2
- GNUTAR{}
- will indicate which option you should use. For example:
- kbd{cat archive.tar.gz | tar tf -}
- tar: Archive is compressed. Use -z option
- tar: Error is not recoverable: exiting now
- GNUTAR{}:
- kbd{cat archive.tar.gz | tar tzf -}
- option{--update}, alias
- option{--delete}) members from them or
- add (option{-r}) members to them. Likewise, you
- cannot append another
- option{--concatenate} (
- table
- opindex gzip
- item -z
- itemx --ungzip
- Filter the archive through
- opindex xz
- itemx --xz
- Filter the archive through
- item -j
- code{bzip2}.
- item --lzip
- Filter the archive through
- opindex lzma
- command{lzma}.
- item --lzop
- Filter the archive through
- opindex compress
- item -Z
- itemx --uncompress
- Filter the archive through
- end table
- When any of these options is given,
- option{--with-command{configure}, e.g.
- command{bzip2} binary.
- command{tar --help} shows the actual
- compressor names along with each of these options.
- You can use any of these options on physical devices (tape drives,
- etc.) and remote files as well as on normal files; data to or from
- such devices or remote files is reblocked by another copy of the
- command{gzip} you can set
- smallexample
- $
- end smallexample
- Another way would be to use the
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- table
- anchor{auto-compress}
- item --auto-compress
- multitable
- headitem Suffix
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- item tab
- end multitable
- opindex use-compress-program
- var{command}
- var{command}
- Use external compression program
- GNUTAR{}
- does not support. The
- ref{external, Running External Commands}, for more detail).
- The
- option{-d} option, it should
- do exactly the opposite, i.e., read the compressed data from the
- standard input and produce uncompressed data on the standard output.
- The latter requirement means that you must not use the
- var{command} itself.
- cindex gpg, using with tar
- cindex Using encrypted archives
- The
- command{gpg} (
- smallexample
- end group
- file{gpgz} and save it somewhere in your
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- option{--gzip}, but I'd also like
- the output to be fed through a program like
- command{ecc} (actually, right now that's
- command{tar} through
- command{tar} use
- command{ecc} but if (as the comments say) it can't
- deal with loss of block sync, I'm tempted to throw some time at adding
- that capability. Supposing I were to actually do such a thing and
- get it (apparently) working, do you accept contributed changes to
- utilities like that? (Leigh Clayton
- option{--use-compress-prog=
- var{prog} script or program able to filter stdin to stdout to
- way you want. It should recognize the
- option{--gzip} or
- end ignore
- GNUTAR{}.
- node lbzip2
- GNUTAR{}.
- cindex Laszlo Ersek
-
- samp{bzip2} compression, written by Laszlo Ersek. It makes use of
- multiple processors to speed up its operation and in general works
- considerably faster than
- command{lbzip2} see /projects/
- uref{http://www.linuxinsight.com/
- command{lbzip2} are mostly command line compatible
- with
- option{--bzip2}
- GNUTAR{} must be configured with the
- smallexample
- $ var{other-options}]}
- command{tar --help} will show the
- following:
- group
- $
- end group
- noindent
- which means that running command{lbzip2}.
- subsection Archiving Sparse Files
- dfn{holes}. A
- command{tar}
- could create an archive longer than the original. To have
- option{--sparse}
- (
- command{tar}
- searches the file for consecutive stretches of zeros. It then records
- in the archive for the file where the consecutive stretches of zeros
- are, and only archives the ``real contents'' of the file. On
- extraction (using
- option{--sparse},
- table
- opindex sparse
- itemx --sparse
- This option instructs
- end table
- Consider using
- option{--sparse} while making file
- system backups as a matter of course, you can be assured the archive
- will never take more space on the media than the files take on disk
- (otherwise, archiving a disk filled with sparse files might take
- hundreds of tapes).
- option{--sparse} option presents a serious
- drawback. Namely, in order to determine if the file is sparse
- strong{twice}. So, always bear in mind that the
- time needed to process all files with this option is roughly twice
- the time needed to archive them without it.
- command{dump} do not have to read the entire file; by
- examining the file system directly, they can determine in advance
- exactly where the holes are and thus avoid reading through them. The
- only data it need read are the actual allocated data blocks.
- file{comp.unix.internals}, on
- 1990-12-10:
- code{st_blocks} at
- best tells you how many holes there are; it doesn't tell you
- code{st_blocks} is (care
- to name one that does?), they may also care where the holes are (I have
- no examples of this one either, but it's equally imaginable).
- I conclude from this that good archivers are not portable. One can
- arguably conclude that if you want a portable program, you can in good
- conscience restore files with as many holes as possible, since you can't
- get it right.
- cindex sparse formats, defined
- When using GNUTAR{} is able to store
- sparse files using in three distinct ways, called
- dfn{number},
- consisting, as usual of two decimal numbers, delimited by a dot. By
- default, format
- option{--sparse-version} option.
- option
- item --sparse-version=
- var{version} values
- are: samp{0.1} and xref{Sparse Formats},
- for a detailed description of each format.
- option{--sparse-format} option implies
- node Attributes
- cindex atrributes, files
- command{tar} reads files, it updates their access times. To
- avoid this, use the
- table
- opindex atime-preserve
- itemx --atime-preserve=replace
- option{--atime-preserve=replace} works on most systems, but it also
- restores the data modification time and updates the status change
- time. Hence it doesn't interact with incremental dumps nicely
- (
- command{tar} is
- running.
- command{tar} knows for sure it won't work, it
- complains right away.
- Currently
- option{--atime-preserve=replace}, but this is intended to change to
- opindex touch
- itemx --touch
- Do not extract data modification time.
- When this option is used,
- option{--list} (
- opindex same-owner
- command{tar}
- is executed on those systems able to give files away. This is
- considered as a security flaw by many people, at least because it
- makes quite difficult to correctly account users for the disk space
- they occupy. Also, the code{sgid} attributes of
- files are easily and silently lost when files are given away.
- When writing an archive, acronym{ID} and user name
- separately. If it can't find a user name (because the user
- file{/etc/passwd}), then it does not write one. When restoring,
- it tries to look the name (if one was written) up in
- acronym{ID} stored in
- the archive instead.
- item --no-same-owner
- opindex numeric-owner
- option{--numeric-owner} option allows (ANSI) archives to be written
- without user/group name information or such information to be ignored
- when extracting. It effectively disables the generation and/or use
- of user/group name information. This option forces extraction using
- the numeric ids from the archive, ignoring the names.
- This is useful in certain circumstances, when restoring a backup from
- an emergency floppy with different passwd/group files for example.
- It is otherwise impossible to extract files with the right ownerships
- if the password file in use during the extraction does not match the
- one belonging to the file system(s) being extracted. This occurs,
- for example, if you are restoring your files after a major crash and
- had booted from an emergency floppy with no password file or put your
- disk into another machine to do the restore.
- The numeric ids are command{tar} archives.
- The identifying names are added at create time when provided by the
- system, unless
- command{tar} file for distribution to other sites, it
- is sometimes cleaner to use a single owner for all files in the
- distribution, and nicer to specify the write permission bits of the
- files as stored in the archive independently of their actual value on
- the file system. The way to prepare a clean distribution is usually
- to have some Makefile rule creating a directory, copying all needed
- files in that directory, then setting ownership and permissions as
- wanted (there are a lot of possible schemes), and only then making a
- GNUTAR{} for fine tuning permissions and ownership.
- This is not the good way, I think.
- xopindex{same-permissions, short description}
- item -p
- itemx --preserve-permissions
- Extract all protection information.
- This option causes
- code{umask} setting limits the permissions
- on extracted files. This option is by default enabled when
- option{--list} (
- opindex preserve
- option{--same-permissions} and
- GNUTAR{} version 1.23.
- node Portability
- command{tar} Archives More Portable
- Creating a
- command{tar}
- is more challenging than you might think.
- command{tar}
- archives more portable.
- One golden rule is simplicity. For example, limit your
- FIXME{Discuss GNU extensions (incremental backups, multi-volume
- archives and archive labels) in GNU and PAX formats.}
- acronym{POSIX} archives
- * Checksumming:: Checksumming Problems
- * Large or Negative Values:: Large files, negative time stamps, etc.
- * Other Tars:: How to Extract GNU-Specific Data Using
- Other
- end menu
- subsection Portable Names
- Use portable file and member names. A name is portable if it contains
- only samp{/}, samp{_}, and
- samp{-} or
- samp{/-}. Avoid deep directory nesting. For portability to
- old Unix hosts, limit your file name components to 14 characters or
- less.
- If you intend to have your
- acronym{GNU}
- node dereference
- cindex File names, using symbolic links
- opindex dereference
- Normally, when
- command{tar} archive is a faithful record of the file system contents.
- When option{-h}) is used with
- option{-c}),
- option{--dereference}
- (
- option{--dereference} (
- command{tar} to follow an already-existing symbolic
- link when
- command{tar} does not follow such a link, though it may
- remove the link before writing a new file.
- option{--dereference} option is unsafe if an untrusted user can
- modify directories while xref{Security}.
- subsection Hard Links
- cindex hard links, dereferencing
- command{tar} archives a hard link, it writes a
- block to the archive naming the target of the link (a
- smallexample
- end group
- file{jeden} is a link to
- smallexample
- $ tar cvvf ../archive.tar .
- drwxr-xr-x gray/staff 0 2007-10-30 15:13 ./
- -rw-r--r-- gray/staff 4 2007-10-30 15:11 ./jeden
- hrw-r--r-- gray/staff 0 2007-10-30 15:11 ./one link to ./jeden
- command{tar} stored it only once, under the name
- file{one} as a hard link to this file.
- It may be important to know that all hard links to the given file are
- stored in the archive. For example, this may be necessary for exact
- reproduction of the file system. The following option does that:
- option
- item --check-links
- end table
- For example, trying to archive only file
- smallexample
- $ tar -c -f ../archive.tar -l jeden
- tar: Missing links to 'jeden'.
- file{one} from the
- archive created in previous examples produces, in the absense of file
- smallexample
- $ tar xf archive.tar ./one
- tar: ./one: Cannot hard link to './jeden': No such file or directory
- tar: Error exit delayed from previous errors
- command{tar} cannot seek back in
- the archive to the previous member (in this case,
- footnote{There are plans to fix this in future releases.}.
- If you wish to avoid such problems at the cost of a bigger archive,
- use the following option:
- option
- item --hard-dereference
- Dereference hard links and store the files they refer to.
- smallexample
- end group
- node old
- cindex Format, old style
- cindex Old style archives
- command{tar} cannot handle additional
- information recorded by newer
- option{--format=v7} option in
- conjunction with the option{-c}) (
- option{--portability} or
- command{tar} leaves out information about directories, pipes, fifos,
- contiguous files, and device files, and specifies file ownership by
- group and user IDs instead of group and user names.
- When updating an archive, do not use
- emph{new} format archive can be read by an
- command{tar} program without serious trouble, so this option should
- seldom be needed. On the other hand, most modern
- option{--format=v7} for your distributions. Notice,
- however, that
- samp{v7}'s drawbacks.
- subsection Ustar Archive Format
- acronym{POSIX}.1-1988 specification is called
- pxref{Formats,ustar}, for the detailed
- description of
- code{ustar} format is a good choice for archives intended to be read
- with other implementations of
- code{ustar} format, use
- option{--create} (
- node gnu
- acronym{GNU} and old
- cindex GNU archive format
- GNUTAR{} was based on an early draft of the
- code{ustar} standard.
- command{tar}, such as the support for file names longer than 100
- characters, use portions of the
- acronym{POSIX} draft as unused. Subsequent changes in
- GNUTAR{} format is
- incompatible with the current
- command{tar} programs that follow it.
- In the majority of cases,
- samp{POSIX} format the default.
- To force creation a
- option{--format=gnu}.
- subsection acronym{POSIX}
- cindex POSIX archive format
- GNUTAR{} features full support for
- acronym{POSIX} conformant archive will be created if
- option{--format=posix} (
- acronym{POSIX}
- archive.
- end menu
- subsubsection Controlling Extended Header Keywords
- option
- item --pax-option=
- acronym{PAX} extended headers. This option is
- equivalent to command{pax} utility.
- var{Keyword-list} is a comma-separated
- list of keyword options, each keyword option taking one of
- the following forms:
- code
- var{pattern}
- When used with one of archive-creation commands,
- this option instructs
- var{pattern}.
- When used in extract or list mode, this option instructs tar
- to ignore any keywords matching the given
- acronym{POSIX 1003.2}, 3.13
- (
- smallexample
- --pax-option delete=security.*
- item exthdr.name=
- var{string} after making the following substitutions:
- columnfractions .25 .55
- tab Replaced By
- tab The directory name of the file, equivalent to the
- result of the
- item %f
- command{basename} utility
- on the translated file name.
- tab The process command{tar} process.
- tab A
- end multitable
- Any other var{string} produce undefined
- results.
- If no option command{tar}
- will use the following default value:
- end smallexample
- var{value}
- This keyword defines the value of the
- samp{mtime} field is set to the modification time
- of the archive member described by that extended headers.
- var{string}
- This keyword allows user control over the name that is written into
- the ustar header blocks for global extended header records. The name
- is obtained from the contents of
- multitable
- headitem Meta-character
- item %n
- item %p acronym{ID} of the
- item %% samp{%} character.
- samp{%} characters in
- samp{globexthdr.name=string} is specified,
- smallexample
- $TMPDIR/GlobalHead.%p.%n
- noindent
- where var{TMPDIR}
- environment variable. If command{tar}
- uses
- item globexthdr.mtime=
- samp{mtime} field that
- is written into the ustar header blocks for the global extended headers.
- By default, the
- command{tar} was invoked.
- var{keyword}=
- command{tar} will behave as if it has encountered these keyword/value
- pairs at the beginning of the archive in a global extended header
- record.
- var{keyword}:=
- var{keyword}=
- command{tar} will
- behave as if these keyword/value pairs were included as records at the
- end of each extended header; thus, they will override any global or
- file-specific extended header record keywords of the same names.
- For example, in the command:
- end smallexample
- the group name will be forced to a new value for all files
- stored in the archive.
- var{value} may be
- a string enclosed in curly braces. In that case, the string
- between the braces is understood either as a textual time
- representation, as described in
- samp{/} or
- smallexample
- --pax-option='mtime:=}'
- cindex archives, binary equivalent
- smallexample
- --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0
- node Checksumming
- command{tar} fail to accept archives created using
- acronym{ASCII} file names, that
- is, file names having characters with the eight bit set, because they
- use signed checksums, while
- acronym{POSIX} standards. On
- reading,
- GNUTAR{} computes checksums both ways, and accept
- any on read, so
- GNUTAR{} produces the standard
- checksum, however, raising incompatibilities with Sun. That is to
- say,
- emph{produce} incorrect archives to be read by buggy
- command{tar} now read standard
- archives, so maybe Sun did a similar patch, after all?
- The story seems to be that when Sun first imported
- code{char}'s in their compiler. So they
- started computing checksums wrongly. When they later realized their
- mistake, they merely decided to stay compatible with it, and with
- themselves afterwards. Presumably, but I do not really know, HP-UX
- has chosen that their
- command{tar} format. In any
- case, it now falls on the shoulders of SunOS and HP-UX users to get
- a
- node Large or Negative Values
- cindex large values
- cindex negative time stamps
- samp{oldest possible} archive
- format if in doubt. However, sometimes it is not possible. If you
- attempt to archive a file whose metadata cannot be represented using
- required format,
- pxref{Formats}) will
- help you to do so.
- In particular, when trying to archive files larger than 8GB or with
- timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
- 12:56:31 acronym{GNU} and
- acronym{GNU} format uses
- two's-complement base-256 notation to store values that do not fit
- into standard
- GNUTAR{} implementation. Moreover, they sometimes
- cannot be correctly restored on another hosts even by
- code{time_t} generates archives
- that are not portable to hosts with differing
- acronym{POSIX} archives, generally speaking, can
- be extracted by any tar implementation that understands older
- FIXME{Describe how
- node Other Tars
- command{tar} Implementations
- In previous sections you became acquainted with various quirks
- necessary to make your archives portable. Sometimes you may need to
- extract archives containing GNU-specific members using some
- third-party
- GNUTAR{}. Of course your best bet is to have
- dfn{GNU-specific} members we mean two classes of
- them: members split between the volumes of a multi-volume archive and
- sparse members. You will be able to always recover such members if
- the archive is in PAX format. In addition split members can be
- recovered from archives in old GNU format. The following subsections
- describe the required procedures in detail.
- end menu
- subsubsection Extracting Members Split Between Volumes
- command{tar} implementation will fail to extract
- it. To extract it, use pxref{Tarcat}).
- This program is available from
- /software//utils/GNUTAR{}
- home page}. It concatenates several archive volumes into a single
- valid archive. For example, if you have three volumes named from
- file{vol-3.tar}, you can do the following to
- extract them using a third-party
- smallexample
- $
- end smallexample
- command{tar} implementations that are not aware of
- GNU extensions. More specifically, the very first part retains its
- original name, and all subsequent parts are named using the pattern:
- end smallexample
- samp{%} are
- multitable
- headitem Meta-character
- item %d
- command{dirname} utility on its full name.
- tab The file name of the file, equivalent to the result
- of the
- item %p acronym{ID} of the
- item %n
- end multitable
- For example, if the file
- command{tar} process
- had process samp{27962}, then the member names will be:
- end smallexample
- When you extract your archive using a third-party
- smallexample
- kbd{cd var}
- $
- end group
- command{tar} implementation you use supports PAX
- format archives, it will probably emit warnings about unknown keywords
- during extraction. They will look like this:
- group
- Tar file too small
- Unknown extended header keyword 'GNU.volume.filename' ignored.
- Unknown extended header keyword 'GNU.volume.size' ignored.
- Unknown extended header keyword 'GNU.volume.offset' ignored.
- end smallexample
- command{tar} implementation is not PAX-aware, you will get
- more warnings and more files generated on your disk, e.g.:
- group
- $
- kbd{tar xf vol-2.tar}
- tmp/GlobalHead.27962.1: Unknown file type 'g', extracted as normal file
- GNUFileParts.27962/PaxHeaders.27962/sparsefile.1: Unknown file type
- 'x', extracted as normal file
- end smallexample
- Ignore these warnings. The
- dfn{extended header keywords} describing the
- extracted files. You can delete them, unless they describe sparse
- members. Read further to learn more about them.
- subsubsection Extracting Sparse Members
- command{tar} implementation will be able to extract sparse members from a
- PAX archive. However, the extracted files will be
- dfn{holes}) back to their original locations, we call this process
- pindex xsparse
- To expand a file, you will need a simple auxiliary program called
- uref{http://www.gnu.org//tar//xsparse.html,
- cindex sparse files v.1.0, extracting with non-GNU tars
- Let's begin with archive members in
- footnote{
- file{var{name}}, then the condensed file will be
- named var{dir}/var{n}/var{name}}, where
- footnote{Technically speaking,
- dfn{process command{tar} process which created the
- archive (
- command{xsparse} as follows:
- kbd{xsparse
- end smallexample
- file{cond-file} is the name of the condensed file. The utility
- will deduce the name for the resulting expanded file using the
- following algorithm:
- item If
- file{../cond-file} will be used;
- file{cond-file} has the form
- var{dir}/var{name}}, where both var{name}
- are simple names, with no
- file{var{name}}.
- file{cond-file} has the form
- var{dir}/
- file{
- end enumerate
- In the unlikely case when this algorithm does not suit your needs,
- you can explicitly specify output file name as a second argument to
- the command:
- kbd{xsparse file{out-file}}
- command{xsparse} in
- option{-n} command line argument:
- group
- $
- end group
- smallexample
- $
- end smallexample
- option{-v} option:
- group
- $
- end group
- command{tar} implementation has extracted the
- command{xstar}
- to use them in order to verify the integrity of the expanded file.
- The option
- smallexample
- kbd{xsparse -v -x /home/gray/PaxHeaders.6058/sparsefile \
- /home/gray/GNUSparseFile.6058/sparsefile}
- Reading extended header file
- Found variable GNU.sparse.major = 1
- Found variable GNU.sparse.minor = 0
- Found variable GNU.sparse.name = sparsefile
- Found variable GNU.sparse.realsize = 217481216
- Reading v.1.0 sparse map
- Expanding file '/home/gray/GNUSparseFile.6058/sparsefile' to
- '/home/gray/sparsefile'
- Done
- end smallexample
- cindex sparse files v.0.1, extracting with non-GNU tars
- dfn{extended header} is a special
- dfn{variables}, describing the member properties that cannot be
- stored in the standard
- ref{Sparse
- Formats}.) So, for these formats, the question is: how to obtain
- extended headers from the archive?
- If you use a
- file{var{name}}, then the extended header file will be
- named var{dir}/var{n}/var{name}}, where
- command{tar} implementation
- does support PAX headers, because in this case you will have to
- manually extract the headers. We recommend the following algorithm:
- item
- Consult the documentation of your
- dfn{block numbers} along with the archive
- listing (analogous to option{-R} option). For example,
- option{-block-number}.
- samp{block number} option, and
- find block numbers of the sparse member in question and the member
- immediately following it. For example, running
- smallexample
- kbd{star -t -v -block-number -f arc.tar}
- dots{}
- end smallexample
- item
- Let var{Bs} be its block number
- and
- smallexample
- var{Bs} - var{size}/512 - 2
- noindent
- This number gives the size of the extended header part in tar
- code{897 - 56 - 425984 / 512 - 2
- = 7}.
- command{dd} to extract the headers:
- kbd{dd if=var{hname} bs=512 skip=var{N}}
- noindent
- where var{hname} is a name of the
- file to store the extended header in, var{N} are
- computed in previous steps.
- In our example, this command will be
- kbd{dd if=arc.tar of=xhdr bs=512 skip=56 count=7}
- end enumerate
- Finally, you can expand the condensed file, using the obtained header:
- group
- $
- dots{}
- Expanding file 'GNUSparseFile.28124/sparsefile' to 'sparsefile'
- Done
- end smallexample
- section Comparison of command{cpio}
- FIXME{Reorganize the following material}
- The command{tar}, do have maximum
- file name lengths. The binary and old
- acronym{ASCII} and
- acronym{GNU}
- command{cpio} implementations
- may crash unexplainedly trying to read them.
- acronym{BSD};
- command{cpio} to know about them.
- Others may have enhanced it in a way other than the way I did it
- at Sun, and which was adopted by AT&T (and which is, I think, also
- present in the
- acronym{BSD} release---I think I gave them my changes).
- (SVR4 does some funny stuff with command{cpio}
- can handle
- command{tar} as a result.)
- command{tar} doesn't.
- acronym{BSD} source;
- acronym{BSD}
- (4.3-tahoe and later).
- acronym{BSD} file system);
- acronym{ASCII}'' format,
- they're 18 bits---it would have to play games with the "file system @acronym{ID}"
- field of the header to make sure that the file system
- command{cpio}s, if any, play those games. Those that don't might get
- confused and think two files are the same file when they're not, and
- make hard links between them.
- emph{only} one you can use to retrieve the file;
- quotation
- What type of check sum (if any) is used, and how is this calculated.
- command{tar} and
- command{tar} uses a checksum which is the sum of all the bytes in the
- command{cpio} uses no checksum.
- command{cpio} was made when
- end quotation
- It wasn't.
- command{tar} at the time. I don't
- know whether any version that was generally available
- command{tar}, or, if so, whether the people within AT&T who did
- command{tar} will stop at
- that point, while
- command{tar} is a little more tape-oriented in that everything is blocked
- to start on a record boundary.
- end quotation
- Theoretically it should be easier under
- samp{dd skip=
- command{cpio}'s and variations have an option to just
- search for the next file header after an error with a reasonable chance
- of resyncing. However, lots of tape driver software won't allow you to
- continue past a media error which should be the only reason for getting
- out of sync unless a file changed sizes while you were writing the
- archive.
- command{cpio} was made when
- end quotation
- Probably because it is more media efficient (by not blocking everything
- and using only the space needed for the headers where
- command{afio},
- command{pax}, each of which have their own extensions with some
- backwards compatibility.
- Sparse files were
- acronym{GNU}
- node Media
- UNREVISED
- A few special cases about tape handling warrant more detailed
- description. These special cases are discussed below.
- Many complexities surround the use of
- command{tar}, it contains many features making
- such manipulation easier.
- Archives are usually written on dismountable media---tape cartridges,
- mag tapes, or floppy disks.
- The amount of data a tape or disk holds depends not only on its size,
- but also on how it is formatted. A 2400 foot long reel of mag tape
- holds 40 megabytes of data when formatted at 1600 bits per inch. The
- physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
- Magnetic media are re-usable---once the archive on a tape is no longer
- needed, the archive can be erased and the tape or disk used over.
- Media quality does deteriorate with use, however. Most tapes or disks
- should be discarded when they begin to produce data errors. EXABYTE
- tape cartridges should be discarded when they generate an
- menu
- * Device:: Device selection and switching
- * Remote Tape Server::
- * Common Problems and Solutions::
- * Blocking:: Blocking
- * Many:: Many archives on one tape
- * Using Multiple Tapes:: Using Multiple Tapes
- * label:: Including a Label in the Archive
- * verify::
- * Write Protection::
- node Device
- UNREVISED
- option
- var{hostname}:]
- itemx --file=[var{file}
- Use archive file or device var{hostname}.
- command{tar}
- works on.
- If the file name is command{tar} reads the archive from standard
- input (when listing or extracting), or writes it to standard output
- (when creating). If the
- command{tar} will read the original archive from its standard
- input, and will write the entire new archive to its standard output.
- If the file name contains a
- samp{hostname:file name}. If the dfn{at}
- sign (samp{userhostname:file name}. In
- either case, command{rsh} (or
- command{/usr/libexec/rmt} on the remote
- machine. If you give an alternate login name, it will be given to the
- command{/usr/libexec/rmt}. This program is free software from the
- University of California, and a copy of the source code can be found
- with the sources for
- file{var{prefix} stands for
- your installation prefix. This location may also be overridden at
- runtime by using the var{command}} option (
- xref{Remote
- Tape Server}, for the description of
- env{TAPE}
- is set, its value is used; otherwise, old versions of
- command{tar} was
- compiled). The default is normally set up to be the
- GNUTAR{} uses
- standard input and standard output as the default device, and I will
- not try anymore supporting automatic device detection at installation
- time. This was failing really in too many cases, it was hopeless.
- This is now completely left to the installer to override standard
- input and standard output for default device, if this seems
- preferable. Further, I think
- command{tar} are done with pipes or disks, not really tapes,
- cartridges or diskettes.
- Some users think that using standard input and output is running
- after trouble. This could lead to a nasty surprise on your screen if
- you forget to specify an output file name---especially if you are going
- through a network or terminal server capable of buffering large amounts
- of output. We had so many bug reports in that area of configuring
- default tapes automatically, and so many contradicting requests, that
- we finally consider the problem to be portably intractable. We could
- of course use something like
- emph{also} running after various kind of trouble, going from hung
- processes to accidental destruction of real tapes. After having seen
- all this mess, using standard input and output as a default really
- sounds like the only clean choice left, and a very useful one too.
- samp{DEFTAPE} in
- table
- xopindex{force-local, short description}
- opindex rsh-command
- var{command}
- Use remote command{rsh}. This option exists
- so that people who use something other than the standard
- command{rsh}) can access a remote device.
- When this command is not used, the shell command found when
- the
- file{/usr/ucb/rsh},
- file{/usr/bin/rsh}, file{/usr/bin/nsh}.
- The installer may have overridden this by defining the environment
- variable emph{at installation time}.
- xopindex{multi-volume, short description}
- itemx --multi-volume
- Create/list/extract multi-volume archive.
- This option causes dfn{multi-volume} archive---one
- that may be larger than will fit on the medium used to hold it.
- xopindex{tape-length, short description}
- var{num}
- var{size}[
- var{size} units of data. Unless
- var{size} is treated as kilobytes, i.e. var{size} x
- 1024} bytes. The following suffixes alter this behavior:
- caption{Size Suffixes}
- columnfractions 0.2 0.3 0.3
- tab Units
- item b tab
- item B tab
- item c tab
- item G tab
- item K tab
- item k tab
- item M tab
- item P tab
- item T tab
- item w tab
- end multitable
- xopindex{info-script, short description}
- item -F
- itemx --info-script=
- itemx --new-volume-script=
- var{command} at end of each tape. This implies
- option{-M}).
- end table
- section Remote Tape Server
- pindex rmt
- In order to access the tape drive on a remote machine,
- file{
- command{tar} calls
- command{rsh} or
- cindex absolute file names
- Unless you use the option{-P}) option,
- samp{/}.) If you try,
- samp{/} from the
- file names it stores in the archive. It will also type a warning
- message telling you what it is doing.
- When reading an archive that was created with a different
- GNUTAR{} automatically
- extracts entries in the archive which have absolute file names as if
- the file names were not absolute. This is an important feature. A
- visitor here once gave a
- command{tar} instead of
- file{/bin} and friends with versions from the tape; needless to
- say, we were unhappy about having to recover the file system from
- backup tapes.
- For example, if the archive contained a file
- GNUTAR{} would extract the file to
- samp{cd /} before extracting the files
- from the archive, or you should either use the
- samp{tar -C /
- cindex Ultrix 3.1 and write failure
- Some versions of Unix (Ultrix 3.1 is known to have this problem),
- can claim that a short write near the end of a tape succeeded,
- when it actually failed. This will result in the -M option not
- working correctly. The best workaround at the moment is to use a
- significantly larger blocking factor than the default 20.
- In order to update an archive,
- samp{lseek}),
- and industry-standard 9-track magnetic tape (or any other kind of tape
- that can be backspaced with the code{ioctl}).
- This means that the option{--concatenate}, and
- command{tar} will work on them
- once
- option{--multi-volume},
- option{--incremental} (
- command{tar}. In particular, restoring a file that was split over
- a volume boundary will require some careful work with
- command{tar} may also create
- an empty file whose name is that of the volume header. Some versions
- of
- option{--incremental} (
- node Common Problems and Solutions
- ifclear PUBLISH
- command{tar}:
- directory checksum error
- header format error
- errors from media/system:
- i/o error
- device busy
- end ifclear
- section Blocking
- cindex record
- dfn{record} terminology is rather confused, and it
- is also confusing to the expert reader. On the other hand, readers
- who are new to the field have a fresh mind, and they may safely skip
- the next two paragraphs, as the remainder of this manual uses those
- two terms in a quite consistent way.
- John Gilmore, the writer of the public domain
- GNUTAR{} was originally derived, wrote (June 1995):
- code{F} (fixed sized records),
- code{FB} (fixed blocked: fixed size records,
- code{VB} (variable size records,
- code{VSB} (variable spanned blocked: variable sized records that can
- occupy more than one block), etc. The samp{DD RECFORM=}
- parameter specified this to the operating system.
- The Unix man page on
- code{PD TAR}, I used the historically correct terminology
- (
- acronym{POSIX} (no surprise
- here), and now Fran
- end quotation
- The term
- dfn{block} usually refers to
- a disk physical block,
- command{tar} ignore these differences in its own
- format, which is meant to be portable, so a
- dfn{block} always mean a
- dfn{logical block} often represents the basic chunk of
- allocation of many disk blocks as a single entity, which the operating
- system treats somewhat atomically; this concept is only barely used
- in
- dfn{physical record} is another way to speak of a physical
- block, those two terms are somewhat interchangeable. In this manual,
- the term
- emph{assuming} that the
- command{tar} tries to read and write the archive one
- dfn{reblocking}, or
- more simply, dfn{logical record} refers to
- the logical organization of many characters into something meaningful
- to the application. The term
- dfn{record} in
- command{tar} writes the contents of the archive
- in chunks known as
- option{--blocking-factor=option{-b
- var{512-size} blocks. (Each
- xref{Standard}.) Each file written to the archive uses at least one
- full record. As a result, using a larger record size can result in
- more wasted space for small files. On the other hand, a larger record
- size can often be read and written much more efficiently.
- Further complicating the problem is that some tape drives ignore the
- blocking entirely. For these, a larger record size can still improve
- performance (because the software layers above the tape drive still
- honor the blocking), but not as dramatically as on tape drives that
- honor blocking.
- When reading an archive,
- command{tar} will
- print a message about a non-standard blocking factor, and then operate
- normally
- option{--warning=no-record-size} option.}. On some tape
- devices, however,
- option{--blocking-factor}) larger than the actual blocking factor,
- and then use the option{-B}) option.
- (If you specify a blocking factor with
- option{--read-full-records} option, then
- option{--blocking-factor} when reading, because
- option{--list} (
- command{tar} is reading the archive
- correctly.
- command{tar} records are all the same size;
- at the end of the file there's a block containing all zeros, which
- is how you tell that the remainder of the last record(s) are garbage.
- In a standard
- option{--blocking-factor} option does is sets the blocking factor,
- changing the record size while leaving the block size at 512 bytes.
- 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
- most tape drives these days prefer much bigger records in order to
- stream and not waste tape. When writing tapes for myself, some tend
- to use a factor of the order of 2048, say, giving a record size of
- around one megabyte.
- If you use a blocking factor larger than 20, older
- GNUTAR{}, however,
- will support arbitrarily large record sizes, limited only by the
- amount of virtual memory or the physical characteristics of the tape
- device.
- end menu
- subsection Format Variations
- cindex Format Options
- cindex Options, format specifying
- command{tar} uses
- default parameters. You cannot modify a compressed archive.
- If you create an archive with the
- pxref{Blocking Factor}), you must specify that
- blocking-factor when operating on the archive.
- node Blocking Factor
- cindex Blocking Factor
- cindex Number of blocks per record
- cindex Bytes per record
- UNREVISED
- dfn{records}. The number of blocks in a record (i.e., the size of a
- record in units of 512 bytes) is called the
- option{--blocking-factor=option{-b
- samp{tar --list --file=
- command{tar} fills out the archive to the end of the record.
- In general, the ideal record size depends on the size of the
- inter-record gaps on the tape you are using, and the average size of the
- files you are archiving.
- FIXME{Need example of using a cartridge with blocking factor=126 or more.}
- Archives with blocking factors larger than 20 cannot be read
- by very old versions of
- command{tar} running on old machines with small address spaces.
- With
- smallexample
- Cannot write to /dev/dlt: Invalid argument
- noindent
- In such cases, it sometimes happen that the
- GNUTAR{}
- requires an explicit specification for the block size,
- which it cannot guess. This yields some people to consider
- cite{the bundle w{
- option{--list} (command{tar}
- reports a non-default record size and then lists the archive members as
- it would normally. To extract files from an archive with a non-standard
- blocking factor (particularly if you're not sure what the blocking factor
- is), you can usually use the option{-B}) option while
- specifying a blocking factor larger then the blocking factor of the archive
- (i.e.,
- xref{list}, for more information on the option{-t})
- operation.
- table
- item --blocking-factor=
- itemx -b
- option{--list} (
- end table
- Device blocking
- option
- var{blocks}
- var{blocks}
- Set record size to var{blocks}*512} bytes.
- This option is used to specify a
- command{tar}, will do reads and writes
- of the archive in records of var{block}*512} bytes. This is true
- even when the archive is compressed. Some devices requires that all
- write operations be a multiple of a certain size, and so,
- command{tar} is compiled, and is
- typically 20. Blocking factors larger than 20 cannot be read by very
- old versions of command{tar}
- running on old machines with small address spaces.
- With a magnetic tape, larger records give faster throughput and fit
- more data on a tape (because there are fewer inter-record gaps).
- If the archive is in a disk file or a pipe, you may want to specify
- a smaller blocking factor, since a large one will result in a large
- number of null bytes at the end of the archive.
- When writing cartridge or other streaming tapes, a much larger
- blocking factor (say 126 or more) will greatly increase performance.
- However, you must specify the same blocking factor when reading or
- updating the archive.
- Apparently, Exabyte drives have a physical block size of 8K bytes.
- If we choose our blocksize as a multiple of 8k bytes, then the problem
- seems to disappear. Id est, we are using block size of 112 right
- now, and we haven't had the problem since we switched
- GNUTAR{} the blocking factor is limited only
- by the maximum record size of the device containing the archive, or by
- the amount of available virtual memory.
- However, deblocking or reblocking is virtually avoided in a special
- case which often occurs in practice, but which requires all the
- following conditions to be simultaneously true:
- bullet
- item
- the archive is not handled through standard input or output, nor
- redirected nor piped,
- item
- command{tar}
- invocation.
- itemize
- item
- samp{
- item
- samp{compress -d} silently adds garbage after
- the result of decompression, which tar ignores because it already
- recognized its end-of-file indicator. So this bug may be safely
- ignored.
- samp{gzip -d -q} will be silent about the trailing zeros indeed,
- but will still return an exit status of 2 which tar reports in turn.
- command{tar} offers users against
- other possible problems at decompression time. If
- emph{and} also avoiding setting the
- exit status in this innocuous case, that would solve this situation.
- command{tar} should become more solid at not stopping to read a pipe at
- the first null block encountered. This inelegantly breaks the pipe.
- end itemize
- item -i
- option{--ignore-zeros} (command{tar} to ignore blocks
- of zeros in the archive. Normally a block of zeros indicates the
- end of the archive, but when reading a damaged archive, or one which
- was created by concatenating several archives together, this option
- allows
- command{tar} write garbage after
- the zeroed blocks.
- Note that this option causes
- xopindex{read-full-records, short description}
- itemx --read-full-records
- Reblock as we read (for reading 4.2
- option{--read-full-records} is used,
- command{tar} will keep reading
- until it has obtained a full
- record.
- This option is turned on by default when
- acronym{BSD} Unix systems, a read of a pipe will return however
- much happens to be in the pipe, even if it is less than
- command{tar} would fail as
- soon as it read an incomplete record from the pipe.
- This option is also useful with the commands for updating an archive.
- FIXME{Appropriate options should be moved here from elsewhere.}
- cindex tape blocking
- When handling various tapes or cartridges, you have to take care of
- selecting a proper blocking, that is, the number of disk blocks you
- put together as a single tape block on the tape, without intervening
- tape gaps. A
- cindex Exabyte blocking
- command{tar} uses by default a blocking of
- 20 for historical reasons, and it does not really matter when reading or
- writing to disk. Current tape technology would easily accommodate higher
- blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
- We were told that for some DLT drives, the blocking should be a multiple
- of 4Kb, preferably 64Kb (kbd{-b 128}}) or 256 for decent performance.
- Other manufacturers may use different recommendations for the same tapes.
- This might also depends of the buffering techniques used inside modern
- tape controllers. Some imposes a minimum blocking, or a maximum blocking.
- Others request blocking to be some exponent of two.
- So, there is no fixed rule for blocking. But blocking at read time
- should ideally be the same as blocking used at write time. At one place
- I know, with a wide variety of equipment, they found it best to use a
- blocking of 32 to guarantee that their tapes are fully interchangeable.
- I was also told that, for recycled tapes, prior erasure (by the same
- drive unit that will be used to create the archives) sometimes lowers
- the error rates observed at rewriting time.
- I might also use
- option{--block-number}, so
- option{--blocking-factor} unambiguously.
- section Many Archives on One Tape
- findex ntape
- file{/dev} directory, or
- entries that come in pairs, which differ only in the minor number for
- this device. Let's take for example
- file{/dev/nrtape} or
- emph{rewinding} version of the device, while the name
- having emph{no rewinding} version of the same
- device.
- A rewinding tape device will bring back the tape to its beginning point
- automatically when this device is opened or closed. Since
- smallexample
- $ var{directory}}
- noindent
- will reposition the tape to its beginning both prior and after saving
- cindex tape positioning
- So, a rewinding device is normally meant to hold one and only one file.
- If you want to put more than one
- emph{cannot} be
- recovered.
- To save
- smallexample
- $
- kbd{tar cf /dev/nrtape
- end smallexample
- dfn{Tape marks} are special magnetic patterns written on the tape
- media, which are later recognizable by the reading hardware. These
- marks are used after each file, when there are many on a single tape.
- An empty file (that is to say, two tape marks in a row) signal the
- logical end of the tape, after which no file exist. Usually,
- non-rewinding tape device drivers will react to the close request issued
- by
- var{directory-2} as a second archive after the
- first on the same tape by issuing the command:
- kbd{tar cf /dev/nrtape
- end smallexample
- var{directory-17}, say, by using
- these commands:
- kbd{mt -f /dev/nrtape rewind}
- $
- kbd{tar cf /dev/nrtape
- end smallexample
- In all the previous examples, we put aside blocking considerations, but
- you should do the proper things for that as well.
- menu
- * Tape Positioning:: Tape Positions and Tape Marks
- * mt:: The
- end menu
- subsection Tape Positions and Tape Marks
- dfn{tape marks} on the
- archive media. Tape drives write one tape mark between files,
- two at the end of all the file entries.
- If you think of data as a series of records "rrrr"'s, and tape marks as
- "*"'s, a tape might look like the following:
- end smallexample
- Tape devices read and write tapes using a read/write
- command{tar} to read or
- write archive data from a tape device, the device will begin reading
- or writing from wherever on the tape the tape head happens to be,
- regardless of which archive or what part of the archive the tape
- head is on. Before writing an archive, you should make sure that no
- data on the tape will be overwritten (unless it is no longer needed).
- Before reading an archive, you should make sure the tape head is at
- the beginning of the archive you want to read. You can do it manually
- via pxref{mt}). The
- pxref{Scripted Restoration}).
- If you want to add new archive file entries to a tape, you should
- advance the tape to the end of the existing file entries, backspace
- over the last tape mark, and write the new archive file. If you were
- to add two archives to the example above, the tape might look like the
- following:
- end smallexample
- subsection The
- UNREVISED
- xref{Blocking Factor}.
- You can use the
- FIXME{Why isn't there an "advance 'til you find two tape marks
- together"?}
- The syntax of the
- smallexample
- var{tapename}] var{number}]}
- var{tapename} is the name of the tape device,
- var{operation} is one of the following:
- table
- item eof
- var{number} tape marks at the current position on the tape.
- var{number} files.
- var{number} files.
- var{number}.)
- itemx rewoff1
- Rewinds the tape and takes the tape device off-line. (Ignores
- item status
- Prints status information about the tape unit.
- var{tapename},
- env{TAPE}; if command{mt} will use
- the default device specified in your
- code{DEFTAPE} variable). If this is not defined, the program will
- display a descriptive error message and exit with code 1.
- node Using Multiple Tapes
- command{tar} commands, but this can be inconvenient, particularly if you
- are using options like var{pattern}} or dumping entire file systems.
- Therefore,
- dfn{Multi-volume} archive is a single
- samp{volume} a
- GNUTAR{} continues to fill
- current volume until it runs out of space, then it switches to
- next volume (usually the operator is queried to replace the tape on
- this point), and continues working on the new volume. This operation
- continues until all requested files are dumped. If
- GNUTAR{} archive, so it can be read
- without any special options. Consequently any file member residing
- entirely on one volume can be extracted or otherwise operated upon
- without needing the other volume. Sure enough, to extract a split
- member you would need all volumes its parts reside on.
- Multi-volume archives suffer from several limitations. In particular,
- they cannot be compressed.
- pxref{Formats}): samp{POSIX}.
- end menu
- subsection Archives Longer than One Tape or Disk
- opindex multi-volume
- To create an archive that is larger than will fit on a single unit of
- the media, use the option{-M}) option in conjunction with
- the pxref{create}). A
- option{--multi-volume} option is specified), but is stored on more
- than one tape or file.
- When you specify command{tar} does not report an
- error when it comes to the end of an archive volume (when reading), or
- the end of the media (when writing). Instead, it prompts you to load
- a new storage volume. If the archive is on a magnetic tape, you
- should change tapes when you see the prompt; if the archive is on a
- floppy disk, you should change disks; etc.
- option
- itemx -M
- Creates a multi-volume archive, when used in conjunction with
- option{-c}). To perform any other operation on a multi-volume
- archive, specify
- smallexample
- $ var{files}}
- end table
- The method
- command{tar}
- cannot detect the end of the tape itself, you can use
- anchor{tape-length}
- option
- item --tape-length=var{suf}]
- var{size}[
- var{suf}, if given, specifies
- units in which samp{2M} mean 2
- megabytes (
- var{suf}, units of 1024 bytes (kilobyte) are
- assumed.
- This option selects
- smallexample
- $ var{files}}
- noindent
- or, which is equivalent:
- kbd{tar --create --tape-length=4G --file=/dev/tape
- end smallexample
- anchor{change volume prompt}
- When
- footnote{If you run
- smallexample
- Prepare volume #var{archive}' and hit return:
- noindent
- where
- var{archive} is archive file or device name.
- When prompting for a new tape,
- table
- item ?
- Request
- item q
- Request
- item n
- command{tar} to write the next volume on the file
- item !
- Request
- option{--restrict} command line option to
- footnote{
- item y
- Request
- end table
- (You should only type
- command{tar} will write over the volume it just finished.)
- cindex volno file
- opindex volno-file
- The volume number used by
- option{--volno-file=
- var{file-of-number} should be an non-existing file to be created, or
- else, a file already containing a decimal number. That number will be
- used as the volume number of the first volume written. When
- ref{label}, it
- cindex End-of-archive info script
- anchor{info-script}
- opindex new-volume-script
- If you want more elaborate behavior than this, you can write a special
- command{tar} to use it instead of its normal
- prompting procedure:
- option
- var{command}
- var{command}
- var{command}
- Specify the command to invoke when switching volumes. The
- samp{Someone please come change my tape} when performing unattended
- backups.
- var{command} can contain additional options, if such are needed.
- GNUTAR{} runs external commands. It inherits
- table
- vrindex TAR_VERSION, info script environment variable
- GNUTAR{} version number.
- item TAR_ARCHIVE
- The name of the archive
- vrindex TAR_BLOCKING_FACTOR, info script environment variable
- pxref{Blocking}).
- item TAR_VOLUME
- Ordinal number of the volume
- vrindex TAR_SUBCOMMAND, info script environment variable
- command{tar} is executing.
- vrindex TAR_FORMAT, info script environment variable
- xref{Formats}, for a complete
- list of archive format names.
- item TAR_FD
- File descriptor which can be used to communicate the new volume
- name to
- end table
- These variables can be used in the
- command{tar}.
- The volume script can instruct
- env{$TAR_FD} (see below for an example).
- If the info script fails,
- command{tar} to cycle through a series of files or tape
- drives, there are three approaches to choose from. First of all, you
- can give option{--file} options. In this case
- the specified files will be used, in sequence, as the successive
- volumes of the archive. Only when the first one in the sequence needs
- to be used again will
- file{/dev/tape0} and
- GNUTAR{} to switch to the second drive when it needs to write the
- second tape, and then back to the first tape, etc., just do either of:
- kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1
- kbd{tar -cM -f /dev/tape0 -f /dev/tape1
- end smallexample
- The second method is to use the
- env{$TAR_FD}. For example, the
- following volume script will create a series of archive files, named
- var{archive}-var{archive} is the name of the
- archive being created (as given by
- var{vol} is the ordinal number of the archive being created:
- group
- #! /bin/bash
- # For this script it's advisable to use a shell, such as Bash,
- # that supports a TAR_FD value greater than 9.
- echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
- name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
- case $TAR_SUBCOMMAND in
- -c) ;;
- -d|-x|-t) test -r $}-$TAR_VOLUME || exit 1
- ;;
- *) exit 1
- esac
- echo $}-$TAR_VOLUME >&$TAR_FD
- end smallexample
- The same script can be used while listing, comparing or extracting
- from the created archive. For example:
- group
- #
- kbd{tar -c -L1024 -f archive.tar -F new-volume .}
- #
- kbd{tar -x -f archive.tar -F new-volume .}
- end smallexample
- option{-L} option, since
- otherwise
- file{archive.tar}.
- You can read each individual volume of a multi-volume archive as if it
- were an archive by itself. For example, to list the contents of one
- volume, use option{--multi-volume} specified.
- To extract an archive member from one volume (assuming it is described
- that volume), use
- option{--multi-volume}.
- If an archive member is split across volumes (i.e., its entry begins on
- one volume of the media and ends on another), you need to specify
- samp{tar --extract --multi-volume}---
- xref{extracting archives}, for more
- information about extracting archives.
- Multi-volume archives can be modified like any other archive. To add
- files to a multi-volume archive, you need to only mount the last
- volume of the archive media (and new volumes, if needed). For all
- other operations, you need to use the entire archive.
- If a multi-volume archive was labeled using
- var{archive-label}} (
- command{tar} will not automatically label volumes which are
- added later. To label subsequent volumes, specify
- var{archive-label}} again in conjunction with the
- option{--update} or
- GNUTAR{}. If you
- absolutely have to process such archives using a third-party
- ref{Split Recovery}.
- subsection Tape Files
- opindex label
- option{--label=option{-V
- var{volume-label} as the name of the archive to the front of the
- archive which will be displayed when the archive is listed with
- option{--multi-volume} (
- samp{Volume
- var{nnn} is the number of the volume of the archive.
- If you use the var{volume-label}} option when
- reading an archive, it checks to make sure the label on the tape
- matches the one you gave.
- command{tar} writes an archive to tape, it creates a single
- tape file. If multiple archives are written to the same tape, one
- after the other, they each get written as separate tape files. When
- extracting, it is necessary to position the tape at the right place
- before running command{mt} command.
- For more information on the
- ref{mt}.
- People seem to often do:
- kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
- node Tarcat
- pindex tarcat
- Sometimes it is necessary to convert existing
- command{tar} archive. Simply concatenating all
- volumes into one will not work, since each volume carries an additional
- information at the beginning.
- command{tarcat} designed for this purpose.
- The script takes a list of files comprising a multi-volume archive
- and creates the resulting archive at the standard output. For example:
- kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
- command{tar} archives.
- It uses
- FIXME{The script is not installed. Should we install it?}
- section Including a Label in the Archive
- cindex Labels on the archive media
- opindex label
- To avoid problems caused by misplaced paper labels on the archive
- media, you can include a
- option{--label=option{-V
- footnote{Until version 1.10, that option was called
- option{--create} operation to include a label
- entry in the archive as it is being created.
- option
- var{archive-label}
- var{archive-label}
- Includes an
- option{--create} operation. Checks to make sure the archive label
- matches the one specified (when used in conjunction with any other
- operation).
- option{--label=option{-V
- option{--multi-volume} (
- samp{
- var{n}}, where
- xref{Using Multiple Tapes}, for information on
- creating multiple volume archives.
- cindex Listing volume label
- The volume label will be displayed by
- smallexample
- kbd{tar --verbose --list --file=iamanarchive}
- V--------- 0/0 0 1992-03-07 12:01 iamalabel--Volume Header--
- -rw-r--r-- ringo/user 40 1990-05-21 13:30 iamafilename
- end smallexample
- anchor{--test-label option}
- However,
- option{--test-label} option. This option reads only the
- first block of an archive, so it can be used with slow storage
- devices. For example:
- group
- $
- end group
- option{--test-label} is used with one or more command line
- arguments,
- footnote{Note that
- option{--verbose} option. For example:
- group
- $
- result{} 0
- $
- result{} 1
- end smallexample
- When used with the command{tar}
- prints the actual volume label (if any), and a verbose diagnostics in
- case of a mismatch:
- group
- $
- result{} 0
- $
- result{} 1
- end smallexample
- If you request any operation, other than
- option{--label} option,
- file{archive}, presumably labeled with string
- smallexample
- kbd{tar -rf archive --label 'My volume' .}
- tar: Archive not labeled to match 'My volume'
- end smallexample
- file{archive} is not labeled at all.
- Similarly,
- var{archive-label}
- specified. In those cases,
- xref{exclude}, for a precise description of how match
- is attemptedcommand{tar} used full
- regular expression matching, or before that, only exact string
- matching, instead of wildcard matchers. We decided for the sake of
- simplicity to use a uniform matching device through
- option{--multi-volume} (
- var{archive-label} by
- samp{ Volume [1-9]*}} if the initial match fails, before giving
- up. Since the volume numbering is automatically added in labels at
- creation time, it sounded logical to equally help the user taking care
- of it when the archive is being read.
- You can also use
- smallexample
- kbd{tar -cM -f /dev/tape -V "Daily backup for `date +%Y-%m-%d`"}
- $
- end group
- itemize
- item Each label has its own date and time, which corresponds
- to the time when
- command{tar} or types the
- carriage return telling that the next tape is ready.
- end itemize
- section Verifying Data as It is Stored
- cindex Double-checking a write operation
- option
- itemx --verify
- end table
- This option causes
- command{tar} can compare an archive to the
- file system as the archive is being written, to verify a write
- operation, or can compare a previously written archive, to insure that
- it is up to date.
- option{--create}}
- option{--verify}}
- To check for discrepancies in an archive immediately after it is
- written, use the option{-W}) option in conjunction with
- the
- command{tar} checks archive members against their counterparts
- in the file system, and reports discrepancies on the standard error.
- To verify an archive, you must be able to read it from before the end
- of the last written entry. This option is useful for detecting data
- errors on some tapes. Archives written to pipes, some cartridge tape
- drives, and some other devices cannot be verified.
- One can explicitly compare an already made archive with the file
- system by using the option{--diff},
- option{--verify} option.
- option{--compare} option checks how identical are the logical contents of some
- archive with what is on your disks, while the
- option{--verify}
- operation,
- option{--compare} option. If you nevertheless use
- option{--verify} option would not be necessary if drivers were indeed
- able to detect dependably all write failures. This sometimes require many
- magnetic heads, some able to read after the writes occurred. One would
- not say that drivers unable to detect all cases are necessarily flawed,
- as long as programming is concerned.
- The option{-W}) option will not work in
- conjunction with the option{-M}) option or
- the option{-r}), option{-u})
- and xref{Operations}, for more
- information on these operations.
- Also, since samp{/} from file
- names (samp{tar --verify -cf
- /tmp/foo.tar /etc} will work as desired only if the working directory is
- command{tar} uses the archive's relative member names
- (e.g.,
- node Write Protection
- dfn{write protected}, to protect data on them from being changed.
- Once an archive is written, you should write protect the media to prevent
- the archive from being accidentally overwritten or deleted. (This will
- protect the archive from being changed with a tape or floppy drive---it
- will not protect it from magnet fields or other physical hazards.)
- The write protection device itself is usually an integral part of the
- physical media, and can be a two position (write enabled/write
- disabled) switch, a notch which can be popped out or covered, a ring
- which can be removed from the center of a tape reel, or some other
- changeable feature.
- chapter Reliability and Security
- The
- menu
- * Reliability::
- * Security::
- node Reliability
- command{tar} is creating an archive, it reads from a
- file system that is not being modified, and encounters no errors or
- inconsistencies while reading and writing. If this is the case, the
- archive should faithfully reflect what was read. Similarly, when
- extracting from an archive, ideally
- menu
- * Permissions problems::
- * Data corruption and repair::
- * Race conditions::
- node Permissions problems
- command{tar} encounters errors while reading or writing files, it
- normally reports an error and exits with nonzero status. The work it
- does may therefore be incomplete. For example, when creating an
- archive, if
- node Data corruption and repair
- command{cksum}.
- When attempting to recover from a read error or data corruption in an
- archive, you may need to skip past the questionable data and read the
- rest of the archive. This requires some expertise in the archive
- format and in other software tools.
- subsection Race conditions
- If some other process is modifying the file system while
- command{tar} is creating an archive
- containing the directory's files,
- command{tar} archive of a live file system may therefore break that
- consistency and may break the application. The simplest way to avoid
- the consistency issues is to avoid making other changes to the file
- system while tar is reading it or writing it.
- When creating an archive, several options are available to avoid race
- conditions. Some hosts have a way of snapshotting a file system, or
- of temporarily suspending all changes to a file system, by (say)
- suspending the only virtual machine that can modify a file system; if
- you use these facilities and have
- command{tar} you could
- suspend or shut down all processes other than
- node Security
- command{tar} may be used in an adversarial situation,
- where an untrusted user is attempting to gain information about or
- modify otherwise-inaccessible files. Dealing with untrusted data
- (that is, data generated by an untrusted user) typically requires
- extra care, because even the smallest mistake in the use of
- menu
- * Privacy::
- * Integrity::
- * Live untrusted data::
- * Security rules of thumb::
- node Privacy
- command{tar}. For
- example, suppose you are archiving your home directory into a file
- file{/archive} so that it is not
- accessible to any user, unless that user also has permission to access
- all the files in your home directory.
- Similarly, when extracting from an archive, take care that the
- permissions of the extracted files are not more generous than what you
- want. Even if the archive itself is readable only to you, files
- extracted from it have their own permissions that may differ.
- subsection Integrity
- When creating archives, take care that they are not writable by a
- untrusted user; otherwise, that user could modify the archive, and
- when you later extract from the archive you will get incorrect data.
- When
- command{tar} in that directory.
- When extracting from two or more untrusted archives, each one should
- be extracted independently, into different empty directories.
- Otherwise, the first archive could create a symbolic link into an area
- outside the working directory, and the second one could follow the
- link and overwrite data that is not under the working directory. For
- example, when restoring from a series of incremental dumps, the
- archives should have been created by a trusted process, as otherwise
- the incremental restores might alter data outside the working
- directory.
- If you use the option{-P}) option when
- extracting,
- file{/} or contain
- option{--absolute-names} (
- option{--keep-old-files} (
- option{--skip-old-files} options,
- option{--no-overwrite-dir} option,
- node Live untrusted data
- command{tar} must be wary about its actions being hijacked
- by an adversary who is reading or writing the file system at the same
- time that
- command{tar} is
- vulnerable to denial-of-service attacks. For example, an adversarial
- user could create the illusion of an indefinitely-deep directory
- hierarchy
- command{tar}, or the illusion of an indefinitely-long file by
- creating a sparse file but arranging for blocks to be allocated just
- before
- command{tar} to distinguish these scenarios from legitimate uses, so
- you may need to monitor
- command{tar} will follow the symbolic link and
- extract data into files that the untrusted user does not have access
- to. Even if the archive was generated by the superuser, it may
- contain a file such as
- file{d/etc} with a symbolic link to
- command{tar} is running,
- file{/etc/passwd}. This attack can be prevented by extracting into a
- directory that is inaccessible to untrusted users.
- Similar attacks via symbolic links are also possible when creating an
- archive, if the untrusted user can modify an ancestor of a top-level
- argument of
- file{/home/eve} can hijack a running instance of
- file{/home/eve/Documents} with a symbolic link to some other
- location. Attacks like these can be prevented by making sure that
- untrusted users cannot modify any files that are top-level arguments
- to
- node Security rules of thumb
- itemize
- item
- Protect archives at least as much as you protect any of the files
- being archived.
- example
- kbd{chmod go-rwx .}
- $
- kbd{cd dir}
- $
- end group
- item
- Do not let untrusted users access files extracted from untrusted
- archives without checking first for problems such as setuid programs.
- command{tar}. For example, while you are
- executing
- file{/}, file{/u}.
- command{tar}.
- command{tar} to detect denial-of-service attacks.
- option{--absolute-names} (
- option{--dereference} (option{--overwrite},
- option{--remove-files} unless you
- understand their security implications.
- node Changes
- GNUTAR{}
- uref{http://www.gnu.org//tar/manual/changes.html,the
- table
- item Use of globbing patterns when listing and extracting.
- Previous versions of GNU tar assumed shell-style globbing when
- extracting from or listing an archive. For example:
- kbd{tar xf foo.tar '*.c'}
- samp{.c}. This behavior
- was not documented and was incompatible with traditional tar
- implementations. Therefore, starting from version 1.15.91, GNU tar
- no longer uses globbing by default. For example, the above invocation
- is now interpreted as a request to extract from the archive the file
- named
- command{tar} will print a warning
- if it finds out that a requested member was not found in the archive
- and its name looks like a globbing pattern. For example:
- kbd{tar xf foo.tar '*.c'}
- tar: Pattern matching characters used in file names. Please,
- tar: use --wildcards to enable pattern matching, or --no-wildcards to
- tar: suppress this warning.
- tar: *.c: Not found in archive
- tar: Error exit delayed from previous errors
- option{--wildcards} option.
- If you want to tar to mimic the behavior of versions prior to 1.15.91,
- add this option to your
- xref{wildcards}, for the detailed discussion of the use of globbing
- patterns by
- item Use of short option
- GNUTAR{} understood
- option{--old-archive}.
- option{--no-same-owner}. This is compatible with
- UNIX98
- option{-o} option retains its
- old semantics when it is used with one of archive-creation commands.
- Users are encouraged to use
- acronym{GNU} Automake
- up to and including 1.8.4 invoke tar with this option to produce
- distribution tarballs.
- xref{Options, tar-formats, Changing Automake's Behavior,
- automake, GNU Automake}, for a description on how to use various
- archive formats with
- GNUTAR{} will understand
- option{--no-same-owner}.
- option{-l}
- Earlier versions of option{-l} option as a
- synonym for
- option{-l} as a short
- variant of
- item Use of options option{--old-archive}
- These options are deprecated. Please use
- item Use of option
- option{--format=posix} instead.
- node Configuring Help Summary
- kbd{tar --help} displays the short
- pxref{help}). This summary is organized by
- kbd{tar
- --help} output:
- end verbatim
- env{ARGP_HELP_FMT} environment variable. The value of this variable
- is a comma-separated list of
- dfn{offset variable} keeps the
- offset of some part of help output text from the leftmost column on
- the screen. A
- table
- item Offset assignment
- The assignment to an offset variable has the following syntax:
- var{variable}=
- end smallexample
- var{variable} is the variable name, and
- item Boolean assignment
- To assign
- code{false} value, prefix the variable name with
- smallexample
- code{true} value:
- dup-args
- # Assign
- end group
- end table
- Following variables are declared:
- smallexample
- -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
- smallexample
- -f, --file=ARCHIVE use archive file or device ARCHIVE
- noindent
- and a message indicating that the argument is applicable to both
- forms is printed below the options. This message can be disabled
- using
- end deftypevr
- quotation
- Mandatory or optional arguments to long options are also mandatory or
- optional for any corresponding short options.
- code{no-dup-args-note} inhibits this message. Normally, only one of
- variables code{dup-args-note} should be set.
- deftypevr {Help Output} offset short-opt-col
- Column in which short options start. Default is 2.
- group
- $
- kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
- -f, --file=ARCHIVE use archive file or device ARCHIVE
- end smallexample
- deftypevr {Help Output} offset long-opt-col
- Column in which long options start. Default is 6. For example:
- group
- $
- kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
- -f, --file=ARCHIVE use archive file or device ARCHIVE
- end smallexample
- deftypevr {Help Output} offset doc-opt-col
- Column in which
- option{--format} option:
- group
- -H, --format=FORMAT create archive of the given format.
- FORMAT is one of the following:
- gnu GNU tar 1.13.x format
- oldgnu GNU format as per tar <= 1.12
- pax POSIX 1003.1-2001 (pax) format
- posix same as pax
- ustar POSIX 1003.1-1988 (ustar) format
- v7 old V7 tar format
- end smallexample
- kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
- will look as follows:
- group
- -H, --format=FORMAT create archive of the given format.
- FORMAT is one of the following:
- gnu GNU tar 1.13.x format
- oldgnu GNU format as per tar <= 1.12
- pax POSIX 1003.1-2001 (pax) format
- posix same as pax
- ustar POSIX 1003.1-1988 (ustar) format
- v7 old V7 tar format
- end smallexample
- deftypevr {Help Output} offset opt-doc-col
- Column in which option description starts. Default is 29.
- group
- $
- kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
- -f, --file=ARCHIVE use archive file or device ARCHIVE
- $
- end group
- noindent
- Notice, that the description starts on a separate line if
- end deftypevr
- dfn{group headers} are printed. A group header is a
- descriptive text preceding an option group. For example, in the
- following text:
- end verbatim
- samp{Main operation mode:} is the group header.
- The default value is 1.
- deftypevr {Help Output} offset usage-indent
- Indentation of wrapped usage lines. Affects
- end deftypevr
- end deftypevr
- appendix Fixing Snapshot Files
- node Tar Internals
- include intern.texi
- appendix Genfile
- node Free Software Needs Free Documentation
- include freemanuals.texi
- appendix GNU Free Documentation License
- node Index of Command Line Options
- GNUTAR{} long command line
- options. The options are listed without the preceding double-dash.
- For a cross-reference of short command line options, see
- printindex op
- appendix Index
- summarycontents
- bye
- c texinfo-column-for-description: 32
|