tar.texi 454 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c Maintenance notes:
  11. @c 1. Pay attention to @FIXME{}s and @UNREVISED{}s
  12. @c 2. Before creating final variant:
  13. @c 2.1. Run `make check-options' to make sure all options are properly
  14. @c documented;
  15. @c 2.2. Run `make master-menu' (see comment before the master menu).
  16. @include rendition.texi
  17. @include value.texi
  18. @defcodeindex op
  19. @defcodeindex kw
  20. @c Put everything in one index (arbitrarily chosen to be the concept index).
  21. @syncodeindex fn cp
  22. @syncodeindex ky cp
  23. @syncodeindex pg cp
  24. @syncodeindex vr cp
  25. @syncodeindex kw cp
  26. @copying
  27. This manual is for @acronym{GNU} @command{tar} (version
  28. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  29. from archives.
  30. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  31. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
  32. Foundation, Inc.
  33. @quotation
  34. Permission is granted to copy, distribute and/or modify this document
  35. under the terms of the GNU Free Documentation License, Version 1.3 or
  36. any later version published by the Free Software Foundation; with no
  37. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  38. A copy of the license is included in the section entitled ``GNU Free
  39. Documentation License''.
  40. @end quotation
  41. @end copying
  42. @dircategory Archiving
  43. @direntry
  44. * Tar: (tar). Making tape (or disk) archives.
  45. @end direntry
  46. @dircategory Individual utilities
  47. @direntry
  48. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  49. @end direntry
  50. @shorttitlepage @acronym{GNU} @command{tar}
  51. @titlepage
  52. @title @acronym{GNU} tar: an archiver tool
  53. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  54. @author John Gilmore, Jay Fenlason et al.
  55. @page
  56. @vskip 0pt plus 1filll
  57. @insertcopying
  58. @end titlepage
  59. @ifnottex
  60. @node Top
  61. @top @acronym{GNU} tar: an archiver tool
  62. @insertcopying
  63. @cindex file archival
  64. @cindex archiving files
  65. The first part of this master menu lists the major nodes in this Info
  66. document. The rest of the menu lists all the lower level nodes.
  67. @end ifnottex
  68. @c The master menu goes here.
  69. @c
  70. @c NOTE: To update it from within Emacs, make sure mastermenu.el is
  71. @c loaded and run texinfo-master-menu.
  72. @c To update it from the command line, run
  73. @c
  74. @c make master-menu
  75. @menu
  76. * Introduction::
  77. * Tutorial::
  78. * tar invocation::
  79. * operations::
  80. * Backups::
  81. * Choosing::
  82. * Date input formats::
  83. * Formats::
  84. * Media::
  85. * Reliability and security::
  86. Appendices
  87. * Changes::
  88. * Configuring Help Summary::
  89. * Fixing Snapshot Files::
  90. * Tar Internals::
  91. * Genfile::
  92. * Free Software Needs Free Documentation::
  93. * GNU Free Documentation License::
  94. * Index of Command Line Options::
  95. * Index::
  96. @detailmenu
  97. --- The Detailed Node Listing ---
  98. Introduction
  99. * Book Contents:: What this Book Contains
  100. * Definitions:: Some Definitions
  101. * What tar Does:: What @command{tar} Does
  102. * Naming tar Archives:: How @command{tar} Archives are Named
  103. * Authors:: @GNUTAR{} Authors
  104. * Reports:: Reporting bugs or suggestions
  105. Tutorial Introduction to @command{tar}
  106. * assumptions::
  107. * stylistic conventions::
  108. * basic tar options:: Basic @command{tar} Operations and Options
  109. * frequent operations::
  110. * Two Frequent Options::
  111. * create:: How to Create Archives
  112. * list:: How to List Archives
  113. * extract:: How to Extract Members from an Archive
  114. * going further::
  115. Two Frequently Used Options
  116. * file tutorial::
  117. * verbose tutorial::
  118. * help tutorial::
  119. How to Create Archives
  120. * prepare for examples::
  121. * Creating the archive::
  122. * create verbose::
  123. * short create::
  124. * create dir::
  125. How to List Archives
  126. * list dir::
  127. How to Extract Members from an Archive
  128. * extracting archives::
  129. * extracting files::
  130. * extract dir::
  131. * extracting untrusted archives::
  132. * failing commands::
  133. Invoking @GNUTAR{}
  134. * Synopsis::
  135. * using tar options::
  136. * Styles::
  137. * All Options::
  138. * help::
  139. * defaults::
  140. * verbose::
  141. * checkpoints::
  142. * warnings::
  143. * interactive::
  144. The Three Option Styles
  145. * Long Options:: Long Option Style
  146. * Short Options:: Short Option Style
  147. * Old Options:: Old Option Style
  148. * Mixing:: Mixing Option Styles
  149. All @command{tar} Options
  150. * Operation Summary::
  151. * Option Summary::
  152. * Short Option Summary::
  153. @GNUTAR{} Operations
  154. * Basic tar::
  155. * Advanced tar::
  156. * create options::
  157. * extract options::
  158. * backup::
  159. * Applications::
  160. * looking ahead::
  161. Advanced @GNUTAR{} Operations
  162. * Operations::
  163. * append::
  164. * update::
  165. * concatenate::
  166. * delete::
  167. * compare::
  168. How to Add Files to Existing Archives: @option{--append}
  169. * appending files:: Appending Files to an Archive
  170. * multiple::
  171. Updating an Archive
  172. * how to update::
  173. Options Used by @option{--create}
  174. * override:: Overriding File Metadata.
  175. * Ignore Failed Read::
  176. Options Used by @option{--extract}
  177. * Reading:: Options to Help Read Archives
  178. * Writing:: Changing How @command{tar} Writes Files
  179. * Scarce:: Coping with Scarce Resources
  180. Options to Help Read Archives
  181. * read full records::
  182. * Ignore Zeros::
  183. Changing How @command{tar} Writes Files
  184. * Dealing with Old Files::
  185. * Overwrite Old Files::
  186. * Keep Old Files::
  187. * Keep Newer Files::
  188. * Unlink First::
  189. * Recursive Unlink::
  190. * Data Modification Times::
  191. * Setting Access Permissions::
  192. * Directory Modification Times and Permissions::
  193. * Writing to Standard Output::
  194. * Writing to an External Program::
  195. * remove files::
  196. Coping with Scarce Resources
  197. * Starting File::
  198. * Same Order::
  199. Performing Backups and Restoring Files
  200. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  201. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  202. * Backup Levels:: Levels of Backups
  203. * Backup Parameters:: Setting Parameters for Backups and Restoration
  204. * Scripted Backups:: Using the Backup Scripts
  205. * Scripted Restoration:: Using the Restore Script
  206. Setting Parameters for Backups and Restoration
  207. * General-Purpose Variables::
  208. * Magnetic Tape Control::
  209. * User Hooks::
  210. * backup-specs example:: An Example Text of @file{Backup-specs}
  211. Choosing Files and Names for @command{tar}
  212. * file:: Choosing the Archive's Name
  213. * Selecting Archive Members::
  214. * files:: Reading Names from a File
  215. * exclude:: Excluding Some Files
  216. * wildcards:: Wildcards Patterns and Matching
  217. * quoting styles:: Ways of Quoting Special Characters in Names
  218. * transform:: Modifying File and Member Names
  219. * after:: Operating Only on New Files
  220. * recurse:: Descending into Directories
  221. * one:: Crossing File System Boundaries
  222. Reading Names from a File
  223. * nul::
  224. Excluding Some Files
  225. * problems with exclude::
  226. Wildcards Patterns and Matching
  227. * controlling pattern-matching::
  228. Crossing File System Boundaries
  229. * directory:: Changing Directory
  230. * absolute:: Absolute File Names
  231. Date input formats
  232. * General date syntax:: Common rules.
  233. * Calendar date items:: 19 Dec 1994.
  234. * Time of day items:: 9:20pm.
  235. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}.
  236. * Day of week items:: Monday and others.
  237. * Relative items in date strings:: next tuesday, 2 years ago.
  238. * Pure numbers in date strings:: 19931219, 1440.
  239. * Seconds since the Epoch:: @@1078100502.
  240. * Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
  241. * Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al.
  242. Controlling the Archive Format
  243. * Compression:: Using Less Space through Compression
  244. * Attributes:: Handling File Attributes
  245. * Portability:: Making @command{tar} Archives More Portable
  246. * cpio:: Comparison of @command{tar} and @command{cpio}
  247. Using Less Space through Compression
  248. * gzip:: Creating and Reading Compressed Archives
  249. * sparse:: Archiving Sparse Files
  250. Creating and Reading Compressed Archives
  251. * lbzip2:: Using lbzip2 with @GNUTAR{}.
  252. Making @command{tar} Archives More Portable
  253. * Portable Names:: Portable Names
  254. * dereference:: Symbolic Links
  255. * hard links:: Hard Links
  256. * old:: Old V7 Archives
  257. * ustar:: Ustar Archives
  258. * gnu:: GNU and old GNU format archives.
  259. * posix:: @acronym{POSIX} archives
  260. * Checksumming:: Checksumming Problems
  261. * Large or Negative Values:: Large files, negative time stamps, etc.
  262. * Other Tars:: How to Extract GNU-Specific Data Using
  263. Other @command{tar} Implementations
  264. @GNUTAR{} and @acronym{POSIX} @command{tar}
  265. * PAX keywords:: Controlling Extended Header Keywords.
  266. How to Extract GNU-Specific Data Using Other @command{tar} Implementations
  267. * Split Recovery:: Members Split Between Volumes
  268. * Sparse Recovery:: Sparse Members
  269. Tapes and Other Archive Media
  270. * Device:: Device selection and switching
  271. * Remote Tape Server::
  272. * Common Problems and Solutions::
  273. * Blocking:: Blocking
  274. * Many:: Many archives on one tape
  275. * Using Multiple Tapes:: Using Multiple Tapes
  276. * label:: Including a Label in the Archive
  277. * verify::
  278. * Write Protection::
  279. Blocking
  280. * Format Variations:: Format Variations
  281. * Blocking Factor:: The Blocking Factor of an Archive
  282. Many Archives on One Tape
  283. * Tape Positioning:: Tape Positions and Tape Marks
  284. * mt:: The @command{mt} Utility
  285. Using Multiple Tapes
  286. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  287. * Tape Files:: Tape Files
  288. * Tarcat:: Concatenate Volumes into a Single Archive
  289. Tar Internals
  290. * Standard:: Basic Tar Format
  291. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  292. * Sparse Formats:: Storing Sparse Files
  293. * Snapshot Files::
  294. * Dumpdir::
  295. Storing Sparse Files
  296. * Old GNU Format::
  297. * PAX 0:: PAX Format, Versions 0.0 and 0.1
  298. * PAX 1:: PAX Format, Version 1.0
  299. Genfile
  300. * Generate Mode:: File Generation Mode.
  301. * Status Mode:: File Status Mode.
  302. * Exec Mode:: Synchronous Execution mode.
  303. Copying This Manual
  304. * GNU Free Documentation License:: License for copying this manual
  305. @end detailmenu
  306. @end menu
  307. @node Introduction
  308. @chapter Introduction
  309. @GNUTAR{} creates
  310. and manipulates @dfn{archives} which are actually collections of
  311. many other files; the program provides users with an organized and
  312. systematic method for controlling a large amount of data.
  313. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  314. archives need not (and these days, typically do not) reside on tapes.
  315. @menu
  316. * Book Contents:: What this Book Contains
  317. * Definitions:: Some Definitions
  318. * What tar Does:: What @command{tar} Does
  319. * Naming tar Archives:: How @command{tar} Archives are Named
  320. * Authors:: @GNUTAR{} Authors
  321. * Reports:: Reporting bugs or suggestions
  322. @end menu
  323. @node Book Contents
  324. @section What this Book Contains
  325. The first part of this chapter introduces you to various terms that will
  326. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  327. and its documentation, and where you should send bug reports
  328. or comments.
  329. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  330. gentle introduction for people who are new to using @command{tar}. It is
  331. meant to be self-contained, not requiring any reading from subsequent
  332. chapters to make sense. It moves from topic to topic in a logical,
  333. progressive order, building on information already explained.
  334. Although the tutorial is paced and structured to allow beginners to
  335. learn how to use @command{tar}, it is not intended solely for beginners.
  336. The tutorial explains how to use the three most frequently used
  337. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  338. two frequently used options (@samp{file} and @samp{verbose}). The other
  339. chapters do not refer to the tutorial frequently; however, if a section
  340. discusses something which is a complex variant of a basic concept, there
  341. may be a cross-reference to that basic concept. (The entire book,
  342. including the tutorial, assumes that the reader understands some basic
  343. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  344. The third chapter presents the remaining five operations, and
  345. information about using @command{tar} options and option syntax.
  346. The other chapters are meant to be used as a reference. Each chapter
  347. presents everything that needs to be said about a specific topic.
  348. One of the chapters (@pxref{Date input formats}) exists in its
  349. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  350. In addition, one section of this manual (@pxref{Standard}) contains a
  351. big quote which is taken directly from @command{tar} sources.
  352. In general, we give both long and short (abbreviated) option names
  353. at least once in each section where the relevant option is covered, so
  354. that novice readers will become familiar with both styles. (A few
  355. options have no short versions, and the relevant sections will
  356. indicate this.)
  357. @node Definitions
  358. @section Some Definitions
  359. @cindex archive
  360. @cindex tar archive
  361. The @command{tar} program is used to create and manipulate @command{tar}
  362. archives. An @dfn{archive} is a single file which contains the contents
  363. of many files, while still identifying the names of the files, their
  364. owner(s), and so forth. (In addition, archives record access
  365. permissions, user and group, size in bytes, and data modification time.
  366. Some archives also record the file names in each archived directory, as
  367. well as other file and directory information.) You can use @command{tar}
  368. to @dfn{create} a new archive in a specified directory.
  369. @cindex member
  370. @cindex archive member
  371. @cindex file name
  372. @cindex member name
  373. The files inside an archive are called @dfn{members}. Within this
  374. manual, we use the term @dfn{file} to refer only to files accessible in
  375. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  376. @dfn{member} to refer only to the members of an archive. Similarly, a
  377. @dfn{file name} is the name of a file, as it resides in the file system,
  378. and a @dfn{member name} is the name of an archive member within the
  379. archive.
  380. @cindex extraction
  381. @cindex unpacking
  382. The term @dfn{extraction} refers to the process of copying an archive
  383. member (or multiple members) into a file in the file system. Extracting
  384. all the members of an archive is often called @dfn{extracting the
  385. archive}. The term @dfn{unpack} can also be used to refer to the
  386. extraction of many or all the members of an archive. Extracting an
  387. archive does not destroy the archive's structure, just as creating an
  388. archive does not destroy the copies of the files that exist outside of
  389. the archive. You may also @dfn{list} the members in a given archive
  390. (this is often thought of as ``printing'' them to the standard output,
  391. or the command line), or @dfn{append} members to a pre-existing archive.
  392. All of these operations can be performed using @command{tar}.
  393. @node What tar Does
  394. @section What @command{tar} Does
  395. @cindex tar
  396. The @command{tar} program provides the ability to create @command{tar}
  397. archives, as well as various other kinds of manipulation. For example,
  398. you can use @command{tar} on previously created archives to extract files,
  399. to store additional files, or to update or list files which were already
  400. stored.
  401. Initially, @command{tar} archives were used to store files conveniently on
  402. magnetic tape. The name @command{tar} comes from this use; it stands for
  403. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  404. direct its output to available devices, files, or other programs (using
  405. pipes). @command{tar} may even access remote devices or files (as archives).
  406. You can use @command{tar} archives in many ways. We want to stress a few
  407. of them: storage, backup, and transportation.
  408. @FIXME{the following table entries need a bit of work.}
  409. @table @asis
  410. @item Storage
  411. Often, @command{tar} archives are used to store related files for
  412. convenient file transfer over a network. For example, the
  413. @acronym{GNU} Project distributes its software bundled into
  414. @command{tar} archives, so that all the files relating to a particular
  415. program (or set of related programs) can be transferred as a single
  416. unit.
  417. A magnetic tape can store several files in sequence. However, the tape
  418. has no names for these files; it only knows their relative position on
  419. the tape. One way to store several files on one tape and retain their
  420. names is by creating a @command{tar} archive. Even when the basic transfer
  421. mechanism can keep track of names, as FTP can, the nuisance of handling
  422. multiple files, directories, and multiple links makes @command{tar}
  423. archives useful.
  424. Archive files are also used for long-term storage. You can think of
  425. this as transportation from the present into the future. (It is a
  426. science-fiction idiom that you can move through time as well as in
  427. space; the idea here is that @command{tar} can be used to move archives in
  428. all dimensions, even time!)
  429. @item Backup
  430. Because the archive created by @command{tar} is capable of preserving
  431. file information and directory structure, @command{tar} is commonly
  432. used for performing full and incremental backups of disks. A backup
  433. puts a collection of files (possibly pertaining to many users and
  434. projects) together on a disk or a tape. This guards against
  435. accidental destruction of the information in those files.
  436. @GNUTAR{} has special features that allow it to be
  437. used to make incremental and full dumps of all the files in a
  438. file system.
  439. @item Transportation
  440. You can create an archive on one system, transfer it to another system,
  441. and extract the contents there. This allows you to transport a group of
  442. files from one system to another.
  443. @end table
  444. @node Naming tar Archives
  445. @section How @command{tar} Archives are Named
  446. Conventionally, @command{tar} archives are given names ending with
  447. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  448. but this manual follows that convention in order to accustom readers to
  449. it and to make examples more clear.
  450. @cindex tar file
  451. @cindex entry
  452. @cindex tar entry
  453. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  454. archive members as ``files'' or ``entries''. For people familiar with
  455. the operation of @command{tar}, this causes no difficulty. However, in
  456. this manual, we consistently refer to ``archives'' and ``archive
  457. members'' to make learning to use @command{tar} easier for novice users.
  458. @node Authors
  459. @section @GNUTAR{} Authors
  460. @GNUTAR{} was originally written by John Gilmore,
  461. and modified by many people. The @acronym{GNU} enhancements were
  462. written by Jay Fenlason, then Joy Kendall, and the whole package has
  463. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  464. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  465. numerous and kind users.
  466. We wish to stress that @command{tar} is a collective work, and owes much to
  467. all those people who reported problems, offered solutions and other
  468. insights, or shared their thoughts and suggestions. An impressive, yet
  469. partial list of those contributors can be found in the @file{THANKS}
  470. file from the @GNUTAR{} distribution.
  471. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  472. sure i want to spell out the history in this detail, at least not for
  473. the printed book. i'm just not sure it needs to be said this way.
  474. i'll think about it.}
  475. @FIXME{History is more important, and surely more interesting, than
  476. actual names. Quoting names without history would be meaningless. FP}
  477. Jay Fenlason put together a draft of a @GNUTAR{}
  478. manual, borrowing notes from the original man page from John Gilmore.
  479. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  480. Gorin worked on a tutorial and manual for @GNUTAR{}.
  481. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  482. taking information from all these sources and merging them. Melissa
  483. Weisshaus finally edited and redesigned the book to create version
  484. 1.12. The book for versions from 1.14 up to @value{VERSION} were edited
  485. by the current maintainer, Sergey Poznyakoff.
  486. For version 1.12, Daniel Hagerty contributed a great deal of technical
  487. consulting. In particular, he is the primary author of @ref{Backups}.
  488. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  489. (see @url{http://savannah.gnu.org/projects/tar}), and
  490. active development and maintenance work has started
  491. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  492. Poznyakoff and Jeff Bailey.
  493. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  494. @node Reports
  495. @section Reporting bugs or suggestions
  496. @cindex bug reports
  497. @cindex reporting bugs
  498. If you find problems or have suggestions about this program or manual,
  499. please report them to @file{bug-tar@@gnu.org}.
  500. When reporting a bug, please be sure to include as much detail as
  501. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  502. like to make this node as detailed as 'Bug reporting' node in Emacs
  503. manual.}
  504. @node Tutorial
  505. @chapter Tutorial Introduction to @command{tar}
  506. This chapter guides you through some basic examples of three @command{tar}
  507. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  508. you already know how to use some other version of @command{tar}, then you
  509. may not need to read this chapter. This chapter omits most complicated
  510. details about how @command{tar} works.
  511. @menu
  512. * assumptions::
  513. * stylistic conventions::
  514. * basic tar options:: Basic @command{tar} Operations and Options
  515. * frequent operations::
  516. * Two Frequent Options::
  517. * create:: How to Create Archives
  518. * list:: How to List Archives
  519. * extract:: How to Extract Members from an Archive
  520. * going further::
  521. @end menu
  522. @node assumptions
  523. @section Assumptions this Tutorial Makes
  524. This chapter is paced to allow beginners to learn about @command{tar}
  525. slowly. At the same time, we will try to cover all the basic aspects of
  526. these three operations. In order to accomplish both of these tasks, we
  527. have made certain assumptions about your knowledge before reading this
  528. manual, and the hardware you will be using:
  529. @itemize @bullet
  530. @item
  531. Before you start to work through this tutorial, you should understand
  532. what the terms ``archive'' and ``archive member'' mean
  533. (@pxref{Definitions}). In addition, you should understand something
  534. about how Unix-type operating systems work, and you should know how to
  535. use some basic utilities. For example, you should know how to create,
  536. list, copy, rename, edit, and delete files and directories; how to
  537. change between directories; and how to figure out where you are in the
  538. file system. You should have some basic understanding of directory
  539. structure and how files are named according to which directory they are
  540. in. You should understand concepts such as standard output and standard
  541. input, what various definitions of the term @samp{argument} mean, and the
  542. differences between relative and absolute file names. @FIXME{and what
  543. else?}
  544. @item
  545. This manual assumes that you are working from your own home directory
  546. (unless we state otherwise). In this tutorial, you will create a
  547. directory to practice @command{tar} commands in. When we show file names,
  548. we will assume that those names are relative to your home directory.
  549. For example, my home directory is @file{/home/fsf/melissa}. All of
  550. my examples are in a subdirectory of the directory named by that file
  551. name; the subdirectory is called @file{practice}.
  552. @item
  553. In general, we show examples of archives which exist on (or can be
  554. written to, or worked with from) a directory on a hard disk. In most
  555. cases, you could write those archives to, or work with them on any other
  556. device, such as a tape drive. However, some of the later examples in
  557. the tutorial and next chapter will not work on tape drives.
  558. Additionally, working with tapes is much more complicated than working
  559. with hard disks. For these reasons, the tutorial does not cover working
  560. with tape drives. @xref{Media}, for complete information on using
  561. @command{tar} archives with tape drives.
  562. @FIXME{this is a cop out. need to add some simple tape drive info.}
  563. @end itemize
  564. @node stylistic conventions
  565. @section Stylistic Conventions
  566. In the examples, @samp{$} represents a typical shell prompt. It
  567. precedes lines you should type; to make this more clear, those lines are
  568. shown in @kbd{this font}, as opposed to lines which represent the
  569. computer's response; those lines are shown in @code{this font}, or
  570. sometimes @samp{like this}.
  571. @c When we have lines which are too long to be
  572. @c displayed in any other way, we will show them like this:
  573. @node basic tar options
  574. @section Basic @command{tar} Operations and Options
  575. @command{tar} can take a wide variety of arguments which specify and define
  576. the actions it will have on the particular set of files or the archive.
  577. The main types of arguments to @command{tar} fall into one of two classes:
  578. operations, and options.
  579. Some arguments fall into a class called @dfn{operations}; exactly one of
  580. these is both allowed and required for any instance of using @command{tar};
  581. you may @emph{not} specify more than one. People sometimes speak of
  582. @dfn{operating modes}. You are in a particular operating mode when you
  583. have specified the operation which specifies it; there are eight
  584. operations in total, and thus there are eight operating modes.
  585. The other arguments fall into the class known as @dfn{options}. You are
  586. not required to specify any options, and you are allowed to specify more
  587. than one at a time (depending on the way you are using @command{tar} at
  588. that time). Some options are used so frequently, and are so useful for
  589. helping you type commands more carefully that they are effectively
  590. ``required''. We will discuss them in this chapter.
  591. You can write most of the @command{tar} operations and options in any
  592. of three forms: long (mnemonic) form, short form, and old style. Some
  593. of the operations and options have no short or ``old'' forms; however,
  594. the operations and options which we will cover in this tutorial have
  595. corresponding abbreviations. We will indicate those abbreviations
  596. appropriately to get you used to seeing them. Note, that the ``old
  597. style'' option forms exist in @GNUTAR{} for compatibility with Unix
  598. @command{tar}. In this book we present a full discussion of this way
  599. of writing options and operations (@pxref{Old Options}), and we discuss
  600. the other two styles of writing options (@xref{Long Options}, and
  601. @pxref{Short Options}).
  602. In the examples and in the text of this tutorial, we usually use the
  603. long forms of operations and options; but the ``short'' forms produce
  604. the same result and can make typing long @command{tar} commands easier.
  605. For example, instead of typing
  606. @smallexample
  607. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  608. @end smallexample
  609. @noindent
  610. you can type
  611. @smallexample
  612. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  613. @end smallexample
  614. @noindent
  615. or even
  616. @smallexample
  617. @kbd{tar -cvf afiles.tar apple angst aspic}
  618. @end smallexample
  619. @noindent
  620. For more information on option syntax, see @ref{Advanced tar}. In
  621. discussions in the text, when we name an option by its long form, we
  622. also give the corresponding short option in parentheses.
  623. The term, ``option'', can be confusing at times, since ``operations''
  624. are often lumped in with the actual, @emph{optional} ``options'' in certain
  625. general class statements. For example, we just talked about ``short and
  626. long forms of options and operations''. However, experienced @command{tar}
  627. users often refer to these by shorthand terms such as, ``short and long
  628. options''. This term assumes that the ``operations'' are included, also.
  629. Context will help you determine which definition of ``options'' to use.
  630. Similarly, the term ``command'' can be confusing, as it is often used in
  631. two different ways. People sometimes refer to @command{tar} ``commands''.
  632. A @command{tar} @dfn{command} is the entire command line of user input
  633. which tells @command{tar} what to do --- including the operation, options,
  634. and any arguments (file names, pipes, other commands, etc.). However,
  635. you will also sometimes hear the term ``the @command{tar} command''. When
  636. the word ``command'' is used specifically like this, a person is usually
  637. referring to the @command{tar} @emph{operation}, not the whole line.
  638. Again, use context to figure out which of the meanings the speaker
  639. intends.
  640. @node frequent operations
  641. @section The Three Most Frequently Used Operations
  642. Here are the three most frequently used operations (both short and long
  643. forms), as well as a brief description of their meanings. The rest of
  644. this chapter will cover how to use these operations in detail. We will
  645. present the rest of the operations in the next chapter.
  646. @table @option
  647. @item --create
  648. @itemx -c
  649. Create a new @command{tar} archive.
  650. @item --list
  651. @itemx -t
  652. List the contents of an archive.
  653. @item --extract
  654. @itemx -x
  655. Extract one or more members from an archive.
  656. @end table
  657. @node Two Frequent Options
  658. @section Two Frequently Used Options
  659. To understand how to run @command{tar} in the three operating modes listed
  660. previously, you also need to understand how to use two of the options to
  661. @command{tar}: @option{--file} (which takes an archive file as an argument)
  662. and @option{--verbose}. (You are usually not @emph{required} to specify
  663. either of these options when you run @command{tar}, but they can be very
  664. useful in making things more clear and helping you avoid errors.)
  665. @menu
  666. * file tutorial::
  667. * verbose tutorial::
  668. * help tutorial::
  669. @end menu
  670. @node file tutorial
  671. @unnumberedsubsec The @option{--file} Option
  672. @table @option
  673. @xopindex{file, tutorial}
  674. @item --file=@var{archive-name}
  675. @itemx -f @var{archive-name}
  676. Specify the name of an archive file.
  677. @end table
  678. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  679. use @command{tar}; this option determines the name of the archive file
  680. that @command{tar} will work on.
  681. @vrindex TAPE
  682. If you don't specify this argument, then @command{tar} will examine
  683. the environment variable @env{TAPE}. If it is set, its value will be
  684. used as the archive name. Otherwise, @command{tar} will use the
  685. default archive, determined at compile time. Usually it is
  686. standard output or some physical tape drive attached to your machine
  687. (you can verify what the default is by running @kbd{tar
  688. --show-defaults}, @pxref{defaults}). If there is no tape drive
  689. attached, or the default is not meaningful, then @command{tar} will
  690. print an error message. The error message might look roughly like one
  691. of the following:
  692. @smallexample
  693. tar: can't open /dev/rmt8 : No such device or address
  694. tar: can't open /dev/rsmt0 : I/O error
  695. @end smallexample
  696. @noindent
  697. To avoid confusion, we recommend that you always specify an archive file
  698. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  699. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  700. @ref{file}.
  701. @node verbose tutorial
  702. @unnumberedsubsec The @option{--verbose} Option
  703. @table @option
  704. @xopindex{verbose, introduced}
  705. @item --verbose
  706. @itemx -v
  707. Show the files being worked on as @command{tar} is running.
  708. @end table
  709. @option{--verbose} (@option{-v}) shows details about the results of running
  710. @command{tar}. This can be especially useful when the results might not be
  711. obvious. For example, if you want to see the progress of @command{tar} as
  712. it writes files into the archive, you can use the @option{--verbose}
  713. option. In the beginning, you may find it useful to use
  714. @option{--verbose} at all times; when you are more accustomed to
  715. @command{tar}, you will likely want to use it at certain times but not at
  716. others. We will use @option{--verbose} at times to help make something
  717. clear, and we will give many examples both using and not using
  718. @option{--verbose} to show the differences.
  719. Each instance of @option{--verbose} on the command line increases the
  720. verbosity level by one, so if you need more details on the output,
  721. specify it twice.
  722. When reading archives (@option{--list}, @option{--extract},
  723. @option{--diff}), @command{tar} by default prints only the names of
  724. the members being extracted. Using @option{--verbose} will show a full,
  725. @command{ls} style member listing.
  726. In contrast, when writing archives (@option{--create}, @option{--append},
  727. @option{--update}), @command{tar} does not print file names by
  728. default. So, a single @option{--verbose} option shows the file names
  729. being added to the archive, while two @option{--verbose} options
  730. enable the full listing.
  731. For example, to create an archive in verbose mode:
  732. @smallexample
  733. $ @kbd{tar -cvf afiles.tar apple angst aspic}
  734. apple
  735. angst
  736. aspic
  737. @end smallexample
  738. @noindent
  739. Creating the same archive with the verbosity level 2 could give:
  740. @smallexample
  741. $ @kbd{tar -cvvf afiles.tar apple angst aspic}
  742. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  743. -rw-r--r-- gray/staff 11481 2006-06-09 12:06 angst
  744. -rw-r--r-- gray/staff 23152 2006-06-09 12:06 aspic
  745. @end smallexample
  746. @noindent
  747. This works equally well using short or long forms of options. Using
  748. long forms, you would simply write out the mnemonic form of the option
  749. twice, like this:
  750. @smallexample
  751. $ @kbd{tar --create --verbose --verbose @dots{}}
  752. @end smallexample
  753. @noindent
  754. Note that you must double the hyphens properly each time.
  755. Later in the tutorial, we will give examples using @w{@option{--verbose
  756. --verbose}}.
  757. @anchor{verbose member listing}
  758. The full output consists of six fields:
  759. @itemize @bullet
  760. @item File type and permissions in symbolic form.
  761. These are displayed in the same format as the first column of
  762. @command{ls -l} output (@pxref{What information is listed,
  763. format=verbose, Verbose listing, fileutils, GNU file utilities}).
  764. @item Owner name and group separated by a slash character.
  765. If these data are not available (for example, when listing a @samp{v7} format
  766. archive), numeric @acronym{ID} values are printed instead.
  767. @item Size of the file, in bytes.
  768. @item File modification date in ISO 8601 format.
  769. @item File modification time.
  770. @item File name.
  771. If the name contains any special characters (white space, newlines,
  772. etc.) these are displayed in an unambiguous form using so called
  773. @dfn{quoting style}. For the detailed discussion of available styles
  774. and on how to use them, see @ref{quoting styles}.
  775. Depending on the file type, the name can be followed by some
  776. additional information, described in the following table:
  777. @table @samp
  778. @item -> @var{link-name}
  779. The file or archive member is a @dfn{symbolic link} and
  780. @var{link-name} is the name of file it links to.
  781. @item link to @var{link-name}
  782. The file or archive member is a @dfn{hard link} and @var{link-name} is
  783. the name of file it links to.
  784. @item --Long Link--
  785. The archive member is an old GNU format long link. You will normally
  786. not encounter this.
  787. @item --Long Name--
  788. The archive member is an old GNU format long name. You will normally
  789. not encounter this.
  790. @item --Volume Header--
  791. The archive member is a GNU @dfn{volume header} (@pxref{Tape Files}).
  792. @item --Continued at byte @var{n}--
  793. Encountered only at the beginning of a multi-volume archive
  794. (@pxref{Using Multiple Tapes}). This archive member is a continuation
  795. from the previous volume. The number @var{n} gives the offset where
  796. the original file was split.
  797. @item unknown file type @var{c}
  798. An archive member of unknown type. @var{c} is the type character from
  799. the archive header. If you encounter such a message, it means that
  800. either your archive contains proprietary member types @GNUTAR{} is not
  801. able to handle, or the archive is corrupted.
  802. @end table
  803. @end itemize
  804. For example, here is an archive listing containing most of the special
  805. suffixes explained above:
  806. @smallexample
  807. @group
  808. V--------- 0/0 1536 2006-06-09 13:07 MyVolume--Volume Header--
  809. -rw-r--r-- gray/staff 456783 2006-06-09 12:06 aspic--Continued at byte 32456--
  810. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  811. lrwxrwxrwx gray/staff 0 2006-06-09 13:01 angst -> apple
  812. -rw-r--r-- gray/staff 35793 2006-06-09 12:06 blues
  813. hrw-r--r-- gray/staff 0 2006-06-09 12:06 music link to blues
  814. @end group
  815. @end smallexample
  816. @smallexample
  817. @end smallexample
  818. @node help tutorial
  819. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  820. @table @option
  821. @opindex help
  822. @item --help
  823. The @option{--help} option to @command{tar} prints out a very brief list of
  824. all operations and option available for the current version of
  825. @command{tar} available on your system.
  826. @end table
  827. @node create
  828. @section How to Create Archives
  829. @UNREVISED
  830. @cindex Creation of the archive
  831. @cindex Archive, creation of
  832. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  833. you use to create a @command{tar} archive. We will explain
  834. @option{--create} first because, in order to learn about the other
  835. operations, you will find it useful to have an archive available to
  836. practice on.
  837. To make this easier, in this section you will first create a directory
  838. containing three files. Then, we will show you how to create an
  839. @emph{archive} (inside the new directory). Both the directory, and
  840. the archive are specifically for you to practice on. The rest of this
  841. chapter and the next chapter will show many examples using this
  842. directory and the files you will create: some of those files may be
  843. other directories and other archives.
  844. The three files you will archive in this example are called
  845. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  846. @file{collection.tar}.
  847. This section will proceed slowly, detailing how to use @option{--create}
  848. in @code{verbose} mode, and showing examples using both short and long
  849. forms. In the rest of the tutorial, and in the examples in the next
  850. chapter, we will proceed at a slightly quicker pace. This section
  851. moves more slowly to allow beginning users to understand how
  852. @command{tar} works.
  853. @menu
  854. * prepare for examples::
  855. * Creating the archive::
  856. * create verbose::
  857. * short create::
  858. * create dir::
  859. @end menu
  860. @node prepare for examples
  861. @subsection Preparing a Practice Directory for Examples
  862. To follow along with this and future examples, create a new directory
  863. called @file{practice} containing files called @file{blues}, @file{folk}
  864. and @file{jazz}. The files can contain any information you like:
  865. ideally, they should contain information which relates to their names,
  866. and be of different lengths. Our examples assume that @file{practice}
  867. is a subdirectory of your home directory.
  868. Now @command{cd} to the directory named @file{practice}; @file{practice}
  869. is now your @dfn{working directory}. (@emph{Please note}: Although
  870. the full file name of this directory is
  871. @file{/@var{homedir}/practice}, in our examples we will refer to
  872. this directory as @file{practice}; the @var{homedir} is presumed.)
  873. In general, you should check that the files to be archived exist where
  874. you think they do (in the working directory) by running @command{ls}.
  875. Because you just created the directory and the files and have changed to
  876. that directory, you probably don't need to do that this time.
  877. It is very important to make sure there isn't already a file in the
  878. working directory with the archive name you intend to use (in this case,
  879. @samp{collection.tar}), or that you don't care about its contents.
  880. Whenever you use @samp{create}, @command{tar} will erase the current
  881. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  882. will not tell you if you are about to overwrite an archive unless you
  883. specify an option which does this (@pxref{backup}, for the
  884. information on how to do so). To add files to an existing archive,
  885. you need to use a different option, such as @option{--append} (@option{-r}); see
  886. @ref{append} for information on how to do this.
  887. @node Creating the archive
  888. @subsection Creating the Archive
  889. @xopindex{create, introduced}
  890. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  891. archive named @file{collection.tar}, use the following command:
  892. @smallexample
  893. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  894. @end smallexample
  895. The order of the arguments is not very important, @emph{when using long
  896. option forms}. You could also say:
  897. @smallexample
  898. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  899. @end smallexample
  900. @noindent
  901. However, you can see that this order is harder to understand; this is
  902. why we will list the arguments in the order that makes the commands
  903. easiest to understand (and we encourage you to do the same when you use
  904. @command{tar}, to avoid errors).
  905. Note that the sequence
  906. @option{--file=@-collection.tar} is considered to be @emph{one} argument.
  907. If you substituted any other string of characters for
  908. @kbd{collection.tar}, then that string would become the name of the
  909. archive file you create.
  910. The order of the options becomes more important when you begin to use
  911. short forms. With short forms, if you type commands in the wrong order
  912. (even if you type them correctly in all other ways), you may end up with
  913. results you don't expect. For this reason, it is a good idea to get
  914. into the habit of typing options in the order that makes inherent sense.
  915. @xref{short create}, for more information on this.
  916. In this example, you type the command as shown above: @option{--create}
  917. is the operation which creates the new archive
  918. (@file{collection.tar}), and @option{--file} is the option which lets
  919. you give it the name you chose. The files, @file{blues}, @file{folk},
  920. and @file{jazz}, are now members of the archive, @file{collection.tar}
  921. (they are @dfn{file name arguments} to the @option{--create} operation.
  922. @xref{Choosing}, for the detailed discussion on these.) Now that they are
  923. in the archive, they are called @emph{archive members}, not files.
  924. (@pxref{Definitions,members}).
  925. When you create an archive, you @emph{must} specify which files you
  926. want placed in the archive. If you do not specify any archive
  927. members, @GNUTAR{} will complain.
  928. If you now list the contents of the working directory (@command{ls}), you will
  929. find the archive file listed as well as the files you saw previously:
  930. @smallexample
  931. blues folk jazz collection.tar
  932. @end smallexample
  933. @noindent
  934. Creating the archive @samp{collection.tar} did not destroy the copies of
  935. the files in the directory.
  936. Keep in mind that if you don't indicate an operation, @command{tar} will not
  937. run and will prompt you for one. If you don't name any files, @command{tar}
  938. will complain. You must have write access to the working directory,
  939. or else you will not be able to create an archive in that directory.
  940. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  941. an existing archive; it will delete the archive and write a new one.
  942. Use @option{--append} (@option{-r}) instead. @xref{append}.
  943. @node create verbose
  944. @subsection Running @option{--create} with @option{--verbose}
  945. @xopindex{create, using with @option{--verbose}}
  946. @xopindex{verbose, using with @option{--create}}
  947. If you include the @option{--verbose} (@option{-v}) option on the command line,
  948. @command{tar} will list the files it is acting on as it is working. In
  949. verbose mode, the @code{create} example above would appear as:
  950. @smallexample
  951. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  952. blues
  953. folk
  954. jazz
  955. @end smallexample
  956. This example is just like the example we showed which did not use
  957. @option{--verbose}, except that @command{tar} generated the remaining
  958. @iftex
  959. lines (note the different font styles).
  960. @end iftex
  961. @ifinfo
  962. lines.
  963. @end ifinfo
  964. In the rest of the examples in this chapter, we will frequently use
  965. @code{verbose} mode so we can show actions or @command{tar} responses that
  966. you would otherwise not see, and which are important for you to
  967. understand.
  968. @node short create
  969. @subsection Short Forms with @samp{create}
  970. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  971. basic uses of @command{tar}, and you will use it countless times.
  972. Eventually, you will probably want to use abbreviated (or ``short'')
  973. forms of options. A full discussion of the three different forms that
  974. options can take appears in @ref{Styles}; for now, here is what the
  975. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  976. using short option forms:
  977. @smallexample
  978. $ @kbd{tar -cvf collection.tar blues folk jazz}
  979. blues
  980. folk
  981. jazz
  982. @end smallexample
  983. @noindent
  984. As you can see, the system responds the same no matter whether you use
  985. long or short option forms.
  986. @FIXME{i don't like how this is worded:} One difference between using
  987. short and long option forms is that, although the exact placement of
  988. arguments following options is no more specific when using short forms,
  989. it is easier to become confused and make a mistake when using short
  990. forms. For example, suppose you attempted the above example in the
  991. following way:
  992. @smallexample
  993. $ @kbd{tar -cfv collection.tar blues folk jazz}
  994. @end smallexample
  995. @noindent
  996. In this case, @command{tar} will make an archive file called @file{v},
  997. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  998. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  999. is thus taken to be the chosen archive file name. @command{tar} will try
  1000. to add a file called @file{collection.tar} to the @file{v} archive file;
  1001. if the file @file{collection.tar} did not already exist, @command{tar} will
  1002. report an error indicating that this file does not exist. If the file
  1003. @file{collection.tar} does already exist (e.g., from a previous command
  1004. you may have run), then @command{tar} will add this file to the archive.
  1005. Because the @option{-v} option did not get registered, @command{tar} will not
  1006. run under @samp{verbose} mode, and will not report its progress.
  1007. The end result is that you may be quite confused about what happened,
  1008. and possibly overwrite a file. To illustrate this further, we will show
  1009. you how an example we showed previously would look using short forms.
  1010. This example,
  1011. @smallexample
  1012. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1013. @end smallexample
  1014. @noindent
  1015. is confusing as it is. When shown using short forms, however, it
  1016. becomes much more so:
  1017. @smallexample
  1018. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1019. @end smallexample
  1020. @noindent
  1021. It would be very easy to put the wrong string of characters
  1022. immediately following the @option{-f}, but doing that could sacrifice
  1023. valuable data.
  1024. For this reason, we recommend that you pay very careful attention to
  1025. the order of options and placement of file and archive names,
  1026. especially when using short option forms. Not having the option name
  1027. written out mnemonically can affect how well you remember which option
  1028. does what, and therefore where different names have to be placed.
  1029. @node create dir
  1030. @subsection Archiving Directories
  1031. @cindex Archiving Directories
  1032. @cindex Directories, Archiving
  1033. You can archive a directory by specifying its directory name as a
  1034. file name argument to @command{tar}. The files in the directory will be
  1035. archived relative to the working directory, and the directory will be
  1036. re-created along with its contents when the archive is extracted.
  1037. To archive a directory, first move to its superior directory. If you
  1038. have followed the previous instructions in this tutorial, you should
  1039. type:
  1040. @smallexample
  1041. $ @kbd{cd ..}
  1042. $
  1043. @end smallexample
  1044. @noindent
  1045. This will put you into the directory which contains @file{practice},
  1046. i.e., your home directory. Once in the superior directory, you can
  1047. specify the subdirectory, @file{practice}, as a file name argument. To
  1048. store @file{practice} in the new archive file @file{music.tar}, type:
  1049. @smallexample
  1050. $ @kbd{tar --create --verbose --file=music.tar practice}
  1051. @end smallexample
  1052. @noindent
  1053. @command{tar} should output:
  1054. @smallexample
  1055. practice/
  1056. practice/blues
  1057. practice/folk
  1058. practice/jazz
  1059. practice/collection.tar
  1060. @end smallexample
  1061. Note that the archive thus created is not in the subdirectory
  1062. @file{practice}, but rather in the current working directory---the
  1063. directory from which @command{tar} was invoked. Before trying to archive a
  1064. directory from its superior directory, you should make sure you have
  1065. write access to the superior directory itself, not only the directory
  1066. you are trying archive with @command{tar}. For example, you will probably
  1067. not be able to store your home directory in an archive by invoking
  1068. @command{tar} from the root directory; @xref{absolute}. (Note
  1069. also that @file{collection.tar}, the original archive file, has itself
  1070. been archived. @command{tar} will accept any file as a file to be
  1071. archived, regardless of its content. When @file{music.tar} is
  1072. extracted, the archive file @file{collection.tar} will be re-written
  1073. into the file system).
  1074. If you give @command{tar} a command such as
  1075. @smallexample
  1076. $ @kbd{tar --create --file=foo.tar .}
  1077. @end smallexample
  1078. @noindent
  1079. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1080. dumped}. This happens because @command{tar} creates the archive
  1081. @file{foo.tar} in the current directory before putting any files into
  1082. it. Then, when @command{tar} attempts to add all the files in the
  1083. directory @file{.} to the archive, it notices that the file
  1084. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1085. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1086. will continue in this case, and create the archive
  1087. normally, except for the exclusion of that one file. (@emph{Please
  1088. note:} Other implementations of @command{tar} may not be so clever;
  1089. they will enter an infinite loop when this happens, so you should not
  1090. depend on this behavior unless you are certain you are running
  1091. @GNUTAR{}. In general, it is wise to always place the archive outside
  1092. of the directory being dumped.)
  1093. @node list
  1094. @section How to List Archives
  1095. @opindex list
  1096. Frequently, you will find yourself wanting to determine exactly what a
  1097. particular archive contains. You can use the @option{--list}
  1098. (@option{-t}) operation to get the member names as they currently
  1099. appear in the archive, as well as various attributes of the files at
  1100. the time they were archived. For example, you can examine the archive
  1101. @file{collection.tar} that you created in the last section with the
  1102. command,
  1103. @smallexample
  1104. $ @kbd{tar --list --file=collection.tar}
  1105. @end smallexample
  1106. @noindent
  1107. The output of @command{tar} would then be:
  1108. @smallexample
  1109. blues
  1110. folk
  1111. jazz
  1112. @end smallexample
  1113. @noindent
  1114. The archive @file{bfiles.tar} would list as follows:
  1115. @smallexample
  1116. ./birds
  1117. baboon
  1118. ./box
  1119. @end smallexample
  1120. @noindent
  1121. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1122. @var{archive-name}}) option just as with @option{--create}
  1123. (@option{-c}) to specify the name of the archive.
  1124. @xopindex{list, using with @option{--verbose}}
  1125. @xopindex{verbose, using with @option{--list}}
  1126. If you use the @option{--verbose} (@option{-v}) option with
  1127. @option{--list}, then @command{tar} will print out a listing
  1128. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so
  1129. forth. This output is described in detail in @ref{verbose member listing}.
  1130. If you had used @option{--verbose} (@option{-v}) mode, the example
  1131. above would look like:
  1132. @smallexample
  1133. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1134. -rw-r--r-- myself/user 62 1990-05-23 10:55 folk
  1135. @end smallexample
  1136. @cindex listing member and file names
  1137. @anchor{listing member and file names}
  1138. It is important to notice that the output of @kbd{tar --list
  1139. --verbose} does not necessarily match that produced by @kbd{tar
  1140. --create --verbose} while creating the archive. It is because
  1141. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1142. prefixes from file names before storing them in the archive
  1143. (@xref{absolute}, for more information). In other
  1144. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1145. an archive and @dfn{member names} when listing it. Consider this
  1146. example:
  1147. @smallexample
  1148. @group
  1149. $ @kbd{tar --create --verbose --file archive /etc/mail}
  1150. tar: Removing leading `/' from member names
  1151. /etc/mail/
  1152. /etc/mail/sendmail.cf
  1153. /etc/mail/aliases
  1154. $ @kbd{tar --test --file archive}
  1155. etc/mail/
  1156. etc/mail/sendmail.cf
  1157. etc/mail/aliases
  1158. @end group
  1159. @end smallexample
  1160. @opindex show-stored-names
  1161. This default behavior can sometimes be inconvenient. You can force
  1162. @GNUTAR{} show member names when creating archive by supplying
  1163. @option{--show-stored-names} option.
  1164. @table @option
  1165. @item --show-stored-names
  1166. Print member (as opposed to @emph{file}) names when creating the archive.
  1167. @end table
  1168. @cindex File name arguments, using @option{--list} with
  1169. @xopindex{list, using with file name arguments}
  1170. You can specify one or more individual member names as arguments when
  1171. using @samp{list}. In this case, @command{tar} will only list the
  1172. names of members you identify. For example, @w{@kbd{tar --list
  1173. --file=afiles.tar apple}} would only print @file{apple}.
  1174. Because @command{tar} preserves file names, these must be specified as
  1175. they appear in the archive (i.e., relative to the directory from which
  1176. the archive was created). Therefore, it is essential when specifying
  1177. member names to @command{tar} that you give the exact member names.
  1178. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1179. error message something like @samp{tar: birds: Not found in archive},
  1180. because there is no member named @file{birds}, only one named
  1181. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1182. the same file, @emph{member} names by default are compared verbatim.
  1183. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1184. with @file{baboon}, because this exact member name is in the archive file
  1185. @file{bfiles.tar}. If you are not sure of the exact file name,
  1186. use @dfn{globbing patterns}, for example:
  1187. @smallexample
  1188. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1189. @end smallexample
  1190. @noindent
  1191. will list all members whose name contains @samp{b}. @xref{wildcards},
  1192. for a detailed discussion of globbing patterns and related
  1193. @command{tar} command line options.
  1194. @menu
  1195. * list dir::
  1196. @end menu
  1197. @node list dir
  1198. @unnumberedsubsec Listing the Contents of a Stored Directory
  1199. To get information about the contents of an archived directory,
  1200. use the directory name as a file name argument in conjunction with
  1201. @option{--list} (@option{-t}). To find out file attributes, include the
  1202. @option{--verbose} (@option{-v}) option.
  1203. For example, to find out about files in the directory @file{practice}, in
  1204. the archive file @file{music.tar}, type:
  1205. @smallexample
  1206. $ @kbd{tar --list --verbose --file=music.tar practice}
  1207. @end smallexample
  1208. @command{tar} responds:
  1209. @smallexample
  1210. drwxrwxrwx myself/user 0 1990-05-31 21:49 practice/
  1211. -rw-r--r-- myself/user 42 1990-05-21 13:29 practice/blues
  1212. -rw-r--r-- myself/user 62 1990-05-23 10:55 practice/folk
  1213. -rw-r--r-- myself/user 40 1990-05-21 13:30 practice/jazz
  1214. -rw-r--r-- myself/user 10240 1990-05-31 21:49 practice/collection.tar
  1215. @end smallexample
  1216. When you use a directory name as a file name argument, @command{tar} acts on
  1217. all the files (including sub-directories) in that directory.
  1218. @node extract
  1219. @section How to Extract Members from an Archive
  1220. @cindex Extraction
  1221. @cindex Retrieving files from an archive
  1222. @cindex Resurrecting files from an archive
  1223. @opindex extract
  1224. Creating an archive is only half the job---there is no point in storing
  1225. files in an archive if you can't retrieve them. The act of retrieving
  1226. members from an archive so they can be used and manipulated as
  1227. unarchived files again is called @dfn{extraction}. To extract files
  1228. from an archive, use the @option{--extract} (@option{--get} or
  1229. @option{-x}) operation. As with @option{--create}, specify the name
  1230. of the archive with @option{--file} (@option{-f}) option. Extracting
  1231. an archive does not modify the archive in any way; you can extract it
  1232. multiple times if you want or need to.
  1233. Using @option{--extract}, you can extract an entire archive, or specific
  1234. files. The files can be directories containing other files, or not. As
  1235. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1236. long form of the operation without affecting the performance.
  1237. @menu
  1238. * extracting archives::
  1239. * extracting files::
  1240. * extract dir::
  1241. * extracting untrusted archives::
  1242. * failing commands::
  1243. @end menu
  1244. @node extracting archives
  1245. @subsection Extracting an Entire Archive
  1246. To extract an entire archive, specify the archive file name only, with
  1247. no individual file names as arguments. For example,
  1248. @smallexample
  1249. $ @kbd{tar -xvf collection.tar}
  1250. @end smallexample
  1251. @noindent
  1252. produces this:
  1253. @smallexample
  1254. -rw-r--r-- me/user 28 1996-10-18 16:31 jazz
  1255. -rw-r--r-- me/user 21 1996-09-23 16:44 blues
  1256. -rw-r--r-- me/user 20 1996-09-23 16:44 folk
  1257. @end smallexample
  1258. @node extracting files
  1259. @subsection Extracting Specific Files
  1260. To extract specific archive members, give their exact member names as
  1261. arguments, as printed by @option{--list} (@option{-t}). If you had
  1262. mistakenly deleted one of the files you had placed in the archive
  1263. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1264. from the archive without changing the archive's structure. Its
  1265. contents will be identical to the original file @file{blues} that you
  1266. deleted.
  1267. First, make sure you are in the @file{practice} directory, and list the
  1268. files in the directory. Now, delete the file, @samp{blues}, and list
  1269. the files in the directory again.
  1270. You can now extract the member @file{blues} from the archive file
  1271. @file{collection.tar} like this:
  1272. @smallexample
  1273. $ @kbd{tar --extract --file=collection.tar blues}
  1274. @end smallexample
  1275. @noindent
  1276. If you list the files in the directory again, you will see that the file
  1277. @file{blues} has been restored, with its original permissions, data
  1278. modification times, and owner.@footnote{This is only accidentally
  1279. true, but not in general. Whereas modification times are always
  1280. restored, in most cases, one has to be root for restoring the owner,
  1281. and use a special option for restoring permissions. Here, it just
  1282. happens that the restoring user is also the owner of the archived
  1283. members, and that the current @code{umask} is compatible with original
  1284. permissions.} (These parameters will be identical to those which
  1285. the file had when you originally placed it in the archive; any changes
  1286. you may have made before deleting the file from the file system,
  1287. however, will @emph{not} have been made to the archive member.) The
  1288. archive file, @samp{collection.tar}, is the same as it was before you
  1289. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1290. @option{--list} (@option{-t}).
  1291. Remember that as with other operations, specifying the exact member
  1292. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1293. will fail, because there is no member named @file{birds}. To extract
  1294. the member named @file{./birds}, you must specify @w{@kbd{tar
  1295. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1296. exact member names, use @option{--list} (@option{-t}) option
  1297. (@pxref{list}). You can also extract those members that match a
  1298. specific @dfn{globbing pattern}. For example, to extract from
  1299. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1300. directory prefix, you could type:
  1301. @smallexample
  1302. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1303. @end smallexample
  1304. @noindent
  1305. Here, @option{--wildcards} instructs @command{tar} to treat
  1306. command line arguments as globbing patterns and @option{--no-anchored}
  1307. informs it that the patterns apply to member names after any @samp{/}
  1308. delimiter. The use of globbing patterns is discussed in detail in
  1309. @xref{wildcards}.
  1310. You can extract a file to standard output by combining the above options
  1311. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1312. Output}).
  1313. If you give the @option{--verbose} option, then @option{--extract}
  1314. will print the names of the archive members as it extracts them.
  1315. @node extract dir
  1316. @subsection Extracting Files that are Directories
  1317. Extracting directories which are members of an archive is similar to
  1318. extracting other files. The main difference to be aware of is that if
  1319. the extracted directory has the same name as any directory already in
  1320. the working directory, then files in the extracted directory will be
  1321. placed into the directory of the same name. Likewise, if there are
  1322. files in the pre-existing directory with the same names as the members
  1323. which you extract, the files from the extracted archive will replace
  1324. the files already in the working directory (and possible
  1325. subdirectories). This will happen regardless of whether or not the
  1326. files in the working directory were more recent than those extracted
  1327. (there exist, however, special options that alter this behavior
  1328. @pxref{Writing}).
  1329. However, if a file was stored with a directory name as part of its file
  1330. name, and that directory does not exist under the working directory when
  1331. the file is extracted, @command{tar} will create the directory.
  1332. We can demonstrate how to use @option{--extract} to extract a directory
  1333. file with an example. Change to the @file{practice} directory if you
  1334. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1335. go back to the parent directory and extract the archive
  1336. @file{music.tar}. You may either extract the entire archive, or you may
  1337. extract only the files you just deleted. To extract the entire archive,
  1338. don't give any file names as arguments after the archive name
  1339. @file{music.tar}. To extract only the files you deleted, use the
  1340. following command:
  1341. @smallexample
  1342. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1343. practice/folk
  1344. practice/jazz
  1345. @end smallexample
  1346. @noindent
  1347. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1348. would have displayed more detail about the extracted files, as shown
  1349. in the example below:
  1350. @smallexample
  1351. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1352. -rw-r--r-- me/user 28 1996-10-18 16:31 practice/jazz
  1353. -rw-r--r-- me/user 20 1996-09-23 16:44 practice/folk
  1354. @end smallexample
  1355. @noindent
  1356. Because you created the directory with @file{practice} as part of the
  1357. file names of each of the files by archiving the @file{practice}
  1358. directory as @file{practice}, you must give @file{practice} as part
  1359. of the file names when you extract those files from the archive.
  1360. @node extracting untrusted archives
  1361. @subsection Extracting Archives from Untrusted Sources
  1362. Extracting files from archives can overwrite files that already exist.
  1363. If you receive an archive from an untrusted source, you should make a
  1364. new directory and extract into that directory, so that you don't have
  1365. to worry about the extraction overwriting one of your existing files.
  1366. For example, if @file{untrusted.tar} came from somewhere else on the
  1367. Internet, and you don't necessarily trust its contents, you can
  1368. extract it as follows:
  1369. @smallexample
  1370. $ @kbd{mkdir newdir}
  1371. $ @kbd{cd newdir}
  1372. $ @kbd{tar -xvf ../untrusted.tar}
  1373. @end smallexample
  1374. It is also a good practice to examine contents of the archive
  1375. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1376. with @option{--verbose} (@option{-v}).
  1377. @node failing commands
  1378. @subsection Commands That Will Fail
  1379. Here are some sample commands you might try which will not work, and why
  1380. they won't work.
  1381. If you try to use this command,
  1382. @smallexample
  1383. $ @kbd{tar -xvf music.tar folk jazz}
  1384. @end smallexample
  1385. @noindent
  1386. you will get the following response:
  1387. @smallexample
  1388. tar: folk: Not found in archive
  1389. tar: jazz: Not found in archive
  1390. @end smallexample
  1391. @noindent
  1392. This is because these files were not originally @emph{in} the parent
  1393. directory @file{..}, where the archive is located; they were in the
  1394. @file{practice} directory, and their file names reflect this:
  1395. @smallexample
  1396. $ @kbd{tar -tvf music.tar}
  1397. practice/blues
  1398. practice/folk
  1399. practice/jazz
  1400. @end smallexample
  1401. @FIXME{make sure the above works when going through the examples in
  1402. order...}
  1403. @noindent
  1404. Likewise, if you try to use this command,
  1405. @smallexample
  1406. $ @kbd{tar -tvf music.tar folk jazz}
  1407. @end smallexample
  1408. @noindent
  1409. you would get a similar response. Members with those names are not in the
  1410. archive. You must use the correct member names, or wildcards, in order
  1411. to extract the files from the archive.
  1412. If you have forgotten the correct names of the files in the archive,
  1413. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1414. @FIXME{more examples, here? hag thinks it's a good idea.}
  1415. @node going further
  1416. @section Going Further Ahead in this Manual
  1417. @UNREVISED
  1418. @FIXME{need to write up a node here about the things that are going to
  1419. be in the rest of the manual.}
  1420. @node tar invocation
  1421. @chapter Invoking @GNUTAR{}
  1422. This chapter is about how one invokes the @GNUTAR{}
  1423. command, from the command synopsis (@pxref{Synopsis}). There are
  1424. numerous options, and many styles for writing them. One mandatory
  1425. option specifies the operation @command{tar} should perform
  1426. (@pxref{Operation Summary}), other options are meant to detail how
  1427. this operation should be performed (@pxref{Option Summary}).
  1428. Non-option arguments are not always interpreted the same way,
  1429. depending on what the operation is.
  1430. You will find in this chapter everything about option styles and rules for
  1431. writing them (@pxref{Styles}). On the other hand, operations and options
  1432. are fully described elsewhere, in other chapters. Here, you will find
  1433. only synthetic descriptions for operations and options, together with
  1434. pointers to other parts of the @command{tar} manual.
  1435. Some options are so special they are fully described right in this
  1436. chapter. They have the effect of inhibiting the normal operation of
  1437. @command{tar} or else, they globally alter the amount of feedback the user
  1438. receives about what is going on. These are the @option{--help} and
  1439. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1440. and @option{--interactive} options (@pxref{interactive}).
  1441. @menu
  1442. * Synopsis::
  1443. * using tar options::
  1444. * Styles::
  1445. * All Options::
  1446. * help::
  1447. * defaults::
  1448. * verbose::
  1449. * checkpoints::
  1450. * warnings::
  1451. * interactive::
  1452. @end menu
  1453. @node Synopsis
  1454. @section General Synopsis of @command{tar}
  1455. The @GNUTAR{} program is invoked as either one of:
  1456. @smallexample
  1457. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1458. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1459. @end smallexample
  1460. The second form is for when old options are being used.
  1461. You can use @command{tar} to store files in an archive, to extract them from
  1462. an archive, and to do other types of archive manipulation. The primary
  1463. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1464. which action to take. The other arguments to @command{tar} are either
  1465. @dfn{options}, which change the way @command{tar} performs an operation,
  1466. or file names or archive members, which specify the files or members
  1467. @command{tar} is to act on.
  1468. You can actually type in arguments in any order, even if in this manual
  1469. the options always precede the other arguments, to make examples easier
  1470. to understand. Further, the option stating the main operation mode
  1471. (the @command{tar} main command) is usually given first.
  1472. Each @var{name} in the synopsis above is interpreted as an archive member
  1473. name when the main command is one of @option{--compare}
  1474. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1475. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1476. @option{--update} (@option{-u}). When naming archive members, you
  1477. must give the exact name of the member in the archive, as it is
  1478. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1479. @option{--create} (@option{-c}), these @var{name} arguments specify
  1480. the names of either files or directory hierarchies to place in the archive.
  1481. These files or hierarchies should already exist in the file system,
  1482. prior to the execution of the @command{tar} command.
  1483. @command{tar} interprets relative file names as being relative to the
  1484. working directory. @command{tar} will make all file names relative
  1485. (by removing leading slashes when archiving or restoring files),
  1486. unless you specify otherwise (using the @option{--absolute-names}
  1487. option). @xref{absolute}, for more information about
  1488. @option{--absolute-names}.
  1489. If you give the name of a directory as either a file name or a member
  1490. name, then @command{tar} acts recursively on all the files and directories
  1491. beneath that directory. For example, the name @file{/} identifies all
  1492. the files in the file system to @command{tar}.
  1493. The distinction between file names and archive member names is especially
  1494. important when shell globbing is used, and sometimes a source of confusion
  1495. for newcomers. @xref{wildcards}, for more information about globbing.
  1496. The problem is that shells may only glob using existing files in the
  1497. file system. Only @command{tar} itself may glob on archive members, so when
  1498. needed, you must ensure that wildcard characters reach @command{tar} without
  1499. being interpreted by the shell first. Using a backslash before @samp{*}
  1500. or @samp{?}, or putting the whole argument between quotes, is usually
  1501. sufficient for this.
  1502. Even if @var{name}s are often specified on the command line, they
  1503. can also be read from a text file in the file system, using the
  1504. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1505. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1506. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1507. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1508. will usually yield a diagnostic and inhibit @command{tar} execution.
  1509. The other operations of @command{tar} (@option{--list},
  1510. @option{--extract}, @option{--compare}, and @option{--update})
  1511. will act on the entire contents of the archive.
  1512. @cindex exit status
  1513. @cindex return status
  1514. Besides successful exits, @GNUTAR{} may fail for
  1515. many reasons. Some reasons correspond to bad usage, that is, when the
  1516. @command{tar} command line is improperly written. Errors may be
  1517. encountered later, while processing the archive or the files. Some
  1518. errors are recoverable, in which case the failure is delayed until
  1519. @command{tar} has completed all its work. Some errors are such that
  1520. it would be not meaningful, or at least risky, to continue processing:
  1521. @command{tar} then aborts processing immediately. All abnormal exits,
  1522. whether immediate or delayed, should always be clearly diagnosed on
  1523. @code{stderr}, after a line stating the nature of the error.
  1524. Possible exit codes of @GNUTAR{} are summarized in the following
  1525. table:
  1526. @table @asis
  1527. @item 0
  1528. @samp{Successful termination}.
  1529. @item 1
  1530. @samp{Some files differ}. If tar was invoked with @option{--compare}
  1531. (@option{--diff}, @option{-d}) command line option, this means that
  1532. some files in the archive differ from their disk counterparts
  1533. (@pxref{compare}). If tar was given @option{--create},
  1534. @option{--append} or @option{--update} option, this exit code means
  1535. that some files were changed while being archived and so the resulting
  1536. archive does not contain the exact copy of the file set.
  1537. @item 2
  1538. @samp{Fatal error}. This means that some fatal, unrecoverable error
  1539. occurred.
  1540. @end table
  1541. If @command{tar} has invoked a subprocess and that subprocess exited with a
  1542. nonzero exit code, @command{tar} exits with that code as well.
  1543. This can happen, for example, if @command{tar} was given some
  1544. compression option (@pxref{gzip}) and the external compressor program
  1545. failed. Another example is @command{rmt} failure during backup to the
  1546. remote device (@pxref{Remote Tape Server}).
  1547. @node using tar options
  1548. @section Using @command{tar} Options
  1549. @GNUTAR{} has a total of eight operating modes which
  1550. allow you to perform a variety of tasks. You are required to choose
  1551. one operating mode each time you employ the @command{tar} program by
  1552. specifying one, and only one operation as an argument to the
  1553. @command{tar} command (the corresponding options may be found
  1554. at @ref{frequent operations} and @ref{Operations}). Depending on
  1555. circumstances, you may also wish to customize how the chosen operating
  1556. mode behaves. For example, you may wish to change the way the output
  1557. looks, or the format of the files that you wish to archive may require
  1558. you to do something special in order to make the archive look right.
  1559. You can customize and control @command{tar}'s performance by running
  1560. @command{tar} with one or more options (such as @option{--verbose}
  1561. (@option{-v}), which we used in the tutorial). As we said in the
  1562. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1563. their name suggests) optional. Depending on the operating mode, you
  1564. may specify one or more options. Different options will have different
  1565. effects, but in general they all change details of the operation, such
  1566. as archive format, archive name, or level of user interaction. Some
  1567. options make sense with all operating modes, while others are
  1568. meaningful only with particular modes. You will likely use some
  1569. options frequently, while you will only use others infrequently, or
  1570. not at all. (A full list of options is available in @pxref{All Options}.)
  1571. @vrindex TAR_OPTIONS, environment variable
  1572. @anchor{TAR_OPTIONS}
  1573. The @env{TAR_OPTIONS} environment variable specifies default options to
  1574. be placed in front of any explicit options. For example, if
  1575. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1576. if the two options @option{-v} and @option{--unlink-first} had been
  1577. specified before any explicit options. Option specifications are
  1578. separated by whitespace. A backslash escapes the next character, so it
  1579. can be used to specify an option containing whitespace or a backslash.
  1580. Note that @command{tar} options are case sensitive. For example, the
  1581. options @option{-T} and @option{-t} are different; the first requires an
  1582. argument for stating the name of a file providing a list of @var{name}s,
  1583. while the second does not require an argument and is another way to
  1584. write @option{--list} (@option{-t}).
  1585. In addition to the eight operations, there are many options to
  1586. @command{tar}, and three different styles for writing both: long (mnemonic)
  1587. form, short form, and old style. These styles are discussed below.
  1588. Both the options and the operations can be written in any of these three
  1589. styles.
  1590. @FIXME{menu at end of this node. need to think of an actual outline
  1591. for this chapter; probably do that after stuff from chapter 4 is
  1592. incorporated.}
  1593. @node Styles
  1594. @section The Three Option Styles
  1595. There are three styles for writing operations and options to the command
  1596. line invoking @command{tar}. The different styles were developed at
  1597. different times during the history of @command{tar}. These styles will be
  1598. presented below, from the most recent to the oldest.
  1599. Some options must take an argument@footnote{For example, @option{--file}
  1600. (@option{-f}) takes the name of an archive file as an argument. If
  1601. you do not supply an archive file name, @command{tar} will use a
  1602. default, but this can be confusing; thus, we recommend that you always
  1603. supply a specific archive file name.}. Where you @emph{place} the
  1604. arguments generally depends on which style of options you choose. We
  1605. will detail specific information relevant to each option style in the
  1606. sections on the different option styles, below. The differences are
  1607. subtle, yet can often be very important; incorrect option placement
  1608. can cause you to overwrite a number of important files. We urge you
  1609. to note these differences, and only use the option style(s) which
  1610. makes the most sense to you until you feel comfortable with the others.
  1611. Some options @emph{may} take an argument. Such options may have at
  1612. most long and short forms, they do not have old style equivalent. The
  1613. rules for specifying an argument for such options are stricter than
  1614. those for specifying mandatory arguments. Please, pay special
  1615. attention to them.
  1616. @menu
  1617. * Long Options:: Long Option Style
  1618. * Short Options:: Short Option Style
  1619. * Old Options:: Old Option Style
  1620. * Mixing:: Mixing Option Styles
  1621. @end menu
  1622. @node Long Options
  1623. @subsection Long Option Style
  1624. @cindex long options
  1625. @cindex options, long style
  1626. @cindex options, GNU style
  1627. @cindex options, mnemonic names
  1628. Each option has at least one @dfn{long} (or @dfn{mnemonic}) name starting with two
  1629. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1630. their corresponding short or old names. It sometimes happens that a
  1631. single long option has many different names which are
  1632. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1633. long option names can be given unique abbreviations. For example,
  1634. @option{--cre} can be used in place of @option{--create} because there is no
  1635. other long option which begins with @samp{cre}. (One way to find
  1636. this out is by trying it and seeing what happens; if a particular
  1637. abbreviation could represent more than one option, @command{tar} will tell
  1638. you that that abbreviation is ambiguous and you'll know that that
  1639. abbreviation won't work. You may also choose to run @samp{tar --help}
  1640. to see a list of options. Be aware that if you run @command{tar} with a
  1641. unique abbreviation for the long name of an option you didn't want to
  1642. use, you are stuck; @command{tar} will perform the command as ordered.)
  1643. Long options are meant to be obvious and easy to remember, and their
  1644. meanings are generally easier to discern than those of their
  1645. corresponding short options (see below). For example:
  1646. @smallexample
  1647. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1648. @end smallexample
  1649. @noindent
  1650. gives a fairly good set of hints about what the command does, even
  1651. for those not fully acquainted with @command{tar}.
  1652. @cindex arguments to long options
  1653. @cindex long options with mandatory arguments
  1654. Long options which require arguments take those arguments
  1655. immediately following the option name. There are two ways of
  1656. specifying a mandatory argument. It can be separated from the
  1657. option name either by an equal sign, or by any amount of
  1658. white space characters. For example, the @option{--file} option (which
  1659. tells the name of the @command{tar} archive) is given a file such as
  1660. @file{archive.tar} as argument by using any of the following notations:
  1661. @option{--file=archive.tar} or @option{--file archive.tar}.
  1662. @cindex optional arguments to long options
  1663. @cindex long options with optional arguments
  1664. In contrast, optional arguments must always be introduced using
  1665. an equal sign. For example, the @option{--backup} option takes
  1666. an optional argument specifying backup type. It must be used
  1667. as @option{--backup=@var{backup-type}}.
  1668. @node Short Options
  1669. @subsection Short Option Style
  1670. @cindex short options
  1671. @cindex options, short style
  1672. @cindex options, traditional
  1673. Most options also have a @dfn{short option} name. Short options start with
  1674. a single dash, and are followed by a single character, e.g., @option{-t}
  1675. (which is equivalent to @option{--list}). The forms are absolutely
  1676. identical in function; they are interchangeable.
  1677. The short option names are faster to type than long option names.
  1678. @cindex arguments to short options
  1679. @cindex short options with mandatory arguments
  1680. Short options which require arguments take their arguments immediately
  1681. following the option, usually separated by white space. It is also
  1682. possible to stick the argument right after the short option name, using
  1683. no intervening space. For example, you might write @w{@option{-f
  1684. archive.tar}} or @option{-farchive.tar} instead of using
  1685. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1686. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1687. specific archive, here named @file{archive.tar}.
  1688. @cindex optional arguments to short options
  1689. @cindex short options with optional arguments
  1690. Short options which take optional arguments take their arguments
  1691. immediately following the option letter, @emph{without any intervening
  1692. white space characters}.
  1693. Short options' letters may be clumped together, but you are not
  1694. required to do this (as compared to old options; see below). When
  1695. short options are clumped as a set, use one (single) dash for them
  1696. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1697. such a set is allowed to have an argument@footnote{Clustering many
  1698. options, the last of which has an argument, is a rather opaque way to
  1699. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1700. even be made helpful enough for considering such usages as invalid.}.
  1701. When the options are separated, the argument for each option which requires
  1702. an argument directly follows that option, as is usual for Unix programs.
  1703. For example:
  1704. @smallexample
  1705. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1706. @end smallexample
  1707. If you reorder short options' locations, be sure to move any arguments
  1708. that belong to them. If you do not move the arguments properly, you may
  1709. end up overwriting files.
  1710. @node Old Options
  1711. @subsection Old Option Style
  1712. @cindex options, old style
  1713. @cindex old option style
  1714. @cindex option syntax, traditional
  1715. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1716. non-@acronym{GNU}, support @dfn{old options}: that is, if the first
  1717. argument does not start with @samp{-}, it is assumed to specify option
  1718. letters. @GNUTAR{} supports old options not only for historical
  1719. reasons, but also because many people are used to them. If the first
  1720. argument does not start with a dash, you are announcing the old option
  1721. style instead of the short option style; old options are decoded
  1722. differently.
  1723. Like short options, old options are single letters. However, old options
  1724. must be written together as a single clumped set, without spaces separating
  1725. them or dashes preceding them. This set
  1726. of letters must be the first to appear on the command line, after the
  1727. @command{tar} program name and some white space; old options cannot appear
  1728. anywhere else. The letter of an old option is exactly the same letter as
  1729. the corresponding short option. For example, the old option @samp{t} is
  1730. the same as the short option @option{-t}, and consequently, the same as the
  1731. long option @option{--list}. So for example, the command @w{@samp{tar
  1732. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1733. @cindex arguments to old options
  1734. @cindex old options with mandatory arguments
  1735. When options that need arguments are given together with the command,
  1736. all the associated arguments follow, in the same order as the options.
  1737. Thus, the example given previously could also be written in the old
  1738. style as follows:
  1739. @smallexample
  1740. $ @kbd{tar cvbf 20 /dev/rmt0}
  1741. @end smallexample
  1742. @noindent
  1743. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1744. the argument of @option{-f}.
  1745. The old style syntax can make it difficult to match
  1746. option letters with their corresponding arguments, and is often
  1747. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1748. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1749. argument for @option{-f}, and @option{-v} does not have a corresponding
  1750. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1751. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1752. pertain to.
  1753. If you want to reorder the letters in the old option argument, be
  1754. sure to reorder any corresponding argument appropriately.
  1755. This old way of writing @command{tar} options can surprise even experienced
  1756. users. For example, the two commands:
  1757. @smallexample
  1758. @kbd{tar cfz archive.tar.gz file}
  1759. @kbd{tar -cfz archive.tar.gz file}
  1760. @end smallexample
  1761. @noindent
  1762. are quite different. The first example uses @file{archive.tar.gz} as
  1763. the value for option @samp{f} and recognizes the option @samp{z}. The
  1764. second example, however, uses @file{z} as the value for option
  1765. @samp{f} --- probably not what was intended.
  1766. This second example could be corrected in many ways, among which the
  1767. following are equivalent:
  1768. @smallexample
  1769. @kbd{tar -czf archive.tar.gz file}
  1770. @kbd{tar -cf archive.tar.gz -z file}
  1771. @kbd{tar cf archive.tar.gz -z file}
  1772. @end smallexample
  1773. @node Mixing
  1774. @subsection Mixing Option Styles
  1775. @cindex options, mixing different styles
  1776. All three styles may be intermixed in a single @command{tar} command,
  1777. so long as the rules for each style are fully
  1778. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1779. a bug prevented intermixing old style options with long options in
  1780. some cases.}. Old style options and either of the modern styles of
  1781. options may be mixed within a single @command{tar} command. However,
  1782. old style options must be introduced as the first arguments only,
  1783. following the rule for old options (old options must appear directly
  1784. after the @command{tar} command and some white space). Modern options
  1785. may be given only after all arguments to the old options have been
  1786. collected. If this rule is not respected, a modern option might be
  1787. falsely interpreted as the value of the argument to one of the old
  1788. style options.
  1789. For example, all the following commands are wholly equivalent, and
  1790. illustrate the many combinations and orderings of option styles.
  1791. @smallexample
  1792. @kbd{tar --create --file=archive.tar}
  1793. @kbd{tar --create -f archive.tar}
  1794. @kbd{tar --create -farchive.tar}
  1795. @kbd{tar --file=archive.tar --create}
  1796. @kbd{tar --file=archive.tar -c}
  1797. @kbd{tar -c --file=archive.tar}
  1798. @kbd{tar -c -f archive.tar}
  1799. @kbd{tar -c -farchive.tar}
  1800. @kbd{tar -cf archive.tar}
  1801. @kbd{tar -cfarchive.tar}
  1802. @kbd{tar -f archive.tar --create}
  1803. @kbd{tar -f archive.tar -c}
  1804. @kbd{tar -farchive.tar --create}
  1805. @kbd{tar -farchive.tar -c}
  1806. @kbd{tar c --file=archive.tar}
  1807. @kbd{tar c -f archive.tar}
  1808. @kbd{tar c -farchive.tar}
  1809. @kbd{tar cf archive.tar}
  1810. @kbd{tar f archive.tar --create}
  1811. @kbd{tar f archive.tar -c}
  1812. @kbd{tar fc archive.tar}
  1813. @end smallexample
  1814. On the other hand, the following commands are @emph{not} equivalent to
  1815. the previous set:
  1816. @smallexample
  1817. @kbd{tar -f -c archive.tar}
  1818. @kbd{tar -fc archive.tar}
  1819. @kbd{tar -fcarchive.tar}
  1820. @kbd{tar -farchive.tarc}
  1821. @kbd{tar cfarchive.tar}
  1822. @end smallexample
  1823. @noindent
  1824. These last examples mean something completely different from what the
  1825. user intended (judging based on the example in the previous set which
  1826. uses long options, whose intent is therefore very clear). The first
  1827. four specify that the @command{tar} archive would be a file named
  1828. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1829. respectively. The first two examples also specify a single non-option,
  1830. @var{name} argument having the value @samp{archive.tar}. The last
  1831. example contains only old style option letters (repeating option
  1832. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1833. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1834. the first sentence of this paragraph..}
  1835. @node All Options
  1836. @section All @command{tar} Options
  1837. The coming manual sections contain an alphabetical listing of all
  1838. @command{tar} operations and options, with brief descriptions and
  1839. cross-references to more in-depth explanations in the body of the manual.
  1840. They also contain an alphabetically arranged table of the short option
  1841. forms with their corresponding long option. You can use this table as
  1842. a reference for deciphering @command{tar} commands in scripts.
  1843. @menu
  1844. * Operation Summary::
  1845. * Option Summary::
  1846. * Short Option Summary::
  1847. @end menu
  1848. @node Operation Summary
  1849. @subsection Operations
  1850. @table @option
  1851. @opsummary{append}
  1852. @item --append
  1853. @itemx -r
  1854. Appends files to the end of the archive. @xref{append}.
  1855. @opsummary{catenate}
  1856. @item --catenate
  1857. @itemx -A
  1858. Same as @option{--concatenate}. @xref{concatenate}.
  1859. @opsummary{compare}
  1860. @item --compare
  1861. @itemx -d
  1862. Compares archive members with their counterparts in the file
  1863. system, and reports differences in file size, mode, owner,
  1864. modification date and contents. @xref{compare}.
  1865. @opsummary{concatenate}
  1866. @item --concatenate
  1867. @itemx -A
  1868. Appends other @command{tar} archives to the end of the archive.
  1869. @xref{concatenate}.
  1870. @opsummary{create}
  1871. @item --create
  1872. @itemx -c
  1873. Creates a new @command{tar} archive. @xref{create}.
  1874. @opsummary{delete}
  1875. @item --delete
  1876. Deletes members from the archive. Don't try this on an archive on a
  1877. tape! @xref{delete}.
  1878. @opsummary{diff}
  1879. @item --diff
  1880. @itemx -d
  1881. Same @option{--compare}. @xref{compare}.
  1882. @opsummary{extract}
  1883. @item --extract
  1884. @itemx -x
  1885. Extracts members from the archive into the file system. @xref{extract}.
  1886. @opsummary{get}
  1887. @item --get
  1888. @itemx -x
  1889. Same as @option{--extract}. @xref{extract}.
  1890. @opsummary{list}
  1891. @item --list
  1892. @itemx -t
  1893. Lists the members in an archive. @xref{list}.
  1894. @opsummary{update}
  1895. @item --update
  1896. @itemx -u
  1897. Adds files to the end of the archive, but only if they are newer than
  1898. their counterparts already in the archive, or if they do not already
  1899. exist in the archive. @xref{update}.
  1900. @end table
  1901. @node Option Summary
  1902. @subsection @command{tar} Options
  1903. @table @option
  1904. @opsummary{absolute-names}
  1905. @item --absolute-names
  1906. @itemx -P
  1907. Normally when creating an archive, @command{tar} strips an initial
  1908. @samp{/} from member names. This option disables that behavior.
  1909. @xref{absolute}.
  1910. @opsummary{after-date}
  1911. @item --after-date
  1912. (See @option{--newer}, @pxref{after})
  1913. @opsummary{anchored}
  1914. @item --anchored
  1915. A pattern must match an initial subsequence of the name's components.
  1916. @xref{controlling pattern-matching}.
  1917. @opsummary{atime-preserve}
  1918. @item --atime-preserve
  1919. @itemx --atime-preserve=replace
  1920. @itemx --atime-preserve=system
  1921. Attempt to preserve the access time of files when reading them. This
  1922. option currently is effective only on files that you own, unless you
  1923. have superuser privileges.
  1924. @option{--atime-preserve=replace} remembers the access time of a file
  1925. before reading it, and then restores the access time afterwards. This
  1926. may cause problems if other programs are reading the file at the same
  1927. time, as the times of their accesses will be lost. On most platforms
  1928. restoring the access time also requires @command{tar} to restore the
  1929. data modification time too, so this option may also cause problems if
  1930. other programs are writing the file at the same time (@command{tar} attempts
  1931. to detect this situation, but cannot do so reliably due to race
  1932. conditions). Worse, on most platforms restoring the access time also
  1933. updates the status change time, which means that this option is
  1934. incompatible with incremental backups.
  1935. @option{--atime-preserve=system} avoids changing time stamps on files,
  1936. without interfering with time stamp updates
  1937. caused by other programs, so it works better with incremental backups.
  1938. However, it requires a special @code{O_NOATIME} option from the
  1939. underlying operating and file system implementation, and it also requires
  1940. that searching directories does not update their access times. As of
  1941. this writing (November 2005) this works only with Linux, and only with
  1942. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1943. way to know whether this feature actually works. Sometimes
  1944. @command{tar} knows that it does not work, and if you use
  1945. @option{--atime-preserve=system} then @command{tar} complains and
  1946. exits right away. But other times @command{tar} might think that the
  1947. option works when it actually does not.
  1948. Currently @option{--atime-preserve} with no operand defaults to
  1949. @option{--atime-preserve=replace}, but this may change in the future
  1950. as support for @option{--atime-preserve=system} improves.
  1951. If your operating or file system does not support
  1952. @option{--atime-preserve=@-system}, you might be able to preserve access
  1953. times reliably by using the @command{mount} command. For example,
  1954. you can mount the file system read-only, or access the file system via
  1955. a read-only loopback mount, or use the @samp{noatime} mount option
  1956. available on some systems. However, mounting typically requires
  1957. superuser privileges and can be a pain to manage.
  1958. @opsummary{auto-compress}
  1959. @item --auto-compress
  1960. @itemx -a
  1961. During a @option{--create} operation, enables automatic compressed
  1962. format recognition based on the archive suffix. The effect of this
  1963. option is cancelled by @option{--no-auto-compress}. @xref{gzip}.
  1964. @opsummary{backup}
  1965. @item --backup=@var{backup-type}
  1966. Rather than deleting files from the file system, @command{tar} will
  1967. back them up using simple or numbered backups, depending upon
  1968. @var{backup-type}. @xref{backup}.
  1969. @opsummary{block-number}
  1970. @item --block-number
  1971. @itemx -R
  1972. With this option present, @command{tar} prints error messages for read errors
  1973. with the block number in the archive file. @xref{block-number}.
  1974. @opsummary{blocking-factor}
  1975. @item --blocking-factor=@var{blocking}
  1976. @itemx -b @var{blocking}
  1977. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1978. record. @xref{Blocking Factor}.
  1979. @opsummary{bzip2}
  1980. @item --bzip2
  1981. @itemx -j
  1982. This option tells @command{tar} to read or write archives through
  1983. @code{bzip2}. @xref{gzip}.
  1984. @opsummary{check-device}
  1985. @item --check-device
  1986. Check device numbers when creating a list of modified files for
  1987. incremental archiving. This is the default. @xref{device numbers},
  1988. for a detailed description.
  1989. @opsummary{checkpoint}
  1990. @item --checkpoint[=@var{number}]
  1991. This option directs @command{tar} to print periodic checkpoint
  1992. messages as it reads through the archive. It is intended for when you
  1993. want a visual indication that @command{tar} is still running, but
  1994. don't want to see @option{--verbose} output. You can also instruct
  1995. @command{tar} to execute a list of actions on each checkpoint, see
  1996. @option{--checkpoint-action} below. For a detailed description, see
  1997. @ref{checkpoints}.
  1998. @opsummary{checkpoint-action}
  1999. @item --checkpoint-action=@var{action}
  2000. Instruct @command{tar} to execute an action upon hitting a
  2001. breakpoint. Here we give only a brief outline. @xref{checkpoints},
  2002. for a complete description.
  2003. The @var{action} argument can be one of the following:
  2004. @table @asis
  2005. @item bell
  2006. Produce an audible bell on the console.
  2007. @item dot
  2008. @itemx .
  2009. Print a single dot on the standard listing stream.
  2010. @item echo
  2011. Display a textual message on the standard error, with the status and
  2012. number of the checkpoint. This is the default.
  2013. @item echo=@var{string}
  2014. Display @var{string} on the standard error. Before output, the string
  2015. is subject to meta-character expansion.
  2016. @item exec=@var{command}
  2017. Execute the given @var{command}.
  2018. @item sleep=@var{time}
  2019. Wait for @var{time} seconds.
  2020. @item ttyout=@var{string}
  2021. Output @var{string} on the current console (@file{/dev/tty}).
  2022. @end table
  2023. Several @option{--checkpoint-action} options can be specified. The
  2024. supplied actions will be executed in order of their appearance in the
  2025. command line.
  2026. Using @option{--checkpoint-action} without @option{--checkpoint}
  2027. assumes default checkpoint frequency of one checkpoint per 10 records.
  2028. @opsummary{check-links}
  2029. @item --check-links
  2030. @itemx -l
  2031. If this option was given, @command{tar} will check the number of links
  2032. dumped for each processed file. If this number does not match the
  2033. total number of hard links for the file, a warning message will be
  2034. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2035. synonym for @option{--one-file-system}. The current semantics, which
  2036. complies to UNIX98, was introduced with version
  2037. 1.15.91. @xref{Changes}, for more information.}.
  2038. @xref{hard links}.
  2039. @opsummary{compress}
  2040. @opsummary{uncompress}
  2041. @item --compress
  2042. @itemx --uncompress
  2043. @itemx -Z
  2044. @command{tar} will use the @command{compress} program when reading or
  2045. writing the archive. This allows you to directly act on archives
  2046. while saving space. @xref{gzip}.
  2047. @opsummary{confirmation}
  2048. @item --confirmation
  2049. (See @option{--interactive}.) @xref{interactive}.
  2050. @opsummary{delay-directory-restore}
  2051. @item --delay-directory-restore
  2052. Delay setting modification times and permissions of extracted
  2053. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  2054. @opsummary{dereference}
  2055. @item --dereference
  2056. @itemx -h
  2057. When reading or writing a file to be archived, @command{tar} accesses
  2058. the file that a symbolic link points to, rather than the symlink
  2059. itself. @xref{dereference}.
  2060. @opsummary{directory}
  2061. @item --directory=@var{dir}
  2062. @itemx -C @var{dir}
  2063. When this option is specified, @command{tar} will change its current directory
  2064. to @var{dir} before performing any operations. When this option is used
  2065. during archive creation, it is order sensitive. @xref{directory}.
  2066. @opsummary{exclude}
  2067. @item --exclude=@var{pattern}
  2068. When performing operations, @command{tar} will skip files that match
  2069. @var{pattern}. @xref{exclude}.
  2070. @opsummary{exclude-backups}
  2071. @item --exclude-backups
  2072. Exclude backup and lock files. @xref{exclude,, exclude-backups}.
  2073. @opsummary{exclude-from}
  2074. @item --exclude-from=@var{file}
  2075. @itemx -X @var{file}
  2076. Similar to @option{--exclude}, except @command{tar} will use the list of
  2077. patterns in the file @var{file}. @xref{exclude}.
  2078. @opsummary{exclude-caches}
  2079. @item --exclude-caches
  2080. Exclude from dump any directory containing a valid cache directory
  2081. tag file, but still dump the directory node and the tag file itself.
  2082. @xref{exclude,, exclude-caches}.
  2083. @opsummary{exclude-caches-under}
  2084. @item --exclude-caches-under
  2085. Exclude from dump any directory containing a valid cache directory
  2086. tag file, but still dump the directory node itself.
  2087. @xref{exclude}.
  2088. @opsummary{exclude-caches-all}
  2089. @item --exclude-caches-all
  2090. Exclude from dump any directory containing a valid cache directory
  2091. tag file. @xref{exclude}.
  2092. @opsummary{exclude-tag}
  2093. @item --exclude-tag=@var{file}
  2094. Exclude from dump any directory containing file named @var{file}, but
  2095. dump the directory node and @var{file} itself. @xref{exclude,, exclude-tag}.
  2096. @opsummary{exclude-tag-under}
  2097. @item --exclude-tag-under=@var{file}
  2098. Exclude from dump the contents of any directory containing file
  2099. named @var{file}, but dump the directory node itself. @xref{exclude,,
  2100. exclude-tag-under}.
  2101. @opsummary{exclude-tag-all}
  2102. @item --exclude-tag-all=@var{file}
  2103. Exclude from dump any directory containing file named @var{file}.
  2104. @xref{exclude,,exclude-tag-all}.
  2105. @opsummary{exclude-vcs}
  2106. @item --exclude-vcs
  2107. Exclude from dump directories and files, that are internal for some
  2108. widely used version control systems.
  2109. @xref{exclude,,exclude-vcs}.
  2110. @opsummary{file}
  2111. @item --file=@var{archive}
  2112. @itemx -f @var{archive}
  2113. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2114. performs operations on, rather than @command{tar}'s compilation dependent
  2115. default. @xref{file tutorial}.
  2116. @opsummary{files-from}
  2117. @item --files-from=@var{file}
  2118. @itemx -T @var{file}
  2119. @command{tar} will use the contents of @var{file} as a list of archive members
  2120. or files to operate on, in addition to those specified on the
  2121. command-line. @xref{files}.
  2122. @opsummary{force-local}
  2123. @item --force-local
  2124. Forces @command{tar} to interpret the file name given to @option{--file}
  2125. as a local file, even if it looks like a remote tape drive name.
  2126. @xref{local and remote archives}.
  2127. @opsummary{format}
  2128. @item --format=@var{format}
  2129. @itemx -H @var{format}
  2130. Selects output archive format. @var{Format} may be one of the
  2131. following:
  2132. @table @samp
  2133. @item v7
  2134. Creates an archive that is compatible with Unix V7 @command{tar}.
  2135. @item oldgnu
  2136. Creates an archive that is compatible with GNU @command{tar} version
  2137. 1.12 or earlier.
  2138. @item gnu
  2139. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2140. @samp{oldgnu} with the only difference in the way it handles long
  2141. numeric fields.
  2142. @item ustar
  2143. Creates a @acronym{POSIX.1-1988} compatible archive.
  2144. @item posix
  2145. Creates a @acronym{POSIX.1-2001 archive}.
  2146. @end table
  2147. @xref{Formats}, for a detailed discussion of these formats.
  2148. @opsummary{full-time}
  2149. @item --full-time
  2150. This option instructs @command{tar} to print file times to their full
  2151. resolution. Usually this means 1-second resolution, but that depends
  2152. on the underlying file system. The @option{--full-time} option takes
  2153. effect only when detailed output (verbosity level 2 or higher) has
  2154. been requested using the @option{--verbose} option, e.g., when listing
  2155. or extracting archives:
  2156. @smallexample
  2157. $ @kbd{tar -t -v --full-time -f archive.tar}
  2158. @end smallexample
  2159. @noindent
  2160. or, when creating an archive:
  2161. @smallexample
  2162. $ @kbd{tar -c -vv --full-time -f archive.tar .}
  2163. @end smallexample
  2164. Notice, thar when creating the archive you need to specify
  2165. @option{--verbose} twice to get a detailed output (@pxref{verbose
  2166. tutorial}).
  2167. @opsummary{group}
  2168. @item --group=@var{group}
  2169. Files added to the @command{tar} archive will have a group @acronym{ID} of @var{group},
  2170. rather than the group from the source file. @var{group} can specify a
  2171. symbolic name, or a numeric @acronym{ID}, or both as
  2172. @var{name}:@var{id}. @xref{override}.
  2173. Also see the comments for the @option{--owner=@var{user}} option.
  2174. @opsummary{gzip}
  2175. @opsummary{gunzip}
  2176. @opsummary{ungzip}
  2177. @item --gzip
  2178. @itemx --gunzip
  2179. @itemx --ungzip
  2180. @itemx -z
  2181. This option tells @command{tar} to read or write archives through
  2182. @command{gzip}, allowing @command{tar} to directly operate on several
  2183. kinds of compressed archives transparently. @xref{gzip}.
  2184. @opsummary{hard-dereference}
  2185. @item --hard-dereference
  2186. When creating an archive, dereference hard links and store the files
  2187. they refer to, instead of creating usual hard link members.
  2188. @xref{hard links}.
  2189. @opsummary{help}
  2190. @item --help
  2191. @itemx -?
  2192. @command{tar} will print out a short message summarizing the operations and
  2193. options to @command{tar} and exit. @xref{help}.
  2194. @opsummary{ignore-case}
  2195. @item --ignore-case
  2196. Ignore case when matching member or file names with
  2197. patterns. @xref{controlling pattern-matching}.
  2198. @opsummary{ignore-command-error}
  2199. @item --ignore-command-error
  2200. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  2201. @opsummary{ignore-failed-read}
  2202. @item --ignore-failed-read
  2203. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2204. @xref{Reading}.
  2205. @opsummary{ignore-zeros}
  2206. @item --ignore-zeros
  2207. @itemx -i
  2208. With this option, @command{tar} will ignore zeroed blocks in the
  2209. archive, which normally signals EOF. @xref{Reading}.
  2210. @opsummary{incremental}
  2211. @item --incremental
  2212. @itemx -G
  2213. Informs @command{tar} that it is working with an old
  2214. @acronym{GNU}-format incremental backup archive. It is intended
  2215. primarily for backwards compatibility only. @xref{Incremental Dumps},
  2216. for a detailed discussion of incremental archives.
  2217. @opsummary{index-file}
  2218. @item --index-file=@var{file}
  2219. Send verbose output to @var{file} instead of to standard output.
  2220. @opsummary{info-script}
  2221. @opsummary{new-volume-script}
  2222. @item --info-script=@var{script-file}
  2223. @itemx --new-volume-script=@var{script-file}
  2224. @itemx -F @var{script-file}
  2225. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2226. at the end of each tape. If @var{script-file} exits with nonzero status,
  2227. @command{tar} fails immediately. @xref{info-script}, for a detailed
  2228. discussion of @var{script-file}.
  2229. @opsummary{interactive}
  2230. @item --interactive
  2231. @itemx --confirmation
  2232. @itemx -w
  2233. Specifies that @command{tar} should ask the user for confirmation before
  2234. performing potentially destructive options, such as overwriting files.
  2235. @xref{interactive}.
  2236. @opsummary{keep-newer-files}
  2237. @item --keep-newer-files
  2238. Do not replace existing files that are newer than their archive copies
  2239. when extracting files from an archive.
  2240. @opsummary{keep-old-files}
  2241. @item --keep-old-files
  2242. @itemx -k
  2243. Do not overwrite existing files when extracting files from an archive.
  2244. @xref{Keep Old Files}.
  2245. @opsummary{label}
  2246. @item --label=@var{name}
  2247. @itemx -V @var{name}
  2248. When creating an archive, instructs @command{tar} to write @var{name}
  2249. as a name record in the archive. When extracting or listing archives,
  2250. @command{tar} will only operate on archives that have a label matching
  2251. the pattern specified in @var{name}. @xref{Tape Files}.
  2252. @opsummary{level}
  2253. @item --level=@var{n}
  2254. Force incremental backup of level @var{n}. As of @GNUTAR version
  2255. @value{VERSION}, the option @option{--level=0} truncates the snapshot
  2256. file, thereby forcing the level 0 dump. Other values of @var{n} are
  2257. effectively ignored. @xref{--level=0}, for details and examples.
  2258. The use of this option is valid only in conjunction with the
  2259. @option{--listed-incremental} option. @xref{Incremental Dumps},
  2260. for a detailed description.
  2261. @opsummary{listed-incremental}
  2262. @item --listed-incremental=@var{snapshot-file}
  2263. @itemx -g @var{snapshot-file}
  2264. During a @option{--create} operation, specifies that the archive that
  2265. @command{tar} creates is a new @acronym{GNU}-format incremental
  2266. backup, using @var{snapshot-file} to determine which files to backup.
  2267. With other operations, informs @command{tar} that the archive is in
  2268. incremental format. @xref{Incremental Dumps}.
  2269. @opsummary{lzip}
  2270. @item --lzip
  2271. This option tells @command{tar} to read or write archives through
  2272. @command{lzip}. @xref{gzip}.
  2273. @opsummary{lzma}
  2274. @item --lzma
  2275. This option tells @command{tar} to read or write archives through
  2276. @command{lzma}. @xref{gzip}.
  2277. @item --lzop
  2278. This option tells @command{tar} to read or write archives through
  2279. @command{lzop}. @xref{gzip}.
  2280. @opsummary{mode}
  2281. @item --mode=@var{permissions}
  2282. When adding files to an archive, @command{tar} will use
  2283. @var{permissions} for the archive members, rather than the permissions
  2284. from the files. @var{permissions} can be specified either as an octal
  2285. number or as symbolic permissions, like with
  2286. @command{chmod}. @xref{override}.
  2287. @opsummary{mtime}
  2288. @item --mtime=@var{date}
  2289. When adding files to an archive, @command{tar} will use @var{date} as
  2290. the modification time of members when creating archives, instead of
  2291. their actual modification times. The value of @var{date} can be
  2292. either a textual date representation (@pxref{Date input formats}) or a
  2293. name of the existing file, starting with @samp{/} or @samp{.}. In the
  2294. latter case, the modification time of that file is used. @xref{override}.
  2295. @opsummary{multi-volume}
  2296. @item --multi-volume
  2297. @itemx -M
  2298. Informs @command{tar} that it should create or otherwise operate on a
  2299. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2300. @opsummary{new-volume-script}
  2301. @item --new-volume-script
  2302. (see @option{--info-script})
  2303. @opsummary{newer}
  2304. @item --newer=@var{date}
  2305. @itemx --after-date=@var{date}
  2306. @itemx -N
  2307. When creating an archive, @command{tar} will only add files that have changed
  2308. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2309. is taken to be the name of a file whose data modification time specifies
  2310. the date. @xref{after}.
  2311. @opsummary{newer-mtime}
  2312. @item --newer-mtime=@var{date}
  2313. Like @option{--newer}, but add only files whose
  2314. contents have changed (as opposed to just @option{--newer}, which will
  2315. also back up files for which any status information has
  2316. changed). @xref{after}.
  2317. @opsummary{no-anchored}
  2318. @item --no-anchored
  2319. An exclude pattern can match any subsequence of the name's components.
  2320. @xref{controlling pattern-matching}.
  2321. @opsummary{no-auto-compress}
  2322. @item --no-auto-compress
  2323. Disables automatic compressed format recognition based on the archive
  2324. suffix. @xref{--auto-compress}. @xref{gzip}.
  2325. @opsummary{no-check-device}
  2326. @item --no-check-device
  2327. Do not check device numbers when creating a list of modified files
  2328. for incremental archiving. @xref{device numbers}, for
  2329. a detailed description.
  2330. @opsummary{no-delay-directory-restore}
  2331. @item --no-delay-directory-restore
  2332. Modification times and permissions of extracted
  2333. directories are set when all files from this directory have been
  2334. extracted. This is the default.
  2335. @xref{Directory Modification Times and Permissions}.
  2336. @opsummary{no-ignore-case}
  2337. @item --no-ignore-case
  2338. Use case-sensitive matching.
  2339. @xref{controlling pattern-matching}.
  2340. @opsummary{no-ignore-command-error}
  2341. @item --no-ignore-command-error
  2342. Print warnings about subprocesses that terminated with a nonzero exit
  2343. code. @xref{Writing to an External Program}.
  2344. @opsummary{no-null}
  2345. @item --no-null
  2346. If the @option{--null} option was given previously, this option
  2347. cancels its effect, so that any following @option{--files-from}
  2348. options will expect their file lists to be newline-terminated.
  2349. @opsummary{no-overwrite-dir}
  2350. @item --no-overwrite-dir
  2351. Preserve metadata of existing directories when extracting files
  2352. from an archive. @xref{Overwrite Old Files}.
  2353. @opsummary{no-quote-chars}
  2354. @item --no-quote-chars=@var{string}
  2355. Remove characters listed in @var{string} from the list of quoted
  2356. characters set by the previous @option{--quote-chars} option
  2357. (@pxref{quoting styles}).
  2358. @opsummary{no-recursion}
  2359. @item --no-recursion
  2360. With this option, @command{tar} will not recurse into directories.
  2361. @xref{recurse}.
  2362. @opsummary{no-same-owner}
  2363. @item --no-same-owner
  2364. @itemx -o
  2365. When extracting an archive, do not attempt to preserve the owner
  2366. specified in the @command{tar} archive. This the default behavior
  2367. for ordinary users.
  2368. @opsummary{no-same-permissions}
  2369. @item --no-same-permissions
  2370. When extracting an archive, subtract the user's umask from files from
  2371. the permissions specified in the archive. This is the default behavior
  2372. for ordinary users.
  2373. @opsummary{no-seek}
  2374. @item --no-seek
  2375. The archive media does not support seeks to arbitrary
  2376. locations. Usually @command{tar} determines automatically whether
  2377. the archive can be seeked or not. Use this option to disable this
  2378. mechanism.
  2379. @opsummary{no-unquote}
  2380. @item --no-unquote
  2381. Treat all input file or member names literally, do not interpret
  2382. escape sequences. @xref{input name quoting}.
  2383. @opsummary{no-wildcards}
  2384. @item --no-wildcards
  2385. Do not use wildcards.
  2386. @xref{controlling pattern-matching}.
  2387. @opsummary{no-wildcards-match-slash}
  2388. @item --no-wildcards-match-slash
  2389. Wildcards do not match @samp{/}.
  2390. @xref{controlling pattern-matching}.
  2391. @opsummary{null}
  2392. @item --null
  2393. When @command{tar} is using the @option{--files-from} option, this option
  2394. instructs @command{tar} to expect file names terminated with @acronym{NUL}, so
  2395. @command{tar} can correctly work with file names that contain newlines.
  2396. @xref{nul}.
  2397. @opsummary{numeric-owner}
  2398. @item --numeric-owner
  2399. This option will notify @command{tar} that it should use numeric user
  2400. and group IDs when creating a @command{tar} file, rather than names.
  2401. @xref{Attributes}.
  2402. @item -o
  2403. The function of this option depends on the action @command{tar} is
  2404. performing. When extracting files, @option{-o} is a synonym for
  2405. @option{--no-same-owner}, i.e., it prevents @command{tar} from
  2406. restoring ownership of files being extracted.
  2407. When creating an archive, it is a synonym for
  2408. @option{--old-archive}. This behavior is for compatibility
  2409. with previous versions of @GNUTAR{}, and will be
  2410. removed in future releases.
  2411. @xref{Changes}, for more information.
  2412. @opsummary{occurrence}
  2413. @item --occurrence[=@var{number}]
  2414. This option can be used in conjunction with one of the subcommands
  2415. @option{--delete}, @option{--diff}, @option{--extract} or
  2416. @option{--list} when a list of files is given either on the command
  2417. line or via @option{-T} option.
  2418. This option instructs @command{tar} to process only the @var{number}th
  2419. occurrence of each named file. @var{Number} defaults to 1, so
  2420. @smallexample
  2421. tar -x -f archive.tar --occurrence filename
  2422. @end smallexample
  2423. @noindent
  2424. will extract the first occurrence of the member @file{filename} from @file{archive.tar}
  2425. and will terminate without scanning to the end of the archive.
  2426. @opsummary{old-archive}
  2427. @item --old-archive
  2428. Synonym for @option{--format=v7}.
  2429. @opsummary{one-file-system}
  2430. @item --one-file-system
  2431. Used when creating an archive. Prevents @command{tar} from recursing into
  2432. directories that are on different file systems from the current
  2433. directory.
  2434. @opsummary{overwrite}
  2435. @item --overwrite
  2436. Overwrite existing files and directory metadata when extracting files
  2437. from an archive. @xref{Overwrite Old Files}.
  2438. @opsummary{overwrite-dir}
  2439. @item --overwrite-dir
  2440. Overwrite the metadata of existing directories when extracting files
  2441. from an archive. @xref{Overwrite Old Files}.
  2442. @opsummary{owner}
  2443. @item --owner=@var{user}
  2444. Specifies that @command{tar} should use @var{user} as the owner of members
  2445. when creating archives, instead of the user associated with the source
  2446. file. @var{user} can specify a symbolic name, or a numeric
  2447. @acronym{ID}, or both as @var{name}:@var{id}.
  2448. @xref{override}.
  2449. This option does not affect extraction from archives.
  2450. @opsummary{pax-option}
  2451. @item --pax-option=@var{keyword-list}
  2452. This option enables creation of the archive in @acronym{POSIX.1-2001}
  2453. format (@pxref{posix}) and modifies the way @command{tar} handles the
  2454. extended header keywords. @var{Keyword-list} is a comma-separated
  2455. list of keyword options. @xref{PAX keywords}, for a detailed
  2456. discussion.
  2457. @opsummary{portability}
  2458. @item --portability
  2459. @itemx --old-archive
  2460. Synonym for @option{--format=v7}.
  2461. @opsummary{posix}
  2462. @item --posix
  2463. Same as @option{--format=posix}.
  2464. @opsummary{preserve}
  2465. @item --preserve
  2466. Synonymous with specifying both @option{--preserve-permissions} and
  2467. @option{--same-order}. @xref{Setting Access Permissions}.
  2468. @opsummary{preserve-order}
  2469. @item --preserve-order
  2470. (See @option{--same-order}; @pxref{Reading}.)
  2471. @opsummary{preserve-permissions}
  2472. @opsummary{same-permissions}
  2473. @item --preserve-permissions
  2474. @itemx --same-permissions
  2475. @itemx -p
  2476. When @command{tar} is extracting an archive, it normally subtracts the
  2477. users' umask from the permissions specified in the archive and uses
  2478. that number as the permissions to create the destination file.
  2479. Specifying this option instructs @command{tar} that it should use the
  2480. permissions directly from the archive. @xref{Setting Access Permissions}.
  2481. @opsummary{quote-chars}
  2482. @item --quote-chars=@var{string}
  2483. Always quote characters from @var{string}, even if the selected
  2484. quoting style would not quote them (@pxref{quoting styles}).
  2485. @opsummary{quoting-style}
  2486. @item --quoting-style=@var{style}
  2487. Set quoting style to use when printing member and file names
  2488. (@pxref{quoting styles}). Valid @var{style} values are:
  2489. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2490. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2491. style is @code{escape}, unless overridden while configuring the
  2492. package.
  2493. @opsummary{read-full-records}
  2494. @item --read-full-records
  2495. @itemx -B
  2496. Specifies that @command{tar} should reblock its input, for reading
  2497. from pipes on systems with buggy implementations. @xref{Reading}.
  2498. @opsummary{record-size}
  2499. @item --record-size=@var{size}[@var{suf}]
  2500. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2501. archive. The argument can be suffixed with a @dfn{size suffix}, e.g.
  2502. @option{--record-size=10K} for 10 Kilobytes. @xref{size-suffixes},
  2503. for a list of valid suffixes. @xref{Blocking Factor}, for a detailed
  2504. description of this option.
  2505. @opsummary{recursion}
  2506. @item --recursion
  2507. With this option, @command{tar} recurses into directories (default).
  2508. @xref{recurse}.
  2509. @opsummary{recursive-unlink}
  2510. @item --recursive-unlink
  2511. Remove existing
  2512. directory hierarchies before extracting directories of the same name
  2513. from the archive. @xref{Recursive Unlink}.
  2514. @opsummary{remove-files}
  2515. @item --remove-files
  2516. Directs @command{tar} to remove the source file from the file system after
  2517. appending it to an archive. @xref{remove files}.
  2518. @opsummary{restrict}
  2519. @item --restrict
  2520. Disable use of some potentially harmful @command{tar} options.
  2521. Currently this option disables shell invocation from multi-volume menu
  2522. (@pxref{Using Multiple Tapes}).
  2523. @opsummary{rmt-command}
  2524. @item --rmt-command=@var{cmd}
  2525. Notifies @command{tar} that it should use @var{cmd} instead of
  2526. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2527. @opsummary{rsh-command}
  2528. @item --rsh-command=@var{cmd}
  2529. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2530. devices. @xref{Device}.
  2531. @opsummary{same-order}
  2532. @item --same-order
  2533. @itemx --preserve-order
  2534. @itemx -s
  2535. This option is an optimization for @command{tar} when running on machines with
  2536. small amounts of memory. It informs @command{tar} that the list of file
  2537. arguments has already been sorted to match the order of files in the
  2538. archive. @xref{Reading}.
  2539. @opsummary{same-owner}
  2540. @item --same-owner
  2541. When extracting an archive, @command{tar} will attempt to preserve the owner
  2542. specified in the @command{tar} archive with this option present.
  2543. This is the default behavior for the superuser; this option has an
  2544. effect only for ordinary users. @xref{Attributes}.
  2545. @opsummary{same-permissions}
  2546. @item --same-permissions
  2547. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2548. @opsummary{seek}
  2549. @item --seek
  2550. @itemx -n
  2551. Assume that the archive media supports seeks to arbitrary
  2552. locations. Usually @command{tar} determines automatically whether
  2553. the archive can be seeked or not. This option is intended for use
  2554. in cases when such recognition fails. It takes effect only if the
  2555. archive is open for reading (e.g. with @option{--list} or
  2556. @option{--extract} options).
  2557. @opsummary{show-defaults}
  2558. @item --show-defaults
  2559. Displays the default options used by @command{tar} and exits
  2560. successfully. This option is intended for use in shell scripts.
  2561. Here is an example of what you can see using this option:
  2562. @smallexample
  2563. $ @kbd{tar --show-defaults}
  2564. --format=gnu -f- -b20 --quoting-style=escape
  2565. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2566. @end smallexample
  2567. @noindent
  2568. Notice, that this option outputs only one line. The example output
  2569. above has been split to fit page boundaries.
  2570. @opsummary{show-omitted-dirs}
  2571. @item --show-omitted-dirs
  2572. Instructs @command{tar} to mention the directories it is skipping when
  2573. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2574. @opsummary{show-transformed-names}
  2575. @opsummary{show-stored-names}
  2576. @item --show-transformed-names
  2577. @itemx --show-stored-names
  2578. Display file or member names after applying any transformations
  2579. (@pxref{transform}). In particular, when used in conjunction with one of
  2580. the archive creation operations it instructs @command{tar} to list the
  2581. member names stored in the archive, as opposed to the actual file
  2582. names. @xref{listing member and file names}.
  2583. @opsummary{sparse}
  2584. @item --sparse
  2585. @itemx -S
  2586. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2587. sparse files efficiently. @xref{sparse}.
  2588. @opsummary{sparse-version}
  2589. @item --sparse-version=@var{version}
  2590. Specifies the @dfn{format version} to use when archiving sparse
  2591. files. Implies @option{--sparse}. @xref{sparse}. For the description
  2592. of the supported sparse formats, @xref{Sparse Formats}.
  2593. @opsummary{starting-file}
  2594. @item --starting-file=@var{name}
  2595. @itemx -K @var{name}
  2596. This option affects extraction only; @command{tar} will skip extracting
  2597. files in the archive until it finds one that matches @var{name}.
  2598. @xref{Scarce}.
  2599. @opsummary{strip-components}
  2600. @item --strip-components=@var{number}
  2601. Strip given @var{number} of leading components from file names before
  2602. extraction. For example, if archive @file{archive.tar} contained
  2603. @file{/some/file/name}, then running
  2604. @smallexample
  2605. tar --extract --file archive.tar --strip-components=2
  2606. @end smallexample
  2607. @noindent
  2608. would extract this file to file @file{name}.
  2609. @opsummary{suffix}
  2610. @item --suffix=@var{suffix}
  2611. Alters the suffix @command{tar} uses when backing up files from the default
  2612. @samp{~}. @xref{backup}.
  2613. @opsummary{tape-length}
  2614. @item --tape-length=@var{num}[@var{suf}]
  2615. @itemx -L @var{num}[@var{suf}]
  2616. Specifies the length of tapes that @command{tar} is writing as being
  2617. @w{@var{num} x 1024} bytes long. If optional @var{suf} is given, it
  2618. specifies a multiplicative factor to be used instead of 1024. For
  2619. example, @samp{-L2M} means 2 megabytes. @xref{size-suffixes}, for a
  2620. list of allowed suffixes. @xref{Using Multiple Tapes}, for a detailed
  2621. discussion of this option.
  2622. @opsummary{test-label}
  2623. @item --test-label
  2624. Reads the volume label. If an argument is specified, test whether it
  2625. matches the volume label. @xref{--test-label option}.
  2626. @opsummary{to-command}
  2627. @item --to-command=@var{command}
  2628. During extraction @command{tar} will pipe extracted files to the
  2629. standard input of @var{command}. @xref{Writing to an External Program}.
  2630. @opsummary{to-stdout}
  2631. @item --to-stdout
  2632. @itemx -O
  2633. During extraction, @command{tar} will extract files to stdout rather
  2634. than to the file system. @xref{Writing to Standard Output}.
  2635. @opsummary{totals}
  2636. @item --totals[=@var{signo}]
  2637. Displays the total number of bytes transferred when processing an
  2638. archive. If an argument is given, these data are displayed on
  2639. request, when signal @var{signo} is delivered to @command{tar}.
  2640. @xref{totals}.
  2641. @opsummary{touch}
  2642. @item --touch
  2643. @itemx -m
  2644. Sets the data modification time of extracted files to the extraction time,
  2645. rather than the data modification time stored in the archive.
  2646. @xref{Data Modification Times}.
  2647. @opsummary{transform}
  2648. @opsummary{xform}
  2649. @item --transform=@var{sed-expr}
  2650. @itemx --xform=@var{sed-expr}
  2651. Transform file or member names using @command{sed} replacement expression
  2652. @var{sed-expr}. For example,
  2653. @smallexample
  2654. $ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
  2655. @end smallexample
  2656. @noindent
  2657. will add to @file{archive} files from the current working directory,
  2658. replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
  2659. discussion, @xref{transform}.
  2660. To see transformed member names in verbose listings, use
  2661. @option{--show-transformed-names} option
  2662. (@pxref{show-transformed-names}).
  2663. @opsummary{uncompress}
  2664. @item --uncompress
  2665. (See @option{--compress}, @pxref{gzip})
  2666. @opsummary{ungzip}
  2667. @item --ungzip
  2668. (See @option{--gzip}, @pxref{gzip})
  2669. @opsummary{unlink-first}
  2670. @item --unlink-first
  2671. @itemx -U
  2672. Directs @command{tar} to remove the corresponding file from the file
  2673. system before extracting it from the archive. @xref{Unlink First}.
  2674. @opsummary{unquote}
  2675. @item --unquote
  2676. Enable unquoting input file or member names (default). @xref{input
  2677. name quoting}.
  2678. @opsummary{use-compress-program}
  2679. @item --use-compress-program=@var{prog}
  2680. @itemx -I=@var{prog}
  2681. Instructs @command{tar} to access the archive through @var{prog}, which is
  2682. presumed to be a compression program of some sort. @xref{gzip}.
  2683. @opsummary{utc}
  2684. @item --utc
  2685. Display file modification dates in @acronym{UTC}. This option implies
  2686. @option{--verbose}.
  2687. @opsummary{verbose}
  2688. @item --verbose
  2689. @itemx -v
  2690. Specifies that @command{tar} should be more verbose about the
  2691. operations it is performing. This option can be specified multiple
  2692. times for some operations to increase the amount of information displayed.
  2693. @xref{verbose}.
  2694. @opsummary{verify}
  2695. @item --verify
  2696. @itemx -W
  2697. Verifies that the archive was correctly written when creating an
  2698. archive. @xref{verify}.
  2699. @opsummary{version}
  2700. @item --version
  2701. Print information about the program's name, version, origin and legal
  2702. status, all on standard output, and then exit successfully.
  2703. @xref{help}.
  2704. @opsummary{volno-file}
  2705. @item --volno-file=@var{file}
  2706. Used in conjunction with @option{--multi-volume}. @command{tar} will
  2707. keep track of which volume of a multi-volume archive it is working in
  2708. @var{file}. @xref{volno-file}.
  2709. @opsummary{warning}
  2710. @item --warning=@var{keyword}
  2711. Enable or disable warning messages identified by @var{keyword}. The
  2712. messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
  2713. @xref{warnings}.
  2714. @opsummary{wildcards}
  2715. @item --wildcards
  2716. Use wildcards when matching member names with patterns.
  2717. @xref{controlling pattern-matching}.
  2718. @opsummary{wildcards-match-slash}
  2719. @item --wildcards-match-slash
  2720. Wildcards match @samp{/}.
  2721. @xref{controlling pattern-matching}.
  2722. @opsummary{xz}
  2723. @item --xz
  2724. @itemx -J
  2725. Use @command{xz} for compressing or decompressing the archives. @xref{gzip}.
  2726. @end table
  2727. @node Short Option Summary
  2728. @subsection Short Options Cross Reference
  2729. Here is an alphabetized list of all of the short option forms, matching
  2730. them with the equivalent long option.
  2731. @multitable @columnfractions 0.20 0.80
  2732. @headitem Short Option @tab Reference
  2733. @item -A @tab @ref{--concatenate}.
  2734. @item -B @tab @ref{--read-full-records}.
  2735. @item -C @tab @ref{--directory}.
  2736. @item -F @tab @ref{--info-script}.
  2737. @item -G @tab @ref{--incremental}.
  2738. @item -J @tab @ref{--xz}.
  2739. @item -K @tab @ref{--starting-file}.
  2740. @item -L @tab @ref{--tape-length}.
  2741. @item -M @tab @ref{--multi-volume}.
  2742. @item -N @tab @ref{--newer}.
  2743. @item -O @tab @ref{--to-stdout}.
  2744. @item -P @tab @ref{--absolute-names}.
  2745. @item -R @tab @ref{--block-number}.
  2746. @item -S @tab @ref{--sparse}.
  2747. @item -T @tab @ref{--files-from}.
  2748. @item -U @tab @ref{--unlink-first}.
  2749. @item -V @tab @ref{--label}.
  2750. @item -W @tab @ref{--verify}.
  2751. @item -X @tab @ref{--exclude-from}.
  2752. @item -Z @tab @ref{--compress}.
  2753. @item -b @tab @ref{--blocking-factor}.
  2754. @item -c @tab @ref{--create}.
  2755. @item -d @tab @ref{--compare}.
  2756. @item -f @tab @ref{--file}.
  2757. @item -g @tab @ref{--listed-incremental}.
  2758. @item -h @tab @ref{--dereference}.
  2759. @item -i @tab @ref{--ignore-zeros}.
  2760. @item -j @tab @ref{--bzip2}.
  2761. @item -k @tab @ref{--keep-old-files}.
  2762. @item -l @tab @ref{--check-links}.
  2763. @item -m @tab @ref{--touch}.
  2764. @item -o @tab When creating, @ref{--no-same-owner}, when extracting ---
  2765. @ref{--portability}.
  2766. The latter usage is deprecated. It is retained for compatibility with
  2767. the earlier versions of @GNUTAR{}. In future releases
  2768. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2769. @item -p @tab @ref{--preserve-permissions}.
  2770. @item -r @tab @ref{--append}.
  2771. @item -s @tab @ref{--same-order}.
  2772. @item -t @tab @ref{--list}.
  2773. @item -u @tab @ref{--update}.
  2774. @item -v @tab @ref{--verbose}.
  2775. @item -w @tab @ref{--interactive}.
  2776. @item -x @tab @ref{--extract}.
  2777. @item -z @tab @ref{--gzip}.
  2778. @end multitable
  2779. @node help
  2780. @section @GNUTAR{} documentation
  2781. @cindex Getting program version number
  2782. @opindex version
  2783. @cindex Version of the @command{tar} program
  2784. Being careful, the first thing is really checking that you are using
  2785. @GNUTAR{}, indeed. The @option{--version} option
  2786. causes @command{tar} to print information about its name, version,
  2787. origin and legal status, all on standard output, and then exit
  2788. successfully. For example, @w{@samp{tar --version}} might print:
  2789. @smallexample
  2790. tar (GNU tar) @value{VERSION}
  2791. Copyright (C) 2011 Free Software Foundation, Inc.
  2792. Copyright (C) 2011 Free Software Foundation, Inc.
  2793. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
  2794. This is free software: you are free to change and redistribute it.
  2795. There is NO WARRANTY, to the extent permitted by law.
  2796. Written by John Gilmore and Jay Fenlason.
  2797. @end smallexample
  2798. @noindent
  2799. The first occurrence of @samp{tar} in the result above is the program
  2800. name in the package (for example, @command{rmt} is another program),
  2801. while the second occurrence of @samp{tar} is the name of the package
  2802. itself, containing possibly many programs. The package is currently
  2803. named @samp{tar}, after the name of the main program it
  2804. contains@footnote{There are plans to merge the @command{cpio} and
  2805. @command{tar} packages into a single one which would be called
  2806. @code{paxutils}. So, who knows if, one of this days, the
  2807. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2808. paxutils) 3.2}}.}.
  2809. @cindex Obtaining help
  2810. @cindex Listing all @command{tar} options
  2811. @xopindex{help, introduction}
  2812. Another thing you might want to do is checking the spelling or meaning
  2813. of some particular @command{tar} option, without resorting to this
  2814. manual, for once you have carefully read it. @GNUTAR{}
  2815. has a short help feature, triggerable through the
  2816. @option{--help} option. By using this option, @command{tar} will
  2817. print a usage message listing all available options on standard
  2818. output, then exit successfully, without doing anything else and
  2819. ignoring all other options. Even if this is only a brief summary, it
  2820. may be several screens long. So, if you are not using some kind of
  2821. scrollable window, you might prefer to use something like:
  2822. @smallexample
  2823. $ @kbd{tar --help | less}
  2824. @end smallexample
  2825. @noindent
  2826. presuming, here, that you like using @command{less} for a pager. Other
  2827. popular pagers are @command{more} and @command{pg}. If you know about some
  2828. @var{keyword} which interests you and do not want to read all the
  2829. @option{--help} output, another common idiom is doing:
  2830. @smallexample
  2831. tar --help | grep @var{keyword}
  2832. @end smallexample
  2833. @noindent
  2834. for getting only the pertinent lines. Notice, however, that some
  2835. @command{tar} options have long description lines and the above
  2836. command will list only the first of them.
  2837. The exact look of the option summary displayed by @kbd{tar --help} is
  2838. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2839. @opindex usage
  2840. If you only wish to check the spelling of an option, running @kbd{tar
  2841. --usage} may be a better choice. This will display a terse list of
  2842. @command{tar} options without accompanying explanations.
  2843. The short help output is quite succinct, and you might have to get
  2844. back to the full documentation for precise points. If you are reading
  2845. this paragraph, you already have the @command{tar} manual in some
  2846. form. This manual is available in a variety of forms from
  2847. @url{http://www.gnu.org/software/tar/manual}. It may be printed out of the @GNUTAR{}
  2848. distribution, provided you have @TeX{} already installed somewhere,
  2849. and a laser printer around. Just configure the distribution, execute
  2850. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2851. usual way (contact your local guru to know how). If @GNUTAR{}
  2852. has been conveniently installed at your place, this
  2853. manual is also available in interactive, hypertextual form as an Info
  2854. file. Just call @w{@samp{info tar}} or, if you do not have the
  2855. @command{info} program handy, use the Info reader provided within
  2856. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2857. There is currently no @code{man} page for @GNUTAR{}.
  2858. If you observe such a @code{man} page on the system you are running,
  2859. either it does not belong to @GNUTAR{}, or it has not
  2860. been produced by @acronym{GNU}. Some package maintainers convert
  2861. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2862. any case, please bear in mind that the authoritative source of
  2863. information about @GNUTAR{} is this Texinfo documentation.
  2864. @node defaults
  2865. @section Obtaining @GNUTAR{} default values
  2866. @opindex show-defaults
  2867. @GNUTAR{} has some predefined defaults that are used when you do not
  2868. explicitly specify another values. To obtain a list of such
  2869. defaults, use @option{--show-defaults} option. This will output the
  2870. values in the form of @command{tar} command line options:
  2871. @smallexample
  2872. @group
  2873. $ @kbd{tar --show-defaults}
  2874. --format=gnu -f- -b20 --quoting-style=escape
  2875. --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2876. @end group
  2877. @end smallexample
  2878. @noindent
  2879. Notice, that this option outputs only one line. The example output above
  2880. has been split to fit page boundaries.
  2881. @noindent
  2882. The above output shows that this version of @GNUTAR{} defaults to
  2883. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2884. output as the archive, if no @option{--file} option has been given
  2885. (@pxref{file tutorial}), the default blocking factor is 20
  2886. (@pxref{Blocking Factor}). It also shows the default locations where
  2887. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2888. @node verbose
  2889. @section Checking @command{tar} progress
  2890. Typically, @command{tar} performs most operations without reporting any
  2891. information to the user except error messages. When using @command{tar}
  2892. with many options, particularly ones with complicated or
  2893. difficult-to-predict behavior, it is possible to make serious mistakes.
  2894. @command{tar} provides several options that make observing @command{tar}
  2895. easier. These options cause @command{tar} to print information as it
  2896. progresses in its job, and you might want to use them just for being
  2897. more careful about what is going on, or merely for entertaining
  2898. yourself. If you have encountered a problem when operating on an
  2899. archive, however, you may need more information than just an error
  2900. message in order to solve the problem. The following options can be
  2901. helpful diagnostic tools.
  2902. @cindex Verbose operation
  2903. @opindex verbose
  2904. Normally, the @option{--list} (@option{-t}) command to list an archive
  2905. prints just the file names (one per line) and the other commands are
  2906. silent. When used with most operations, the @option{--verbose}
  2907. (@option{-v}) option causes @command{tar} to print the name of each
  2908. file or archive member as it is processed. This and the other options
  2909. which make @command{tar} print status information can be useful in
  2910. monitoring @command{tar}.
  2911. With @option{--create} or @option{--extract}, @option{--verbose} used
  2912. once just prints the names of the files or members as they are processed.
  2913. Using it twice causes @command{tar} to print a longer listing
  2914. (@xref{verbose member listing}, for the description) for each member.
  2915. Since @option{--list} already prints the names of the members,
  2916. @option{--verbose} used once with @option{--list} causes @command{tar}
  2917. to print an @samp{ls -l} type listing of the files in the archive.
  2918. The following examples both extract members with long list output:
  2919. @smallexample
  2920. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2921. $ @kbd{tar xvvf archive.tar}
  2922. @end smallexample
  2923. Verbose output appears on the standard output except when an archive is
  2924. being written to the standard output, as with @samp{tar --create
  2925. --file=- --verbose} (@samp{tar cvf -}, or even @samp{tar cv}---if the
  2926. installer let standard output be the default archive). In that case
  2927. @command{tar} writes verbose output to the standard error stream.
  2928. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2929. verbose output to @var{file} rather than to standard output or standard
  2930. error.
  2931. @anchor{totals}
  2932. @cindex Obtaining total status information
  2933. @opindex totals
  2934. The @option{--totals} option causes @command{tar} to print on the
  2935. standard error the total amount of bytes transferred when processing
  2936. an archive. When creating or appending to an archive, this option
  2937. prints the number of bytes written to the archive and the average
  2938. speed at which they have been written, e.g.:
  2939. @smallexample
  2940. @group
  2941. $ @kbd{tar -c -f archive.tar --totals /home}
  2942. Total bytes written: 7924664320 (7.4GiB, 85MiB/s)
  2943. @end group
  2944. @end smallexample
  2945. When reading an archive, this option displays the number of bytes
  2946. read:
  2947. @smallexample
  2948. @group
  2949. $ @kbd{tar -x -f archive.tar --totals}
  2950. Total bytes read: 7924664320 (7.4GiB, 95MiB/s)
  2951. @end group
  2952. @end smallexample
  2953. Finally, when deleting from an archive, the @option{--totals} option
  2954. displays both numbers plus number of bytes removed from the archive:
  2955. @smallexample
  2956. @group
  2957. $ @kbd{tar --delete -f foo.tar --totals --wildcards '*~'}
  2958. Total bytes read: 9543680 (9.2MiB, 201MiB/s)
  2959. Total bytes written: 3829760 (3.7MiB, 81MiB/s)
  2960. Total bytes deleted: 1474048
  2961. @end group
  2962. @end smallexample
  2963. You can also obtain this information on request. When
  2964. @option{--totals} is used with an argument, this argument is
  2965. interpreted as a symbolic name of a signal, upon delivery of which the
  2966. statistics is to be printed:
  2967. @table @option
  2968. @item --totals=@var{signo}
  2969. Print statistics upon delivery of signal @var{signo}. Valid arguments
  2970. are: @code{SIGHUP}, @code{SIGQUIT}, @code{SIGINT}, @code{SIGUSR1} and
  2971. @code{SIGUSR2}. Shortened names without @samp{SIG} prefix are also
  2972. accepted.
  2973. @end table
  2974. Both forms of @option{--totals} option can be used simultaneously.
  2975. Thus, @kbd{tar -x --totals --totals=USR1} instructs @command{tar} to
  2976. extract all members from its default archive and print statistics
  2977. after finishing the extraction, as well as when receiving signal
  2978. @code{SIGUSR1}.
  2979. @anchor{Progress information}
  2980. @cindex Progress information
  2981. The @option{--checkpoint} option prints an occasional message
  2982. as @command{tar} reads or writes the archive. It is designed for
  2983. those who don't need the more detailed (and voluminous) output of
  2984. @option{--block-number} (@option{-R}), but do want visual confirmation
  2985. that @command{tar} is actually making forward progress. By default it
  2986. prints a message each 10 records read or written. This can be changed
  2987. by giving it a numeric argument after an equal sign:
  2988. @smallexample
  2989. $ @kbd{tar -c --checkpoint=1000} /var
  2990. tar: Write checkpoint 1000
  2991. tar: Write checkpoint 2000
  2992. tar: Write checkpoint 3000
  2993. @end smallexample
  2994. This example shows the default checkpoint message used by
  2995. @command{tar}. If you place a dot immediately after the equal
  2996. sign, it will print a @samp{.} at each checkpoint@footnote{This is
  2997. actually a shortcut for @option{--checkpoint=@var{n}
  2998. --checkpoint-action=dot}. @xref{checkpoints, dot}.}. For example:
  2999. @smallexample
  3000. $ @kbd{tar -c --checkpoint=.1000} /var
  3001. ...
  3002. @end smallexample
  3003. The @option{--checkpoint} option provides a flexible mechanism for
  3004. executing arbitrary actions upon hitting checkpoints, see the next
  3005. section (@pxref{checkpoints}), for more information on it.
  3006. @opindex show-omitted-dirs
  3007. @anchor{show-omitted-dirs}
  3008. The @option{--show-omitted-dirs} option, when reading an archive---with
  3009. @option{--list} or @option{--extract}, for example---causes a message
  3010. to be printed for each directory in the archive which is skipped.
  3011. This happens regardless of the reason for skipping: the directory might
  3012. not have been named on the command line (implicitly or explicitly),
  3013. it might be excluded by the use of the
  3014. @option{--exclude=@var{pattern}} option, or some other reason.
  3015. @opindex block-number
  3016. @cindex Block number where error occurred
  3017. @anchor{block-number}
  3018. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  3019. every message it would normally produce, the block number within the
  3020. archive where the message was triggered. Also, supplementary messages
  3021. are triggered when reading blocks full of NULs, or when hitting end of
  3022. file on the archive. As of now, if the archive is properly terminated
  3023. with a NUL block, the reading of the file may stop before end of file
  3024. is met, so the position of end of file will not usually show when
  3025. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  3026. drains the archive before exiting when reading the
  3027. archive from a pipe.
  3028. @cindex Error message, block number of
  3029. This option is especially useful when reading damaged archives, since
  3030. it helps pinpoint the damaged sections. It can also be used with
  3031. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  3032. choose among several backup tapes when retrieving a file later, in
  3033. favor of the tape where the file appears earliest (closest to the
  3034. front of the tape). @xref{backup}.
  3035. @node checkpoints
  3036. @section Checkpoints
  3037. @cindex checkpoints, defined
  3038. @opindex checkpoint
  3039. @opindex checkpoint-action
  3040. A @dfn{checkpoint} is a moment of time before writing @var{n}th record to
  3041. the archive (a @dfn{write checkpoint}), or before reading @var{n}th record
  3042. from the archive (a @dfn{read checkpoint}). Checkpoints allow to
  3043. periodically execute arbitrary actions.
  3044. The checkpoint facility is enabled using the following option:
  3045. @table @option
  3046. @xopindex{checkpoint, defined}
  3047. @item --checkpoint[=@var{n}]
  3048. Schedule checkpoints before writing or reading each @var{n}th record.
  3049. The default value for @var{n} is 10.
  3050. @end table
  3051. A list of arbitrary @dfn{actions} can be executed at each checkpoint.
  3052. These actions include: pausing, displaying textual messages, and
  3053. executing arbitrary external programs. Actions are defined using
  3054. the @option{--checkpoint-action} option.
  3055. @table @option
  3056. @xopindex{checkpoint-action, defined}
  3057. @item --checkpoint-action=@var{action}
  3058. Execute an @var{action} at each checkpoint.
  3059. @end table
  3060. @cindex @code{echo}, checkpoint action
  3061. The simplest value of @var{action} is @samp{echo}. It instructs
  3062. @command{tar} to display the default message on the standard error
  3063. stream upon arriving at each checkpoint. The default message is (in
  3064. @acronym{POSIX} locale) @samp{Write checkpoint @var{n}}, for write
  3065. checkpoints, and @samp{Read checkpoint @var{n}}, for read checkpoints.
  3066. Here, @var{n} represents ordinal number of the checkpoint.
  3067. In another locales, translated versions of this message are used.
  3068. This is the default action, so running:
  3069. @smallexample
  3070. $ @kbd{tar -c --checkpoint=1000 --checkpoint-action=echo} /var
  3071. @end smallexample
  3072. @noindent
  3073. is equivalent to:
  3074. @smallexample
  3075. $ @kbd{tar -c --checkpoint=1000} /var
  3076. @end smallexample
  3077. The @samp{echo} action also allows to supply a customized message.
  3078. You do so by placing an equals sign and the message right after it,
  3079. e.g.:
  3080. @smallexample
  3081. --checkpoint-action="echo=Hit %s checkpoint #%u"
  3082. @end smallexample
  3083. The @samp{%s} and @samp{%u} in the above example are
  3084. @dfn{meta-characters}. The @samp{%s} meta-character is replaced with
  3085. the @dfn{type} of the checkpoint: @samp{write} or
  3086. @samp{read} (or a corresponding translated version in locales other
  3087. than @acronym{POSIX}). The @samp{%u} meta-character is replaced with
  3088. the ordinal number of the checkpoint. Thus, the above example could
  3089. produce the following output when used with the @option{--create}
  3090. option:
  3091. @smallexample
  3092. tar: Hit write checkpoint #10
  3093. tar: Hit write checkpoint #20
  3094. tar: Hit write checkpoint #30
  3095. @end smallexample
  3096. Aside from meta-character expansion, the message string is subject to
  3097. @dfn{unquoting}, during which the backslash @dfn{escape sequences} are
  3098. replaced with their corresponding @acronym{ASCII} characters
  3099. (@pxref{escape sequences}). E.g. the following action will produce an
  3100. audible bell and the message described above at each checkpoint:
  3101. @smallexample
  3102. --checkpoint-action='echo=\aHit %s checkpoint #%u'
  3103. @end smallexample
  3104. @cindex @code{bell}, checkpoint action
  3105. There is also a special action which produces an audible signal:
  3106. @samp{bell}. It is not equivalent to @samp{echo='\a'}, because
  3107. @samp{bell} sends the bell directly to the console (@file{/dev/tty}),
  3108. whereas @samp{echo='\a'} sends it to the standard error.
  3109. @cindex @code{ttyout}, checkpoint action
  3110. The @samp{ttyout=@var{string}} action outputs @var{string} to
  3111. @file{/dev/tty}, so it can be used even if the standard output is
  3112. redirected elsewhere. The @var{string} is subject to the same
  3113. modifications as with @samp{echo} action. In contrast to the latter,
  3114. @samp{ttyout} does not prepend @command{tar} executable name to the
  3115. string, nor does it output a newline after it. For example, the
  3116. following action will print the checkpoint message at the same screen
  3117. line, overwriting any previous message:
  3118. @smallexample
  3119. --checkpoint-action="ttyout=\rHit %s checkpoint #%u"
  3120. @end smallexample
  3121. @cindex @code{dot}, checkpoint action
  3122. Another available checkpoint action is @samp{dot} (or @samp{.}). It
  3123. instructs @command{tar} to print a single dot on the standard listing
  3124. stream, e.g.:
  3125. @smallexample
  3126. $ @kbd{tar -c --checkpoint=1000 --checkpoint-action=dot} /var
  3127. ...
  3128. @end smallexample
  3129. For compatibility with previous @GNUTAR{} versions, this action can
  3130. be abbreviated by placing a dot in front of the checkpoint frequency,
  3131. as shown in the previous section.
  3132. @cindex @code{sleep}, checkpoint action
  3133. Yet another action, @samp{sleep}, pauses @command{tar} for a specified
  3134. amount of seconds. The following example will stop for 30 seconds at each
  3135. checkpoint:
  3136. @smallexample
  3137. $ @kbd{tar -c --checkpoint=1000 --checkpoint-action=sleep=30}
  3138. @end smallexample
  3139. @cindex @code{exec}, checkpoint action
  3140. Finally, the @code{exec} action executes a given external program.
  3141. For example:
  3142. @smallexample
  3143. $ @kbd{tar -c --checkpoint=1000 --checkpoint-action=exec=/sbin/cpoint}
  3144. @end smallexample
  3145. This program is executed using @command{/bin/sh -c}, with no
  3146. additional arguments. Its exit code is ignored. It gets a copy of
  3147. @command{tar}'s environment plus the following variables:
  3148. @table @env
  3149. @vrindex TAR_VERSION, checkpoint script environment
  3150. @item TAR_VERSION
  3151. @GNUTAR{} version number.
  3152. @vrindex TAR_ARCHIVE, checkpoint script environment
  3153. @item TAR_ARCHIVE
  3154. The name of the archive @command{tar} is processing.
  3155. @vrindex TAR_BLOCKING_FACTOR, checkpoint script environment
  3156. @item TAR_BLOCKING_FACTOR
  3157. Current blocking factor (@pxref{Blocking}).
  3158. @vrindex TAR_CHECKPOINT, checkpoint script environment
  3159. @item TAR_CHECKPOINT
  3160. Number of the checkpoint.
  3161. @vrindex TAR_SUBCOMMAND, checkpoint script environment
  3162. @item TAR_SUBCOMMAND
  3163. A short option describing the operation @command{tar} is executing.
  3164. @xref{Operations}, for a complete list of subcommand options.
  3165. @vrindex TAR_FORMAT, checkpoint script environment
  3166. @item TAR_FORMAT
  3167. Format of the archive being processed. @xref{Formats}, for a complete
  3168. list of archive format names.
  3169. @end table
  3170. Any number of actions can be defined, by supplying several
  3171. @option{--checkpoint-action} options in the command line. For
  3172. example, the command below displays two messages, pauses
  3173. execution for 30 seconds and executes the @file{/sbin/cpoint} script:
  3174. @example
  3175. @group
  3176. $ @kbd{tar -c -f arc.tar \
  3177. --checkpoint-action='\aecho=Hit %s checkpoint #%u' \
  3178. --checkpoint-action='echo=Sleeping for 30 seconds' \
  3179. --checkpoint-action='sleep=30' \
  3180. --checkpoint-action='exec=/sbin/cpoint'}
  3181. @end group
  3182. @end example
  3183. This example also illustrates the fact that
  3184. @option{--checkpoint-action} can be used without
  3185. @option{--checkpoint}. In this case, the default checkpoint frequency
  3186. (at each 10th record) is assumed.
  3187. @node warnings
  3188. @section Controlling Warning Messages
  3189. Sometimes, while performing the requested task, @GNUTAR{} notices
  3190. some conditions that are not exactly errors, but which the user
  3191. should be aware of. When this happens, @command{tar} issues a
  3192. @dfn{warning message} describing the condition. Warning messages
  3193. are output to the standard error and they do not affect the exit
  3194. code of @command{tar} command.
  3195. @xopindex{warning, explained}
  3196. @GNUTAR{} allows the user to suppress some or all of its warning
  3197. messages:
  3198. @table @option
  3199. @item --warning=@var{keyword}
  3200. Control display of the warning messages identified by @var{keyword}.
  3201. If @var{keyword} starts with the prefix @samp{no-}, such messages are
  3202. suppressed. Otherwise, they are enabled.
  3203. Multiple @option{--warning} messages accumulate.
  3204. The tables below list allowed values for @var{keyword} along with the
  3205. warning messages they control.
  3206. @end table
  3207. @subheading Keywords controlling @command{tar} operation
  3208. @table @asis
  3209. @kwindex all
  3210. @item all
  3211. Enable all warning messages. This is the default.
  3212. @kwindex none
  3213. @item none
  3214. Disable all warning messages.
  3215. @kwindex filename-with-nuls
  3216. @cindex @samp{file name read contains nul character}, warning message
  3217. @item filename-with-nuls
  3218. @samp{%s: file name read contains nul character}
  3219. @kwindex alone-zero-block
  3220. @cindex @samp{A lone zero block at}, warning message
  3221. @item alone-zero-block
  3222. @samp{A lone zero block at %s}
  3223. @end table
  3224. @subheading Keywords applicable for @command{tar --create}
  3225. @table @asis
  3226. @kwindex cachedir
  3227. @cindex @samp{contains a cache directory tag}, warning message
  3228. @item cachedir
  3229. @samp{%s: contains a cache directory tag %s; %s}
  3230. @kwindex file-shrank
  3231. @cindex @samp{File shrank by %s bytes}, warning message
  3232. @item file-shrank
  3233. @samp{%s: File shrank by %s bytes; padding with zeros}
  3234. @kwindex xdev
  3235. @cindex @samp{file is on a different filesystem}, warning message
  3236. @item xdev
  3237. @samp{%s: file is on a different filesystem; not dumped}
  3238. @kwindex file-ignored
  3239. @cindex @samp{Unknown file type; file ignored}, warning message
  3240. @cindex @samp{socket ignored}, warning message
  3241. @cindex @samp{door ignored}, warning message
  3242. @item file-ignored
  3243. @samp{%s: Unknown file type; file ignored}
  3244. @*@samp{%s: socket ignored}
  3245. @*@samp{%s: door ignored}
  3246. @kwindex file-unchanged
  3247. @cindex @samp{file is unchanged; not dumped}, warning message
  3248. @item file-unchanged
  3249. @samp{%s: file is unchanged; not dumped}
  3250. @kwindex ignore-archive
  3251. @cindex @samp{file is the archive; not dumped}, warning message
  3252. @kwindex ignore-archive
  3253. @cindex @samp{file is the archive; not dumped}, warning message
  3254. @item ignore-archive
  3255. @samp{%s: file is the archive; not dumped}
  3256. @kwindex file-removed
  3257. @cindex @samp{File removed before we read it}, warning message
  3258. @item file-removed
  3259. @samp{%s: File removed before we read it}
  3260. @kwindex file-changed
  3261. @cindex @samp{file changed as we read it}, warning message
  3262. @item file-changed
  3263. @samp{%s: file changed as we read it}
  3264. @end table
  3265. @subheading Keywords applicable for @command{tar --extract}
  3266. @table @asis
  3267. @kwindex timestamp
  3268. @cindex @samp{implausibly old time stamp %s}, warning message
  3269. @cindex @samp{time stamp %s is %s s in the future}, warning message
  3270. @item timestamp
  3271. @samp{%s: implausibly old time stamp %s}
  3272. @*@samp{%s: time stamp %s is %s s in the future}
  3273. @kwindex contiguous-cast
  3274. @cindex @samp{Extracting contiguous files as regular files}, warning message
  3275. @item contiguous-cast
  3276. @samp{Extracting contiguous files as regular files}
  3277. @kwindex symlink-cast
  3278. @cindex @samp{Attempting extraction of symbolic links as hard links}, warning message
  3279. @item symlink-cast
  3280. @samp{Attempting extraction of symbolic links as hard links}
  3281. @kwindex unknown-cast
  3282. @cindex @samp{Unknown file type `%c', extracted as normal file}, warning message
  3283. @item unknown-cast
  3284. @samp{%s: Unknown file type `%c', extracted as normal file}
  3285. @kwindex ignore-newer
  3286. @cindex @samp{Current %s is newer or same age}, warning message
  3287. @item ignore-newer
  3288. @samp{Current %s is newer or same age}
  3289. @kwindex unknown-keyword
  3290. @cindex @samp{Ignoring unknown extended header keyword `%s'}, warning message
  3291. @item unknown-keyword
  3292. @samp{Ignoring unknown extended header keyword `%s'}
  3293. @kwindex decompress-program
  3294. @item decompress-program
  3295. Controls verbose description of failures occurring when trying to run
  3296. alternative decompressor programs (@pxref{alternative decompression
  3297. programs}). This warning is disabled by default (unless
  3298. @option{--verbose} is used). A common example of what you can get
  3299. when using this warning is:
  3300. @smallexample
  3301. $ @kbd{tar --warning=decompress-program -x -f archive.Z}
  3302. tar (child): cannot run compress: No such file or directory
  3303. tar (child): trying gzip
  3304. @end smallexample
  3305. This means that @command{tar} first tried to decompress
  3306. @file{archive.Z} using @command{compress}, and, when that
  3307. failed, switched to @command{gzip}.
  3308. @end table
  3309. @subheading Keywords controlling incremental extraction:
  3310. @table @asis
  3311. @kwindex rename-directory
  3312. @cindex @samp{%s: Directory has been renamed from %s}, warning message
  3313. @cindex @samp{%s: Directory has been renamed}, warning message
  3314. @item rename-directory
  3315. @samp{%s: Directory has been renamed from %s}
  3316. @*@samp{%s: Directory has been renamed}
  3317. @kwindex new-directory
  3318. @cindex @samp{%s: Directory is new}, warning message
  3319. @item new-directory
  3320. @samp{%s: Directory is new}
  3321. @kwindex xdev
  3322. @cindex @samp{%s: directory is on a different device: not purging}, warning message
  3323. @item xdev
  3324. @samp{%s: directory is on a different device: not purging}
  3325. @kwindex bad-dumpdir
  3326. @cindex @samp{Malformed dumpdir: 'X' never used}, warning message
  3327. @item bad-dumpdir
  3328. @samp{Malformed dumpdir: 'X' never used}
  3329. @end table
  3330. @node interactive
  3331. @section Asking for Confirmation During Operations
  3332. @cindex Interactive operation
  3333. Typically, @command{tar} carries out a command without stopping for
  3334. further instructions. In some situations however, you may want to
  3335. exclude some files and archive members from the operation (for instance
  3336. if disk or storage space is tight). You can do this by excluding
  3337. certain files automatically (@pxref{Choosing}), or by performing
  3338. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  3339. @command{tar} also accepts @option{--confirmation} for this option.
  3340. @opindex interactive
  3341. When the @option{--interactive} (@option{-w}) option is specified, before
  3342. reading, writing, or deleting files, @command{tar} first prints a message
  3343. for each such file, telling what operation it intends to take, then asks
  3344. for confirmation on the terminal. The actions which require
  3345. confirmation include adding a file to the archive, extracting a file
  3346. from the archive, deleting a file from the archive, and deleting a file
  3347. from disk. To confirm the action, you must type a line of input
  3348. beginning with @samp{y}. If your input line begins with anything other
  3349. than @samp{y}, @command{tar} skips that file.
  3350. If @command{tar} is reading the archive from the standard input,
  3351. @command{tar} opens the file @file{/dev/tty} to support the interactive
  3352. communications.
  3353. Verbose output is normally sent to standard output, separate from
  3354. other error messages. However, if the archive is produced directly
  3355. on standard output, then verbose output is mixed with errors on
  3356. @code{stderr}. Producing the archive on standard output may be used
  3357. as a way to avoid using disk space, when the archive is soon to be
  3358. consumed by another process reading it, say. Some people felt the need
  3359. of producing an archive on stdout, still willing to segregate between
  3360. verbose output and error output. A possible approach would be using a
  3361. named pipe to receive the archive, and having the consumer process to
  3362. read from that named pipe. This has the advantage of letting standard
  3363. output free to receive verbose output, all separate from errors.
  3364. @node operations
  3365. @chapter @GNUTAR{} Operations
  3366. @menu
  3367. * Basic tar::
  3368. * Advanced tar::
  3369. * create options::
  3370. * extract options::
  3371. * backup::
  3372. * Applications::
  3373. * looking ahead::
  3374. @end menu
  3375. @node Basic tar
  3376. @section Basic @GNUTAR{} Operations
  3377. The basic @command{tar} operations, @option{--create} (@option{-c}),
  3378. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  3379. @option{-x}), are currently presented and described in the tutorial
  3380. chapter of this manual. This section provides some complementary notes
  3381. for these operations.
  3382. @table @option
  3383. @xopindex{create, complementary notes}
  3384. @item --create
  3385. @itemx -c
  3386. Creating an empty archive would have some kind of elegance. One can
  3387. initialize an empty archive and later use @option{--append}
  3388. (@option{-r}) for adding all members. Some applications would not
  3389. welcome making an exception in the way of adding the first archive
  3390. member. On the other hand, many people reported that it is
  3391. dangerously too easy for @command{tar} to destroy a magnetic tape with
  3392. an empty archive@footnote{This is well described in @cite{Unix-haters
  3393. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  3394. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  3395. @enumerate
  3396. @item
  3397. Mistakingly using @code{create} instead of @code{extract}, when the
  3398. intent was to extract the full contents of an archive. This error
  3399. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  3400. the QWERTY keyboard. Instead of being unpacked, the archive then
  3401. gets wholly destroyed. When users speak about @dfn{exploding} an
  3402. archive, they usually mean something else :-).
  3403. @item
  3404. Forgetting the argument to @code{file}, when the intent was to create
  3405. an archive with a single file in it. This error is likely because a
  3406. tired user can easily add the @kbd{f} key to the cluster of option
  3407. letters, by the mere force of habit, without realizing the full
  3408. consequence of doing so. The usual consequence is that the single
  3409. file, which was meant to be saved, is rather destroyed.
  3410. @end enumerate
  3411. So, recognizing the likelihood and the catastrophic nature of these
  3412. errors, @GNUTAR{} now takes some distance from elegance, and
  3413. cowardly refuses to create an archive when @option{--create} option is
  3414. given, there are no arguments besides options, and
  3415. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  3416. around the cautiousness of @GNUTAR{} and nevertheless create an
  3417. archive with nothing in it, one may still use, as the value for the
  3418. @option{--files-from} option, a file with no names in it, as shown in
  3419. the following commands:
  3420. @smallexample
  3421. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  3422. @kbd{tar -cf empty-archive.tar -T /dev/null}
  3423. @end smallexample
  3424. @xopindex{extract, complementary notes}
  3425. @item --extract
  3426. @itemx --get
  3427. @itemx -x
  3428. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  3429. @item @option{--list} (@option{-t})
  3430. @GNUTAR{} now shows dates as @samp{1996-08-30},
  3431. while it used to show them as @samp{Aug 30 1996}. Preferably,
  3432. people should get used to ISO 8601 dates. Local American dates should
  3433. be made available again with full date localization support, once
  3434. ready. In the meantime, programs not being localizable for dates
  3435. should prefer international dates, that's really the way to go.
  3436. Look up @url{http://www.cl.cam.ac.uk/@/~mgk25/@/iso-time.html} if you
  3437. are curious, it contains a detailed explanation of the ISO 8601 standard.
  3438. @end table
  3439. @node Advanced tar
  3440. @section Advanced @GNUTAR{} Operations
  3441. Now that you have learned the basics of using @GNUTAR{}, you may want
  3442. to learn about further ways in which @command{tar} can help you.
  3443. This chapter presents five, more advanced operations which you probably
  3444. won't use on a daily basis, but which serve more specialized functions.
  3445. We also explain the different styles of options and why you might want
  3446. to use one or another, or a combination of them in your @command{tar}
  3447. commands. Additionally, this chapter includes options which allow you to
  3448. define the output from @command{tar} more carefully, and provide help and
  3449. error correction in special circumstances.
  3450. @FIXME{check this after the chapter is actually revised to make sure
  3451. it still introduces the info in the chapter correctly : ).}
  3452. @menu
  3453. * Operations::
  3454. * append::
  3455. * update::
  3456. * concatenate::
  3457. * delete::
  3458. * compare::
  3459. @end menu
  3460. @node Operations
  3461. @subsection The Five Advanced @command{tar} Operations
  3462. @cindex basic operations
  3463. In the last chapter, you learned about the first three operations to
  3464. @command{tar}. This chapter presents the remaining five operations to
  3465. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  3466. @option{--delete}, and @option{--compare}.
  3467. You are not likely to use these operations as frequently as those
  3468. covered in the last chapter; however, since they perform specialized
  3469. functions, they are quite useful when you do need to use them. We
  3470. will give examples using the same directory and files that you created
  3471. in the last chapter. As you may recall, the directory is called
  3472. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  3473. and the two archive files you created are
  3474. @samp{collection.tar} and @samp{music.tar}.
  3475. We will also use the archive files @samp{afiles.tar} and
  3476. @samp{bfiles.tar}. The archive @samp{afiles.tar} contains the members @samp{apple},
  3477. @samp{angst}, and @samp{aspic}; @samp{bfiles.tar} contains the members
  3478. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  3479. Unless we state otherwise, all practicing you do and examples you follow
  3480. in this chapter will take place in the @file{practice} directory that
  3481. you created in the previous chapter; see @ref{prepare for examples}.
  3482. (Below in this section, we will remind you of the state of the examples
  3483. where the last chapter left them.)
  3484. The five operations that we will cover in this chapter are:
  3485. @table @option
  3486. @item --append
  3487. @itemx -r
  3488. Add new entries to an archive that already exists.
  3489. @item --update
  3490. @itemx -u
  3491. Add more recent copies of archive members to the end of an archive, if
  3492. they exist.
  3493. @item --concatenate
  3494. @itemx --catenate
  3495. @itemx -A
  3496. Add one or more pre-existing archives to the end of another archive.
  3497. @item --delete
  3498. Delete items from an archive (does not work on tapes).
  3499. @item --compare
  3500. @itemx --diff
  3501. @itemx -d
  3502. Compare archive members to their counterparts in the file system.
  3503. @end table
  3504. @node append
  3505. @subsection How to Add Files to Existing Archives: @option{--append}
  3506. @cindex appending files to existing archive
  3507. @opindex append
  3508. If you want to add files to an existing archive, you don't need to
  3509. create a new archive; you can use @option{--append} (@option{-r}).
  3510. The archive must already exist in order to use @option{--append}. (A
  3511. related operation is the @option{--update} operation; you can use this
  3512. to add newer versions of archive members to an existing archive. To learn how to
  3513. do this with @option{--update}, @pxref{update}.)
  3514. If you use @option{--append} to add a file that has the same name as an
  3515. archive member to an archive containing that archive member, then the
  3516. old member is not deleted. What does happen, however, is somewhat
  3517. complex. @command{tar} @emph{allows} you to have infinite number of files
  3518. with the same name. Some operations treat these same-named members no
  3519. differently than any other set of archive members: for example, if you
  3520. view an archive with @option{--list} (@option{-t}), you will see all
  3521. of those members listed, with their data modification times, owners, etc.
  3522. Other operations don't deal with these members as perfectly as you might
  3523. prefer; if you were to use @option{--extract} to extract the archive,
  3524. only the most recently added copy of a member with the same name as
  3525. other members would end up in the working directory. This is because
  3526. @option{--extract} extracts an archive in the order the members appeared
  3527. in the archive; the most recently archived members will be extracted
  3528. last. Additionally, an extracted member will @emph{replace} a file of
  3529. the same name which existed in the directory already, and @command{tar}
  3530. will not prompt you about this@footnote{Unless you give it
  3531. @option{--keep-old-files} option, or the disk copy is newer than
  3532. the one in the archive and you invoke @command{tar} with
  3533. @option{--keep-newer-files} option.}. Thus, only the most recently archived
  3534. member will end up being extracted, as it will replace the one
  3535. extracted before it, and so on.
  3536. @cindex extracting @var{n}th copy of the file
  3537. @xopindex{occurrence, described}
  3538. There exists a special option that allows you to get around this
  3539. behavior and extract (or list) only a particular copy of the file.
  3540. This is @option{--occurrence} option. If you run @command{tar} with
  3541. this option, it will extract only the first copy of the file. You
  3542. may also give this option an argument specifying the number of
  3543. copy to be extracted. Thus, for example if the archive
  3544. @file{archive.tar} contained three copies of file @file{myfile}, then
  3545. the command
  3546. @smallexample
  3547. tar --extract --file archive.tar --occurrence=2 myfile
  3548. @end smallexample
  3549. @noindent
  3550. would extract only the second copy. @xref{Option
  3551. Summary,---occurrence}, for the description of @option{--occurrence}
  3552. option.
  3553. @FIXME{ hag -- you might want to incorporate some of the above into the
  3554. MMwtSN node; not sure. i didn't know how to make it simpler...
  3555. There are a few ways to get around this. Xref to Multiple Members
  3556. with the Same Name, maybe.}
  3557. @cindex Members, replacing with other members
  3558. @cindex Replacing members with other members
  3559. @xopindex{delete, using before --append}
  3560. If you want to replace an archive member, use @option{--delete} to
  3561. delete the member you want to remove from the archive, and then use
  3562. @option{--append} to add the member you want to be in the archive. Note
  3563. that you can not change the order of the archive; the most recently
  3564. added member will still appear last. In this sense, you cannot truly
  3565. ``replace'' one member with another. (Replacing one member with another
  3566. will not work on certain types of media, such as tapes; see @ref{delete}
  3567. and @ref{Media}, for more information.)
  3568. @menu
  3569. * appending files:: Appending Files to an Archive
  3570. * multiple::
  3571. @end menu
  3572. @node appending files
  3573. @subsubsection Appending Files to an Archive
  3574. @cindex Adding files to an Archive
  3575. @cindex Appending files to an Archive
  3576. @cindex Archives, Appending files to
  3577. @opindex append
  3578. The simplest way to add a file to an already existing archive is the
  3579. @option{--append} (@option{-r}) operation, which writes specified
  3580. files into the archive whether or not they are already among the
  3581. archived files.
  3582. When you use @option{--append}, you @emph{must} specify file name
  3583. arguments, as there is no default. If you specify a file that already
  3584. exists in the archive, another copy of the file will be added to the
  3585. end of the archive. As with other operations, the member names of the
  3586. newly added files will be exactly the same as their names given on the
  3587. command line. The @option{--verbose} (@option{-v}) option will print
  3588. out the names of the files as they are written into the archive.
  3589. @option{--append} cannot be performed on some tape drives, unfortunately,
  3590. due to deficiencies in the formats those tape drives use. The archive
  3591. must be a valid @command{tar} archive, or else the results of using this
  3592. operation will be unpredictable. @xref{Media}.
  3593. To demonstrate using @option{--append} to add a file to an archive,
  3594. create a file called @file{rock} in the @file{practice} directory.
  3595. Make sure you are in the @file{practice} directory. Then, run the
  3596. following @command{tar} command to add @file{rock} to
  3597. @file{collection.tar}:
  3598. @smallexample
  3599. $ @kbd{tar --append --file=collection.tar rock}
  3600. @end smallexample
  3601. @noindent
  3602. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3603. @file{rock} has been added to the archive:
  3604. @smallexample
  3605. $ @kbd{tar --list --file=collection.tar}
  3606. -rw-r--r-- me/user 28 1996-10-18 16:31 jazz
  3607. -rw-r--r-- me/user 21 1996-09-23 16:44 blues
  3608. -rw-r--r-- me/user 20 1996-09-23 16:44 folk
  3609. -rw-r--r-- me/user 20 1996-09-23 16:44 rock
  3610. @end smallexample
  3611. @node multiple
  3612. @subsubsection Multiple Members with the Same Name
  3613. @cindex members, multiple
  3614. @cindex multiple members
  3615. You can use @option{--append} (@option{-r}) to add copies of files
  3616. which have been updated since the archive was created. (However, we
  3617. do not recommend doing this since there is another @command{tar}
  3618. option called @option{--update}; @xref{update}, for more information.
  3619. We describe this use of @option{--append} here for the sake of
  3620. completeness.) When you extract the archive, the older version will
  3621. be effectively lost. This works because files are extracted from an
  3622. archive in the order in which they were archived. Thus, when the
  3623. archive is extracted, a file archived later in time will replace a
  3624. file of the same name which was archived earlier, even though the
  3625. older version of the file will remain in the archive unless you delete
  3626. all versions of the file.
  3627. Supposing you change the file @file{blues} and then append the changed
  3628. version to @file{collection.tar}. As you saw above, the original
  3629. @file{blues} is in the archive @file{collection.tar}. If you change the
  3630. file and append the new version of the file to the archive, there will
  3631. be two copies in the archive. When you extract the archive, the older
  3632. version of the file will be extracted first, and then replaced by the
  3633. newer version when it is extracted.
  3634. You can append the new, changed copy of the file @file{blues} to the
  3635. archive in this way:
  3636. @smallexample
  3637. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3638. blues
  3639. @end smallexample
  3640. @noindent
  3641. Because you specified the @option{--verbose} option, @command{tar} has
  3642. printed the name of the file being appended as it was acted on. Now
  3643. list the contents of the archive:
  3644. @smallexample
  3645. $ @kbd{tar --list --verbose --file=collection.tar}
  3646. -rw-r--r-- me/user 28 1996-10-18 16:31 jazz
  3647. -rw-r--r-- me/user 21 1996-09-23 16:44 blues
  3648. -rw-r--r-- me/user 20 1996-09-23 16:44 folk
  3649. -rw-r--r-- me/user 20 1996-09-23 16:44 rock
  3650. -rw-r--r-- me/user 58 1996-10-24 18:30 blues
  3651. @end smallexample
  3652. @noindent
  3653. The newest version of @file{blues} is now at the end of the archive
  3654. (note the different creation dates and file sizes). If you extract
  3655. the archive, the older version of the file @file{blues} will be
  3656. replaced by the newer version. You can confirm this by extracting
  3657. the archive and running @samp{ls} on the directory.
  3658. If you wish to extract the first occurrence of the file @file{blues}
  3659. from the archive, use @option{--occurrence} option, as shown in
  3660. the following example:
  3661. @smallexample
  3662. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3663. -rw-r--r-- me/user 21 1996-09-23 16:44 blues
  3664. @end smallexample
  3665. @xref{Writing}, for more information on @option{--extract} and
  3666. see @ref{Option Summary, --occurrence}, for a description of
  3667. @option{--occurrence} option.
  3668. @node update
  3669. @subsection Updating an Archive
  3670. @cindex Updating an archive
  3671. @opindex update
  3672. In the previous section, you learned how to use @option{--append} to
  3673. add a file to an existing archive. A related operation is
  3674. @option{--update} (@option{-u}). The @option{--update} operation
  3675. updates a @command{tar} archive by comparing the date of the specified
  3676. archive members against the date of the file with the same name. If
  3677. the file has been modified more recently than the archive member, then
  3678. the newer version of the file is added to the archive (as with
  3679. @option{--append}).
  3680. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3681. The operation will fail.
  3682. @FIXME{other examples of media on which --update will fail? need to ask
  3683. charles and/or mib/thomas/dave shevett..}
  3684. Both @option{--update} and @option{--append} work by adding to the end
  3685. of the archive. When you extract a file from the archive, only the
  3686. version stored last will wind up in the file system, unless you use
  3687. the @option{--backup} option. @xref{multiple}, for a detailed discussion.
  3688. @menu
  3689. * how to update::
  3690. @end menu
  3691. @node how to update
  3692. @subsubsection How to Update an Archive Using @option{--update}
  3693. @opindex update
  3694. You must use file name arguments with the @option{--update}
  3695. (@option{-u}) operation. If you don't specify any files,
  3696. @command{tar} won't act on any files and won't tell you that it didn't
  3697. do anything (which may end up confusing you).
  3698. @c note: the above parenthetical added because in fact, this
  3699. @c behavior just confused the author. :-)
  3700. To see the @option{--update} option at work, create a new file,
  3701. @file{classical}, in your practice directory, and some extra text to the
  3702. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3703. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3704. option specified, using the names of all the files in the @file{practice}
  3705. directory as file name arguments:
  3706. @smallexample
  3707. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3708. blues
  3709. classical
  3710. $
  3711. @end smallexample
  3712. @noindent
  3713. Because we have specified verbose mode, @command{tar} prints out the names
  3714. of the files it is working on, which in this case are the names of the
  3715. files that needed to be updated. If you run @samp{tar --list} and look
  3716. at the archive, you will see @file{blues} and @file{classical} at its
  3717. end. There will be a total of two versions of the member @samp{blues};
  3718. the one at the end will be newer and larger, since you added text before
  3719. updating it.
  3720. The reason @command{tar} does not overwrite the older file when updating
  3721. it is because writing to the middle of a section of tape is a difficult
  3722. process. Tapes are not designed to go backward. @xref{Media}, for more
  3723. information about tapes.
  3724. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3725. reasons: it does not change directory content entries, and it
  3726. lengthens the archive every time it is used. The @GNUTAR{}
  3727. options intended specifically for backups are more
  3728. efficient. If you need to run backups, please consult @ref{Backups}.
  3729. @node concatenate
  3730. @subsection Combining Archives with @option{--concatenate}
  3731. @cindex Adding archives to an archive
  3732. @cindex Concatenating Archives
  3733. @opindex concatenate
  3734. @opindex catenate
  3735. @c @cindex @option{-A} described
  3736. Sometimes it may be convenient to add a second archive onto the end of
  3737. an archive rather than adding individual files to the archive. To add
  3738. one or more archives to the end of another archive, you should use the
  3739. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3740. To use @option{--concatenate}, give the first archive with
  3741. @option{--file} option and name the rest of archives to be
  3742. concatenated on the command line. The members, and their member
  3743. names, will be copied verbatim from those archives to the first
  3744. one@footnote{This can cause multiple members to have the same name. For
  3745. information on how this affects reading the archive, see @ref{multiple}.}.
  3746. The new, concatenated archive will be called by the same name as the
  3747. one given with the @option{--file} option. As usual, if you omit
  3748. @option{--file}, @command{tar} will use the value of the environment
  3749. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3750. @FIXME{There is no way to specify a new name...}
  3751. To demonstrate how @option{--concatenate} works, create two small archives
  3752. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3753. files from @file{practice}:
  3754. @smallexample
  3755. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3756. blues
  3757. rock
  3758. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3759. folk
  3760. jazz
  3761. @end smallexample
  3762. @noindent
  3763. If you like, You can run @samp{tar --list} to make sure the archives
  3764. contain what they are supposed to:
  3765. @smallexample
  3766. $ @kbd{tar -tvf bluesrock.tar}
  3767. -rw-r--r-- melissa/user 105 1997-01-21 19:42 blues
  3768. -rw-r--r-- melissa/user 33 1997-01-20 15:34 rock
  3769. $ @kbd{tar -tvf jazzfolk.tar}
  3770. -rw-r--r-- melissa/user 20 1996-09-23 16:44 folk
  3771. -rw-r--r-- melissa/user 65 1997-01-30 14:15 jazz
  3772. @end smallexample
  3773. We can concatenate these two archives with @command{tar}:
  3774. @smallexample
  3775. $ @kbd{cd ..}
  3776. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3777. @end smallexample
  3778. If you now list the contents of the @file{bluesrock.tar}, you will see
  3779. that now it also contains the archive members of @file{jazzfolk.tar}:
  3780. @smallexample
  3781. $ @kbd{tar --list --file=bluesrock.tar}
  3782. blues
  3783. rock
  3784. folk
  3785. jazz
  3786. @end smallexample
  3787. When you use @option{--concatenate}, the source and target archives must
  3788. already exist and must have been created using compatible format
  3789. parameters. Notice, that @command{tar} does not check whether the
  3790. archives it concatenates have compatible formats, it does not
  3791. even check if the files are really tar archives.
  3792. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3793. tape drives, due to deficiencies in the formats those tape drives use.
  3794. @cindex @code{concatenate} vs @command{cat}
  3795. @cindex @command{cat} vs @code{concatenate}
  3796. It may seem more intuitive to you to want or try to use @command{cat} to
  3797. concatenate two archives instead of using the @option{--concatenate}
  3798. operation; after all, @command{cat} is the utility for combining files.
  3799. However, @command{tar} archives incorporate an end-of-file marker which
  3800. must be removed if the concatenated archives are to be read properly as
  3801. one archive. @option{--concatenate} removes the end-of-archive marker
  3802. from the target archive before each new archive is appended. If you use
  3803. @command{cat} to combine the archives, the result will not be a valid
  3804. @command{tar} format archive. If you need to retrieve files from an
  3805. archive that was added to using the @command{cat} utility, use the
  3806. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3807. information on dealing with archives improperly combined using the
  3808. @command{cat} shell utility.
  3809. @node delete
  3810. @subsection Removing Archive Members Using @option{--delete}
  3811. @cindex Deleting files from an archive
  3812. @cindex Removing files from an archive
  3813. @opindex delete
  3814. You can remove members from an archive by using the @option{--delete}
  3815. option. Specify the name of the archive with @option{--file}
  3816. (@option{-f}) and then specify the names of the members to be deleted;
  3817. if you list no member names, nothing will be deleted. The
  3818. @option{--verbose} option will cause @command{tar} to print the names
  3819. of the members as they are deleted. As with @option{--extract}, you
  3820. must give the exact member names when using @samp{tar --delete}.
  3821. @option{--delete} will remove all versions of the named file from the
  3822. archive. The @option{--delete} operation can run very slowly.
  3823. Unlike other operations, @option{--delete} has no short form.
  3824. @cindex Tapes, using @option{--delete} and
  3825. @cindex Deleting from tape archives
  3826. This operation will rewrite the archive. You can only use
  3827. @option{--delete} on an archive if the archive device allows you to
  3828. write to any point on the media, such as a disk; because of this, it
  3829. does not work on magnetic tapes. Do not try to delete an archive member
  3830. from a magnetic tape; the action will not succeed, and you will be
  3831. likely to scramble the archive and damage your tape. There is no safe
  3832. way (except by completely re-writing the archive) to delete files from
  3833. most kinds of magnetic tape. @xref{Media}.
  3834. To delete all versions of the file @file{blues} from the archive
  3835. @file{collection.tar} in the @file{practice} directory, make sure you
  3836. are in that directory, and then,
  3837. @smallexample
  3838. $ @kbd{tar --list --file=collection.tar}
  3839. blues
  3840. folk
  3841. jazz
  3842. rock
  3843. $ @kbd{tar --delete --file=collection.tar blues}
  3844. $ @kbd{tar --list --file=collection.tar}
  3845. folk
  3846. jazz
  3847. rock
  3848. @end smallexample
  3849. @FIXME{Check if the above listing is actually produced after running
  3850. all the examples on collection.tar.}
  3851. The @option{--delete} option has been reported to work properly when
  3852. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3853. @node compare
  3854. @subsection Comparing Archive Members with the File System
  3855. @cindex Verifying the currency of an archive
  3856. @opindex compare
  3857. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3858. specified archive members against files with the same names, and then
  3859. reports differences in file size, mode, owner, modification date and
  3860. contents. You should @emph{only} specify archive member names, not file
  3861. names. If you do not name any members, then @command{tar} will compare the
  3862. entire archive. If a file is represented in the archive but does not
  3863. exist in the file system, @command{tar} reports a difference.
  3864. You have to specify the record size of the archive when modifying an
  3865. archive with a non-default record size.
  3866. @command{tar} ignores files in the file system that do not have
  3867. corresponding members in the archive.
  3868. The following example compares the archive members @file{rock},
  3869. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3870. files of the same name in the file system. (Note that there is no file,
  3871. @file{funk}; @command{tar} will report an error message.)
  3872. @smallexample
  3873. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3874. rock
  3875. blues
  3876. tar: funk not found in archive
  3877. @end smallexample
  3878. The spirit behind the @option{--compare} (@option{--diff},
  3879. @option{-d}) option is to check whether the archive represents the
  3880. current state of files on disk, more than validating the integrity of
  3881. the archive media. For this latter goal, see @ref{verify}.
  3882. @node create options
  3883. @section Options Used by @option{--create}
  3884. @xopindex{create, additional options}
  3885. The previous chapter described the basics of how to use
  3886. @option{--create} (@option{-c}) to create an archive from a set of files.
  3887. @xref{create}. This section described advanced options to be used with
  3888. @option{--create}.
  3889. @menu
  3890. * override:: Overriding File Metadata.
  3891. * Ignore Failed Read::
  3892. @end menu
  3893. @node override
  3894. @subsection Overriding File Metadata
  3895. As described above, a @command{tar} archive keeps, for each member it contains,
  3896. its @dfn{metadata}, such as modification time, mode and ownership of
  3897. the file. @GNUTAR{} allows to replace these data with other values
  3898. when adding files to the archive. The options described in this
  3899. section affect creation of archives of any type. For POSIX archives,
  3900. see also @ref{PAX keywords}, for additional ways of controlling
  3901. metadata, stored in the archive.
  3902. @table @option
  3903. @opindex mode
  3904. @item --mode=@var{permissions}
  3905. When adding files to an archive, @command{tar} will use
  3906. @var{permissions} for the archive members, rather than the permissions
  3907. from the files. @var{permissions} can be specified either as an octal
  3908. number or as symbolic permissions, like with
  3909. @command{chmod} (@xref{File permissions, Permissions, File
  3910. permissions, fileutils, @acronym{GNU} file utilities}. This reference
  3911. also has useful information for those not being overly familiar with
  3912. the UNIX permission system). Using latter syntax allows for
  3913. more flexibility. For example, the value @samp{a+rw} adds read and write
  3914. permissions for everybody, while retaining executable bits on directories
  3915. or on any other file already marked as executable:
  3916. @smallexample
  3917. $ @kbd{tar -c -f archive.tar --mode='a+rw' .}
  3918. @end smallexample
  3919. @item --mtime=@var{date}
  3920. @opindex mtime
  3921. When adding files to an archive, @command{tar} will use @var{date} as
  3922. the modification time of members when creating archives, instead of
  3923. their actual modification times. The argument @var{date} can be
  3924. either a textual date representation in almost arbitrary format
  3925. (@pxref{Date input formats}) or a name of an existing file, starting
  3926. with @samp{/} or @samp{.}. In the latter case, the modification time
  3927. of that file will be used.
  3928. The following example will set the modification date to 00:00:00,
  3929. January 1, 1970:
  3930. @smallexample
  3931. $ @kbd{tar -c -f archive.tar --mtime='1970-01-01' .}
  3932. @end smallexample
  3933. @noindent
  3934. When used with @option{--verbose} (@pxref{verbose tutorial}) @GNUTAR{}
  3935. will try to convert the specified date back to its textual
  3936. representation and compare it with the one given with
  3937. @option{--mtime} options. If the two dates differ, @command{tar} will
  3938. print a warning saying what date it will use. This is to help user
  3939. ensure he is using the right date.
  3940. For example:
  3941. @smallexample
  3942. $ @kbd{tar -c -f archive.tar -v --mtime=yesterday .}
  3943. tar: Option --mtime: Treating date `yesterday' as 2006-06-20
  3944. 13:06:29.152478
  3945. @dots{}
  3946. @end smallexample
  3947. @item --owner=@var{user}
  3948. @opindex owner
  3949. Specifies that @command{tar} should use @var{user} as the owner of members
  3950. when creating archives, instead of the user associated with the source
  3951. file.
  3952. If @var{user} contains a colon, it is taken to be of the form
  3953. @var{name}:@var{id} where a nonempty @var{name} specifies the user
  3954. name and a nonempty @var{id} specifies the decimal numeric user
  3955. @acronym{ID}. If @var{user} does not contain a colon, it is taken to
  3956. be a user number if it is one or more decimal digits; otherwise it is
  3957. taken to be a user name.
  3958. If a name is given but no number, the number is inferred from the
  3959. current host's user database if possible, and the file's user number
  3960. is used otherwise. If a number is given but no name, the name is
  3961. inferred from the number if possible, and an empty name is used
  3962. otherwise. If both name and number are given, the user database is
  3963. not consulted, and the name and number need not be valid on the
  3964. current host.
  3965. There is no value indicating a missing number, and @samp{0} usually means
  3966. @code{root}. Some people like to force @samp{0} as the value to offer in
  3967. their distributions for the owner of files, because the @code{root} user is
  3968. anonymous anyway, so that might as well be the owner of anonymous
  3969. archives. For example:
  3970. @smallexample
  3971. $ @kbd{tar -c -f archive.tar --owner=0 .}
  3972. @end smallexample
  3973. @noindent
  3974. or:
  3975. @smallexample
  3976. $ @kbd{tar -c -f archive.tar --owner=root .}
  3977. @end smallexample
  3978. @item --group=@var{group}
  3979. @opindex group
  3980. Files added to the @command{tar} archive will have a group @acronym{ID} of @var{group},
  3981. rather than the group from the source file. As with @option{--owner},
  3982. the argument @var{group} can be an existing group symbolic name, or a
  3983. decimal numeric group @acronym{ID}, or @var{name}:@var{id}.
  3984. @end table
  3985. @node Ignore Failed Read
  3986. @subsection Ignore Fail Read
  3987. @table @option
  3988. @item --ignore-failed-read
  3989. @opindex ignore-failed-read
  3990. Do not exit with nonzero on unreadable files or directories.
  3991. @end table
  3992. @node extract options
  3993. @section Options Used by @option{--extract}
  3994. @cindex options for use with @option{--extract}
  3995. @xopindex{extract, additional options}
  3996. The previous chapter showed how to use @option{--extract} to extract
  3997. an archive into the file system. Various options cause @command{tar} to
  3998. extract more information than just file contents, such as the owner,
  3999. the permissions, the modification date, and so forth. This section
  4000. presents options to be used with @option{--extract} when certain special
  4001. considerations arise. You may review the information presented in
  4002. @ref{extract} for more basic information about the
  4003. @option{--extract} operation.
  4004. @menu
  4005. * Reading:: Options to Help Read Archives
  4006. * Writing:: Changing How @command{tar} Writes Files
  4007. * Scarce:: Coping with Scarce Resources
  4008. @end menu
  4009. @node Reading
  4010. @subsection Options to Help Read Archives
  4011. @cindex Options when reading archives
  4012. @cindex Reading incomplete records
  4013. @cindex Records, incomplete
  4014. @opindex read-full-records
  4015. Normally, @command{tar} will request data in full record increments from
  4016. an archive storage device. If the device cannot return a full record,
  4017. @command{tar} will report an error. However, some devices do not always
  4018. return full records, or do not require the last record of an archive to
  4019. be padded out to the next record boundary. To keep reading until you
  4020. obtain a full record, or to accept an incomplete record if it contains
  4021. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  4022. in conjunction with the @option{--extract} or @option{--list} operations.
  4023. @xref{Blocking}.
  4024. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  4025. @command{tar} reads an archive from standard input, or from a remote
  4026. machine. This is because on @acronym{BSD} Unix systems, attempting to read a
  4027. pipe returns however much happens to be in the pipe, even if it is
  4028. less than was requested. If this option were not enabled, @command{tar}
  4029. would fail as soon as it read an incomplete record from the pipe.
  4030. If you're not sure of the blocking factor of an archive, you can
  4031. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  4032. @option{--blocking-factor=@var{512-size}} (@option{-b
  4033. @var{512-size}}), using a blocking factor larger than what the archive
  4034. uses. This lets you avoid having to determine the blocking factor
  4035. of an archive. @xref{Blocking Factor}.
  4036. @menu
  4037. * read full records::
  4038. * Ignore Zeros::
  4039. @end menu
  4040. @node read full records
  4041. @unnumberedsubsubsec Reading Full Records
  4042. @FIXME{need sentence or so of intro here}
  4043. @table @option
  4044. @opindex read-full-records
  4045. @item --read-full-records
  4046. @item -B
  4047. Use in conjunction with @option{--extract} (@option{--get},
  4048. @option{-x}) to read an archive which contains incomplete records, or
  4049. one which has a blocking factor less than the one specified.
  4050. @end table
  4051. @node Ignore Zeros
  4052. @unnumberedsubsubsec Ignoring Blocks of Zeros
  4053. @cindex End-of-archive blocks, ignoring
  4054. @cindex Ignoring end-of-archive blocks
  4055. @opindex ignore-zeros
  4056. Normally, @command{tar} stops reading when it encounters a block of zeros
  4057. between file entries (which usually indicates the end of the archive).
  4058. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  4059. completely read an archive which contains a block of zeros before the
  4060. end (i.e., a damaged archive, or one that was created by concatenating
  4061. several archives together).
  4062. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  4063. versions of @command{tar} write garbage after the end-of-archive entry,
  4064. since that part of the media is never supposed to be read. @GNUTAR{}
  4065. does not write after the end of an archive, but seeks to
  4066. maintain compatibility among archiving utilities.
  4067. @table @option
  4068. @item --ignore-zeros
  4069. @itemx -i
  4070. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  4071. encountered while reading an archive. Use in conjunction with
  4072. @option{--extract} or @option{--list}.
  4073. @end table
  4074. @node Writing
  4075. @subsection Changing How @command{tar} Writes Files
  4076. @UNREVISED
  4077. @FIXME{Introductory paragraph}
  4078. @menu
  4079. * Dealing with Old Files::
  4080. * Overwrite Old Files::
  4081. * Keep Old Files::
  4082. * Keep Newer Files::
  4083. * Unlink First::
  4084. * Recursive Unlink::
  4085. * Data Modification Times::
  4086. * Setting Access Permissions::
  4087. * Directory Modification Times and Permissions::
  4088. * Writing to Standard Output::
  4089. * Writing to an External Program::
  4090. * remove files::
  4091. @end menu
  4092. @node Dealing with Old Files
  4093. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  4094. @xopindex{overwrite-dir, introduced}
  4095. When extracting files, if @command{tar} discovers that the extracted
  4096. file already exists, it normally replaces the file by removing it before
  4097. extracting it, to prevent confusion in the presence of hard or symbolic
  4098. links. (If the existing file is a symbolic link, it is removed, not
  4099. followed.) However, if a directory cannot be removed because it is
  4100. nonempty, @command{tar} normally overwrites its metadata (ownership,
  4101. permission, etc.). The @option{--overwrite-dir} option enables this
  4102. default behavior. To be more cautious and preserve the metadata of
  4103. such a directory, use the @option{--no-overwrite-dir} option.
  4104. @cindex Overwriting old files, prevention
  4105. @xopindex{keep-old-files, introduced}
  4106. To be even more cautious and prevent existing files from being replaced, use
  4107. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  4108. to replace or update a file that already exists, i.e., a file with the
  4109. same name as an archive member prevents extraction of that archive
  4110. member. Instead, it reports an error.
  4111. @xopindex{overwrite, introduced}
  4112. To be more aggressive about altering existing files, use the
  4113. @option{--overwrite} option. It causes @command{tar} to overwrite
  4114. existing files and to follow existing symbolic links when extracting.
  4115. @cindex Protecting old files
  4116. Some people argue that @GNUTAR{} should not hesitate
  4117. to overwrite files with other files when extracting. When extracting
  4118. a @command{tar} archive, they expect to see a faithful copy of the
  4119. state of the file system when the archive was created. It is debatable
  4120. that this would always be a proper behavior. For example, suppose one
  4121. has an archive in which @file{usr/local} is a link to
  4122. @file{usr/local2}. Since then, maybe the site removed the link and
  4123. renamed the whole hierarchy from @file{/usr/local2} to
  4124. @file{/usr/local}. Such things happen all the time. I guess it would
  4125. not be welcome at all that @GNUTAR{} removes the
  4126. whole hierarchy just to make room for the link to be reinstated
  4127. (unless it @emph{also} simultaneously restores the full
  4128. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  4129. able to remove a whole hierarchy to reestablish a symbolic link, for
  4130. example, but @emph{only if} @option{--recursive-unlink} is specified
  4131. to allow this behavior. In any case, single files are silently
  4132. removed.
  4133. @xopindex{unlink-first, introduced}
  4134. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  4135. some cases by causing @command{tar} to remove files unconditionally
  4136. before extracting them.
  4137. @node Overwrite Old Files
  4138. @unnumberedsubsubsec Overwrite Old Files
  4139. @table @option
  4140. @opindex overwrite
  4141. @item --overwrite
  4142. Overwrite existing files and directory metadata when extracting files
  4143. from an archive.
  4144. This causes @command{tar} to write extracted files into the file system without
  4145. regard to the files already on the system; i.e., files with the same
  4146. names as archive members are overwritten when the archive is extracted.
  4147. It also causes @command{tar} to extract the ownership, permissions,
  4148. and time stamps onto any preexisting files or directories.
  4149. If the name of a corresponding file name is a symbolic link, the file
  4150. pointed to by the symbolic link will be overwritten instead of the
  4151. symbolic link itself (if this is possible). Moreover, special devices,
  4152. empty directories and even symbolic links are automatically removed if
  4153. they are in the way of extraction.
  4154. Be careful when using the @option{--overwrite} option, particularly when
  4155. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  4156. can change the contents, ownership or permissions of any file on your
  4157. system. Also, many systems do not take kindly to overwriting files that
  4158. are currently being executed.
  4159. @opindex overwrite-dir
  4160. @item --overwrite-dir
  4161. Overwrite the metadata of directories when extracting files from an
  4162. archive, but remove other files before extracting.
  4163. @end table
  4164. @node Keep Old Files
  4165. @unnumberedsubsubsec Keep Old Files
  4166. @table @option
  4167. @opindex keep-old-files
  4168. @item --keep-old-files
  4169. @itemx -k
  4170. Do not replace existing files from archive. The
  4171. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  4172. from replacing existing files with files with the same name from the
  4173. archive. The @option{--keep-old-files} option is meaningless with
  4174. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  4175. files in the file system during extraction.
  4176. @end table
  4177. @node Keep Newer Files
  4178. @unnumberedsubsubsec Keep Newer Files
  4179. @table @option
  4180. @opindex keep-newer-files
  4181. @item --keep-newer-files
  4182. Do not replace existing files that are newer than their archive
  4183. copies. This option is meaningless with @option{--list} (@option{-t}).
  4184. @end table
  4185. @node Unlink First
  4186. @unnumberedsubsubsec Unlink First
  4187. @table @option
  4188. @opindex unlink-first
  4189. @item --unlink-first
  4190. @itemx -U
  4191. Remove files before extracting over them.
  4192. This can make @command{tar} run a bit faster if you know in advance
  4193. that the extracted files all need to be removed. Normally this option
  4194. slows @command{tar} down slightly, so it is disabled by default.
  4195. @end table
  4196. @node Recursive Unlink
  4197. @unnumberedsubsubsec Recursive Unlink
  4198. @table @option
  4199. @opindex recursive-unlink
  4200. @item --recursive-unlink
  4201. When this option is specified, try removing files and directory hierarchies
  4202. before extracting over them. @emph{This is a dangerous option!}
  4203. @end table
  4204. If you specify the @option{--recursive-unlink} option,
  4205. @command{tar} removes @emph{anything} that keeps you from extracting a file
  4206. as far as current permissions will allow it. This could include removal
  4207. of the contents of a full directory hierarchy.
  4208. @node Data Modification Times
  4209. @unnumberedsubsubsec Setting Data Modification Times
  4210. @cindex Data modification times of extracted files
  4211. @cindex Modification times of extracted files
  4212. Normally, @command{tar} sets the data modification times of extracted
  4213. files to the corresponding times recorded for the files in the archive, but
  4214. limits the permissions of extracted files by the current @code{umask}
  4215. setting.
  4216. To set the data modification times of extracted files to the time when
  4217. the files were extracted, use the @option{--touch} (@option{-m}) option in
  4218. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  4219. @table @option
  4220. @opindex touch
  4221. @item --touch
  4222. @itemx -m
  4223. Sets the data modification time of extracted archive members to the time
  4224. they were extracted, not the time recorded for them in the archive.
  4225. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  4226. @end table
  4227. @node Setting Access Permissions
  4228. @unnumberedsubsubsec Setting Access Permissions
  4229. @cindex Permissions of extracted files
  4230. @cindex Modes of extracted files
  4231. To set the modes (access permissions) of extracted files to those
  4232. recorded for those files in the archive, use @option{--same-permissions}
  4233. in conjunction with the @option{--extract} (@option{--get},
  4234. @option{-x}) operation.
  4235. @table @option
  4236. @opindex preserve-permissions
  4237. @opindex same-permissions
  4238. @item --preserve-permissions
  4239. @itemx --same-permissions
  4240. @c @itemx --ignore-umask
  4241. @itemx -p
  4242. Set modes of extracted archive members to those recorded in the
  4243. archive, instead of current umask settings. Use in conjunction with
  4244. @option{--extract} (@option{--get}, @option{-x}).
  4245. @end table
  4246. @node Directory Modification Times and Permissions
  4247. @unnumberedsubsubsec Directory Modification Times and Permissions
  4248. After successfully extracting a file member, @GNUTAR{} normally
  4249. restores its permissions and modification times, as described in the
  4250. previous sections. This cannot be done for directories, because
  4251. after extracting a directory @command{tar} will almost certainly
  4252. extract files into that directory and this will cause the directory
  4253. modification time to be updated. Moreover, restoring that directory
  4254. permissions may not permit file creation within it. Thus, restoring
  4255. directory permissions and modification times must be delayed at least
  4256. until all files have been extracted into that directory. @GNUTAR{}
  4257. restores directories using the following approach.
  4258. The extracted directories are created with the mode specified in the
  4259. archive, as modified by the umask of the user, which gives sufficient
  4260. permissions to allow file creation. The meta-information about the
  4261. directory is recorded in the temporary list of directories. When
  4262. preparing to extract next archive member, @GNUTAR{} checks if the
  4263. directory prefix of this file contains the remembered directory. If
  4264. it does not, the program assumes that all files have been extracted
  4265. into that directory, restores its modification time and permissions
  4266. and removes its entry from the internal list. This approach allows
  4267. to correctly restore directory meta-information in the majority of
  4268. cases, while keeping memory requirements sufficiently small. It is
  4269. based on the fact, that most @command{tar} archives use the predefined
  4270. order of members: first the directory, then all the files and
  4271. subdirectories in that directory.
  4272. However, this is not always true. The most important exception are
  4273. incremental archives (@pxref{Incremental Dumps}). The member order in
  4274. an incremental archive is reversed: first all directory members are
  4275. stored, followed by other (non-directory) members. So, when extracting
  4276. from incremental archives, @GNUTAR{} alters the above procedure. It
  4277. remembers all restored directories, and restores their meta-data
  4278. only after the entire archive has been processed. Notice, that you do
  4279. not need to specify any special options for that, as @GNUTAR{}
  4280. automatically detects archives in incremental format.
  4281. There may be cases, when such processing is required for normal archives
  4282. too. Consider the following example:
  4283. @smallexample
  4284. @group
  4285. $ @kbd{tar --no-recursion -cvf archive \
  4286. foo foo/file1 bar bar/file foo/file2}
  4287. foo/
  4288. foo/file1
  4289. bar/
  4290. bar/file
  4291. foo/file2
  4292. @end group
  4293. @end smallexample
  4294. During the normal operation, after encountering @file{bar}
  4295. @GNUTAR{} will assume that all files from the directory @file{foo}
  4296. were already extracted and will therefore restore its timestamp and
  4297. permission bits. However, after extracting @file{foo/file2} the
  4298. directory timestamp will be offset again.
  4299. To correctly restore directory meta-information in such cases, use
  4300. the @option{--delay-directory-restore} command line option:
  4301. @table @option
  4302. @opindex delay-directory-restore
  4303. @item --delay-directory-restore
  4304. Delays restoring of the modification times and permissions of extracted
  4305. directories until the end of extraction. This way, correct
  4306. meta-information is restored even if the archive has unusual member
  4307. ordering.
  4308. @opindex no-delay-directory-restore
  4309. @item --no-delay-directory-restore
  4310. Cancel the effect of the previous @option{--delay-directory-restore}.
  4311. Use this option if you have used @option{--delay-directory-restore} in
  4312. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  4313. temporarily disable it.
  4314. @end table
  4315. @node Writing to Standard Output
  4316. @unnumberedsubsubsec Writing to Standard Output
  4317. @cindex Writing extracted files to standard output
  4318. @cindex Standard output, writing extracted files to
  4319. To write the extracted files to the standard output, instead of
  4320. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  4321. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  4322. extracting files to send them through a pipe, and do not need to
  4323. preserve them in the file system. If you extract multiple members,
  4324. they appear on standard output concatenated, in the order they are
  4325. found in the archive.
  4326. @table @option
  4327. @opindex to-stdout
  4328. @item --to-stdout
  4329. @itemx -O
  4330. Writes files to the standard output. Use only in conjunction with
  4331. @option{--extract} (@option{--get}, @option{-x}). When this option is
  4332. used, instead of creating the files specified, @command{tar} writes
  4333. the contents of the files extracted to its standard output. This may
  4334. be useful if you are only extracting the files in order to send them
  4335. through a pipe. This option is meaningless with @option{--list}
  4336. (@option{-t}).
  4337. @end table
  4338. This can be useful, for example, if you have a tar archive containing
  4339. a big file and don't want to store the file on disk before processing
  4340. it. You can use a command like this:
  4341. @smallexample
  4342. tar -xOzf foo.tgz bigfile | process
  4343. @end smallexample
  4344. or even like this if you want to process the concatenation of the files:
  4345. @smallexample
  4346. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  4347. @end smallexample
  4348. However, @option{--to-command} may be more convenient for use with
  4349. multiple files. See the next section.
  4350. @node Writing to an External Program
  4351. @unnumberedsubsubsec Writing to an External Program
  4352. You can instruct @command{tar} to send the contents of each extracted
  4353. file to the standard input of an external program:
  4354. @table @option
  4355. @opindex to-command
  4356. @item --to-command=@var{command}
  4357. Extract files and pipe their contents to the standard input of
  4358. @var{command}. When this option is used, instead of creating the
  4359. files specified, @command{tar} invokes @var{command} and pipes the
  4360. contents of the files to its standard output. The @var{command} may
  4361. contain command line arguments. The program is executed via
  4362. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  4363. extracted. Non-regular files (directories, etc.) are ignored when this
  4364. option is used.
  4365. @end table
  4366. The command can obtain the information about the file it processes
  4367. from the following environment variables:
  4368. @table @env
  4369. @vrindex TAR_FILETYPE, to-command environment
  4370. @item TAR_FILETYPE
  4371. Type of the file. It is a single letter with the following meaning:
  4372. @multitable @columnfractions 0.10 0.90
  4373. @item f @tab Regular file
  4374. @item d @tab Directory
  4375. @item l @tab Symbolic link
  4376. @item h @tab Hard link
  4377. @item b @tab Block device
  4378. @item c @tab Character device
  4379. @end multitable
  4380. Currently only regular files are supported.
  4381. @vrindex TAR_MODE, to-command environment
  4382. @item TAR_MODE
  4383. File mode, an octal number.
  4384. @vrindex TAR_FILENAME, to-command environment
  4385. @item TAR_FILENAME
  4386. The name of the file.
  4387. @vrindex TAR_REALNAME, to-command environment
  4388. @item TAR_REALNAME
  4389. Name of the file as stored in the archive.
  4390. @vrindex TAR_UNAME, to-command environment
  4391. @item TAR_UNAME
  4392. Name of the file owner.
  4393. @vrindex TAR_GNAME, to-command environment
  4394. @item TAR_GNAME
  4395. Name of the file owner group.
  4396. @vrindex TAR_ATIME, to-command environment
  4397. @item TAR_ATIME
  4398. Time of last access. It is a decimal number, representing seconds
  4399. since the Epoch. If the archive provides times with nanosecond
  4400. precision, the nanoseconds are appended to the timestamp after a
  4401. decimal point.
  4402. @vrindex TAR_MTIME, to-command environment
  4403. @item TAR_MTIME
  4404. Time of last modification.
  4405. @vrindex TAR_CTIME, to-command environment
  4406. @item TAR_CTIME
  4407. Time of last status change.
  4408. @vrindex TAR_SIZE, to-command environment
  4409. @item TAR_SIZE
  4410. Size of the file.
  4411. @vrindex TAR_UID, to-command environment
  4412. @item TAR_UID
  4413. UID of the file owner.
  4414. @vrindex TAR_GID, to-command environment
  4415. @item TAR_GID
  4416. GID of the file owner.
  4417. @end table
  4418. Additionally, the following variables contain information about
  4419. tar mode and the archive being processed:
  4420. @table @env
  4421. @vrindex TAR_VERSION, to-command environment
  4422. @item TAR_VERSION
  4423. @GNUTAR{} version number.
  4424. @vrindex TAR_ARCHIVE, to-command environment
  4425. @item TAR_ARCHIVE
  4426. The name of the archive @command{tar} is processing.
  4427. @vrindex TAR_BLOCKING_FACTOR, to-command environment
  4428. @item TAR_BLOCKING_FACTOR
  4429. Current blocking factor (@pxref{Blocking}).
  4430. @vrindex TAR_VOLUME, to-command environment
  4431. @item TAR_VOLUME
  4432. Ordinal number of the volume @command{tar} is processing.
  4433. @vrindex TAR_FORMAT, to-command environment
  4434. @item TAR_FORMAT
  4435. Format of the archive being processed. @xref{Formats}, for a complete
  4436. list of archive format names.
  4437. @end table
  4438. If @var{command} exits with a non-0 status, @command{tar} will print
  4439. an error message similar to the following:
  4440. @smallexample
  4441. tar: 2345: Child returned status 1
  4442. @end smallexample
  4443. Here, @samp{2345} is the PID of the finished process.
  4444. If this behavior is not wanted, use @option{--ignore-command-error}:
  4445. @table @option
  4446. @opindex ignore-command-error
  4447. @item --ignore-command-error
  4448. Ignore exit codes of subprocesses. Notice that if the program
  4449. exits on signal or otherwise terminates abnormally, the error message
  4450. will be printed even if this option is used.
  4451. @opindex no-ignore-command-error
  4452. @item --no-ignore-command-error
  4453. Cancel the effect of any previous @option{--ignore-command-error}
  4454. option. This option is useful if you have set
  4455. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  4456. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  4457. @end table
  4458. @node remove files
  4459. @unnumberedsubsubsec Removing Files
  4460. @FIXME{The section is too terse. Something more to add? An example,
  4461. maybe?}
  4462. @table @option
  4463. @opindex remove-files
  4464. @item --remove-files
  4465. Remove files after adding them to the archive.
  4466. @end table
  4467. @node Scarce
  4468. @subsection Coping with Scarce Resources
  4469. @UNREVISED
  4470. @cindex Small memory
  4471. @cindex Running out of space
  4472. @menu
  4473. * Starting File::
  4474. * Same Order::
  4475. @end menu
  4476. @node Starting File
  4477. @unnumberedsubsubsec Starting File
  4478. @table @option
  4479. @opindex starting-file
  4480. @item --starting-file=@var{name}
  4481. @itemx -K @var{name}
  4482. Starts an operation in the middle of an archive. Use in conjunction
  4483. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  4484. @end table
  4485. @cindex Middle of the archive, starting in the
  4486. If a previous attempt to extract files failed due to lack of disk
  4487. space, you can use @option{--starting-file=@var{name}} (@option{-K
  4488. @var{name}}) to start extracting only after member @var{name} of the
  4489. archive. This assumes, of course, that there is now free space, or
  4490. that you are now extracting into a different file system. (You could
  4491. also choose to suspend @command{tar}, remove unnecessary files from
  4492. the file system, and then resume the same @command{tar} operation.
  4493. In this case, @option{--starting-file} is not necessary.) See also
  4494. @ref{interactive}, and @ref{exclude}.
  4495. @node Same Order
  4496. @unnumberedsubsubsec Same Order
  4497. @table @option
  4498. @cindex Large lists of file names on small machines
  4499. @opindex same-order
  4500. @opindex preserve-order
  4501. @item --same-order
  4502. @itemx --preserve-order
  4503. @itemx -s
  4504. To process large lists of file names on machines with small amounts of
  4505. memory. Use in conjunction with @option{--compare} (@option{--diff},
  4506. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  4507. (@option{--get}, @option{-x}).
  4508. @end table
  4509. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  4510. names to be listed or extracted is sorted in the same order as the
  4511. files in the archive. This allows a large list of names to be used,
  4512. even on a small machine that would not otherwise be able to hold all
  4513. the names in memory at the same time. Such a sorted list can easily be
  4514. created by running @samp{tar -t} on the archive and editing its output.
  4515. This option is probably never needed on modern computer systems.
  4516. @node backup
  4517. @section Backup options
  4518. @cindex backup options
  4519. @GNUTAR{} offers options for making backups of files
  4520. before writing new versions. These options control the details of
  4521. these backups. They may apply to the archive itself before it is
  4522. created or rewritten, as well as individual extracted members. Other
  4523. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  4524. and @command{mv}, for example) offer similar options.
  4525. Backup options may prove unexpectedly useful when extracting archives
  4526. containing many members having identical name, or when extracting archives
  4527. on systems having file name limitations, making different members appear
  4528. as having similar names through the side-effect of name truncation.
  4529. @FIXME{This is true only if we have a good scheme for truncated backup names,
  4530. which I'm not sure at all: I suspect work is needed in this area.}
  4531. When any existing file is backed up before being overwritten by extraction,
  4532. then clashing files are automatically be renamed to be unique, and the
  4533. true name is kept for only the last file of a series of clashing files.
  4534. By using verbose mode, users may track exactly what happens.
  4535. At the detail level, some decisions are still experimental, and may
  4536. change in the future, we are waiting comments from our users. So, please
  4537. do not learn to depend blindly on the details of the backup features.
  4538. For example, currently, directories themselves are never renamed through
  4539. using these options, so, extracting a file over a directory still has
  4540. good chances to fail. Also, backup options apply to created archives,
  4541. not only to extracted members. For created archives, backups will not
  4542. be attempted when the archive is a block or character device, or when it
  4543. refers to a remote file.
  4544. For the sake of simplicity and efficiency, backups are made by renaming old
  4545. files prior to creation or extraction, and not by copying. The original
  4546. name is restored if the file creation fails. If a failure occurs after a
  4547. partial extraction of a file, both the backup and the partially extracted
  4548. file are kept.
  4549. @table @samp
  4550. @item --backup[=@var{method}]
  4551. @opindex backup
  4552. @vindex VERSION_CONTROL
  4553. @cindex backups
  4554. Back up files that are about to be overwritten or removed.
  4555. Without this option, the original versions are destroyed.
  4556. Use @var{method} to determine the type of backups made.
  4557. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  4558. environment variable. And if @env{VERSION_CONTROL} is not set,
  4559. use the @samp{existing} method.
  4560. @vindex version-control @r{Emacs variable}
  4561. This option corresponds to the Emacs variable @samp{version-control};
  4562. the same values for @var{method} are accepted as in Emacs. This option
  4563. also allows more descriptive names. The valid @var{method}s are:
  4564. @table @samp
  4565. @item t
  4566. @itemx numbered
  4567. @cindex numbered @r{backup method}
  4568. Always make numbered backups.
  4569. @item nil
  4570. @itemx existing
  4571. @cindex existing @r{backup method}
  4572. Make numbered backups of files that already have them, simple backups
  4573. of the others.
  4574. @item never
  4575. @itemx simple
  4576. @cindex simple @r{backup method}
  4577. Always make simple backups.
  4578. @end table
  4579. @item --suffix=@var{suffix}
  4580. @opindex suffix
  4581. @cindex backup suffix
  4582. @vindex SIMPLE_BACKUP_SUFFIX
  4583. Append @var{suffix} to each backup file made with @option{--backup}. If this
  4584. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  4585. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  4586. set, the default is @samp{~}, just as in Emacs.
  4587. @end table
  4588. @node Applications
  4589. @section Notable @command{tar} Usages
  4590. @UNREVISED
  4591. @FIXME{Using Unix file linking capability to recreate directory
  4592. structures---linking files into one subdirectory and then
  4593. @command{tar}ring that directory.}
  4594. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  4595. @findex uuencode
  4596. You can easily use archive files to transport a group of files from
  4597. one system to another: put all relevant files into an archive on one
  4598. computer system, transfer the archive to another system, and extract
  4599. the contents there. The basic transfer medium might be magnetic tape,
  4600. Internet FTP, or even electronic mail (though you must encode the
  4601. archive with @command{uuencode} in order to transport it properly by
  4602. mail). Both machines do not have to use the same operating system, as
  4603. long as they both support the @command{tar} program.
  4604. For example, here is how you might copy a directory's contents from
  4605. one disk to another, while preserving the dates, modes, owners and
  4606. link-structure of all the files therein. In this case, the transfer
  4607. medium is a @dfn{pipe}:
  4608. @smallexample
  4609. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  4610. @end smallexample
  4611. @noindent
  4612. You can avoid subshells by using @option{-C} option:
  4613. @smallexample
  4614. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  4615. @end smallexample
  4616. @noindent
  4617. The command also works using long option forms:
  4618. @smallexample
  4619. @group
  4620. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  4621. | (cd targetdir; tar --extract --file=-)}
  4622. @end group
  4623. @end smallexample
  4624. @noindent
  4625. or
  4626. @smallexample
  4627. @group
  4628. $ @kbd{tar --directory sourcedir --create --file=- . \
  4629. | tar --directory targetdir --extract --file=-}
  4630. @end group
  4631. @end smallexample
  4632. @noindent
  4633. This is one of the easiest methods to transfer a @command{tar} archive.
  4634. @node looking ahead
  4635. @section Looking Ahead: The Rest of this Manual
  4636. You have now seen how to use all eight of the operations available to
  4637. @command{tar}, and a number of the possible options. The next chapter
  4638. explains how to choose and change file and archive names, how to use
  4639. files to store names of other files which you can then call as
  4640. arguments to @command{tar} (this can help you save time if you expect to
  4641. archive the same list of files a number of times), and so forth.
  4642. @FIXME{in case it's not obvious, i'm making this up in some sense
  4643. based on my limited memory of what the next chapter *really* does. i
  4644. just wanted to flesh out this final section a little bit so i'd
  4645. remember to stick it in here. :-)}
  4646. If there are too many files to conveniently list on the command line,
  4647. you can list the names in a file, and @command{tar} will read that file.
  4648. @xref{files}.
  4649. There are various ways of causing @command{tar} to skip over some files,
  4650. and not archive them. @xref{Choosing}.
  4651. @node Backups
  4652. @chapter Performing Backups and Restoring Files
  4653. @cindex backups
  4654. @GNUTAR{} is distributed along with the scripts for performing backups
  4655. and restores. Even if there is a good chance those scripts may be
  4656. satisfying to you, they are not the only scripts or methods available for doing
  4657. backups and restore. You may well create your own, or use more
  4658. sophisticated packages dedicated to that purpose.
  4659. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4660. Automatic Network Disk Archiver), a backup system developed by James
  4661. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4662. This is free software, and it is available from @uref{http://www.amanda.org}.
  4663. @FIXME{
  4664. Here is a possible plan for a future documentation about the backuping
  4665. scripts which are provided within the @GNUTAR{}
  4666. distribution.
  4667. @itemize @bullet
  4668. @item dumps
  4669. @itemize @minus
  4670. @item what are dumps
  4671. @item different levels of dumps
  4672. @itemize +
  4673. @item full dump = dump everything
  4674. @item level 1, level 2 dumps etc
  4675. A level @var{n} dump dumps everything changed since the last level
  4676. @var{n}-1 dump (?)
  4677. @end itemize
  4678. @item how to use scripts for dumps (ie, the concept)
  4679. @itemize +
  4680. @item scripts to run after editing backup specs (details)
  4681. @end itemize
  4682. @item Backup Specs, what is it.
  4683. @itemize +
  4684. @item how to customize
  4685. @item actual text of script [/sp/dump/backup-specs]
  4686. @end itemize
  4687. @item Problems
  4688. @itemize +
  4689. @item rsh doesn't work
  4690. @item rtape isn't installed
  4691. @item (others?)
  4692. @end itemize
  4693. @item the @option{--incremental} option of tar
  4694. @item tapes
  4695. @itemize +
  4696. @item write protection
  4697. @item types of media, different sizes and types, useful for different things
  4698. @item files and tape marks
  4699. one tape mark between files, two at end.
  4700. @item positioning the tape
  4701. MT writes two at end of write,
  4702. backspaces over one when writing again.
  4703. @end itemize
  4704. @end itemize
  4705. @end itemize
  4706. }
  4707. This chapter documents both the provided shell scripts and @command{tar}
  4708. options which are more specific to usage as a backup tool.
  4709. To @dfn{back up} a file system means to create archives that contain
  4710. all the files in that file system. Those archives can then be used to
  4711. restore any or all of those files (for instance if a disk crashes or a
  4712. file is accidentally deleted). File system @dfn{backups} are also
  4713. called @dfn{dumps}.
  4714. @menu
  4715. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4716. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4717. * Backup Levels:: Levels of Backups
  4718. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4719. * Scripted Backups:: Using the Backup Scripts
  4720. * Scripted Restoration:: Using the Restore Script
  4721. @end menu
  4722. @node Full Dumps
  4723. @section Using @command{tar} to Perform Full Dumps
  4724. @UNREVISED
  4725. @cindex full dumps
  4726. @cindex dumps, full
  4727. @cindex corrupted archives
  4728. Full dumps should only be made when no other people or programs
  4729. are modifying files in the file system. If files are modified while
  4730. @command{tar} is making the backup, they may not be stored properly in
  4731. the archive, in which case you won't be able to restore them if you
  4732. have to. (Files not being modified are written with no trouble, and do
  4733. not corrupt the entire archive.)
  4734. You will want to use the @option{--label=@var{archive-label}}
  4735. (@option{-V @var{archive-label}}) option to give the archive a
  4736. volume label, so you can tell what this archive is even if the label
  4737. falls off the tape, or anything like that.
  4738. Unless the file system you are dumping is guaranteed to fit on
  4739. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4740. Make sure you have enough tapes on hand to complete the backup.
  4741. If you want to dump each file system separately you will need to use
  4742. the @option{--one-file-system} option to prevent
  4743. @command{tar} from crossing file system boundaries when storing
  4744. (sub)directories.
  4745. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4746. option is not needed, since this is a complete copy of everything in
  4747. the file system, and a full restore from this backup would only be
  4748. done onto a completely
  4749. empty disk.
  4750. Unless you are in a hurry, and trust the @command{tar} program (and your
  4751. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4752. option, to make sure your files really made it onto the dump properly.
  4753. This will also detect cases where the file was modified while (or just
  4754. after) it was being archived. Not all media (notably cartridge tapes)
  4755. are capable of being verified, unfortunately.
  4756. @node Incremental Dumps
  4757. @section Using @command{tar} to Perform Incremental Dumps
  4758. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4759. stores additional metadata so that exact state of the file system
  4760. can be restored when extracting the archive.
  4761. @GNUTAR{} currently offers two options for handling incremental
  4762. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4763. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4764. @xopindex{listed-incremental, described}
  4765. The option @option{--listed-incremental} instructs tar to operate on
  4766. an incremental archive with additional metadata stored in a standalone
  4767. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4768. determine which files have been changed, added or deleted since the
  4769. last backup, so that the next incremental backup will contain only
  4770. modified files. The name of the snapshot file is given as an argument
  4771. to the option:
  4772. @table @option
  4773. @item --listed-incremental=@var{file}
  4774. @itemx -g @var{file}
  4775. Handle incremental backups with snapshot data in @var{file}.
  4776. @end table
  4777. To create an incremental backup, you would use
  4778. @option{--listed-incremental} together with @option{--create}
  4779. (@pxref{create}). For example:
  4780. @smallexample
  4781. $ @kbd{tar --create \
  4782. --file=archive.1.tar \
  4783. --listed-incremental=/var/log/usr.snar \
  4784. /usr}
  4785. @end smallexample
  4786. This will create in @file{archive.1.tar} an incremental backup of
  4787. the @file{/usr} file system, storing additional metadata in the file
  4788. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4789. created. The created archive will then be a @dfn{level 0 backup};
  4790. please see the next section for more on backup levels.
  4791. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4792. determines which files are modified. In this case only these files will be
  4793. stored in the archive. Suppose, for example, that after running the
  4794. above command, you delete file @file{/usr/doc/old} and create
  4795. directory @file{/usr/local/db} with the following contents:
  4796. @smallexample
  4797. $ @kbd{ls /usr/local/db}
  4798. /usr/local/db/data
  4799. /usr/local/db/index
  4800. @end smallexample
  4801. Some time later you create another incremental backup. You will
  4802. then see:
  4803. @smallexample
  4804. $ @kbd{tar --create \
  4805. --file=archive.2.tar \
  4806. --listed-incremental=/var/log/usr.snar \
  4807. /usr}
  4808. tar: usr/local/db: Directory is new
  4809. usr/local/db/
  4810. usr/local/db/data
  4811. usr/local/db/index
  4812. @end smallexample
  4813. @noindent
  4814. The created archive @file{archive.2.tar} will contain only these
  4815. three members. This archive is called a @dfn{level 1 backup}. Notice
  4816. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4817. you plan to create more @samp{level 1} backups, it is necessary to
  4818. create a working copy of the snapshot file before running
  4819. @command{tar}. The above example will then be modified as follows:
  4820. @smallexample
  4821. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4822. $ @kbd{tar --create \
  4823. --file=archive.2.tar \
  4824. --listed-incremental=/var/log/usr.snar-1 \
  4825. /usr}
  4826. @end smallexample
  4827. @anchor{--level=0}
  4828. @xopindex{level, described}
  4829. You can force @samp{level 0} backups either by removing the snapshot
  4830. file before running @command{tar}, or by supplying the
  4831. @option{--level=0} option, e.g.:
  4832. @smallexample
  4833. $ @kbd{tar --create \
  4834. --file=archive.2.tar \
  4835. --listed-incremental=/var/log/usr.snar-0 \
  4836. --level=0 \
  4837. /usr}
  4838. @end smallexample
  4839. Incremental dumps depend crucially on time stamps, so the results are
  4840. unreliable if you modify a file's time stamps during dumping (e.g.,
  4841. with the @option{--atime-preserve=replace} option), or if you set the clock
  4842. backwards.
  4843. @anchor{device numbers}
  4844. @cindex Device numbers, using in incremental backups
  4845. Metadata stored in snapshot files include device numbers, which,
  4846. obviously are supposed to be non-volatile values. However, it turns
  4847. out that @acronym{NFS} devices have undependable values when an automounter
  4848. gets in the picture. This can lead to a great deal of spurious
  4849. redumping in incremental dumps, so it is somewhat useless to compare
  4850. two @acronym{NFS} devices numbers over time. The solution implemented
  4851. currently is to consider all @acronym{NFS} devices as being equal
  4852. when it comes to comparing directories; this is fairly gross, but
  4853. there does not seem to be a better way to go.
  4854. Apart from using @acronym{NFS}, there are a number of cases where
  4855. relying on device numbers can cause spurious redumping of unmodified
  4856. files. For example, this occurs when archiving @acronym{LVM} snapshot
  4857. volumes. To avoid this, use @option{--no-check-device} option:
  4858. @table @option
  4859. @xopindex{no-check-device, described}
  4860. @item --no-check-device
  4861. Do not rely on device numbers when preparing a list of changed files
  4862. for an incremental dump.
  4863. @xopindex{check-device, described}
  4864. @item --check-device
  4865. Use device numbers when preparing a list of changed files
  4866. for an incremental dump. This is the default behavior. The purpose
  4867. of this option is to undo the effect of the @option{--no-check-device}
  4868. if it was given in @env{TAR_OPTIONS} environment variable
  4869. (@pxref{TAR_OPTIONS}).
  4870. @end table
  4871. There is also another way to cope with changing device numbers. It is
  4872. described in detail in @ref{Fixing Snapshot Files}.
  4873. Note that incremental archives use @command{tar} extensions and may
  4874. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4875. @xopindex{listed-incremental, using with @option{--extract}}
  4876. @xopindex{extract, using with @option{--listed-incremental}}
  4877. To extract from the incremental dumps, use
  4878. @option{--listed-incremental} together with @option{--extract}
  4879. option (@pxref{extracting files}). In this case, @command{tar} does
  4880. not need to access snapshot file, since all the data necessary for
  4881. extraction are stored in the archive itself. So, when extracting, you
  4882. can give whatever argument to @option{--listed-incremental}, the usual
  4883. practice is to use @option{--listed-incremental=/dev/null}.
  4884. Alternatively, you can use @option{--incremental}, which needs no
  4885. arguments. In general, @option{--incremental} (@option{-G}) can be
  4886. used as a shortcut for @option{--listed-incremental} when listing or
  4887. extracting incremental backups (for more information regarding this
  4888. option, @pxref{incremental-op}).
  4889. When extracting from the incremental backup @GNUTAR{} attempts to
  4890. restore the exact state the file system had when the archive was
  4891. created. In particular, it will @emph{delete} those files in the file
  4892. system that did not exist in their directories when the archive was
  4893. created. If you have created several levels of incremental files,
  4894. then in order to restore the exact contents the file system had when
  4895. the last level was created, you will need to restore from all backups
  4896. in turn. Continuing our example, to restore the state of @file{/usr}
  4897. file system, one would do@footnote{Notice, that since both archives
  4898. were created without @option{-P} option (@pxref{absolute}), these
  4899. commands should be run from the root file system.}:
  4900. @smallexample
  4901. $ @kbd{tar --extract \
  4902. --listed-incremental=/dev/null \
  4903. --file archive.1.tar}
  4904. $ @kbd{tar --extract \
  4905. --listed-incremental=/dev/null \
  4906. --file archive.2.tar}
  4907. @end smallexample
  4908. To list the contents of an incremental archive, use @option{--list}
  4909. (@pxref{list}), as usual. To obtain more information about the
  4910. archive, use @option{--listed-incremental} or @option{--incremental}
  4911. combined with two @option{--verbose} options@footnote{Two
  4912. @option{--verbose} options were selected to avoid breaking usual
  4913. verbose listing output (@option{--list --verbose}) when using in
  4914. scripts.
  4915. @xopindex{incremental, using with @option{--list}}
  4916. @xopindex{listed-incremental, using with @option{--list}}
  4917. @xopindex{list, using with @option{--incremental}}
  4918. @xopindex{list, using with @option{--listed-incremental}}
  4919. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4920. contents of the DUMPDIR header (with terminating nulls) when
  4921. @option{--incremental} or @option{--listed-incremental} option was
  4922. given, no matter what the verbosity level. This behavior, and,
  4923. especially, the binary output it produced were considered inconvenient
  4924. and were changed in version 1.16.}:
  4925. @smallexample
  4926. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4927. @end smallexample
  4928. This command will print, for each directory in the archive, the list
  4929. of files in that directory at the time the archive was created. This
  4930. information is put out in a format which is both human-readable and
  4931. unambiguous for a program: each file name is printed as
  4932. @smallexample
  4933. @var{x} @var{file}
  4934. @end smallexample
  4935. @noindent
  4936. where @var{x} is a letter describing the status of the file: @samp{Y}
  4937. if the file is present in the archive, @samp{N} if the file is not
  4938. included in the archive, or a @samp{D} if the file is a directory (and
  4939. is included in the archive). @xref{Dumpdir}, for the detailed
  4940. description of dumpdirs and status codes. Each such
  4941. line is terminated by a newline character. The last line is followed
  4942. by an additional newline to indicate the end of the data.
  4943. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4944. gives the same behavior as @option{--listed-incremental} when used
  4945. with @option{--list} and @option{--extract} options. When used with
  4946. @option{--create} option, it creates an incremental archive without
  4947. creating snapshot file. Thus, it is impossible to create several
  4948. levels of incremental backups with @option{--incremental} option.
  4949. @node Backup Levels
  4950. @section Levels of Backups
  4951. An archive containing all the files in the file system is called a
  4952. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4953. creating a full dump every day. This strategy, however, would waste a
  4954. substantial amount of archive media and user time, as unchanged files
  4955. are daily re-archived.
  4956. It is more efficient to do a full dump only occasionally. To back up
  4957. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4958. one} dump archives all the files that have changed since the last full
  4959. dump.
  4960. A typical dump strategy would be to perform a full dump once a week,
  4961. and a level one dump once a day. This means some versions of files
  4962. will in fact be archived more than once, but this dump strategy makes
  4963. it possible to restore a file system to within one day of accuracy by
  4964. only extracting two archives---the last weekly (full) dump and the
  4965. last daily (level one) dump. The only information lost would be in
  4966. files changed or created since the last daily backup. (Doing dumps
  4967. more than once a day is usually not worth the trouble.)
  4968. @GNUTAR{} comes with scripts you can use to do full
  4969. and level-one (actually, even level-two and so on) dumps. Using
  4970. scripts (shell programs) to perform backups and restoration is a
  4971. convenient and reliable alternative to typing out file name lists
  4972. and @command{tar} commands by hand.
  4973. Before you use these scripts, you need to edit the file
  4974. @file{backup-specs}, which specifies parameters used by the backup
  4975. scripts and by the restore script. This file is usually located
  4976. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4977. detailed description. Once the backup parameters are set, you can
  4978. perform backups or restoration by running the appropriate script.
  4979. The name of the backup script is @code{backup}. The name of the
  4980. restore script is @code{restore}. The following sections describe
  4981. their use in detail.
  4982. @emph{Please Note:} The backup and restoration scripts are
  4983. designed to be used together. While it is possible to restore files by
  4984. hand from an archive which was created using a backup script, and to create
  4985. an archive by hand which could then be extracted using the restore script,
  4986. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4987. making such an attempt.
  4988. @node Backup Parameters
  4989. @section Setting Parameters for Backups and Restoration
  4990. The file @file{backup-specs} specifies backup parameters for the
  4991. backup and restoration scripts provided with @command{tar}. You must
  4992. edit @file{backup-specs} to fit your system configuration and schedule
  4993. before using these scripts.
  4994. Syntactically, @file{backup-specs} is a shell script, containing
  4995. mainly variable assignments. However, any valid shell construct
  4996. is allowed in this file. Particularly, you may wish to define
  4997. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4998. For more information about shell script syntax, please refer to
  4999. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  5000. g_02, the definition of the Shell Command Language}. See also
  5001. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  5002. The shell variables controlling behavior of @code{backup} and
  5003. @code{restore} are described in the following subsections.
  5004. @menu
  5005. * General-Purpose Variables::
  5006. * Magnetic Tape Control::
  5007. * User Hooks::
  5008. * backup-specs example:: An Example Text of @file{Backup-specs}
  5009. @end menu
  5010. @node General-Purpose Variables
  5011. @subsection General-Purpose Variables
  5012. @defvr {Backup variable} ADMINISTRATOR
  5013. The user name of the backup administrator. @code{Backup} scripts
  5014. sends a backup report to this address.
  5015. @end defvr
  5016. @defvr {Backup variable} BACKUP_HOUR
  5017. The hour at which the backups are done. This can be a number from 0
  5018. to 23, or the time specification in form @var{hours}:@var{minutes},
  5019. or the string @samp{now}.
  5020. This variable is used by @code{backup}. Its value may be overridden
  5021. using @option{--time} option (@pxref{Scripted Backups}).
  5022. @end defvr
  5023. @defvr {Backup variable} TAPE_FILE
  5024. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  5025. is a remote archive (@pxref{remote-dev}), backup script will suppose
  5026. that your @command{mt} is able to access remote devices. If @var{RSH}
  5027. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  5028. invocations of @command{mt}.
  5029. @end defvr
  5030. @defvr {Backup variable} BLOCKING
  5031. The blocking factor @command{tar} will use when writing the dump archive.
  5032. @xref{Blocking Factor}.
  5033. @end defvr
  5034. @defvr {Backup variable} BACKUP_DIRS
  5035. A list of file systems to be dumped (for @code{backup}), or restored
  5036. (for @code{restore}). You can include any directory
  5037. name in the list --- subdirectories on that file system will be
  5038. included, regardless of how they may look to other networked machines.
  5039. Subdirectories on other file systems will be ignored.
  5040. The host name specifies which host to run @command{tar} on, and should
  5041. normally be the host that actually contains the file system. However,
  5042. the host machine must have @GNUTAR{} installed, and
  5043. must be able to access the directory containing the backup scripts and
  5044. their support files using the same file name that is used on the
  5045. machine where the scripts are run (i.e., what @command{pwd} will print
  5046. when in that directory on that machine). If the host that contains
  5047. the file system does not have this capability, you can specify another
  5048. host as long as it can access the file system through @acronym{NFS}.
  5049. If the list of file systems is very long you may wish to put it
  5050. in a separate file. This file is usually named
  5051. @file{/etc/backup/dirs}, but this name may be overridden in
  5052. @file{backup-specs} using @code{DIRLIST} variable.
  5053. @end defvr
  5054. @defvr {Backup variable} DIRLIST
  5055. The name of the file that contains a list of file systems to backup
  5056. or restore. By default it is @file{/etc/backup/dirs}.
  5057. @end defvr
  5058. @defvr {Backup variable} BACKUP_FILES
  5059. A list of individual files to be dumped (for @code{backup}), or restored
  5060. (for @code{restore}). These should be accessible from the machine on
  5061. which the backup script is run.
  5062. If the list of individual files is very long you may wish to store it
  5063. in a separate file. This file is usually named
  5064. @file{/etc/backup/files}, but this name may be overridden in
  5065. @file{backup-specs} using @code{FILELIST} variable.
  5066. @end defvr
  5067. @defvr {Backup variable} FILELIST
  5068. The name of the file that contains a list of individual files to backup
  5069. or restore. By default it is @file{/etc/backup/files}.
  5070. @end defvr
  5071. @defvr {Backup variable} MT
  5072. Full file name of @command{mt} binary.
  5073. @end defvr
  5074. @defvr {Backup variable} RSH
  5075. @anchor{RSH}
  5076. Full file name of @command{rsh} binary or its equivalent. You may wish to
  5077. set it to @code{ssh}, to improve security. In this case you will have
  5078. to use public key authentication.
  5079. @end defvr
  5080. @defvr {Backup variable} RSH_COMMAND
  5081. Full file name of @command{rsh} binary on remote machines. This will
  5082. be passed via @option{--rsh-command} option to the remote invocation
  5083. of @GNUTAR{}.
  5084. @end defvr
  5085. @defvr {Backup variable} VOLNO_FILE
  5086. Name of temporary file to hold volume numbers. This needs to be accessible
  5087. by all the machines which have file systems to be dumped.
  5088. @end defvr
  5089. @defvr {Backup variable} XLIST
  5090. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  5091. located on the remote machine and containing the list of files to
  5092. be excluded from the backup. Exclude file lists are searched in
  5093. /etc/tar-backup directory. A common use for exclude file lists
  5094. is to exclude files containing security-sensitive information
  5095. (e.g., @file{/etc/shadow} from backups).
  5096. This variable affects only @code{backup}.
  5097. @end defvr
  5098. @defvr {Backup variable} SLEEP_TIME
  5099. Time to sleep between dumps of any two successive file systems
  5100. This variable affects only @code{backup}.
  5101. @end defvr
  5102. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  5103. Script to be run when it's time to insert a new tape in for the next
  5104. volume. Administrators may want to tailor this script for their site.
  5105. If this variable isn't set, @GNUTAR{} will display its built-in
  5106. prompt, and will expect confirmation from the console. For the
  5107. description of the default prompt, see @ref{change volume prompt}.
  5108. @end defvr
  5109. @defvr {Backup variable} SLEEP_MESSAGE
  5110. Message to display on the terminal while waiting for dump time. Usually
  5111. this will just be some literal text.
  5112. @end defvr
  5113. @defvr {Backup variable} TAR
  5114. Full file name of the @GNUTAR{} executable. If this is not set, backup
  5115. scripts will search @command{tar} in the current shell path.
  5116. @end defvr
  5117. @node Magnetic Tape Control
  5118. @subsection Magnetic Tape Control
  5119. Backup scripts access tape device using special @dfn{hook functions}.
  5120. These functions take a single argument --- the name of the tape
  5121. device. Their names are kept in the following variables:
  5122. @defvr {Backup variable} MT_BEGIN
  5123. The name of @dfn{begin} function. This function is called before
  5124. accessing the drive. By default it retensions the tape:
  5125. @smallexample
  5126. MT_BEGIN=mt_begin
  5127. mt_begin() @{
  5128. mt -f "$1" retension
  5129. @}
  5130. @end smallexample
  5131. @end defvr
  5132. @defvr {Backup variable} MT_REWIND
  5133. The name of @dfn{rewind} function. The default definition is as
  5134. follows:
  5135. @smallexample
  5136. MT_REWIND=mt_rewind
  5137. mt_rewind() @{
  5138. mt -f "$1" rewind
  5139. @}
  5140. @end smallexample
  5141. @end defvr
  5142. @defvr {Backup variable} MT_OFFLINE
  5143. The name of the function switching the tape off line. By default
  5144. it is defined as follows:
  5145. @smallexample
  5146. MT_OFFLINE=mt_offline
  5147. mt_offline() @{
  5148. mt -f "$1" offl
  5149. @}
  5150. @end smallexample
  5151. @end defvr
  5152. @defvr {Backup variable} MT_STATUS
  5153. The name of the function used to obtain the status of the archive device,
  5154. including error count. Default definition:
  5155. @smallexample
  5156. MT_STATUS=mt_status
  5157. mt_status() @{
  5158. mt -f "$1" status
  5159. @}
  5160. @end smallexample
  5161. @end defvr
  5162. @node User Hooks
  5163. @subsection User Hooks
  5164. @dfn{User hooks} are shell functions executed before and after
  5165. each @command{tar} invocation. Thus, there are @dfn{backup
  5166. hooks}, which are executed before and after dumping each file
  5167. system, and @dfn{restore hooks}, executed before and
  5168. after restoring a file system. Each user hook is a shell function
  5169. taking four arguments:
  5170. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  5171. Its arguments are:
  5172. @table @var
  5173. @item level
  5174. Current backup or restore level.
  5175. @item host
  5176. Name or IP address of the host machine being dumped or restored.
  5177. @item fs
  5178. Full file name of the file system being dumped or restored.
  5179. @item fsname
  5180. File system name with directory separators replaced with colons. This
  5181. is useful, e.g., for creating unique files.
  5182. @end table
  5183. @end deffn
  5184. Following variables keep the names of user hook functions:
  5185. @defvr {Backup variable} DUMP_BEGIN
  5186. Dump begin function. It is executed before dumping the file system.
  5187. @end defvr
  5188. @defvr {Backup variable} DUMP_END
  5189. Executed after dumping the file system.
  5190. @end defvr
  5191. @defvr {Backup variable} RESTORE_BEGIN
  5192. Executed before restoring the file system.
  5193. @end defvr
  5194. @defvr {Backup variable} RESTORE_END
  5195. Executed after restoring the file system.
  5196. @end defvr
  5197. @node backup-specs example
  5198. @subsection An Example Text of @file{Backup-specs}
  5199. The following is an example of @file{backup-specs}:
  5200. @smallexample
  5201. # site-specific parameters for file system backup.
  5202. ADMINISTRATOR=friedman
  5203. BACKUP_HOUR=1
  5204. TAPE_FILE=/dev/nrsmt0
  5205. # Use @code{ssh} instead of the less secure @code{rsh}
  5206. RSH=/usr/bin/ssh
  5207. RSH_COMMAND=/usr/bin/ssh
  5208. # Override MT_STATUS function:
  5209. my_status() @{
  5210. mts -t $TAPE_FILE
  5211. @}
  5212. MT_STATUS=my_status
  5213. # Disable MT_OFFLINE function
  5214. MT_OFFLINE=:
  5215. BLOCKING=124
  5216. BACKUP_DIRS="
  5217. albert:/fs/fsf
  5218. apple-gunkies:/gd
  5219. albert:/fs/gd2
  5220. albert:/fs/gp
  5221. geech:/usr/jla
  5222. churchy:/usr/roland
  5223. albert:/
  5224. albert:/usr
  5225. apple-gunkies:/
  5226. apple-gunkies:/usr
  5227. gnu:/hack
  5228. gnu:/u
  5229. apple-gunkies:/com/mailer/gnu
  5230. apple-gunkies:/com/archive/gnu"
  5231. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  5232. @end smallexample
  5233. @node Scripted Backups
  5234. @section Using the Backup Scripts
  5235. The syntax for running a backup script is:
  5236. @smallexample
  5237. backup --level=@var{level} --time=@var{time}
  5238. @end smallexample
  5239. The @option{--level} option requests the dump level. Thus, to produce
  5240. a full dump, specify @code{--level=0} (this is the default, so
  5241. @option{--level} may be omitted if its value is
  5242. @code{0})@footnote{For backward compatibility, the @code{backup} will also
  5243. try to deduce the requested dump level from the name of the
  5244. script itself. If the name consists of a string @samp{level-}
  5245. followed by a single decimal digit, that digit is taken as
  5246. the dump level number. Thus, you may create a link from @code{backup}
  5247. to @code{level-1} and then run @code{level-1} whenever you need to
  5248. create a level one dump.}.
  5249. The @option{--time} option determines when should the backup be
  5250. run. @var{Time} may take three forms:
  5251. @table @asis
  5252. @item @var{hh}:@var{mm}
  5253. The dump must be run at @var{hh} hours @var{mm} minutes.
  5254. @item @var{hh}
  5255. The dump must be run at @var{hh} hours.
  5256. @item now
  5257. The dump must be run immediately.
  5258. @end table
  5259. You should start a script with a tape or disk mounted. Once you
  5260. start a script, it prompts you for new tapes or disks as it
  5261. needs them. Media volumes don't have to correspond to archive
  5262. files --- a multi-volume archive can be started in the middle of a
  5263. tape that already contains the end of another multi-volume archive.
  5264. The @code{restore} script prompts for media by its archive volume,
  5265. so to avoid an error message you should keep track of which tape
  5266. (or disk) contains which volume of the archive (@pxref{Scripted
  5267. Restoration}).
  5268. The backup scripts write two files on the file system. The first is a
  5269. record file in @file{/etc/tar-backup/}, which is used by the scripts
  5270. to store and retrieve information about which files were dumped. This
  5271. file is not meant to be read by humans, and should not be deleted by
  5272. them. @xref{Snapshot Files}, for a more detailed explanation of this
  5273. file.
  5274. The second file is a log file containing the names of the file systems
  5275. and files dumped, what time the backup was made, and any error
  5276. messages that were generated, as well as how much space was left in
  5277. the media volume after the last volume of the archive was written.
  5278. You should check this log file after every backup. The file name is
  5279. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  5280. represents current date, and @var{n} represents current dump level number.
  5281. The script also prints the name of each system being dumped to the
  5282. standard output.
  5283. Following is the full list of options accepted by @code{backup}
  5284. script:
  5285. @table @option
  5286. @item -l @var{level}
  5287. @itemx --level=@var{level}
  5288. Do backup level @var{level} (default 0).
  5289. @item -f
  5290. @itemx --force
  5291. Force backup even if today's log file already exists.
  5292. @item -v[@var{level}]
  5293. @itemx --verbose[=@var{level}]
  5294. Set verbosity level. The higher the level is, the more debugging
  5295. information will be output during execution. Default @var{level}
  5296. is 100, which means the highest debugging level.
  5297. @item -t @var{start-time}
  5298. @itemx --time=@var{start-time}
  5299. Wait till @var{time}, then do backup.
  5300. @item -h
  5301. @itemx --help
  5302. Display short help message and exit.
  5303. @item -V
  5304. @itemx --version
  5305. Display information about the program's name, version, origin and legal
  5306. status, all on standard output, and then exit successfully.
  5307. @end table
  5308. @node Scripted Restoration
  5309. @section Using the Restore Script
  5310. To restore files that were archived using a scripted backup, use the
  5311. @code{restore} script. Its usage is quite straightforward. In the
  5312. simplest form, invoke @code{restore --all}, it will
  5313. then restore all the file systems and files specified in
  5314. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  5315. You may select the file systems (and/or files) to restore by
  5316. giving @code{restore} a list of @dfn{patterns} in its command
  5317. line. For example, running
  5318. @smallexample
  5319. restore 'albert:*'
  5320. @end smallexample
  5321. @noindent
  5322. will restore all file systems on the machine @samp{albert}. A more
  5323. complicated example:
  5324. @smallexample
  5325. restore 'albert:*' '*:/var'
  5326. @end smallexample
  5327. @noindent
  5328. This command will restore all file systems on the machine @samp{albert}
  5329. as well as @file{/var} file system on all machines.
  5330. By default @code{restore} will start restoring files from the lowest
  5331. available dump level (usually zero) and will continue through
  5332. all available dump levels. There may be situations where such a
  5333. thorough restore is not necessary. For example, you may wish to
  5334. restore only files from the recent level one backup. To do so,
  5335. use @option{--level} option, as shown in the example below:
  5336. @smallexample
  5337. restore --level=1
  5338. @end smallexample
  5339. The full list of options accepted by @code{restore} follows:
  5340. @table @option
  5341. @item -a
  5342. @itemx --all
  5343. Restore all file systems and files specified in @file{backup-specs}.
  5344. @item -l @var{level}
  5345. @itemx --level=@var{level}
  5346. Start restoring from the given backup level, instead of the default 0.
  5347. @item -v[@var{level}]
  5348. @itemx --verbose[=@var{level}]
  5349. Set verbosity level. The higher the level is, the more debugging
  5350. information will be output during execution. Default @var{level}
  5351. is 100, which means the highest debugging level.
  5352. @item -h
  5353. @itemx --help
  5354. Display short help message and exit.
  5355. @item -V
  5356. @itemx --version
  5357. Display information about the program's name, version, origin and legal
  5358. status, all on standard output, and then exit successfully.
  5359. @end table
  5360. You should start the restore script with the media containing the
  5361. first volume of the archive mounted. The script will prompt for other
  5362. volumes as they are needed. If the archive is on tape, you don't need
  5363. to rewind the tape to to its beginning---if the tape head is
  5364. positioned past the beginning of the archive, the script will rewind
  5365. the tape as needed. @xref{Tape Positioning}, for a discussion of tape
  5366. positioning.
  5367. @quotation
  5368. @strong{Warning:} The script will delete files from the active file
  5369. system if they were not in the file system when the archive was made.
  5370. @end quotation
  5371. @xref{Incremental Dumps}, for an explanation of how the script makes
  5372. that determination.
  5373. @node Choosing
  5374. @chapter Choosing Files and Names for @command{tar}
  5375. Certain options to @command{tar} enable you to specify a name for your
  5376. archive. Other options let you decide which files to include or exclude
  5377. from the archive, based on when or whether files were modified, whether
  5378. the file names do or don't match specified patterns, or whether files
  5379. are in specified directories.
  5380. This chapter discusses these options in detail.
  5381. @menu
  5382. * file:: Choosing the Archive's Name
  5383. * Selecting Archive Members::
  5384. * files:: Reading Names from a File
  5385. * exclude:: Excluding Some Files
  5386. * wildcards:: Wildcards Patterns and Matching
  5387. * quoting styles:: Ways of Quoting Special Characters in Names
  5388. * transform:: Modifying File and Member Names
  5389. * after:: Operating Only on New Files
  5390. * recurse:: Descending into Directories
  5391. * one:: Crossing File System Boundaries
  5392. @end menu
  5393. @node file
  5394. @section Choosing and Naming Archive Files
  5395. @cindex Naming an archive
  5396. @cindex Archive Name
  5397. @cindex Choosing an archive file
  5398. @cindex Where is the archive?
  5399. @opindex file
  5400. By default, @command{tar} uses an archive file name that was compiled when
  5401. it was built on the system; usually this name refers to some physical
  5402. tape drive on the machine. However, the person who installed @command{tar}
  5403. on the system may not have set the default to a meaningful value as far as
  5404. most users are concerned. As a result, you will usually want to tell
  5405. @command{tar} where to find (or create) the archive. The
  5406. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  5407. option allows you to either specify or name a file to use as the archive
  5408. instead of the default archive file location.
  5409. @table @option
  5410. @xopindex{file, short description}
  5411. @item --file=@var{archive-name}
  5412. @itemx -f @var{archive-name}
  5413. Name the archive to create or operate on. Use in conjunction with
  5414. any operation.
  5415. @end table
  5416. For example, in this @command{tar} command,
  5417. @smallexample
  5418. $ @kbd{tar -cvf collection.tar blues folk jazz}
  5419. @end smallexample
  5420. @noindent
  5421. @file{collection.tar} is the name of the archive. It must directly
  5422. follow the @option{-f} option, since whatever directly follows @option{-f}
  5423. @emph{will} end up naming the archive. If you neglect to specify an
  5424. archive name, you may end up overwriting a file in the working directory
  5425. with the archive you create since @command{tar} will use this file's name
  5426. for the archive name.
  5427. An archive can be saved as a file in the file system, sent through a
  5428. pipe or over a network, or written to an I/O device such as a tape,
  5429. floppy disk, or CD write drive.
  5430. @cindex Writing new archives
  5431. @cindex Archive creation
  5432. If you do not name the archive, @command{tar} uses the value of the
  5433. environment variable @env{TAPE} as the file name for the archive. If
  5434. that is not available, @command{tar} uses a default, compiled-in archive
  5435. name, usually that for tape unit zero (i.e., @file{/dev/tu00}).
  5436. @cindex Standard input and output
  5437. @cindex tar to standard input and output
  5438. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  5439. archive from standard input (when listing or extracting files), or
  5440. writes it to standard output (when creating an archive). If you use
  5441. @file{-} as an @var{archive-name} when modifying an archive,
  5442. @command{tar} reads the original archive from its standard input and
  5443. writes the entire new archive to its standard output.
  5444. The following example is a convenient way of copying directory
  5445. hierarchy from @file{sourcedir} to @file{targetdir}.
  5446. @smallexample
  5447. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  5448. @end smallexample
  5449. The @option{-C} option allows to avoid using subshells:
  5450. @smallexample
  5451. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  5452. @end smallexample
  5453. In both examples above, the leftmost @command{tar} invocation archives
  5454. the contents of @file{sourcedir} to the standard output, while the
  5455. rightmost one reads this archive from its standard input and
  5456. extracts it. The @option{-p} option tells it to restore permissions
  5457. of the extracted files.
  5458. @cindex Remote devices
  5459. @cindex tar to a remote device
  5460. @anchor{remote-dev}
  5461. To specify an archive file on a device attached to a remote machine,
  5462. use the following:
  5463. @smallexample
  5464. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  5465. @end smallexample
  5466. @noindent
  5467. @command{tar} will set up the remote connection, if possible, and
  5468. prompt you for a username and password. If you use
  5469. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  5470. will attempt to set up the remote connection using your username
  5471. as the username on the remote machine.
  5472. @cindex Local and remote archives
  5473. @anchor{local and remote archives}
  5474. If the archive file name includes a colon (@samp{:}), then it is assumed
  5475. to be a file on another machine. If the archive file is
  5476. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  5477. host @var{host}. The remote host is accessed using the @command{rsh}
  5478. program, with a username of @var{user}. If the username is omitted
  5479. (along with the @samp{@@} sign), then your user name will be used.
  5480. (This is the normal @command{rsh} behavior.) It is necessary for the
  5481. remote machine, in addition to permitting your @command{rsh} access, to
  5482. have the @file{rmt} program installed (this command is included in
  5483. the @GNUTAR{} distribution and by default is installed under
  5484. @file{@var{prefix}/libexec/rmt}, where @var{prefix} means your
  5485. installation prefix). If you need to use a file whose name includes a
  5486. colon, then the remote tape drive behavior
  5487. can be inhibited by using the @option{--force-local} option.
  5488. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  5489. tries to minimize input and output operations. The Amanda backup
  5490. system, when used with @GNUTAR{}, has an initial sizing pass which
  5491. uses this feature.
  5492. @node Selecting Archive Members
  5493. @section Selecting Archive Members
  5494. @cindex Specifying files to act on
  5495. @cindex Specifying archive members
  5496. @dfn{File Name arguments} specify which files in the file system
  5497. @command{tar} operates on, when creating or adding to an archive, or which
  5498. archive members @command{tar} operates on, when reading or deleting from
  5499. an archive. @xref{Operations}.
  5500. To specify file names, you can include them as the last arguments on
  5501. the command line, as follows:
  5502. @smallexample
  5503. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  5504. @end smallexample
  5505. If a file name begins with dash (@samp{-}), precede it with
  5506. @option{--add-file} option to prevent it from being treated as an
  5507. option.
  5508. @anchor{input name quoting}
  5509. By default @GNUTAR{} attempts to @dfn{unquote} each file or member
  5510. name, replacing @dfn{escape sequences} according to the following
  5511. table:
  5512. @multitable @columnfractions 0.20 0.60
  5513. @headitem Escape @tab Replaced with
  5514. @item \a @tab Audible bell (@acronym{ASCII} 7)
  5515. @item \b @tab Backspace (@acronym{ASCII} 8)
  5516. @item \f @tab Form feed (@acronym{ASCII} 12)
  5517. @item \n @tab New line (@acronym{ASCII} 10)
  5518. @item \r @tab Carriage return (@acronym{ASCII} 13)
  5519. @item \t @tab Horizontal tabulation (@acronym{ASCII} 9)
  5520. @item \v @tab Vertical tabulation (@acronym{ASCII} 11)
  5521. @item \? @tab @acronym{ASCII} 127
  5522. @item \@var{n} @tab @acronym{ASCII} @var{n} (@var{n} should be an octal number
  5523. of up to 3 digits)
  5524. @end multitable
  5525. A backslash followed by any other symbol is retained.
  5526. This default behavior is controlled by the following command line
  5527. option:
  5528. @table @option
  5529. @opindex unquote
  5530. @item --unquote
  5531. Enable unquoting input file or member names (default).
  5532. @opindex no-unquote
  5533. @item --no-unquote
  5534. Disable unquoting input file or member names.
  5535. @end table
  5536. If you specify a directory name as a file name argument, all the files
  5537. in that directory are operated on by @command{tar}.
  5538. If you do not specify files, @command{tar} behavior differs depending
  5539. on the operation mode as described below:
  5540. When @command{tar} is invoked with @option{--create} (@option{-c}),
  5541. @command{tar} will stop immediately, reporting the following:
  5542. @smallexample
  5543. @group
  5544. $ @kbd{tar cf a.tar}
  5545. tar: Cowardly refusing to create an empty archive
  5546. Try `tar --help' or `tar --usage' for more information.
  5547. @end group
  5548. @end smallexample
  5549. If you specify either @option{--list} (@option{-t}) or
  5550. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  5551. operates on all the archive members in the archive.
  5552. If run with @option{--diff} option, tar will compare the archive with
  5553. the contents of the current working directory.
  5554. If you specify any other operation, @command{tar} does nothing.
  5555. By default, @command{tar} takes file names from the command line. However,
  5556. there are other ways to specify file or member names, or to modify the
  5557. manner in which @command{tar} selects the files or members upon which to
  5558. operate. In general, these methods work both for specifying the names
  5559. of files and archive members.
  5560. @node files
  5561. @section Reading Names from a File
  5562. @cindex Reading file names from a file
  5563. @cindex Lists of file names
  5564. @cindex File Name arguments, alternatives
  5565. @cindex @command{find}, using with @command{tar}
  5566. Instead of giving the names of files or archive members on the command
  5567. line, you can put the names into a file, and then use the
  5568. @option{--files-from=@var{file-of-names}} (@option{-T
  5569. @var{file-of-names}}) option to @command{tar}. Give the name of the
  5570. file which contains the list of files to include as the argument to
  5571. @option{--files-from}. In the list, the file names should be separated by
  5572. newlines. You will frequently use this option when you have generated
  5573. the list of files to archive with the @command{find} utility.
  5574. @table @option
  5575. @opindex files-from
  5576. @item --files-from=@var{file-name}
  5577. @itemx -T @var{file-name}
  5578. Get names to extract or create from file @var{file-name}.
  5579. @end table
  5580. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  5581. you specify either @code{--files-from=-} or @code{-T -}), then the file
  5582. names are read from standard input.
  5583. Unless you are running @command{tar} with @option{--create}, you can not use
  5584. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  5585. command.
  5586. Any number of @option{-T} options can be given in the command line.
  5587. The following example shows how to use @command{find} to generate a list of
  5588. files smaller than 400K in length and put that list into a file
  5589. called @file{small-files}. You can then use the @option{-T} option to
  5590. @command{tar} to specify the files from that file, @file{small-files}, to
  5591. create the archive @file{little.tgz}. (The @option{-z} option to
  5592. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  5593. more information.)
  5594. @smallexample
  5595. $ @kbd{find . -size -400 -print > small-files}
  5596. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  5597. @end smallexample
  5598. @noindent
  5599. In the file list given by @option{-T} option, any file name beginning
  5600. with @samp{-} character is considered a @command{tar} option and is
  5601. processed accordingly@footnote{Versions of @GNUTAR{} up to 1.15.1
  5602. recognized only @option{-C} option in file lists, and only if the
  5603. option and its argument occupied two consecutive lines.}. For example,
  5604. the common use of this feature is to change to another directory by
  5605. specifying @option{-C} option:
  5606. @smallexample
  5607. @group
  5608. $ @kbd{cat list}
  5609. -C/etc
  5610. passwd
  5611. hosts
  5612. -C/lib
  5613. libc.a
  5614. $ @kbd{tar -c -f foo.tar --files-from list}
  5615. @end group
  5616. @end smallexample
  5617. @noindent
  5618. In this example, @command{tar} will first switch to @file{/etc}
  5619. directory and add files @file{passwd} and @file{hosts} to the
  5620. archive. Then it will change to @file{/lib} directory and will archive
  5621. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  5622. contain:
  5623. @smallexample
  5624. @group
  5625. $ @kbd{tar tf foo.tar}
  5626. passwd
  5627. hosts
  5628. libc.a
  5629. @end group
  5630. @end smallexample
  5631. @noindent
  5632. @xopindex{directory, using in @option{--files-from} argument}
  5633. Notice that the option parsing algorithm used with @option{-T} is
  5634. stricter than the one used by shell. Namely, when specifying option
  5635. arguments, you should observe the following rules:
  5636. @itemize @bullet
  5637. @item
  5638. When using short (single-letter) option form, its argument must
  5639. immediately follow the option letter, without any intervening
  5640. whitespace. For example: @code{-Cdir}.
  5641. @item
  5642. When using long option form, the option argument must be separated
  5643. from the option by a single equal sign. No whitespace is allowed on
  5644. any side of the equal sign. For example: @code{--directory=dir}.
  5645. @item
  5646. For both short and long option forms, the option argument can be given
  5647. on the next line after the option name, e.g.:
  5648. @smallexample
  5649. @group
  5650. --directory
  5651. dir
  5652. @end group
  5653. @end smallexample
  5654. @noindent
  5655. and
  5656. @smallexample
  5657. @group
  5658. -C
  5659. dir
  5660. @end group
  5661. @end smallexample
  5662. @end itemize
  5663. @opindex add-file
  5664. If you happen to have a file whose name starts with @samp{-},
  5665. precede it with @option{--add-file} option to prevent it from
  5666. being recognized as an option. For example: @code{--add-file=--my-file}.
  5667. @menu
  5668. * nul::
  5669. @end menu
  5670. @node nul
  5671. @subsection @code{NUL}-Terminated File Names
  5672. @cindex File names, terminated by @code{NUL}
  5673. @cindex @code{NUL}-terminated file names
  5674. The @option{--null} option causes
  5675. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  5676. to read file names terminated by a @code{NUL} instead of a newline, so
  5677. files whose names contain newlines can be archived using
  5678. @option{--files-from}.
  5679. @table @option
  5680. @xopindex{null, described}
  5681. @item --null
  5682. Only consider @code{NUL}-terminated file names, instead of files that
  5683. terminate in a newline.
  5684. @xopindex{no-null, described}
  5685. @item --no-null
  5686. Undo the effect of any previous @option{--null} option.
  5687. @end table
  5688. The @option{--null} option is just like the one in @acronym{GNU}
  5689. @command{xargs} and @command{cpio}, and is useful with the
  5690. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  5691. @command{tar}, @option{--null} also disables special handling for
  5692. file names that begin with dash.
  5693. This example shows how to use @command{find} to generate a list of files
  5694. larger than 800K in length and put that list into a file called
  5695. @file{long-files}. The @option{-print0} option to @command{find} is just
  5696. like @option{-print}, except that it separates files with a @code{NUL}
  5697. rather than with a newline. You can then run @command{tar} with both the
  5698. @option{--null} and @option{-T} options to specify that @command{tar} gets the
  5699. files from that file, @file{long-files}, to create the archive
  5700. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5701. @command{tar} to recognize the @code{NUL} separator between files.
  5702. @smallexample
  5703. $ @kbd{find . -size +800 -print0 > long-files}
  5704. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5705. @end smallexample
  5706. The @option{--no-null} option can be used if you need to read both
  5707. @code{NUL}-terminated and newline-terminated files on the same command line.
  5708. For example, if @file{flist} is a newline-terminated file, then the
  5709. following command can be used to combine it with the above command:
  5710. @smallexample
  5711. @group
  5712. $ @kbd{find . -size +800 -print0 |
  5713. tar -c -f big.tar --null -T - --no-null -T flist}
  5714. @end group
  5715. @end smallexample
  5716. This example uses short options for typographic reasons, to avoid
  5717. very long lines.
  5718. @GNUTAR is able to automatically detect @code{NUL}-terminated file lists, so
  5719. it is safe to use them even without the @option{--null} option. In
  5720. this case @command{tar} will print a warning and continue reading such
  5721. a file as if @option{--null} were actually given:
  5722. @smallexample
  5723. @group
  5724. $ @kbd{find . -size +800 -print0 | tar -c -f big.tar -T -}
  5725. tar: -: file name read contains nul character
  5726. @end group
  5727. @end smallexample
  5728. The null terminator, however, remains in effect only for this
  5729. particular file, any following @option{-T} options will assume
  5730. newline termination. Of course, the null autodetection applies
  5731. to these eventual surplus @option{-T} options as well.
  5732. @node exclude
  5733. @section Excluding Some Files
  5734. @cindex File names, excluding files by
  5735. @cindex Excluding files by name and pattern
  5736. @cindex Excluding files by file system
  5737. @opindex exclude
  5738. @opindex exclude-from
  5739. To avoid operating on files whose names match a particular pattern,
  5740. use the @option{--exclude} or @option{--exclude-from} options.
  5741. @table @option
  5742. @opindex exclude
  5743. @item --exclude=@var{pattern}
  5744. Causes @command{tar} to ignore files that match the @var{pattern}.
  5745. @end table
  5746. @findex exclude
  5747. The @option{--exclude=@var{pattern}} option prevents any file or
  5748. member whose name matches the shell wildcard (@var{pattern}) from
  5749. being operated on.
  5750. For example, to create an archive with all the contents of the directory
  5751. @file{src} except for files whose names end in @file{.o}, use the
  5752. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5753. You may give multiple @option{--exclude} options.
  5754. @table @option
  5755. @opindex exclude-from
  5756. @item --exclude-from=@var{file}
  5757. @itemx -X @var{file}
  5758. Causes @command{tar} to ignore files that match the patterns listed in
  5759. @var{file}.
  5760. @end table
  5761. @findex exclude-from
  5762. Use the @option{--exclude-from} option to read a
  5763. list of patterns, one per line, from @var{file}; @command{tar} will
  5764. ignore files matching those patterns. Thus if @command{tar} is
  5765. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5766. single line @file{*.o}, no files whose names end in @file{.o} will be
  5767. added to the archive.
  5768. Notice, that lines from @var{file} are read verbatim. One of the
  5769. frequent errors is leaving some extra whitespace after a file name,
  5770. which is difficult to catch using text editors.
  5771. However, empty lines are OK.
  5772. @table @option
  5773. @cindex version control system, excluding files
  5774. @cindex VCS, excluding files
  5775. @cindex SCCS, excluding files
  5776. @cindex RCS, excluding files
  5777. @cindex CVS, excluding files
  5778. @cindex SVN, excluding files
  5779. @cindex git, excluding files
  5780. @cindex Bazaar, excluding files
  5781. @cindex Arch, excluding files
  5782. @cindex Mercurial, excluding files
  5783. @cindex Darcs, excluding files
  5784. @opindex exclude-vcs
  5785. @item --exclude-vcs
  5786. Exclude files and directories used by following version control
  5787. systems: @samp{CVS}, @samp{RCS}, @samp{SCCS}, @samp{SVN}, @samp{Arch},
  5788. @samp{Bazaar}, @samp{Mercurial}, and @samp{Darcs}.
  5789. As of version @value{VERSION}, the following files are excluded:
  5790. @itemize @bullet
  5791. @item @file{CVS/}, and everything under it
  5792. @item @file{RCS/}, and everything under it
  5793. @item @file{SCCS/}, and everything under it
  5794. @item @file{.git/}, and everything under it
  5795. @item @file{.gitignore}
  5796. @item @file{.cvsignore}
  5797. @item @file{.svn/}, and everything under it
  5798. @item @file{.arch-ids/}, and everything under it
  5799. @item @file{@{arch@}/}, and everything under it
  5800. @item @file{=RELEASE-ID}
  5801. @item @file{=meta-update}
  5802. @item @file{=update}
  5803. @item @file{.bzr}
  5804. @item @file{.bzrignore}
  5805. @item @file{.bzrtags}
  5806. @item @file{.hg}
  5807. @item @file{.hgignore}
  5808. @item @file{.hgrags}
  5809. @item @file{_darcs}
  5810. @end itemize
  5811. @opindex exclude-backups
  5812. @item --exclude-backups
  5813. Exclude backup and lock files. This option causes exclusion of files
  5814. that match the following shell globbing patterns:
  5815. @table @asis
  5816. @item .#*
  5817. @item *~
  5818. @item #*#
  5819. @end table
  5820. @end table
  5821. @findex exclude-caches
  5822. When creating an archive, the @option{--exclude-caches} option family
  5823. causes @command{tar} to exclude all directories that contain a @dfn{cache
  5824. directory tag}. A cache directory tag is a short file with the
  5825. well-known name @file{CACHEDIR.TAG} and having a standard header
  5826. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5827. Various applications write cache directory tags into directories they
  5828. use to hold regenerable, non-precious data, so that such data can be
  5829. more easily excluded from backups.
  5830. There are three @samp{exclude-caches} options, each providing a different
  5831. exclusion semantics:
  5832. @table @option
  5833. @opindex exclude-caches
  5834. @item --exclude-caches
  5835. Do not archive the contents of the directory, but archive the
  5836. directory itself and the @file{CACHEDIR.TAG} file.
  5837. @opindex exclude-caches-under
  5838. @item --exclude-caches-under
  5839. Do not archive the contents of the directory, nor the
  5840. @file{CACHEDIR.TAG} file, archive only the directory itself.
  5841. @opindex exclude-caches-all
  5842. @item --exclude-caches-all
  5843. Omit directories containing @file{CACHEDIR.TAG} file entirely.
  5844. @end table
  5845. @findex exclude-tag
  5846. Another option family, @option{--exclude-tag}, provides a generalization of
  5847. this concept. It takes a single argument, a file name to look for.
  5848. Any directory that contains this file will be excluded from the dump.
  5849. Similarly to @samp{exclude-caches}, there are three options in this
  5850. option family:
  5851. @table @option
  5852. @opindex exclude-tag
  5853. @item --exclude-tag=@var{file}
  5854. Do not dump the contents of the directory, but dump the
  5855. directory itself and the @var{file}.
  5856. @opindex exclude-tag-under
  5857. @item --exclude-tag-under=@var{file}
  5858. Do not dump the contents of the directory, nor the
  5859. @var{file}, archive only the directory itself.
  5860. @opindex exclude-tag-all
  5861. @item --exclude-tag-all=@var{file}
  5862. Omit directories containing @var{file} file entirely.
  5863. @end table
  5864. Multiple @option{--exclude-tag*} options can be given.
  5865. For example, given this directory:
  5866. @smallexample
  5867. @group
  5868. $ @kbd{find dir}
  5869. dir
  5870. dir/blues
  5871. dir/jazz
  5872. dir/folk
  5873. dir/folk/tagfile
  5874. dir/folk/sanjuan
  5875. dir/folk/trote
  5876. @end group
  5877. @end smallexample
  5878. The @option{--exclude-tag} will produce the following:
  5879. @smallexample
  5880. $ @kbd{tar -cf archive.tar --exclude-tag=tagfile -v dir}
  5881. dir/
  5882. dir/blues
  5883. dir/jazz
  5884. dir/folk/
  5885. tar: dir/folk/: contains a cache directory tag tagfile;
  5886. contents not dumped
  5887. dir/folk/tagfile
  5888. @end smallexample
  5889. Both the @file{dir/folk} directory and its tagfile are preserved in
  5890. the archive, however the rest of files in this directory are not.
  5891. Now, using the @option{--exclude-tag-under} option will exclude
  5892. @file{tagfile} from the dump, while still preserving the directory
  5893. itself, as shown in this example:
  5894. @smallexample
  5895. $ @kbd{tar -cf archive.tar --exclude-tag-under=tagfile -v dir}
  5896. dir/
  5897. dir/blues
  5898. dir/jazz
  5899. dir/folk/
  5900. ./tar: dir/folk/: contains a cache directory tag tagfile;
  5901. contents not dumped
  5902. @end smallexample
  5903. Finally, using @option{--exclude-tag-all} omits the @file{dir/folk}
  5904. directory entirely:
  5905. @smallexample
  5906. $ @kbd{tar -cf archive.tar --exclude-tag-all=tagfile -v dir}
  5907. dir/
  5908. dir/blues
  5909. dir/jazz
  5910. ./tar: dir/folk/: contains a cache directory tag tagfile;
  5911. directory not dumped
  5912. @end smallexample
  5913. @menu
  5914. * problems with exclude::
  5915. @end menu
  5916. @node problems with exclude
  5917. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5918. @xopindex{exclude, potential problems with}
  5919. Some users find @samp{exclude} options confusing. Here are some common
  5920. pitfalls:
  5921. @itemize @bullet
  5922. @item
  5923. The main operating mode of @command{tar} does not act on a file name
  5924. explicitly listed on the command line, if one of its file name
  5925. components is excluded. In the example above, if
  5926. you create an archive and exclude files that end with @samp{*.o}, but
  5927. explicitly name the file @samp{dir.o/foo} after all the options have been
  5928. listed, @samp{dir.o/foo} will be excluded from the archive.
  5929. @item
  5930. You can sometimes confuse the meanings of @option{--exclude} and
  5931. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5932. to be excluded are given as a pattern on the command line. Use
  5933. @option{--exclude-from} to introduce the name of a file which contains
  5934. a list of patterns, one per line; each of these patterns can exclude
  5935. zero, one, or many files.
  5936. @item
  5937. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5938. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5939. like @samp{*}. If you do not do this, the shell might expand the
  5940. @samp{*} itself using files at hand, so @command{tar} might receive a
  5941. list of files instead of one pattern, or none at all, making the
  5942. command somewhat illegal. This might not correspond to what you want.
  5943. For example, write:
  5944. @smallexample
  5945. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5946. @end smallexample
  5947. @noindent
  5948. rather than:
  5949. @smallexample
  5950. # @emph{Wrong!}
  5951. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5952. @end smallexample
  5953. @item
  5954. You must use use shell syntax, or globbing, rather than @code{regexp}
  5955. syntax, when using exclude options in @command{tar}. If you try to use
  5956. @code{regexp} syntax to describe files to be excluded, your command
  5957. might fail.
  5958. @item
  5959. @FIXME{The change in semantics must have occurred before 1.11,
  5960. so I doubt if it is worth mentioning at all. Anyway, should at
  5961. least specify in which version the semantics changed.}
  5962. In earlier versions of @command{tar}, what is now the
  5963. @option{--exclude-from} option was called @option{--exclude} instead.
  5964. Now, @option{--exclude} applies to patterns listed on the command
  5965. line and @option{--exclude-from} applies to patterns listed in a
  5966. file.
  5967. @end itemize
  5968. @node wildcards
  5969. @section Wildcards Patterns and Matching
  5970. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5971. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5972. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5973. patterns for matching (or globbing) archive members when extracting
  5974. from or listing an archive. Wildcard patterns are also used for
  5975. verifying volume labels of @command{tar} archives. This section has the
  5976. purpose of explaining wildcard syntax for @command{tar}.
  5977. @FIXME{the next few paragraphs need work.}
  5978. A @var{pattern} should be written according to shell syntax, using wildcard
  5979. characters to effect globbing. Most characters in the pattern stand
  5980. for themselves in the matched string, and case is significant: @samp{a}
  5981. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5982. pattern matches any single character in the matched string. The character
  5983. @samp{*} in the pattern matches zero, one, or more single characters in
  5984. the matched string. The character @samp{\} says to take the following
  5985. character of the pattern @emph{literally}; it is useful when one needs to
  5986. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5987. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5988. class. A @dfn{character class} is a list of acceptable characters
  5989. for the next single character of the matched string. For example,
  5990. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5991. Note that within a character class, all of the ``special characters''
  5992. listed above other than @samp{\} lose their special meaning; for example,
  5993. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5994. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5995. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5996. @emph{last} in a character class.)
  5997. @cindex Excluding characters from a character class
  5998. @cindex Character class, excluding characters from
  5999. If the first character of the class after the opening @samp{[}
  6000. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  6001. Rather than listing character to match, it lists those characters which
  6002. are @emph{forbidden} as the next single character of the matched string.
  6003. Other characters of the class stand for themselves. The special
  6004. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  6005. letters, is meant to represent all characters between @var{a} and
  6006. @var{e}, inclusive.
  6007. @FIXME{need to add a sentence or so here to make this clear for those
  6008. who don't have dan around.}
  6009. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  6010. special for wildcard matches. However, if a pattern completely matches
  6011. a directory prefix of a matched string, then it matches the full matched
  6012. string: thus, excluding a directory also excludes all the files beneath it.
  6013. @menu
  6014. * controlling pattern-matching::
  6015. @end menu
  6016. @node controlling pattern-matching
  6017. @unnumberedsubsec Controlling Pattern-Matching
  6018. For the purposes of this section, we call @dfn{exclusion members} all
  6019. member names obtained while processing @option{--exclude} and
  6020. @option{--exclude-from} options, and @dfn{inclusion members} those
  6021. member names that were given in the command line or read from the file
  6022. specified with @option{--files-from} option.
  6023. These two pairs of member lists are used in the following operations:
  6024. @option{--diff}, @option{--extract}, @option{--list},
  6025. @option{--update}.
  6026. There are no inclusion members in create mode (@option{--create} and
  6027. @option{--append}), since in this mode the names obtained from the
  6028. command line refer to @emph{files}, not archive members.
  6029. By default, inclusion members are compared with archive members
  6030. literally @footnote{Notice that earlier @GNUTAR{} versions used
  6031. globbing for inclusion members, which contradicted to UNIX98
  6032. specification and was not documented. @xref{Changes}, for more
  6033. information on this and other changes.} and exclusion members are
  6034. treated as globbing patterns. For example:
  6035. @smallexample
  6036. @group
  6037. $ @kbd{tar tf foo.tar}
  6038. a.c
  6039. b.c
  6040. a.txt
  6041. [remarks]
  6042. # @i{Member names are used verbatim:}
  6043. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  6044. [remarks]
  6045. # @i{Exclude member names are globbed:}
  6046. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  6047. a.txt
  6048. [remarks]
  6049. @end group
  6050. @end smallexample
  6051. This behavior can be altered by using the following options:
  6052. @table @option
  6053. @opindex wildcards
  6054. @item --wildcards
  6055. Treat all member names as wildcards.
  6056. @opindex no-wildcards
  6057. @item --no-wildcards
  6058. Treat all member names as literal strings.
  6059. @end table
  6060. Thus, to extract files whose names end in @samp{.c}, you can use:
  6061. @smallexample
  6062. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  6063. a.c
  6064. b.c
  6065. @end smallexample
  6066. @noindent
  6067. Notice quoting of the pattern to prevent the shell from interpreting
  6068. it.
  6069. The effect of @option{--wildcards} option is canceled by
  6070. @option{--no-wildcards}. This can be used to pass part of
  6071. the command line arguments verbatim and other part as globbing
  6072. patterns. For example, the following invocation:
  6073. @smallexample
  6074. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  6075. @end smallexample
  6076. @noindent
  6077. instructs @command{tar} to extract from @file{foo.tar} all files whose
  6078. names end in @samp{.txt} and the file named @file{[remarks]}.
  6079. Normally, a pattern matches a name if an initial subsequence of the
  6080. name's components matches the pattern, where @samp{*}, @samp{?}, and
  6081. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  6082. and wildcards can match @samp{/}.
  6083. Other than optionally stripping leading @samp{/} from names
  6084. (@pxref{absolute}), patterns and names are used as-is. For
  6085. example, trailing @samp{/} is not trimmed from a user-specified name
  6086. before deciding whether to exclude it.
  6087. However, this matching procedure can be altered by the options listed
  6088. below. These options accumulate. For example:
  6089. @smallexample
  6090. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  6091. @end smallexample
  6092. @noindent
  6093. ignores case when excluding @samp{makefile}, but not when excluding
  6094. @samp{readme}.
  6095. @table @option
  6096. @opindex anchored
  6097. @opindex no-anchored
  6098. @item --anchored
  6099. @itemx --no-anchored
  6100. If anchored, a pattern must match an initial subsequence
  6101. of the name's components. Otherwise, the pattern can match any
  6102. subsequence. Default is @option{--no-anchored} for exclusion members
  6103. and @option{--anchored} inclusion members.
  6104. @opindex ignore-case
  6105. @opindex no-ignore-case
  6106. @item --ignore-case
  6107. @itemx --no-ignore-case
  6108. When ignoring case, upper-case patterns match lower-case names and vice versa.
  6109. When not ignoring case (the default), matching is case-sensitive.
  6110. @opindex wildcards-match-slash
  6111. @opindex no-wildcards-match-slash
  6112. @item --wildcards-match-slash
  6113. @itemx --no-wildcards-match-slash
  6114. When wildcards match slash (the default for exclusion members), a
  6115. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  6116. name. Otherwise, @samp{/} is matched only by @samp{/}.
  6117. @end table
  6118. The @option{--recursion} and @option{--no-recursion} options
  6119. (@pxref{recurse}) also affect how member patterns are interpreted. If
  6120. recursion is in effect, a pattern matches a name if it matches any of
  6121. the name's parent directories.
  6122. The following table summarizes pattern-matching default values:
  6123. @multitable @columnfractions .3 .7
  6124. @headitem Members @tab Default settings
  6125. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  6126. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  6127. @end multitable
  6128. @node quoting styles
  6129. @section Quoting Member Names
  6130. When displaying member names, @command{tar} takes care to avoid
  6131. ambiguities caused by certain characters. This is called @dfn{name
  6132. quoting}. The characters in question are:
  6133. @itemize @bullet
  6134. @item Non-printable control characters:
  6135. @anchor{escape sequences}
  6136. @multitable @columnfractions 0.20 0.10 0.60
  6137. @headitem Character @tab @acronym{ASCII} @tab Character name
  6138. @item \a @tab 7 @tab Audible bell
  6139. @item \b @tab 8 @tab Backspace
  6140. @item \f @tab 12 @tab Form feed
  6141. @item \n @tab 10 @tab New line
  6142. @item \r @tab 13 @tab Carriage return
  6143. @item \t @tab 9 @tab Horizontal tabulation
  6144. @item \v @tab 11 @tab Vertical tabulation
  6145. @end multitable
  6146. @item Space (@acronym{ASCII} 32)
  6147. @item Single and double quotes (@samp{'} and @samp{"})
  6148. @item Backslash (@samp{\})
  6149. @end itemize
  6150. The exact way @command{tar} uses to quote these characters depends on
  6151. the @dfn{quoting style}. The default quoting style, called
  6152. @dfn{escape} (see below), uses backslash notation to represent control
  6153. characters, space and backslash. Using this quoting style, control
  6154. characters are represented as listed in column @samp{Character} in the
  6155. above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
  6156. @GNUTAR{} offers seven distinct quoting styles, which can be selected
  6157. using @option{--quoting-style} option:
  6158. @table @option
  6159. @item --quoting-style=@var{style}
  6160. @opindex quoting-style
  6161. Sets quoting style. Valid values for @var{style} argument are:
  6162. literal, shell, shell-always, c, escape, locale, clocale.
  6163. @end table
  6164. These styles are described in detail below. To illustrate their
  6165. effect, we will use an imaginary tar archive @file{arch.tar}
  6166. containing the following members:
  6167. @smallexample
  6168. @group
  6169. # 1. Contains horizontal tabulation character.
  6170. a tab
  6171. # 2. Contains newline character
  6172. a
  6173. newline
  6174. # 3. Contains a space
  6175. a space
  6176. # 4. Contains double quotes
  6177. a"double"quote
  6178. # 5. Contains single quotes
  6179. a'single'quote
  6180. # 6. Contains a backslash character:
  6181. a\backslash
  6182. @end group
  6183. @end smallexample
  6184. Here is how usual @command{ls} command would have listed them, if they
  6185. had existed in the current working directory:
  6186. @smallexample
  6187. @group
  6188. $ @kbd{ls}
  6189. a\ttab
  6190. a\nnewline
  6191. a\ space
  6192. a"double"quote
  6193. a'single'quote
  6194. a\\backslash
  6195. @end group
  6196. @end smallexample
  6197. Quoting styles:
  6198. @table @samp
  6199. @item literal
  6200. No quoting, display each character as is:
  6201. @smallexample
  6202. @group
  6203. $ @kbd{tar tf arch.tar --quoting-style=literal}
  6204. ./
  6205. ./a space
  6206. ./a'single'quote
  6207. ./a"double"quote
  6208. ./a\backslash
  6209. ./a tab
  6210. ./a
  6211. newline
  6212. @end group
  6213. @end smallexample
  6214. @item shell
  6215. Display characters the same way Bourne shell does:
  6216. control characters, except @samp{\t} and @samp{\n}, are printed using
  6217. backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
  6218. single quote is printed as @samp{\'}. If a name contains any quoted
  6219. characters, it is enclosed in single quotes. In particular, if a name
  6220. contains single quotes, it is printed as several single-quoted strings:
  6221. @smallexample
  6222. @group
  6223. $ @kbd{tar tf arch.tar --quoting-style=shell}
  6224. ./
  6225. './a space'
  6226. './a'\''single'\''quote'
  6227. './a"double"quote'
  6228. './a\backslash'
  6229. './a tab'
  6230. './a
  6231. newline'
  6232. @end group
  6233. @end smallexample
  6234. @item shell-always
  6235. Same as @samp{shell}, but the names are always enclosed in single
  6236. quotes:
  6237. @smallexample
  6238. @group
  6239. $ @kbd{tar tf arch.tar --quoting-style=shell-always}
  6240. './'
  6241. './a space'
  6242. './a'\''single'\''quote'
  6243. './a"double"quote'
  6244. './a\backslash'
  6245. './a tab'
  6246. './a
  6247. newline'
  6248. @end group
  6249. @end smallexample
  6250. @item c
  6251. Use the notation of the C programming language. All names are
  6252. enclosed in double quotes. Control characters are quoted using
  6253. backslash notations, double quotes are represented as @samp{\"},
  6254. backslash characters are represented as @samp{\\}. Single quotes and
  6255. spaces are not quoted:
  6256. @smallexample
  6257. @group
  6258. $ @kbd{tar tf arch.tar --quoting-style=c}
  6259. "./"
  6260. "./a space"
  6261. "./a'single'quote"
  6262. "./a\"double\"quote"
  6263. "./a\\backslash"
  6264. "./a\ttab"
  6265. "./a\nnewline"
  6266. @end group
  6267. @end smallexample
  6268. @item escape
  6269. Control characters are printed using backslash notation, a space is
  6270. printed as @samp{\ } and a backslash as @samp{\\}. This is the
  6271. default quoting style, unless it was changed when configured the
  6272. package.
  6273. @smallexample
  6274. @group
  6275. $ @kbd{tar tf arch.tar --quoting-style=escape}
  6276. ./
  6277. ./a space
  6278. ./a'single'quote
  6279. ./a"double"quote
  6280. ./a\\backslash
  6281. ./a\ttab
  6282. ./a\nnewline
  6283. @end group
  6284. @end smallexample
  6285. @item locale
  6286. Control characters, single quote and backslash are printed using
  6287. backslash notation. All names are quoted using left and right
  6288. quotation marks, appropriate to the current locale. If it does not
  6289. define quotation marks, use @samp{`} as left and @samp{'} as right
  6290. quotation marks. Any occurrences of the right quotation mark in a
  6291. name are escaped with @samp{\}, for example:
  6292. For example:
  6293. @smallexample
  6294. @group
  6295. $ @kbd{tar tf arch.tar --quoting-style=locale}
  6296. `./'
  6297. `./a space'
  6298. `./a\'single\'quote'
  6299. `./a"double"quote'
  6300. `./a\\backslash'
  6301. `./a\ttab'
  6302. `./a\nnewline'
  6303. @end group
  6304. @end smallexample
  6305. @item clocale
  6306. Same as @samp{locale}, but @samp{"} is used for both left and right
  6307. quotation marks, if not provided by the currently selected locale:
  6308. @smallexample
  6309. @group
  6310. $ @kbd{tar tf arch.tar --quoting-style=clocale}
  6311. "./"
  6312. "./a space"
  6313. "./a'single'quote"
  6314. "./a\"double\"quote"
  6315. "./a\\backslash"
  6316. "./a\ttab"
  6317. "./a\nnewline"
  6318. @end group
  6319. @end smallexample
  6320. @end table
  6321. You can specify which characters should be quoted in addition to those
  6322. implied by the current quoting style:
  6323. @table @option
  6324. @item --quote-chars=@var{string}
  6325. Always quote characters from @var{string}, even if the selected
  6326. quoting style would not quote them.
  6327. @end table
  6328. For example, using @samp{escape} quoting (compare with the usual
  6329. escape listing above):
  6330. @smallexample
  6331. @group
  6332. $ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
  6333. ./
  6334. ./a\ space
  6335. ./a'single'quote
  6336. ./a\"double\"quote
  6337. ./a\\backslash
  6338. ./a\ttab
  6339. ./a\nnewline
  6340. @end group
  6341. @end smallexample
  6342. To disable quoting of such additional characters, use the following
  6343. option:
  6344. @table @option
  6345. @item --no-quote-chars=@var{string}
  6346. Remove characters listed in @var{string} from the list of quoted
  6347. characters set by the previous @option{--quote-chars} option.
  6348. @end table
  6349. This option is particularly useful if you have added
  6350. @option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
  6351. and wish to disable it for the current invocation.
  6352. Note, that @option{--no-quote-chars} does @emph{not} disable those
  6353. characters that are quoted by default in the selected quoting style.
  6354. @node transform
  6355. @section Modifying File and Member Names
  6356. @command{Tar} archives contain detailed information about files stored
  6357. in them and full file names are part of that information. When
  6358. storing a file to an archive, its file name is recorded in it,
  6359. along with the actual file contents. When restoring from an archive,
  6360. a file is created on disk with exactly the same name as that stored
  6361. in the archive. In the majority of cases this is the desired behavior
  6362. of a file archiver. However, there are some cases when it is not.
  6363. First of all, it is often unsafe to extract archive members with
  6364. absolute file names or those that begin with a @file{../}. @GNUTAR{}
  6365. takes special precautions when extracting such names and provides a
  6366. special option for handling them, which is described in
  6367. @ref{absolute}.
  6368. Secondly, you may wish to extract file names without some leading
  6369. directory components, or with otherwise modified names. In other
  6370. cases it is desirable to store files under differing names in the
  6371. archive.
  6372. @GNUTAR{} provides several options for these needs.
  6373. @table @option
  6374. @opindex strip-components
  6375. @item --strip-components=@var{number}
  6376. Strip given @var{number} of leading components from file names before
  6377. extraction.
  6378. @end table
  6379. For example, suppose you have archived whole @file{/usr} hierarchy to
  6380. a tar archive named @file{usr.tar}. Among other files, this archive
  6381. contains @file{usr/include/stdlib.h}, which you wish to extract to
  6382. the current working directory. To do so, you type:
  6383. @smallexample
  6384. $ @kbd{tar -xf usr.tar --strip=2 usr/include/stdlib.h}
  6385. @end smallexample
  6386. The option @option{--strip=2} instructs @command{tar} to strip the
  6387. two leading components (@file{usr/} and @file{include/}) off the file
  6388. name.
  6389. If you add the @option{--verbose} (@option{-v}) option to the invocation
  6390. above, you will note that the verbose listing still contains the
  6391. full file name, with the two removed components still in place. This
  6392. can be inconvenient, so @command{tar} provides a special option for
  6393. altering this behavior:
  6394. @anchor{show-transformed-names}
  6395. @table @option
  6396. @opindex show-transformed-names
  6397. @item --show-transformed-names
  6398. Display file or member names with all requested transformations
  6399. applied.
  6400. @end table
  6401. @noindent
  6402. For example:
  6403. @smallexample
  6404. @group
  6405. $ @kbd{tar -xf usr.tar -v --strip=2 usr/include/stdlib.h}
  6406. usr/include/stdlib.h
  6407. $ @kbd{tar -xf usr.tar -v --strip=2 --show-transformed usr/include/stdlib.h}
  6408. stdlib.h
  6409. @end group
  6410. @end smallexample
  6411. Notice that in both cases the file @file{stdlib.h} is extracted to the
  6412. current working directory, @option{--show-transformed-names} affects
  6413. only the way its name is displayed.
  6414. This option is especially useful for verifying whether the invocation
  6415. will have the desired effect. Thus, before running
  6416. @smallexample
  6417. $ @kbd{tar -x --strip=@var{n}}
  6418. @end smallexample
  6419. @noindent
  6420. it is often advisable to run
  6421. @smallexample
  6422. $ @kbd{tar -t -v --show-transformed --strip=@var{n}}
  6423. @end smallexample
  6424. @noindent
  6425. to make sure the command will produce the intended results.
  6426. In case you need to apply more complex modifications to the file name,
  6427. @GNUTAR{} provides a general-purpose transformation option:
  6428. @table @option
  6429. @opindex transform
  6430. @opindex xform
  6431. @item --transform=@var{expression}
  6432. @itemx --xform=@var{expression}
  6433. Modify file names using supplied @var{expression}.
  6434. @end table
  6435. @noindent
  6436. The @var{expression} is a @command{sed}-like replace expression of the
  6437. form:
  6438. @smallexample
  6439. s/@var{regexp}/@var{replace}/[@var{flags}]
  6440. @end smallexample
  6441. @noindent
  6442. where @var{regexp} is a @dfn{regular expression}, @var{replace} is a
  6443. replacement for each file name part that matches @var{regexp}. Both
  6444. @var{regexp} and @var{replace} are described in detail in
  6445. @ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}.
  6446. Any delimiter can be used in lieu of @samp{/}, the only requirement being
  6447. that it be used consistently throughout the expression. For example,
  6448. the following two expressions are equivalent:
  6449. @smallexample
  6450. @group
  6451. s/one/two/
  6452. s,one,two,
  6453. @end group
  6454. @end smallexample
  6455. Changing delimiters is often useful when the @var{regex} contains
  6456. slashes. For example, it is more convenient to write @code{s,/,-,} than
  6457. @code{s/\//-/}.
  6458. As in @command{sed}, you can give several replace expressions,
  6459. separated by a semicolon.
  6460. Supported @var{flags} are:
  6461. @table @samp
  6462. @item g
  6463. Apply the replacement to @emph{all} matches to the @var{regexp}, not
  6464. just the first.
  6465. @item i
  6466. Use case-insensitive matching.
  6467. @item x
  6468. @var{regexp} is an @dfn{extended regular expression} (@pxref{Extended
  6469. regexps, Extended regular expressions, Extended regular expressions,
  6470. sed, GNU sed}).
  6471. @item @var{number}
  6472. Only replace the @var{number}th match of the @var{regexp}.
  6473. Note: the @acronym{POSIX} standard does not specify what should happen
  6474. when you mix the @samp{g} and @var{number} modifiers. @GNUTAR{}
  6475. follows the GNU @command{sed} implementation in this regard, so
  6476. the interaction is defined to be: ignore matches before the
  6477. @var{number}th, and then match and replace all matches from the
  6478. @var{number}th on.
  6479. @end table
  6480. In addition, several @dfn{transformation scope} flags are supported,
  6481. that control to what files transformations apply. These are:
  6482. @table @samp
  6483. @item r
  6484. Apply transformation to regular archive members.
  6485. @item R
  6486. Do not apply transformation to regular archive members.
  6487. @item s
  6488. Apply transformation to symbolic link targets.
  6489. @item S
  6490. Do not apply transformation to symbolic link targets.
  6491. @item h
  6492. Apply transformation to hard link targets.
  6493. @item H
  6494. Do not apply transformation to hard link targets.
  6495. @end table
  6496. Default is @samp{rsh}, which means to apply tranformations to both archive
  6497. members and targets of symbolic and hard links.
  6498. Default scope flags can also be changed using @samp{flags=} statement
  6499. in the transform expression. The flags set this way remain in force
  6500. until next @samp{flags=} statement or end of expression, whichever
  6501. occurs first. For example:
  6502. @smallexample
  6503. --transform 'flags=S;s|^|/usr/local/|'
  6504. @end smallexample
  6505. Here are several examples of @option{--transform} usage:
  6506. @enumerate
  6507. @item Extract @file{usr/} hierarchy into @file{usr/local/}:
  6508. @smallexample
  6509. $ @kbd{tar --transform='s,usr/,usr/local/,' -x -f arch.tar}
  6510. @end smallexample
  6511. @item Strip two leading directory components (equivalent to
  6512. @option{--strip-components=2}):
  6513. @smallexample
  6514. $ @kbd{tar --transform='s,/*[^/]*/[^/]*/,,' -x -f arch.tar}
  6515. @end smallexample
  6516. @item Convert each file name to lower case:
  6517. @smallexample
  6518. $ @kbd{tar --transform 's/.*/\L&/' -x -f arch.tar}
  6519. @end smallexample
  6520. @item Prepend @file{/prefix/} to each file name:
  6521. @smallexample
  6522. $ @kbd{tar --transform 's,^,/prefix/,' -x -f arch.tar}
  6523. @end smallexample
  6524. @item Archive the @file{/lib} directory, prepending @samp{/usr/local}
  6525. to each archive member:
  6526. @smallexample
  6527. $ @kbd{tar --transform 's,^,/usr/local/,S' -c -f arch.tar /lib}
  6528. @end smallexample
  6529. @end enumerate
  6530. Notice the use of flags in the last example. The @file{/lib}
  6531. directory often contains many symbolic links to files within it.
  6532. It may look, for example, like this:
  6533. @smallexample
  6534. $ @kbd{ls -l}
  6535. drwxr-xr-x root/root 0 2008-07-08 16:20 /lib/
  6536. -rwxr-xr-x root/root 1250840 2008-05-25 07:44 /lib/libc-2.3.2.so
  6537. lrwxrwxrwx root/root 0 2008-06-24 17:12 /lib/libc.so.6 -> libc-2.3.2.so
  6538. ...
  6539. @end smallexample
  6540. Using the expression @samp{s,^,/usr/local/,} would mean adding
  6541. @samp{/usr/local} to both regular archive members and to link
  6542. targets. In this case, @file{/lib/libc.so.6} would become:
  6543. @smallexample
  6544. /usr/local/lib/libc.so.6 -> /usr/local/libc-2.3.2.so
  6545. @end smallexample
  6546. This is definitely not desired. To avoid this, the @samp{S} flag
  6547. is used, which excludes symbolic link targets from filename
  6548. transformations. The result is:
  6549. @smallexample
  6550. $ @kbd{tar --transform 's,^,/usr/local/,S', -c -v -f arch.tar \
  6551. --show-transformed /lib}
  6552. drwxr-xr-x root/root 0 2008-07-08 16:20 /usr/local/lib/
  6553. -rwxr-xr-x root/root 1250840 2008-05-25 07:44 /usr/local/lib/libc-2.3.2.so
  6554. lrwxrwxrwx root/root 0 2008-06-24 17:12 /usr/local/lib/libc.so.6 \
  6555. -> libc-2.3.2.so
  6556. @end smallexample
  6557. Unlike @option{--strip-components}, @option{--transform} can be used
  6558. in any @GNUTAR{} operation mode. For example, the following command
  6559. adds files to the archive while replacing the leading @file{usr/}
  6560. component with @file{var/}:
  6561. @smallexample
  6562. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' /}
  6563. @end smallexample
  6564. To test @option{--transform} effect we suggest using
  6565. @option{--show-transformed-names} option:
  6566. @smallexample
  6567. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' \
  6568. --verbose --show-transformed-names /}
  6569. @end smallexample
  6570. If both @option{--strip-components} and @option{--transform} are used
  6571. together, then @option{--transform} is applied first, and the required
  6572. number of components is then stripped from its result.
  6573. You can use as many @option{--transform} options in a single command
  6574. line as you want. The specified expressions will then be applied in
  6575. order of their appearance. For example, the following two invocations
  6576. are equivalent:
  6577. @smallexample
  6578. $ @kbd{tar -cf arch.tar --transform='s,/usr/var,/var/' \
  6579. --transform='s,/usr/local,/usr/,'}
  6580. $ @kbd{tar -cf arch.tar \
  6581. --transform='s,/usr/var,/var/;s,/usr/local,/usr/,'}
  6582. @end smallexample
  6583. @node after
  6584. @section Operating Only on New Files
  6585. @cindex Excluding file by age
  6586. @cindex Data Modification time, excluding files by
  6587. @cindex Modification time, excluding files by
  6588. @cindex Age, excluding files by
  6589. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  6590. @option{-N @var{date}}) option causes @command{tar} to only work on
  6591. files whose data modification or status change times are newer than
  6592. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  6593. it is taken to be a file name; the data modification time of that file
  6594. is used as the date. If you use this option when creating or appending
  6595. to an archive, the archive will only include new files. If you use
  6596. @option{--after-date} when extracting an archive, @command{tar} will
  6597. only extract files newer than the @var{date} you specify.
  6598. If you only want @command{tar} to make the date comparison based on
  6599. modification of the file's data (rather than status
  6600. changes), then use the @option{--newer-mtime=@var{date}} option.
  6601. @cindex --after-date and --update compared
  6602. @cindex --newer-mtime and --update compared
  6603. You may use these options with any operation. Note that these options
  6604. differ from the @option{--update} (@option{-u}) operation in that they
  6605. allow you to specify a particular date against which @command{tar} can
  6606. compare when deciding whether or not to archive the files.
  6607. @table @option
  6608. @opindex after-date
  6609. @opindex newer
  6610. @item --after-date=@var{date}
  6611. @itemx --newer=@var{date}
  6612. @itemx -N @var{date}
  6613. Only store files newer than @var{date}.
  6614. Acts on files only if their data modification or status change times are
  6615. later than @var{date}. Use in conjunction with any operation.
  6616. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  6617. name; the data modification time of that file is used as the date.
  6618. @opindex newer-mtime
  6619. @item --newer-mtime=@var{date}
  6620. Acts like @option{--after-date}, but only looks at data modification times.
  6621. @end table
  6622. These options limit @command{tar} to operate only on files which have
  6623. been modified after the date specified. A file's status is considered to have
  6624. changed if its contents have been modified, or if its owner,
  6625. permissions, and so forth, have been changed. (For more information on
  6626. how to specify a date, see @ref{Date input formats}; remember that the
  6627. entire date argument must be quoted if it contains any spaces.)
  6628. Gurus would say that @option{--after-date} tests both the data
  6629. modification time (@code{mtime}, the time the contents of the file
  6630. were last modified) and the status change time (@code{ctime}, the time
  6631. the file's status was last changed: owner, permissions, etc.@:)
  6632. fields, while @option{--newer-mtime} tests only the @code{mtime}
  6633. field.
  6634. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  6635. @code{ctime} and processes the file if either one is more recent than
  6636. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  6637. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  6638. contents of the file were looked at).
  6639. Date specifiers can have embedded spaces. Because of this, you may need
  6640. to quote date arguments to keep the shell from parsing them as separate
  6641. arguments. For example, the following command will add to the archive
  6642. all the files modified less than two days ago:
  6643. @smallexample
  6644. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  6645. @end smallexample
  6646. When any of these options is used with the option @option{--verbose}
  6647. (@pxref{verbose tutorial}) @GNUTAR{} will try to convert the specified
  6648. date back to its textual representation and compare that with the
  6649. one given with the option. If the two dates differ, @command{tar} will
  6650. print a warning saying what date it will use. This is to help user
  6651. ensure he is using the right date. For example:
  6652. @smallexample
  6653. @group
  6654. $ @kbd{tar -c -f archive.tar --after-date='10 days ago' .}
  6655. tar: Option --after-date: Treating date `10 days ago' as 2006-06-11
  6656. 13:19:37.232434
  6657. @end group
  6658. @end smallexample
  6659. @quotation
  6660. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  6661. should not be used for incremental backups. @xref{Incremental Dumps},
  6662. for proper way of creating incremental backups.
  6663. @end quotation
  6664. @node recurse
  6665. @section Descending into Directories
  6666. @cindex Avoiding recursion in directories
  6667. @cindex Descending directories, avoiding
  6668. @cindex Directories, avoiding recursion
  6669. @cindex Recursion in directories, avoiding
  6670. Usually, @command{tar} will recursively explore all directories (either
  6671. those given on the command line or through the @option{--files-from}
  6672. option) for the various files they contain. However, you may not always
  6673. want @command{tar} to act this way.
  6674. @opindex no-recursion
  6675. @cindex @command{find}, using with @command{tar}
  6676. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  6677. into specified directories. If you specify @option{--no-recursion}, you can
  6678. use the @command{find} (@pxref{Top,, find, find, GNU Find Manual})
  6679. utility for hunting through levels of directories to
  6680. construct a list of file names which you could then pass to @command{tar}.
  6681. @command{find} allows you to be more selective when choosing which files to
  6682. archive; see @ref{files}, for more information on using @command{find} with
  6683. @command{tar}.
  6684. @table @option
  6685. @item --no-recursion
  6686. Prevents @command{tar} from recursively descending directories.
  6687. @opindex recursion
  6688. @item --recursion
  6689. Requires @command{tar} to recursively descend directories.
  6690. This is the default.
  6691. @end table
  6692. When you use @option{--no-recursion}, @GNUTAR{} grabs
  6693. directory entries themselves, but does not descend on them
  6694. recursively. Many people use @command{find} for locating files they
  6695. want to back up, and since @command{tar} @emph{usually} recursively
  6696. descends on directories, they have to use the @samp{@w{-not -type d}}
  6697. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  6698. find, Finding Files}), as they usually do not want all the files in a
  6699. directory. They then use the @option{--files-from} option to archive
  6700. the files located via @command{find}.
  6701. The problem when restoring files archived in this manner is that the
  6702. directories themselves are not in the archive; so the
  6703. @option{--same-permissions} (@option{--preserve-permissions},
  6704. @option{-p}) option does not affect them---while users might really
  6705. like it to. Specifying @option{--no-recursion} is a way to tell
  6706. @command{tar} to grab only the directory entries given to it, adding
  6707. no new files on its own. To summarize, if you use @command{find} to
  6708. create a list of files to be stored in an archive, use it as follows:
  6709. @smallexample
  6710. @group
  6711. $ @kbd{find @var{dir} @var{tests} | \
  6712. tar -cf @var{archive} -T - --no-recursion}
  6713. @end group
  6714. @end smallexample
  6715. The @option{--no-recursion} option also applies when extracting: it
  6716. causes @command{tar} to extract only the matched directory entries, not
  6717. the files under those directories.
  6718. The @option{--no-recursion} option also affects how globbing patterns
  6719. are interpreted (@pxref{controlling pattern-matching}).
  6720. The @option{--no-recursion} and @option{--recursion} options apply to
  6721. later options and operands, and can be overridden by later occurrences
  6722. of @option{--no-recursion} and @option{--recursion}. For example:
  6723. @smallexample
  6724. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  6725. @end smallexample
  6726. @noindent
  6727. creates an archive with one entry for @file{grape}, and the recursive
  6728. contents of @file{grape/concord}, but no entries under @file{grape}
  6729. other than @file{grape/concord}.
  6730. @node one
  6731. @section Crossing File System Boundaries
  6732. @cindex File system boundaries, not crossing
  6733. @command{tar} will normally automatically cross file system boundaries in
  6734. order to archive files which are part of a directory tree. You can
  6735. change this behavior by running @command{tar} and specifying
  6736. @option{--one-file-system}. This option only affects files that are
  6737. archived because they are in a directory that is being archived;
  6738. @command{tar} will still archive files explicitly named on the command line
  6739. or through @option{--files-from}, regardless of where they reside.
  6740. @table @option
  6741. @opindex one-file-system
  6742. @item --one-file-system
  6743. Prevents @command{tar} from crossing file system boundaries when
  6744. archiving. Use in conjunction with any write operation.
  6745. @end table
  6746. The @option{--one-file-system} option causes @command{tar} to modify its
  6747. normal behavior in archiving the contents of directories. If a file in
  6748. a directory is not on the same file system as the directory itself, then
  6749. @command{tar} will not archive that file. If the file is a directory
  6750. itself, @command{tar} will not archive anything beneath it; in other words,
  6751. @command{tar} will not cross mount points.
  6752. This option is useful for making full or incremental archival backups of
  6753. a file system. If this option is used in conjunction with
  6754. @option{--verbose} (@option{-v}), files that are excluded are
  6755. mentioned by name on the standard error.
  6756. @menu
  6757. * directory:: Changing Directory
  6758. * absolute:: Absolute File Names
  6759. @end menu
  6760. @node directory
  6761. @subsection Changing the Working Directory
  6762. @FIXME{need to read over this node now for continuity; i've switched
  6763. things around some.}
  6764. @cindex Changing directory mid-stream
  6765. @cindex Directory, changing mid-stream
  6766. @cindex Working directory, specifying
  6767. To change the working directory in the middle of a list of file names,
  6768. either on the command line or in a file specified using
  6769. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  6770. This will change the working directory to the specified directory
  6771. after that point in the list.
  6772. @table @option
  6773. @opindex directory
  6774. @item --directory=@var{directory}
  6775. @itemx -C @var{directory}
  6776. Changes the working directory in the middle of a command line.
  6777. @end table
  6778. For example,
  6779. @smallexample
  6780. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  6781. @end smallexample
  6782. @noindent
  6783. will place the files @file{grape} and @file{prune} from the current
  6784. directory into the archive @file{jams.tar}, followed by the file
  6785. @file{cherry} from the directory @file{food}. This option is especially
  6786. useful when you have several widely separated files that you want to
  6787. store in the same archive.
  6788. Note that the file @file{cherry} is recorded in the archive under the
  6789. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  6790. archive will contain three files that all appear to have come from the
  6791. same directory; if the archive is extracted with plain @samp{tar
  6792. --extract}, all three files will be written in the current directory.
  6793. Contrast this with the command,
  6794. @smallexample
  6795. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  6796. @end smallexample
  6797. @noindent
  6798. which records the third file in the archive under the name
  6799. @file{red/cherry} so that, if the archive is extracted using
  6800. @samp{tar --extract}, the third file will be written in a subdirectory
  6801. named @file{red}.
  6802. You can use the @option{--directory} option to make the archive
  6803. independent of the original name of the directory holding the files.
  6804. The following command places the files @file{/etc/passwd},
  6805. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  6806. @file{foo.tar}:
  6807. @smallexample
  6808. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  6809. @end smallexample
  6810. @noindent
  6811. However, the names of the archive members will be exactly what they were
  6812. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  6813. They will not appear to be related by file name to the original
  6814. directories where those files were located.
  6815. Note that @option{--directory} options are interpreted consecutively. If
  6816. @option{--directory} specifies a relative file name, it is interpreted
  6817. relative to the then current directory, which might not be the same as
  6818. the original current working directory of @command{tar}, due to a previous
  6819. @option{--directory} option.
  6820. When using @option{--files-from} (@pxref{files}), you can put various
  6821. @command{tar} options (including @option{-C}) in the file list. Notice,
  6822. however, that in this case the option and its argument may not be
  6823. separated by whitespace. If you use short option, its argument must
  6824. either follow the option letter immediately, without any intervening
  6825. whitespace, or occupy the next line. Otherwise, if you use long
  6826. option, separate its argument by an equal sign.
  6827. For instance, the file list for the above example will be:
  6828. @smallexample
  6829. @group
  6830. -C/etc
  6831. passwd
  6832. hosts
  6833. --directory=/lib
  6834. libc.a
  6835. @end group
  6836. @end smallexample
  6837. @noindent
  6838. To use it, you would invoke @command{tar} as follows:
  6839. @smallexample
  6840. $ @kbd{tar -c -f foo.tar --files-from list}
  6841. @end smallexample
  6842. The interpretation of @option{--directory} is disabled by
  6843. @option{--null} option.
  6844. @node absolute
  6845. @subsection Absolute File Names
  6846. @cindex absolute file names
  6847. @cindex file names, absolute
  6848. By default, @GNUTAR{} drops a leading @samp{/} on
  6849. input or output, and complains about file names containing a @file{..}
  6850. component. There is an option that turns off this behavior:
  6851. @table @option
  6852. @opindex absolute-names
  6853. @item --absolute-names
  6854. @itemx -P
  6855. Do not strip leading slashes from file names, and permit file names
  6856. containing a @file{..} file name component.
  6857. @end table
  6858. When @command{tar} extracts archive members from an archive, it strips any
  6859. leading slashes (@samp{/}) from the member name. This causes absolute
  6860. member names in the archive to be treated as relative file names. This
  6861. allows you to have such members extracted wherever you want, instead of
  6862. being restricted to extracting the member in the exact directory named
  6863. in the archive. For example, if the archive member has the name
  6864. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  6865. really @file{etc/passwd}.
  6866. File names containing @file{..} can cause problems when extracting, so
  6867. @command{tar} normally warns you about such files when creating an
  6868. archive, and rejects attempts to extracts such files.
  6869. Other @command{tar} programs do not do this. As a result, if you
  6870. create an archive whose member names start with a slash, they will be
  6871. difficult for other people with a non-@GNUTAR{}
  6872. program to use. Therefore, @GNUTAR{} also strips
  6873. leading slashes from member names when putting members into the
  6874. archive. For example, if you ask @command{tar} to add the file
  6875. @file{/bin/ls} to an archive, it will do so, but the member name will
  6876. be @file{bin/ls}@footnote{A side effect of this is that when
  6877. @option{--create} is used with @option{--verbose} the resulting output
  6878. is not, generally speaking, the same as the one you'd get running
  6879. @kbd{tar --list} command. This may be important if you use some
  6880. scripts for comparing both outputs. @xref{listing member and file names},
  6881. for the information on how to handle this case.}.
  6882. If you use the @option{--absolute-names} (@option{-P}) option,
  6883. @command{tar} will do none of these transformations.
  6884. To archive or extract files relative to the root directory, specify
  6885. the @option{--absolute-names} (@option{-P}) option.
  6886. Normally, @command{tar} acts on files relative to the working
  6887. directory---ignoring superior directory names when archiving, and
  6888. ignoring leading slashes when extracting.
  6889. When you specify @option{--absolute-names} (@option{-P}),
  6890. @command{tar} stores file names including all superior directory
  6891. names, and preserves leading slashes. If you only invoked
  6892. @command{tar} from the root directory you would never need the
  6893. @option{--absolute-names} option, but using this option
  6894. may be more convenient than switching to root.
  6895. @FIXME{Should be an example in the tutorial/wizardry section using this
  6896. to transfer files between systems.}
  6897. @table @option
  6898. @item --absolute-names
  6899. Preserves full file names (including superior directory names) when
  6900. archiving files. Preserves leading slash when extracting files.
  6901. @end table
  6902. @command{tar} prints out a message about removing the @samp{/} from
  6903. file names. This message appears once per @GNUTAR{}
  6904. invocation. It represents something which ought to be told; ignoring
  6905. what it means can cause very serious surprises, later.
  6906. Some people, nevertheless, do not want to see this message. Wanting to
  6907. play really dangerously, one may of course redirect @command{tar} standard
  6908. error to the sink. For example, under @command{sh}:
  6909. @smallexample
  6910. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  6911. @end smallexample
  6912. @noindent
  6913. Another solution, both nicer and simpler, would be to change to
  6914. the @file{/} directory first, and then avoid absolute notation.
  6915. For example:
  6916. @smallexample
  6917. $ @kbd{tar -c -f archive.tar -C / home}
  6918. @end smallexample
  6919. @xref{Integrity}, for some of the security-related implications
  6920. of using this option.
  6921. @include parse-datetime.texi
  6922. @node Formats
  6923. @chapter Controlling the Archive Format
  6924. @cindex Tar archive formats
  6925. Due to historical reasons, there are several formats of tar archives.
  6926. All of them are based on the same principles, but have some subtle
  6927. differences that often make them incompatible with each other.
  6928. GNU tar is able to create and handle archives in a variety of formats.
  6929. The most frequently used formats are (in alphabetical order):
  6930. @table @asis
  6931. @item gnu
  6932. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  6933. from an early @acronym{POSIX} standard, adding some improvements such as
  6934. sparse file handling and incremental archives. Unfortunately these
  6935. features were implemented in a way incompatible with other archive
  6936. formats.
  6937. Archives in @samp{gnu} format are able to hold file names of unlimited
  6938. length.
  6939. @item oldgnu
  6940. Format used by @GNUTAR{} of versions prior to 1.12.
  6941. @item v7
  6942. Archive format, compatible with the V7 implementation of tar. This
  6943. format imposes a number of limitations. The most important of them
  6944. are:
  6945. @enumerate
  6946. @item The maximum length of a file name is limited to 99 characters.
  6947. @item The maximum length of a symbolic link is limited to 99 characters.
  6948. @item It is impossible to store special files (block and character
  6949. devices, fifos etc.)
  6950. @item Maximum value of user or group @acronym{ID} is limited to 2097151 (7777777
  6951. octal)
  6952. @item V7 archives do not contain symbolic ownership information (user
  6953. and group name of the file owner).
  6954. @end enumerate
  6955. This format has traditionally been used by Automake when producing
  6956. Makefiles. This practice will change in the future, in the meantime,
  6957. however this means that projects containing file names more than 99
  6958. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  6959. Automake prior to 1.9.
  6960. @item ustar
  6961. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  6962. symbolic ownership information. It is also able to store
  6963. special files. However, it imposes several restrictions as well:
  6964. @enumerate
  6965. @item The maximum length of a file name is limited to 256 characters,
  6966. provided that the file name can be split at a directory separator in
  6967. two parts, first of them being at most 155 bytes long. So, in most
  6968. cases the maximum file name length will be shorter than 256
  6969. characters.
  6970. @item The maximum length of a symbolic link name is limited to
  6971. 100 characters.
  6972. @item Maximum size of a file the archive is able to accommodate
  6973. is 8GB
  6974. @item Maximum value of UID/GID is 2097151.
  6975. @item Maximum number of bits in device major and minor numbers is 21.
  6976. @end enumerate
  6977. @item star
  6978. Format used by J@"org Schilling @command{star}
  6979. implementation. @GNUTAR{} is able to read @samp{star} archives but
  6980. currently does not produce them.
  6981. @item posix
  6982. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  6983. most flexible and feature-rich format. It does not impose any
  6984. restrictions on file sizes or file name lengths. This format is quite
  6985. recent, so not all tar implementations are able to handle it properly.
  6986. However, this format is designed in such a way that any tar
  6987. implementation able to read @samp{ustar} archives will be able to read
  6988. most @samp{posix} archives as well, with the only exception that any
  6989. additional information (such as long file names etc.) will in such
  6990. case be extracted as plain text files along with the files it refers to.
  6991. This archive format will be the default format for future versions
  6992. of @GNUTAR{}.
  6993. @end table
  6994. The following table summarizes the limitations of each of these
  6995. formats:
  6996. @multitable @columnfractions .10 .20 .20 .20 .20
  6997. @headitem Format @tab UID @tab File Size @tab File Name @tab Devn
  6998. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6999. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  7000. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  7001. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  7002. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  7003. @end multitable
  7004. The default format for @GNUTAR{} is defined at compilation
  7005. time. You may check it by running @command{tar --help}, and examining
  7006. the last lines of its output. Usually, @GNUTAR{} is configured
  7007. to create archives in @samp{gnu} format, however, future version will
  7008. switch to @samp{posix}.
  7009. @menu
  7010. * Compression:: Using Less Space through Compression
  7011. * Attributes:: Handling File Attributes
  7012. * Portability:: Making @command{tar} Archives More Portable
  7013. * cpio:: Comparison of @command{tar} and @command{cpio}
  7014. @end menu
  7015. @node Compression
  7016. @section Using Less Space through Compression
  7017. @menu
  7018. * gzip:: Creating and Reading Compressed Archives
  7019. * sparse:: Archiving Sparse Files
  7020. @end menu
  7021. @node gzip
  7022. @subsection Creating and Reading Compressed Archives
  7023. @cindex Compressed archives
  7024. @cindex Storing archives in compressed format
  7025. @cindex gzip
  7026. @cindex bzip2
  7027. @cindex lzip
  7028. @cindex lzma
  7029. @cindex lzop
  7030. @cindex compress
  7031. @GNUTAR{} is able to create and read compressed archives. It supports
  7032. a wide variety of compression programs, namely: @command{gzip},
  7033. @command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
  7034. @command{xz} and traditional @command{compress}. The latter is
  7035. supported mostly for backward compatibility, and we recommend
  7036. against using it, because it is by far less effective than the other
  7037. compression programs@footnote{It also had patent problems in the past.}.
  7038. Creating a compressed archive is simple: you just specify a
  7039. @dfn{compression option} along with the usual archive creation
  7040. commands. The compression option is @option{-z} (@option{--gzip}) to
  7041. create a @command{gzip} compressed archive, @option{-j}
  7042. (@option{--bzip2}) to create a @command{bzip2} compressed archive,
  7043. @option{--lzip} to create an @asis{lzip} compressed archive,
  7044. @option{-J} (@option{--xz}) to create an @asis{XZ} archive,
  7045. @option{--lzma} to create an @asis{LZMA} compressed
  7046. archive, @option{--lzop} to create an @asis{LSOP} archive, and
  7047. @option{-Z} (@option{--compress}) to use @command{compress} program.
  7048. For example:
  7049. @smallexample
  7050. $ @kbd{tar czf archive.tar.gz .}
  7051. @end smallexample
  7052. You can also let @GNUTAR{} select the compression program based on
  7053. the suffix of the archive file name. This is done using
  7054. @option{--auto-compress} (@option{-a}) command line option. For
  7055. example, the following invocation will use @command{bzip2} for
  7056. compression:
  7057. @smallexample
  7058. $ @kbd{tar caf archive.tar.bz2 .}
  7059. @end smallexample
  7060. @noindent
  7061. whereas the following one will use @command{lzma}:
  7062. @smallexample
  7063. $ @kbd{tar caf archive.tar.lzma .}
  7064. @end smallexample
  7065. For a complete list of file name suffixes recognized by @GNUTAR{},
  7066. see @ref{auto-compress}.
  7067. Reading compressed archive is even simpler: you don't need to specify
  7068. any additional options as @GNUTAR{} recognizes its format
  7069. automatically. Thus, the following commands will list and extract the
  7070. archive created in previous example:
  7071. @smallexample
  7072. # List the compressed archive
  7073. $ @kbd{tar tf archive.tar.gz}
  7074. # Extract the compressed archive
  7075. $ @kbd{tar xf archive.tar.gz}
  7076. @end smallexample
  7077. The format recognition algorithm is based on @dfn{signatures}, a
  7078. special byte sequences in the beginning of file, that are specific for
  7079. certain compression formats. If this approach fails, @command{tar}
  7080. falls back to using archive name suffix to determine its format
  7081. (@pxref{auto-compress}, for a list of recognized suffixes).
  7082. @anchor{alternative decompression programs}
  7083. @cindex alternative decompression programs
  7084. Some compression programs are able to handle different compression
  7085. formats. @GNUTAR{} uses this, if the principal decompressor for the
  7086. given format is not available. For example, if @command{compress} is
  7087. not installed, @command{tar} will try to use @command{gzip}. As of
  7088. version @value{VERSION} the following alternatives are
  7089. tried@footnote{To verbosely trace the decompressor selection, use the
  7090. @option{--warning=decompress-program} option
  7091. (@pxref{warnings,decompress-program}).}:
  7092. @multitable @columnfractions 0.3 0.3 0.3
  7093. @headitem Format @tab Main decompressor @tab Alternatives
  7094. @item compress @tab compress @tab gzip
  7095. @item lzma @tab lzma @tab xz
  7096. @item bzip2 @tab bzip2 @tab lbzip2
  7097. @end multitable
  7098. The only case when you have to specify a decompression option while
  7099. reading the archive is when reading from a pipe or from a tape drive
  7100. that does not support random access. However, in this case @GNUTAR{}
  7101. will indicate which option you should use. For example:
  7102. @smallexample
  7103. $ @kbd{cat archive.tar.gz | tar tf -}
  7104. tar: Archive is compressed. Use -z option
  7105. tar: Error is not recoverable: exiting now
  7106. @end smallexample
  7107. If you see such diagnostics, just add the suggested option to the
  7108. invocation of @GNUTAR{}:
  7109. @smallexample
  7110. $ @kbd{cat archive.tar.gz | tar tzf -}
  7111. @end smallexample
  7112. Notice also, that there are several restrictions on operations on
  7113. compressed archives. First of all, compressed archives cannot be
  7114. modified, i.e., you cannot update (@option{--update}, alias @option{-u})
  7115. them or delete (@option{--delete}) members from them or
  7116. add (@option{--append}, alias @option{-r}) members to them. Likewise, you
  7117. cannot append another @command{tar} archive to a compressed archive using
  7118. @option{--concatenate} (@option{-A}). Secondly, multi-volume
  7119. archives cannot be compressed.
  7120. The following options allow to select a particular compressor program:
  7121. @table @option
  7122. @opindex gzip
  7123. @opindex ungzip
  7124. @item -z
  7125. @itemx --gzip
  7126. @itemx --ungzip
  7127. Filter the archive through @command{gzip}.
  7128. @opindex xz
  7129. @item -J
  7130. @itemx --xz
  7131. Filter the archive through @code{xz}.
  7132. @item -j
  7133. @itemx --bzip2
  7134. Filter the archive through @code{bzip2}.
  7135. @opindex lzip
  7136. @item --lzip
  7137. Filter the archive through @command{lzip}.
  7138. @opindex lzma
  7139. @item --lzma
  7140. Filter the archive through @command{lzma}.
  7141. @opindex lzop
  7142. @item --lzop
  7143. Filter the archive through @command{lzop}.
  7144. @opindex compress
  7145. @opindex uncompress
  7146. @item -Z
  7147. @itemx --compress
  7148. @itemx --uncompress
  7149. Filter the archive through @command{compress}.
  7150. @end table
  7151. When any of these options is given, @GNUTAR{} searches the compressor
  7152. binary in the current path and invokes it. The name of the compressor
  7153. program is specified at compilation time using a corresponding
  7154. @option{--with-@var{compname}} option to @command{configure}, e.g.
  7155. @option{--with-bzip2} to select a specific @command{bzip2} binary.
  7156. @xref{lbzip2}, for a detailed discussion.
  7157. The output produced by @command{tar --help} shows the actual
  7158. compressor names along with each of these options.
  7159. You can use any of these options on physical devices (tape drives,
  7160. etc.) and remote files as well as on normal files; data to or from
  7161. such devices or remote files is reblocked by another copy of the
  7162. @command{tar} program to enforce the specified (or default) record
  7163. size. The default compression parameters are used. Most compression
  7164. programs allow to override these by setting a program-specific
  7165. environment variable. For example, when using @command{gzip} you can
  7166. use @env{GZIP} as in the example below:
  7167. @smallexample
  7168. $ @kbd{GZIP=--best tar czf archive.tar.gz subdir}
  7169. @end smallexample
  7170. @noindent
  7171. Another way would be to use the @option{-I} option instead (see
  7172. below), e.g.:
  7173. @smallexample
  7174. $ @kbd{tar -cf archive.tar.gz -I 'gzip --best' subdir}
  7175. @end smallexample
  7176. @noindent
  7177. Finally, the third, traditional, way to achieve the same result is to
  7178. use pipe:
  7179. @smallexample
  7180. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  7181. @end smallexample
  7182. @cindex corrupted archives
  7183. About corrupted compressed archives: compressed files have no
  7184. redundancy, for maximum compression. The adaptive nature of the
  7185. compression scheme means that the compression tables are implicitly
  7186. spread all over the archive. If you lose a few blocks, the dynamic
  7187. construction of the compression tables becomes unsynchronized, and there
  7188. is little chance that you could recover later in the archive.
  7189. Another compression options provide a better control over creating
  7190. compressed archives. These are:
  7191. @table @option
  7192. @anchor{auto-compress}
  7193. @opindex auto-compress
  7194. @item --auto-compress
  7195. @itemx -a
  7196. Select a compression program to use by the archive file name
  7197. suffix. The following suffixes are recognized:
  7198. @multitable @columnfractions 0.3 0.6
  7199. @headitem Suffix @tab Compression program
  7200. @item @samp{.gz} @tab @command{gzip}
  7201. @item @samp{.tgz} @tab @command{gzip}
  7202. @item @samp{.taz} @tab @command{gzip}
  7203. @item @samp{.Z} @tab @command{compress}
  7204. @item @samp{.taZ} @tab @command{compress}
  7205. @item @samp{.bz2} @tab @command{bzip2}
  7206. @item @samp{.tz2} @tab @command{bzip2}
  7207. @item @samp{.tbz2} @tab @command{bzip2}
  7208. @item @samp{.tbz} @tab @command{bzip2}
  7209. @item @samp{.lz} @tab @command{lzip}
  7210. @item @samp{.lzma} @tab @command{lzma}
  7211. @item @samp{.tlz} @tab @command{lzma}
  7212. @item @samp{.lzo} @tab @command{lzop}
  7213. @item @samp{.xz} @tab @command{xz}
  7214. @end multitable
  7215. @opindex use-compress-program
  7216. @item --use-compress-program=@var{prog}
  7217. @itemx -I=@var{prog}
  7218. Use external compression program @var{prog}. Use this option if you
  7219. are not happy with the compression program associated with the suffix
  7220. at compile time or if you have a compression program that @GNUTAR{}
  7221. does not support. There are two requirements to which @var{prog}
  7222. should comply:
  7223. First, when called without options, it should read data from standard
  7224. input, compress it and output it on standard output.
  7225. Secondly, if called with @option{-d} argument, it should do exactly
  7226. the opposite, i.e., read the compressed data from the standard input
  7227. and produce uncompressed data on the standard output.
  7228. @end table
  7229. @cindex gpg, using with tar
  7230. @cindex gnupg, using with tar
  7231. @cindex Using encrypted archives
  7232. The @option{--use-compress-program} option, in particular, lets you
  7233. implement your own filters, not necessarily dealing with
  7234. compression/decompression. For example, suppose you wish to implement
  7235. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  7236. gpg, gpg ---- encryption and signing tool, gpg, GNU Privacy Guard
  7237. Manual}). The following script does that:
  7238. @smallexample
  7239. @group
  7240. #! /bin/sh
  7241. case $1 in
  7242. -d) gpg --decrypt - | gzip -d -c;;
  7243. '') gzip -c | gpg -s;;
  7244. *) echo "Unknown option $1">&2; exit 1;;
  7245. esac
  7246. @end group
  7247. @end smallexample
  7248. Suppose you name it @file{gpgz} and save it somewhere in your
  7249. @env{PATH}. Then the following command will create a compressed
  7250. archive signed with your private key:
  7251. @smallexample
  7252. $ @kbd{tar -cf foo.tar.gpgz -Igpgz .}
  7253. @end smallexample
  7254. @noindent
  7255. Likewise, the command below will list its contents:
  7256. @smallexample
  7257. $ @kbd{tar -tf foo.tar.gpgz -Igpgz .}
  7258. @end smallexample
  7259. @ignore
  7260. The above is based on the following discussion:
  7261. I have one question, or maybe it's a suggestion if there isn't a way
  7262. to do it now. I would like to use @option{--gzip}, but I'd also like
  7263. the output to be fed through a program like @acronym{GNU}
  7264. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  7265. to use :-)), basically adding ECC protection on top of compression.
  7266. It seems as if this should be quite easy to do, but I can't work out
  7267. exactly how to go about it. Of course, I can pipe the standard output
  7268. of @command{tar} through @command{ecc}, but then I lose (though I
  7269. haven't started using it yet, I confess) the ability to have
  7270. @command{tar} use @command{rmt} for it's I/O (I think).
  7271. I think the most straightforward thing would be to let me specify a
  7272. general set of filters outboard of compression (preferably ordered,
  7273. so the order can be automatically reversed on input operations, and
  7274. with the options they require specifiable), but beggars shouldn't be
  7275. choosers and anything you decide on would be fine with me.
  7276. By the way, I like @command{ecc} but if (as the comments say) it can't
  7277. deal with loss of block sync, I'm tempted to throw some time at adding
  7278. that capability. Supposing I were to actually do such a thing and
  7279. get it (apparently) working, do you accept contributed changes to
  7280. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  7281. Isn't that exactly the role of the
  7282. @option{--use-compress-prog=@var{program}} option?
  7283. I never tried it myself, but I suspect you may want to write a
  7284. @var{prog} script or program able to filter stdin to stdout to
  7285. way you want. It should recognize the @option{-d} option, for when
  7286. extraction is needed rather than creation.
  7287. It has been reported that if one writes compressed data (through the
  7288. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  7289. the DLT compression mode, the data will actually get bigger and one will
  7290. end up with less space on the tape.
  7291. @end ignore
  7292. @menu
  7293. * lbzip2:: Using lbzip2 with @GNUTAR{}.
  7294. @end menu
  7295. @node lbzip2
  7296. @subsubsection Using lbzip2 with @GNUTAR{}.
  7297. @cindex lbzip2
  7298. @cindex Laszlo Ersek
  7299. @command{Lbzip2} is a multithreaded utility for handling
  7300. @samp{bzip2} compression, written by Laszlo Ersek. It makes use of
  7301. multiple processors to speed up its operation and in general works
  7302. considerably faster than @command{bzip2}. For a detailed description
  7303. of @command{lbzip2} see @uref{http://freshmeat.net/@/projects/@/lbzip2} and
  7304. @uref{http://www.linuxinsight.com/@/lbzip2-parallel-bzip2-utility.html,
  7305. lbzip2: parallel bzip2 utility}.
  7306. Recent versions of @command{lbzip2} are mostly command line compatible
  7307. with @command{bzip2}, which makes it possible to automatically invoke
  7308. it via the @option{--bzip2} @GNUTAR{} command line option. To do so,
  7309. @GNUTAR{} must be configured with the @option{--with-bzip2} command
  7310. line option, like this:
  7311. @smallexample
  7312. $ @kbd{./configure --with-bzip2=lbzip2 [@var{other-options}]}
  7313. @end smallexample
  7314. Once configured and compiled this way, @command{tar --help} will show the
  7315. following:
  7316. @smallexample
  7317. @group
  7318. $ @kbd{tar --help | grep -- --bzip2}
  7319. -j, --bzip2 filter the archive through lbzip2
  7320. @end group
  7321. @end smallexample
  7322. @noindent
  7323. which means that running @command{tar --bzip2} will invoke @command{lbzip2}.
  7324. @node sparse
  7325. @subsection Archiving Sparse Files
  7326. @cindex Sparse Files
  7327. Files in the file system occasionally have @dfn{holes}. A @dfn{hole}
  7328. in a file is a section of the file's contents which was never written.
  7329. The contents of a hole reads as all zeros. On many operating systems,
  7330. actual disk storage is not allocated for holes, but they are counted
  7331. in the length of the file. If you archive such a file, @command{tar}
  7332. could create an archive longer than the original. To have @command{tar}
  7333. attempt to recognize the holes in a file, use @option{--sparse}
  7334. (@option{-S}). When you use this option, then, for any file using
  7335. less disk space than would be expected from its length, @command{tar}
  7336. searches the file for consecutive stretches of zeros. It then records
  7337. in the archive for the file where the consecutive stretches of zeros
  7338. are, and only archives the ``real contents'' of the file. On
  7339. extraction (using @option{--sparse} is not needed on extraction) any
  7340. such files have holes created wherever the continuous stretches of zeros
  7341. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  7342. won't take more space than the original.
  7343. @table @option
  7344. @opindex sparse
  7345. @item -S
  7346. @itemx --sparse
  7347. This option instructs @command{tar} to test each file for sparseness
  7348. before attempting to archive it. If the file is found to be sparse it
  7349. is treated specially, thus allowing to decrease the amount of space
  7350. used by its image in the archive.
  7351. This option is meaningful only when creating or updating archives. It
  7352. has no effect on extraction.
  7353. @end table
  7354. Consider using @option{--sparse} when performing file system backups,
  7355. to avoid archiving the expanded forms of files stored sparsely in the
  7356. system.
  7357. Even if your system has no sparse files currently, some may be
  7358. created in the future. If you use @option{--sparse} while making file
  7359. system backups as a matter of course, you can be assured the archive
  7360. will never take more space on the media than the files take on disk
  7361. (otherwise, archiving a disk filled with sparse files might take
  7362. hundreds of tapes). @xref{Incremental Dumps}.
  7363. However, be aware that @option{--sparse} option presents a serious
  7364. drawback. Namely, in order to determine if the file is sparse
  7365. @command{tar} has to read it before trying to archive it, so in total
  7366. the file is read @strong{twice}. So, always bear in mind that the
  7367. time needed to process all files with this option is roughly twice
  7368. the time needed to archive them without it.
  7369. @FIXME{A technical note:
  7370. Programs like @command{dump} do not have to read the entire file; by
  7371. examining the file system directly, they can determine in advance
  7372. exactly where the holes are and thus avoid reading through them. The
  7373. only data it need read are the actual allocated data blocks.
  7374. @GNUTAR{} uses a more portable and straightforward
  7375. archiving approach, it would be fairly difficult that it does
  7376. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  7377. 1990-12-10:
  7378. @quotation
  7379. What I did say is that you cannot tell the difference between a hole and an
  7380. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  7381. best tells you how many holes there are; it doesn't tell you @emph{where}.
  7382. Just as programs may, conceivably, care what @code{st_blocks} is (care
  7383. to name one that does?), they may also care where the holes are (I have
  7384. no examples of this one either, but it's equally imaginable).
  7385. I conclude from this that good archivers are not portable. One can
  7386. arguably conclude that if you want a portable program, you can in good
  7387. conscience restore files with as many holes as possible, since you can't
  7388. get it right.
  7389. @end quotation
  7390. }
  7391. @cindex sparse formats, defined
  7392. When using @samp{POSIX} archive format, @GNUTAR{} is able to store
  7393. sparse files using in three distinct ways, called @dfn{sparse
  7394. formats}. A sparse format is identified by its @dfn{number},
  7395. consisting, as usual of two decimal numbers, delimited by a dot. By
  7396. default, format @samp{1.0} is used. If, for some reason, you wish to
  7397. use an earlier format, you can select it using
  7398. @option{--sparse-version} option.
  7399. @table @option
  7400. @opindex sparse-version
  7401. @item --sparse-version=@var{version}
  7402. Select the format to store sparse files in. Valid @var{version} values
  7403. are: @samp{0.0}, @samp{0.1} and @samp{1.0}. @xref{Sparse Formats},
  7404. for a detailed description of each format.
  7405. @end table
  7406. Using @option{--sparse-format} option implies @option{--sparse}.
  7407. @node Attributes
  7408. @section Handling File Attributes
  7409. @cindex atrributes, files
  7410. @cindex file attributes
  7411. When @command{tar} reads files, it updates their access times. To
  7412. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  7413. reset the access time retroactively or avoid changing it in the first
  7414. place.
  7415. @table @option
  7416. @opindex atime-preserve
  7417. @item --atime-preserve
  7418. @itemx --atime-preserve=replace
  7419. @itemx --atime-preserve=system
  7420. Preserve the access times of files that are read. This works only for
  7421. files that you own, unless you have superuser privileges.
  7422. @option{--atime-preserve=replace} works on most systems, but it also
  7423. restores the data modification time and updates the status change
  7424. time. Hence it doesn't interact with incremental dumps nicely
  7425. (@pxref{Incremental Dumps}), and it can set access or data modification times
  7426. incorrectly if other programs access the file while @command{tar} is
  7427. running.
  7428. @option{--atime-preserve=system} avoids changing the access time in
  7429. the first place, if the operating system supports this.
  7430. Unfortunately, this may or may not work on any given operating system
  7431. or file system. If @command{tar} knows for sure it won't work, it
  7432. complains right away.
  7433. Currently @option{--atime-preserve} with no operand defaults to
  7434. @option{--atime-preserve=replace}, but this is intended to change to
  7435. @option{--atime-preserve=system} when the latter is better-supported.
  7436. @opindex touch
  7437. @item -m
  7438. @itemx --touch
  7439. Do not extract data modification time.
  7440. When this option is used, @command{tar} leaves the data modification times
  7441. of the files it extracts as the times when the files were extracted,
  7442. instead of setting it to the times recorded in the archive.
  7443. This option is meaningless with @option{--list} (@option{-t}).
  7444. @opindex same-owner
  7445. @item --same-owner
  7446. Create extracted files with the same ownership they have in the
  7447. archive.
  7448. This is the default behavior for the superuser,
  7449. so this option is meaningful only for non-root users, when @command{tar}
  7450. is executed on those systems able to give files away. This is
  7451. considered as a security flaw by many people, at least because it
  7452. makes quite difficult to correctly account users for the disk space
  7453. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  7454. files are easily and silently lost when files are given away.
  7455. When writing an archive, @command{tar} writes the user @acronym{ID} and user name
  7456. separately. If it can't find a user name (because the user @acronym{ID} is not
  7457. in @file{/etc/passwd}), then it does not write one. When restoring,
  7458. it tries to look the name (if one was written) up in
  7459. @file{/etc/passwd}. If it fails, then it uses the user @acronym{ID} stored in
  7460. the archive instead.
  7461. @opindex no-same-owner
  7462. @item --no-same-owner
  7463. @itemx -o
  7464. Do not attempt to restore ownership when extracting. This is the
  7465. default behavior for ordinary users, so this option has an effect
  7466. only for the superuser.
  7467. @opindex numeric-owner
  7468. @item --numeric-owner
  7469. The @option{--numeric-owner} option allows (ANSI) archives to be written
  7470. without user/group name information or such information to be ignored
  7471. when extracting. It effectively disables the generation and/or use
  7472. of user/group name information. This option forces extraction using
  7473. the numeric ids from the archive, ignoring the names.
  7474. This is useful in certain circumstances, when restoring a backup from
  7475. an emergency floppy with different passwd/group files for example.
  7476. It is otherwise impossible to extract files with the right ownerships
  7477. if the password file in use during the extraction does not match the
  7478. one belonging to the file system(s) being extracted. This occurs,
  7479. for example, if you are restoring your files after a major crash and
  7480. had booted from an emergency floppy with no password file or put your
  7481. disk into another machine to do the restore.
  7482. The numeric ids are @emph{always} saved into @command{tar} archives.
  7483. The identifying names are added at create time when provided by the
  7484. system, unless @option{--format=oldgnu} is used. Numeric ids could be
  7485. used when moving archives between a collection of machines using
  7486. a centralized management for attribution of numeric ids to users
  7487. and groups. This is often made through using the NIS capabilities.
  7488. When making a @command{tar} file for distribution to other sites, it
  7489. is sometimes cleaner to use a single owner for all files in the
  7490. distribution, and nicer to specify the write permission bits of the
  7491. files as stored in the archive independently of their actual value on
  7492. the file system. The way to prepare a clean distribution is usually
  7493. to have some Makefile rule creating a directory, copying all needed
  7494. files in that directory, then setting ownership and permissions as
  7495. wanted (there are a lot of possible schemes), and only then making a
  7496. @command{tar} archive out of this directory, before cleaning
  7497. everything out. Of course, we could add a lot of options to
  7498. @GNUTAR{} for fine tuning permissions and ownership.
  7499. This is not the good way, I think. @GNUTAR{} is
  7500. already crowded with options and moreover, the approach just explained
  7501. gives you a great deal of control already.
  7502. @xopindex{same-permissions, short description}
  7503. @xopindex{preserve-permissions, short description}
  7504. @item -p
  7505. @itemx --same-permissions
  7506. @itemx --preserve-permissions
  7507. Extract all protection information.
  7508. This option causes @command{tar} to set the modes (access permissions) of
  7509. extracted files exactly as recorded in the archive. If this option
  7510. is not used, the current @code{umask} setting limits the permissions
  7511. on extracted files. This option is by default enabled when
  7512. @command{tar} is executed by a superuser.
  7513. This option is meaningless with @option{--list} (@option{-t}).
  7514. @opindex preserve
  7515. @item --preserve
  7516. Same as both @option{--same-permissions} and @option{--same-order}.
  7517. This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
  7518. @end table
  7519. @node Portability
  7520. @section Making @command{tar} Archives More Portable
  7521. Creating a @command{tar} archive on a particular system that is meant to be
  7522. useful later on many other machines and with other versions of @command{tar}
  7523. is more challenging than you might think. @command{tar} archive formats
  7524. have been evolving since the first versions of Unix. Many such formats
  7525. are around, and are not always compatible with each other. This section
  7526. discusses a few problems, and gives some advice about making @command{tar}
  7527. archives more portable.
  7528. One golden rule is simplicity. For example, limit your @command{tar}
  7529. archives to contain only regular files and directories, avoiding
  7530. other kind of special files. Do not attempt to save sparse files or
  7531. contiguous files as such. Let's discuss a few more problems, in turn.
  7532. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  7533. archives and archive labels) in GNU and PAX formats.}
  7534. @menu
  7535. * Portable Names:: Portable Names
  7536. * dereference:: Symbolic Links
  7537. * hard links:: Hard Links
  7538. * old:: Old V7 Archives
  7539. * ustar:: Ustar Archives
  7540. * gnu:: GNU and old GNU format archives.
  7541. * posix:: @acronym{POSIX} archives
  7542. * Checksumming:: Checksumming Problems
  7543. * Large or Negative Values:: Large files, negative time stamps, etc.
  7544. * Other Tars:: How to Extract GNU-Specific Data Using
  7545. Other @command{tar} Implementations
  7546. @end menu
  7547. @node Portable Names
  7548. @subsection Portable Names
  7549. Use portable file and member names. A name is portable if it contains
  7550. only @acronym{ASCII} letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  7551. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  7552. contain @samp{/-}. Avoid deep directory nesting. For portability to
  7553. old Unix hosts, limit your file name components to 14 characters or
  7554. less.
  7555. If you intend to have your @command{tar} archives to be read under
  7556. MSDOS, you should not rely on case distinction for file names, and you
  7557. might use the @acronym{GNU} @command{doschk} program for helping you
  7558. further diagnosing illegal MSDOS names, which are even more limited
  7559. than System V's.
  7560. @node dereference
  7561. @subsection Symbolic Links
  7562. @cindex File names, using symbolic links
  7563. @cindex Symbolic link as file name
  7564. @opindex dereference
  7565. Normally, when @command{tar} archives a symbolic link, it writes a
  7566. block to the archive naming the target of the link. In that way, the
  7567. @command{tar} archive is a faithful record of the file system contents.
  7568. When @option{--dereference} (@option{-h}) is used with
  7569. @option{--create} (@option{-c}), @command{tar} archives the files
  7570. symbolic links point to, instead of
  7571. the links themselves.
  7572. When creating portable archives, use @option{--dereference}
  7573. (@option{-h}): some systems do not support
  7574. symbolic links, and moreover, your distribution might be unusable if
  7575. it contains unresolved symbolic links.
  7576. When reading from an archive, the @option{--dereference} (@option{-h})
  7577. option causes @command{tar} to follow an already-existing symbolic
  7578. link when @command{tar} writes or reads a file named in the archive.
  7579. Ordinarily, @command{tar} does not follow such a link, though it may
  7580. remove the link before writing a new file. @xref{Dealing with Old
  7581. Files}.
  7582. The @option{--dereference} option is unsafe if an untrusted user can
  7583. modify directories while @command{tar} is running. @xref{Security}.
  7584. @node hard links
  7585. @subsection Hard Links
  7586. @cindex File names, using hard links
  7587. @cindex hard links, dereferencing
  7588. @cindex dereferencing hard links
  7589. Normally, when @command{tar} archives a hard link, it writes a
  7590. block to the archive naming the target of the link (a @samp{1} type
  7591. block). In that way, the actual file contents is stored in file only
  7592. once. For example, consider the following two files:
  7593. @smallexample
  7594. @group
  7595. $ ls -l
  7596. -rw-r--r-- 2 gray staff 4 2007-10-30 15:11 one
  7597. -rw-r--r-- 2 gray staff 4 2007-10-30 15:11 jeden
  7598. @end group
  7599. @end smallexample
  7600. Here, @file{jeden} is a link to @file{one}. When archiving this
  7601. directory with a verbose level 2, you will get an output similar to
  7602. the following:
  7603. @smallexample
  7604. $ tar cvvf ../archive.tar .
  7605. drwxr-xr-x gray/staff 0 2007-10-30 15:13 ./
  7606. -rw-r--r-- gray/staff 4 2007-10-30 15:11 ./jeden
  7607. hrw-r--r-- gray/staff 0 2007-10-30 15:11 ./one link to ./jeden
  7608. @end smallexample
  7609. The last line shows that, instead of storing two copies of the file,
  7610. @command{tar} stored it only once, under the name @file{jeden}, and
  7611. stored file @file{one} as a hard link to this file.
  7612. It may be important to know that all hard links to the given file are
  7613. stored in the archive. For example, this may be necessary for exact
  7614. reproduction of the file system. The following option does that:
  7615. @table @option
  7616. @xopindex{check-links, described}
  7617. @item --check-links
  7618. @itemx -l
  7619. Check the number of links dumped for each processed file. If this
  7620. number does not match the total number of hard links for the file, print
  7621. a warning message.
  7622. @end table
  7623. For example, trying to archive only file @file{jeden} with this option
  7624. produces the following diagnostics:
  7625. @smallexample
  7626. $ tar -c -f ../archive.tar -l jeden
  7627. tar: Missing links to `jeden'.
  7628. @end smallexample
  7629. Although creating special records for hard links helps keep a faithful
  7630. record of the file system contents and makes archives more compact, it
  7631. may present some difficulties when extracting individual members from
  7632. the archive. For example, trying to extract file @file{one} from the
  7633. archive created in previous examples produces, in the absense of file
  7634. @file{jeden}:
  7635. @smallexample
  7636. $ tar xf archive.tar ./one
  7637. tar: ./one: Cannot hard link to `./jeden': No such file or directory
  7638. tar: Error exit delayed from previous errors
  7639. @end smallexample
  7640. The reason for this behavior is that @command{tar} cannot seek back in
  7641. the archive to the previous member (in this case, @file{one}), to
  7642. extract it@footnote{There are plans to fix this in future releases.}.
  7643. If you wish to avoid such problems at the cost of a bigger archive,
  7644. use the following option:
  7645. @table @option
  7646. @xopindex{hard-dereference, described}
  7647. @item --hard-dereference
  7648. Dereference hard links and store the files they refer to.
  7649. @end table
  7650. For example, trying this option on our two sample files, we get two
  7651. copies in the archive, each of which can then be extracted
  7652. independently of the other:
  7653. @smallexample
  7654. @group
  7655. $ tar -c -vv -f ../archive.tar --hard-dereference .
  7656. drwxr-xr-x gray/staff 0 2007-10-30 15:13 ./
  7657. -rw-r--r-- gray/staff 4 2007-10-30 15:11 ./jeden
  7658. -rw-r--r-- gray/staff 4 2007-10-30 15:11 ./one
  7659. @end group
  7660. @end smallexample
  7661. @node old
  7662. @subsection Old V7 Archives
  7663. @cindex Format, old style
  7664. @cindex Old style format
  7665. @cindex Old style archives
  7666. @cindex v7 archive format
  7667. Certain old versions of @command{tar} cannot handle additional
  7668. information recorded by newer @command{tar} programs. To create an
  7669. archive in V7 format (not ANSI), which can be read by these old
  7670. versions, specify the @option{--format=v7} option in
  7671. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  7672. accepts @option{--portability} or @option{--old-archive} for this
  7673. option). When you specify it,
  7674. @command{tar} leaves out information about directories, pipes, fifos,
  7675. contiguous files, and device files, and specifies file ownership by
  7676. group and user IDs instead of group and user names.
  7677. When updating an archive, do not use @option{--format=v7}
  7678. unless the archive was created using this option.
  7679. In most cases, a @emph{new} format archive can be read by an @emph{old}
  7680. @command{tar} program without serious trouble, so this option should
  7681. seldom be needed. On the other hand, most modern @command{tar}s are
  7682. able to read old format archives, so it might be safer for you to
  7683. always use @option{--format=v7} for your distributions. Notice,
  7684. however, that @samp{ustar} format is a better alternative, as it is
  7685. free from many of @samp{v7}'s drawbacks.
  7686. @node ustar
  7687. @subsection Ustar Archive Format
  7688. @cindex ustar archive format
  7689. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  7690. @code{ustar}. Although it is more flexible than the V7 format, it
  7691. still has many restrictions (@pxref{Formats,ustar}, for the detailed
  7692. description of @code{ustar} format). Along with V7 format,
  7693. @code{ustar} format is a good choice for archives intended to be read
  7694. with other implementations of @command{tar}.
  7695. To create archive in @code{ustar} format, use @option{--format=ustar}
  7696. option in conjunction with the @option{--create} (@option{-c}).
  7697. @node gnu
  7698. @subsection @acronym{GNU} and old @GNUTAR{} format
  7699. @cindex GNU archive format
  7700. @cindex Old GNU archive format
  7701. @GNUTAR{} was based on an early draft of the
  7702. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  7703. @command{tar}, such as the support for file names longer than 100
  7704. characters, use portions of the @command{tar} header record which were
  7705. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  7706. @acronym{POSIX} have allocated the same parts of the header record for
  7707. other purposes. As a result, @GNUTAR{} format is
  7708. incompatible with the current @acronym{POSIX} specification, and with
  7709. @command{tar} programs that follow it.
  7710. In the majority of cases, @command{tar} will be configured to create
  7711. this format by default. This will change in future releases, since
  7712. we plan to make @samp{POSIX} format the default.
  7713. To force creation a @GNUTAR{} archive, use option
  7714. @option{--format=gnu}.
  7715. @node posix
  7716. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  7717. @cindex POSIX archive format
  7718. @cindex PAX archive format
  7719. Starting from version 1.14 @GNUTAR{} features full support for
  7720. @acronym{POSIX.1-2001} archives.
  7721. A @acronym{POSIX} conformant archive will be created if @command{tar}
  7722. was given @option{--format=posix} (@option{--format=pax}) option. No
  7723. special option is required to read and extract from a @acronym{POSIX}
  7724. archive.
  7725. @menu
  7726. * PAX keywords:: Controlling Extended Header Keywords.
  7727. @end menu
  7728. @node PAX keywords
  7729. @subsubsection Controlling Extended Header Keywords
  7730. @table @option
  7731. @opindex pax-option
  7732. @item --pax-option=@var{keyword-list}
  7733. Handle keywords in @acronym{PAX} extended headers. This option is
  7734. equivalent to @option{-o} option of the @command{pax} utility.
  7735. @end table
  7736. @var{Keyword-list} is a comma-separated
  7737. list of keyword options, each keyword option taking one of
  7738. the following forms:
  7739. @table @code
  7740. @item delete=@var{pattern}
  7741. When used with one of archive-creation commands,
  7742. this option instructs @command{tar} to omit from extended header records
  7743. that it produces any keywords matching the string @var{pattern}.
  7744. When used in extract or list mode, this option instructs tar
  7745. to ignore any keywords matching the given @var{pattern} in the extended
  7746. header records. In both cases, matching is performed using the pattern
  7747. matching notation described in @acronym{POSIX 1003.2}, 3.13
  7748. (@pxref{wildcards}). For example:
  7749. @smallexample
  7750. --pax-option delete=security.*
  7751. @end smallexample
  7752. would suppress security-related information.
  7753. @item exthdr.name=@var{string}
  7754. This keyword allows user control over the name that is written into the
  7755. ustar header blocks for the extended headers. The name is obtained
  7756. from @var{string} after making the following substitutions:
  7757. @multitable @columnfractions .25 .55
  7758. @headitem Meta-character @tab Replaced By
  7759. @item %d @tab The directory name of the file, equivalent to the
  7760. result of the @command{dirname} utility on the translated file name.
  7761. @item %f @tab The name of the file with the directory information
  7762. stripped, equivalent to the result of the @command{basename} utility
  7763. on the translated file name.
  7764. @item %p @tab The process @acronym{ID} of the @command{tar} process.
  7765. @item %% @tab A @samp{%} character.
  7766. @end multitable
  7767. Any other @samp{%} characters in @var{string} produce undefined
  7768. results.
  7769. If no option @samp{exthdr.name=string} is specified, @command{tar}
  7770. will use the following default value:
  7771. @smallexample
  7772. %d/PaxHeaders.%p/%f
  7773. @end smallexample
  7774. @item exthdr.mtime=@var{value}
  7775. This keyword defines the value of the @samp{mtime} field that
  7776. is written into the ustar header blocks for the extended headers.
  7777. By default, the @samp{mtime} field is set to the modification time
  7778. of the archive member described by that extended headers.
  7779. @item globexthdr.name=@var{string}
  7780. This keyword allows user control over the name that is written into
  7781. the ustar header blocks for global extended header records. The name
  7782. is obtained from the contents of @var{string}, after making
  7783. the following substitutions:
  7784. @multitable @columnfractions .25 .55
  7785. @headitem Meta-character @tab Replaced By
  7786. @item %n @tab An integer that represents the
  7787. sequence number of the global extended header record in the archive,
  7788. starting at 1.
  7789. @item %p @tab The process @acronym{ID} of the @command{tar} process.
  7790. @item %% @tab A @samp{%} character.
  7791. @end multitable
  7792. Any other @samp{%} characters in @var{string} produce undefined results.
  7793. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  7794. will use the following default value:
  7795. @smallexample
  7796. $TMPDIR/GlobalHead.%p.%n
  7797. @end smallexample
  7798. @noindent
  7799. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  7800. environment variable. If @var{TMPDIR} is not set, @command{tar}
  7801. uses @samp{/tmp}.
  7802. @item globexthdr.mtime=@var{value}
  7803. This keyword defines the value of the @samp{mtime} field that
  7804. is written into the ustar header blocks for the global extended headers.
  7805. By default, the @samp{mtime} field is set to the time when
  7806. @command{tar} was invoked.
  7807. @item @var{keyword}=@var{value}
  7808. When used with one of archive-creation commands, these keyword/value pairs
  7809. will be included at the beginning of the archive in a global extended
  7810. header record. When used with one of archive-reading commands,
  7811. @command{tar} will behave as if it has encountered these keyword/value
  7812. pairs at the beginning of the archive in a global extended header
  7813. record.
  7814. @item @var{keyword}:=@var{value}
  7815. When used with one of archive-creation commands, these keyword/value pairs
  7816. will be included as records at the beginning of an extended header for
  7817. each file. This is effectively equivalent to @var{keyword}=@var{value}
  7818. form except that it creates no global extended header records.
  7819. When used with one of archive-reading commands, @command{tar} will
  7820. behave as if these keyword/value pairs were included as records at the
  7821. end of each extended header; thus, they will override any global or
  7822. file-specific extended header record keywords of the same names.
  7823. For example, in the command:
  7824. @smallexample
  7825. tar --format=posix --create \
  7826. --file archive --pax-option gname:=user .
  7827. @end smallexample
  7828. the group name will be forced to a new value for all files
  7829. stored in the archive.
  7830. @end table
  7831. In any of the forms described above, the @var{value} may be
  7832. a string enclosed in curly braces. In that case, the string
  7833. between the braces is understood either as a textual time
  7834. representation, as described in @ref{Date input formats}, or a name of
  7835. the existing file, starting with @samp{/} or @samp{.}. In the latter
  7836. case, the modification time of that file is used.
  7837. For example, to set all modification times to the current date, you
  7838. use the following option:
  7839. @smallexample
  7840. --pax-option='mtime:=@{now@}'
  7841. @end smallexample
  7842. Note quoting of the option's argument.
  7843. @cindex archives, binary equivalent
  7844. @cindex binary equivalent archives, creating
  7845. As another example, here is the option that ensures that any two
  7846. archives created using it, will be binary equivalent if they have the
  7847. same contents:
  7848. @smallexample
  7849. --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0
  7850. @end smallexample
  7851. @node Checksumming
  7852. @subsection Checksumming Problems
  7853. SunOS and HP-UX @command{tar} fail to accept archives created using
  7854. @GNUTAR{} and containing non-@acronym{ASCII} file names, that
  7855. is, file names having characters with the eight bit set, because they
  7856. use signed checksums, while @GNUTAR{} uses unsigned
  7857. checksums while creating archives, as per @acronym{POSIX} standards. On
  7858. reading, @GNUTAR{} computes both checksums and
  7859. accepts any. It is somewhat worrying that a lot of people may go
  7860. around doing backup of their files using faulty (or at least
  7861. non-standard) software, not learning about it until it's time to
  7862. restore their missing files with an incompatible file extractor, or
  7863. vice versa.
  7864. @GNUTAR{} computes checksums both ways, and accept
  7865. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  7866. wrong checksums. @GNUTAR{} produces the standard
  7867. checksum, however, raising incompatibilities with Sun. That is to
  7868. say, @GNUTAR{} has not been modified to
  7869. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  7870. I've been told that more recent Sun @command{tar} now read standard
  7871. archives, so maybe Sun did a similar patch, after all?
  7872. The story seems to be that when Sun first imported @command{tar}
  7873. sources on their system, they recompiled it without realizing that
  7874. the checksums were computed differently, because of a change in
  7875. the default signing of @code{char}'s in their compiler. So they
  7876. started computing checksums wrongly. When they later realized their
  7877. mistake, they merely decided to stay compatible with it, and with
  7878. themselves afterwards. Presumably, but I do not really know, HP-UX
  7879. has chosen that their @command{tar} archives to be compatible with Sun's.
  7880. The current standards do not favor Sun @command{tar} format. In any
  7881. case, it now falls on the shoulders of SunOS and HP-UX users to get
  7882. a @command{tar} able to read the good archives they receive.
  7883. @node Large or Negative Values
  7884. @subsection Large or Negative Values
  7885. @cindex large values
  7886. @cindex future time stamps
  7887. @cindex negative time stamps
  7888. @UNREVISED
  7889. The above sections suggest to use @samp{oldest possible} archive
  7890. format if in doubt. However, sometimes it is not possible. If you
  7891. attempt to archive a file whose metadata cannot be represented using
  7892. required format, @GNUTAR{} will print error message and ignore such a
  7893. file. You will than have to switch to a format that is able to
  7894. handle such values. The format summary table (@pxref{Formats}) will
  7895. help you to do so.
  7896. In particular, when trying to archive files larger than 8GB or with
  7897. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  7898. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  7899. @acronym{POSIX} archive formats. When considering which format to
  7900. choose, bear in mind that the @acronym{GNU} format uses
  7901. two's-complement base-256 notation to store values that do not fit
  7902. into standard @acronym{ustar} range. Such archives can generally be
  7903. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  7904. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  7905. example, using two's complement representation for negative time
  7906. stamps that assumes a signed 32-bit @code{time_t} generates archives
  7907. that are not portable to hosts with differing @code{time_t}
  7908. representations.
  7909. On the other hand, @acronym{POSIX} archives, generally speaking, can
  7910. be extracted by any tar implementation that understands older
  7911. @acronym{ustar} format. The only exception are files larger than 8GB.
  7912. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  7913. POSIX-aware tars.}
  7914. @node Other Tars
  7915. @subsection How to Extract GNU-Specific Data Using Other @command{tar} Implementations
  7916. In previous sections you became acquainted with various quirks
  7917. necessary to make your archives portable. Sometimes you may need to
  7918. extract archives containing GNU-specific members using some
  7919. third-party @command{tar} implementation or an older version of
  7920. @GNUTAR{}. Of course your best bet is to have @GNUTAR{} installed,
  7921. but if it is for some reason impossible, this section will explain
  7922. how to cope without it.
  7923. When we speak about @dfn{GNU-specific} members we mean two classes of
  7924. them: members split between the volumes of a multi-volume archive and
  7925. sparse members. You will be able to always recover such members if
  7926. the archive is in PAX format. In addition split members can be
  7927. recovered from archives in old GNU format. The following subsections
  7928. describe the required procedures in detail.
  7929. @menu
  7930. * Split Recovery:: Members Split Between Volumes
  7931. * Sparse Recovery:: Sparse Members
  7932. @end menu
  7933. @node Split Recovery
  7934. @subsubsection Extracting Members Split Between Volumes
  7935. @cindex Mutli-volume archives, extracting using non-GNU tars
  7936. If a member is split between several volumes of an old GNU format archive
  7937. most third party @command{tar} implementation will fail to extract
  7938. it. To extract it, use @command{tarcat} program (@pxref{Tarcat}).
  7939. This program is available from
  7940. @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/tarcat.html, @GNUTAR{}
  7941. home page}. It concatenates several archive volumes into a single
  7942. valid archive. For example, if you have three volumes named from
  7943. @file{vol-1.tar} to @file{vol-3.tar}, you can do the following to
  7944. extract them using a third-party @command{tar}:
  7945. @smallexample
  7946. $ @kbd{tarcat vol-1.tar vol-2.tar vol-3.tar | tar xf -}
  7947. @end smallexample
  7948. @cindex Mutli-volume archives in PAX format, extracting using non-GNU tars
  7949. You could use this approach for most (although not all) PAX
  7950. format archives as well. However, extracting split members from a PAX
  7951. archive is a much easier task, because PAX volumes are constructed in
  7952. such a way that each part of a split member is extracted to a
  7953. different file by @command{tar} implementations that are not aware of
  7954. GNU extensions. More specifically, the very first part retains its
  7955. original name, and all subsequent parts are named using the pattern:
  7956. @smallexample
  7957. %d/GNUFileParts.%p/%f.%n
  7958. @end smallexample
  7959. @noindent
  7960. where symbols preceeded by @samp{%} are @dfn{macro characters} that
  7961. have the following meaning:
  7962. @multitable @columnfractions .25 .55
  7963. @headitem Meta-character @tab Replaced By
  7964. @item %d @tab The directory name of the file, equivalent to the
  7965. result of the @command{dirname} utility on its full name.
  7966. @item %f @tab The file name of the file, equivalent to the result
  7967. of the @command{basename} utility on its full name.
  7968. @item %p @tab The process @acronym{ID} of the @command{tar} process that
  7969. created the archive.
  7970. @item %n @tab Ordinal number of this particular part.
  7971. @end multitable
  7972. For example, if the file @file{var/longfile} was split during archive
  7973. creation between three volumes, and the creator @command{tar} process
  7974. had process @acronym{ID} @samp{27962}, then the member names will be:
  7975. @smallexample
  7976. var/longfile
  7977. var/GNUFileParts.27962/longfile.1
  7978. var/GNUFileParts.27962/longfile.2
  7979. @end smallexample
  7980. When you extract your archive using a third-party @command{tar}, these
  7981. files will be created on your disk, and the only thing you will need
  7982. to do to restore your file in its original form is concatenate them in
  7983. the proper order, for example:
  7984. @smallexample
  7985. @group
  7986. $ @kbd{cd var}
  7987. $ @kbd{cat GNUFileParts.27962/longfile.1 \
  7988. GNUFileParts.27962/longfile.2 >> longfile}
  7989. $ rm -f GNUFileParts.27962
  7990. @end group
  7991. @end smallexample
  7992. Notice, that if the @command{tar} implementation you use supports PAX
  7993. format archives, it will probably emit warnings about unknown keywords
  7994. during extraction. They will look like this:
  7995. @smallexample
  7996. @group
  7997. Tar file too small
  7998. Unknown extended header keyword 'GNU.volume.filename' ignored.
  7999. Unknown extended header keyword 'GNU.volume.size' ignored.
  8000. Unknown extended header keyword 'GNU.volume.offset' ignored.
  8001. @end group
  8002. @end smallexample
  8003. @noindent
  8004. You can safely ignore these warnings.
  8005. If your @command{tar} implementation is not PAX-aware, you will get
  8006. more warnings and more files generated on your disk, e.g.:
  8007. @smallexample
  8008. @group
  8009. $ @kbd{tar xf vol-1.tar}
  8010. var/PaxHeaders.27962/longfile: Unknown file type 'x', extracted as
  8011. normal file
  8012. Unexpected EOF in archive
  8013. $ @kbd{tar xf vol-2.tar}
  8014. tmp/GlobalHead.27962.1: Unknown file type 'g', extracted as normal file
  8015. GNUFileParts.27962/PaxHeaders.27962/sparsefile.1: Unknown file type
  8016. 'x', extracted as normal file
  8017. @end group
  8018. @end smallexample
  8019. Ignore these warnings. The @file{PaxHeaders.*} directories created
  8020. will contain files with @dfn{extended header keywords} describing the
  8021. extracted files. You can delete them, unless they describe sparse
  8022. members. Read further to learn more about them.
  8023. @node Sparse Recovery
  8024. @subsubsection Extracting Sparse Members
  8025. @cindex sparse files, extracting with non-GNU tars
  8026. Any @command{tar} implementation will be able to extract sparse members from a
  8027. PAX archive. However, the extracted files will be @dfn{condensed},
  8028. i.e., any zero blocks will be removed from them. When we restore such
  8029. a condensed file to its original form, by adding zero blocks (or
  8030. @dfn{holes}) back to their original locations, we call this process
  8031. @dfn{expanding} a compressed sparse file.
  8032. @pindex xsparse
  8033. To expand a file, you will need a simple auxiliary program called
  8034. @command{xsparse}. It is available in source form from
  8035. @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/xsparse.html, @GNUTAR{}
  8036. home page}.
  8037. @cindex sparse files v.1.0, extracting with non-GNU tars
  8038. Let's begin with archive members in @dfn{sparse format
  8039. version 1.0}@footnote{@xref{PAX 1}.}, which are the easiest to expand.
  8040. The condensed file will contain both file map and file data, so no
  8041. additional data will be needed to restore it. If the original file
  8042. name was @file{@var{dir}/@var{name}}, then the condensed file will be
  8043. named @file{@var{dir}/@/GNUSparseFile.@var{n}/@/@var{name}}, where
  8044. @var{n} is a decimal number@footnote{Technically speaking, @var{n} is a
  8045. @dfn{process @acronym{ID}} of the @command{tar} process which created the
  8046. archive (@pxref{PAX keywords}).}.
  8047. To expand a version 1.0 file, run @command{xsparse} as follows:
  8048. @smallexample
  8049. $ @kbd{xsparse @file{cond-file}}
  8050. @end smallexample
  8051. @noindent
  8052. where @file{cond-file} is the name of the condensed file. The utility
  8053. will deduce the name for the resulting expanded file using the
  8054. following algorithm:
  8055. @enumerate 1
  8056. @item If @file{cond-file} does not contain any directories,
  8057. @file{../cond-file} will be used;
  8058. @item If @file{cond-file} has the form
  8059. @file{@var{dir}/@var{t}/@var{name}}, where both @var{t} and @var{name}
  8060. are simple names, with no @samp{/} characters in them, the output file
  8061. name will be @file{@var{dir}/@var{name}}.
  8062. @item Otherwise, if @file{cond-file} has the form
  8063. @file{@var{dir}/@var{name}}, the output file name will be
  8064. @file{@var{name}}.
  8065. @end enumerate
  8066. In the unlikely case when this algorithm does not suit your needs,
  8067. you can explicitly specify output file name as a second argument to
  8068. the command:
  8069. @smallexample
  8070. $ @kbd{xsparse @file{cond-file} @file{out-file}}
  8071. @end smallexample
  8072. It is often a good idea to run @command{xsparse} in @dfn{dry run} mode
  8073. first. In this mode, the command does not actually expand the file,
  8074. but verbosely lists all actions it would be taking to do so. The dry
  8075. run mode is enabled by @option{-n} command line argument:
  8076. @smallexample
  8077. @group
  8078. $ @kbd{xsparse -n /home/gray/GNUSparseFile.6058/sparsefile}
  8079. Reading v.1.0 sparse map
  8080. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  8081. `/home/gray/sparsefile'
  8082. Finished dry run
  8083. @end group
  8084. @end smallexample
  8085. To actually expand the file, you would run:
  8086. @smallexample
  8087. $ @kbd{xsparse /home/gray/GNUSparseFile.6058/sparsefile}
  8088. @end smallexample
  8089. @noindent
  8090. The program behaves the same way all UNIX utilities do: it will keep
  8091. quiet unless it has simething important to tell you (e.g. an error
  8092. condition or something). If you wish it to produce verbose output,
  8093. similar to that from the dry run mode, use @option{-v} option:
  8094. @smallexample
  8095. @group
  8096. $ @kbd{xsparse -v /home/gray/GNUSparseFile.6058/sparsefile}
  8097. Reading v.1.0 sparse map
  8098. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  8099. `/home/gray/sparsefile'
  8100. Done
  8101. @end group
  8102. @end smallexample
  8103. Additionally, if your @command{tar} implementation has extracted the
  8104. @dfn{extended headers} for this file, you can instruct @command{xstar}
  8105. to use them in order to verify the integrity of the expanded file.
  8106. The option @option{-x} sets the name of the extended header file to
  8107. use. Continuing our example:
  8108. @smallexample
  8109. @group
  8110. $ @kbd{xsparse -v -x /home/gray/PaxHeaders.6058/sparsefile \
  8111. /home/gray/GNUSparseFile.6058/sparsefile}
  8112. Reading extended header file
  8113. Found variable GNU.sparse.major = 1
  8114. Found variable GNU.sparse.minor = 0
  8115. Found variable GNU.sparse.name = sparsefile
  8116. Found variable GNU.sparse.realsize = 217481216
  8117. Reading v.1.0 sparse map
  8118. Expanding file `/home/gray/GNUSparseFile.6058/sparsefile' to
  8119. `/home/gray/sparsefile'
  8120. Done
  8121. @end group
  8122. @end smallexample
  8123. @anchor{extracting sparse v.0.x}
  8124. @cindex sparse files v.0.1, extracting with non-GNU tars
  8125. @cindex sparse files v.0.0, extracting with non-GNU tars
  8126. An @dfn{extended header} is a special @command{tar} archive header
  8127. that precedes an archive member and contains a set of
  8128. @dfn{variables}, describing the member properties that cannot be
  8129. stored in the standard @code{ustar} header. While optional for
  8130. expanding sparse version 1.0 members, the use of extended headers is
  8131. mandatory when expanding sparse members in older sparse formats: v.0.0
  8132. and v.0.1 (The sparse formats are described in detail in @ref{Sparse
  8133. Formats}.) So, for these formats, the question is: how to obtain
  8134. extended headers from the archive?
  8135. If you use a @command{tar} implementation that does not support PAX
  8136. format, extended headers for each member will be extracted as a
  8137. separate file. If we represent the member name as
  8138. @file{@var{dir}/@var{name}}, then the extended header file will be
  8139. named @file{@var{dir}/@/PaxHeaders.@var{n}/@/@var{name}}, where
  8140. @var{n} is an integer number.
  8141. Things become more difficult if your @command{tar} implementation
  8142. does support PAX headers, because in this case you will have to
  8143. manually extract the headers. We recommend the following algorithm:
  8144. @enumerate 1
  8145. @item
  8146. Consult the documentation of your @command{tar} implementation for an
  8147. option that prints @dfn{block numbers} along with the archive
  8148. listing (analogous to @GNUTAR{}'s @option{-R} option). For example,
  8149. @command{star} has @option{-block-number}.
  8150. @item
  8151. Obtain verbose listing using the @samp{block number} option, and
  8152. find block numbers of the sparse member in question and the member
  8153. immediately following it. For example, running @command{star} on our
  8154. archive we obtain:
  8155. @smallexample
  8156. @group
  8157. $ @kbd{star -t -v -block-number -f arc.tar}
  8158. @dots{}
  8159. star: Unknown extended header keyword 'GNU.sparse.size' ignored.
  8160. star: Unknown extended header keyword 'GNU.sparse.numblocks' ignored.
  8161. star: Unknown extended header keyword 'GNU.sparse.name' ignored.
  8162. star: Unknown extended header keyword 'GNU.sparse.map' ignored.
  8163. block 56: 425984 -rw-r--r-- gray/users Jun 25 14:46 2006 GNUSparseFile.28124/sparsefile
  8164. block 897: 65391 -rw-r--r-- gray/users Jun 24 20:06 2006 README
  8165. @dots{}
  8166. @end group
  8167. @end smallexample
  8168. @noindent
  8169. (as usual, ignore the warnings about unknown keywords.)
  8170. @item
  8171. Let @var{size} be the size of the sparse member, @var{Bs} be its block number
  8172. and @var{Bn} be the block number of the next member.
  8173. Compute:
  8174. @smallexample
  8175. @var{N} = @var{Bs} - @var{Bn} - @var{size}/512 - 2
  8176. @end smallexample
  8177. @noindent
  8178. This number gives the size of the extended header part in tar @dfn{blocks}.
  8179. In our example, this formula gives: @code{897 - 56 - 425984 / 512 - 2
  8180. = 7}.
  8181. @item
  8182. Use @command{dd} to extract the headers:
  8183. @smallexample
  8184. @kbd{dd if=@var{archive} of=@var{hname} bs=512 skip=@var{Bs} count=@var{N}}
  8185. @end smallexample
  8186. @noindent
  8187. where @var{archive} is the archive name, @var{hname} is a name of the
  8188. file to store the extended header in, @var{Bs} and @var{N} are
  8189. computed in previous steps.
  8190. In our example, this command will be
  8191. @smallexample
  8192. $ @kbd{dd if=arc.tar of=xhdr bs=512 skip=56 count=7}
  8193. @end smallexample
  8194. @end enumerate
  8195. Finally, you can expand the condensed file, using the obtained header:
  8196. @smallexample
  8197. @group
  8198. $ @kbd{xsparse -v -x xhdr GNUSparseFile.6058/sparsefile}
  8199. Reading extended header file
  8200. Found variable GNU.sparse.size = 217481216
  8201. Found variable GNU.sparse.numblocks = 208
  8202. Found variable GNU.sparse.name = sparsefile
  8203. Found variable GNU.sparse.map = 0,2048,1050624,2048,@dots{}
  8204. Expanding file `GNUSparseFile.28124/sparsefile' to `sparsefile'
  8205. Done
  8206. @end group
  8207. @end smallexample
  8208. @node cpio
  8209. @section Comparison of @command{tar} and @command{cpio}
  8210. @UNREVISED
  8211. @FIXME{Reorganize the following material}
  8212. The @command{cpio} archive formats, like @command{tar}, do have maximum
  8213. file name lengths. The binary and old @acronym{ASCII} formats have a maximum file
  8214. length of 256, and the new @acronym{ASCII} and @acronym{CRC ASCII} formats have a max
  8215. file length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  8216. with arbitrary file name lengths, but other @command{cpio} implementations
  8217. may crash unexplainedly trying to read them.
  8218. @command{tar} handles symbolic links in the form in which it comes in @acronym{BSD};
  8219. @command{cpio} doesn't handle symbolic links in the form in which it comes
  8220. in System V prior to SVR4, and some vendors may have added symlinks
  8221. to their system without enhancing @command{cpio} to know about them.
  8222. Others may have enhanced it in a way other than the way I did it
  8223. at Sun, and which was adopted by AT&T (and which is, I think, also
  8224. present in the @command{cpio} that Berkeley picked up from AT&T and put
  8225. into a later @acronym{BSD} release---I think I gave them my changes).
  8226. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  8227. can handle @command{tar} format input, and write it on output, and it
  8228. probably handles symbolic links. They may not have bothered doing
  8229. anything to enhance @command{tar} as a result.)
  8230. @command{cpio} handles special files; traditional @command{tar} doesn't.
  8231. @command{tar} comes with V7, System III, System V, and @acronym{BSD} source;
  8232. @command{cpio} comes only with System III, System V, and later @acronym{BSD}
  8233. (4.3-tahoe and later).
  8234. @command{tar}'s way of handling multiple hard links to a file can handle
  8235. file systems that support 32-bit i-numbers (e.g., the @acronym{BSD} file system);
  8236. @command{cpio}s way requires you to play some games (in its ``binary''
  8237. format, i-numbers are only 16 bits, and in its ``portable @acronym{ASCII}'' format,
  8238. they're 18 bits---it would have to play games with the "file system @acronym{ID}"
  8239. field of the header to make sure that the file system @acronym{ID}/i-number pairs
  8240. of different files were always different), and I don't know which
  8241. @command{cpio}s, if any, play those games. Those that don't might get
  8242. confused and think two files are the same file when they're not, and
  8243. make hard links between them.
  8244. @command{tar}s way of handling multiple hard links to a file places only
  8245. one copy of the link on the tape, but the name attached to that copy
  8246. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  8247. way puts one copy for every link, but you can retrieve it using any
  8248. of the names.
  8249. @quotation
  8250. What type of check sum (if any) is used, and how is this calculated.
  8251. @end quotation
  8252. See the attached manual pages for @command{tar} and @command{cpio} format.
  8253. @command{tar} uses a checksum which is the sum of all the bytes in the
  8254. @command{tar} header for a file; @command{cpio} uses no checksum.
  8255. @quotation
  8256. If anyone knows why @command{cpio} was made when @command{tar} was present
  8257. at the unix scene,
  8258. @end quotation
  8259. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  8260. generally-available version of UNIX had @command{tar} at the time. I don't
  8261. know whether any version that was generally available @emph{within AT&T}
  8262. had @command{tar}, or, if so, whether the people within AT&T who did
  8263. @command{cpio} knew about it.
  8264. On restore, if there is a corruption on a tape @command{tar} will stop at
  8265. that point, while @command{cpio} will skip over it and try to restore the
  8266. rest of the files.
  8267. The main difference is just in the command syntax and header format.
  8268. @command{tar} is a little more tape-oriented in that everything is blocked
  8269. to start on a record boundary.
  8270. @quotation
  8271. Is there any differences between the ability to recover crashed
  8272. archives between the two of them. (Is there any chance of recovering
  8273. crashed archives at all.)
  8274. @end quotation
  8275. Theoretically it should be easier under @command{tar} since the blocking
  8276. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  8277. However, modern @command{cpio}'s and variations have an option to just
  8278. search for the next file header after an error with a reasonable chance
  8279. of resyncing. However, lots of tape driver software won't allow you to
  8280. continue past a media error which should be the only reason for getting
  8281. out of sync unless a file changed sizes while you were writing the
  8282. archive.
  8283. @quotation
  8284. If anyone knows why @command{cpio} was made when @command{tar} was present
  8285. at the unix scene, please tell me about this too.
  8286. @end quotation
  8287. Probably because it is more media efficient (by not blocking everything
  8288. and using only the space needed for the headers where @command{tar}
  8289. always uses 512 bytes per file header) and it knows how to archive
  8290. special files.
  8291. You might want to look at the freely available alternatives. The
  8292. major ones are @command{afio}, @GNUTAR{}, and
  8293. @command{pax}, each of which have their own extensions with some
  8294. backwards compatibility.
  8295. Sparse files were @command{tar}red as sparse files (which you can
  8296. easily test, because the resulting archive gets smaller, and
  8297. @acronym{GNU} @command{cpio} can no longer read it).
  8298. @node Media
  8299. @chapter Tapes and Other Archive Media
  8300. @UNREVISED
  8301. A few special cases about tape handling warrant more detailed
  8302. description. These special cases are discussed below.
  8303. Many complexities surround the use of @command{tar} on tape drives. Since
  8304. the creation and manipulation of archives located on magnetic tape was
  8305. the original purpose of @command{tar}, it contains many features making
  8306. such manipulation easier.
  8307. Archives are usually written on dismountable media---tape cartridges,
  8308. mag tapes, or floppy disks.
  8309. The amount of data a tape or disk holds depends not only on its size,
  8310. but also on how it is formatted. A 2400 foot long reel of mag tape
  8311. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  8312. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  8313. Magnetic media are re-usable---once the archive on a tape is no longer
  8314. needed, the archive can be erased and the tape or disk used over.
  8315. Media quality does deteriorate with use, however. Most tapes or disks
  8316. should be discarded when they begin to produce data errors. EXABYTE
  8317. tape cartridges should be discarded when they generate an @dfn{error
  8318. count} (number of non-usable bits) of more than 10k.
  8319. Magnetic media are written and erased using magnetic fields, and
  8320. should be protected from such fields to avoid damage to stored data.
  8321. Sticking a floppy disk to a filing cabinet using a magnet is probably
  8322. not a good idea.
  8323. @menu
  8324. * Device:: Device selection and switching
  8325. * Remote Tape Server::
  8326. * Common Problems and Solutions::
  8327. * Blocking:: Blocking
  8328. * Many:: Many archives on one tape
  8329. * Using Multiple Tapes:: Using Multiple Tapes
  8330. * label:: Including a Label in the Archive
  8331. * verify::
  8332. * Write Protection::
  8333. @end menu
  8334. @node Device
  8335. @section Device Selection and Switching
  8336. @UNREVISED
  8337. @table @option
  8338. @item -f [@var{hostname}:]@var{file}
  8339. @itemx --file=[@var{hostname}:]@var{file}
  8340. Use archive file or device @var{file} on @var{hostname}.
  8341. @end table
  8342. This option is used to specify the file name of the archive @command{tar}
  8343. works on.
  8344. If the file name is @samp{-}, @command{tar} reads the archive from standard
  8345. input (when listing or extracting), or writes it to standard output
  8346. (when creating). If the @samp{-} file name is given when updating an
  8347. archive, @command{tar} will read the original archive from its standard
  8348. input, and will write the entire new archive to its standard output.
  8349. If the file name contains a @samp{:}, it is interpreted as
  8350. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  8351. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  8352. either case, @command{tar} will invoke the command @command{rsh} (or
  8353. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  8354. machine. If you give an alternate login name, it will be given to the
  8355. @command{rsh}.
  8356. Naturally, the remote machine must have an executable
  8357. @command{/usr/libexec/rmt}. This program is free software from the
  8358. University of California, and a copy of the source code can be found
  8359. with the sources for @command{tar}; it's compiled and installed by default.
  8360. The exact path to this utility is determined when configuring the package.
  8361. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  8362. your installation prefix. This location may also be overridden at
  8363. runtime by using the @option{--rmt-command=@var{command}} option (@xref{Option Summary,
  8364. ---rmt-command}, for detailed description of this option. @xref{Remote
  8365. Tape Server}, for the description of @command{rmt} command).
  8366. If this option is not given, but the environment variable @env{TAPE}
  8367. is set, its value is used; otherwise, old versions of @command{tar}
  8368. used a default archive name (which was picked when @command{tar} was
  8369. compiled). The default is normally set up to be the @dfn{first} tape
  8370. drive or other transportable I/O medium on the system.
  8371. Starting with version 1.11.5, @GNUTAR{} uses
  8372. standard input and standard output as the default device, and I will
  8373. not try anymore supporting automatic device detection at installation
  8374. time. This was failing really in too many cases, it was hopeless.
  8375. This is now completely left to the installer to override standard
  8376. input and standard output for default device, if this seems
  8377. preferable. Further, I think @emph{most} actual usages of
  8378. @command{tar} are done with pipes or disks, not really tapes,
  8379. cartridges or diskettes.
  8380. Some users think that using standard input and output is running
  8381. after trouble. This could lead to a nasty surprise on your screen if
  8382. you forget to specify an output file name---especially if you are going
  8383. through a network or terminal server capable of buffering large amounts
  8384. of output. We had so many bug reports in that area of configuring
  8385. default tapes automatically, and so many contradicting requests, that
  8386. we finally consider the problem to be portably intractable. We could
  8387. of course use something like @samp{/dev/tape} as a default, but this
  8388. is @emph{also} running after various kind of trouble, going from hung
  8389. processes to accidental destruction of real tapes. After having seen
  8390. all this mess, using standard input and output as a default really
  8391. sounds like the only clean choice left, and a very useful one too.
  8392. @GNUTAR{} reads and writes archive in records, I
  8393. suspect this is the main reason why block devices are preferred over
  8394. character devices. Most probably, block devices are more efficient
  8395. too. The installer could also check for @samp{DEFTAPE} in
  8396. @file{<sys/mtio.h>}.
  8397. @table @option
  8398. @xopindex{force-local, short description}
  8399. @item --force-local
  8400. Archive file is local even if it contains a colon.
  8401. @opindex rsh-command
  8402. @item --rsh-command=@var{command}
  8403. Use remote @var{command} instead of @command{rsh}. This option exists
  8404. so that people who use something other than the standard @command{rsh}
  8405. (e.g., a Kerberized @command{rsh}) can access a remote device.
  8406. When this command is not used, the shell command found when
  8407. the @command{tar} program was installed is used instead. This is
  8408. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  8409. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  8410. The installer may have overridden this by defining the environment
  8411. variable @env{RSH} @emph{at installation time}.
  8412. @item -[0-7][lmh]
  8413. Specify drive and density.
  8414. @xopindex{multi-volume, short description}
  8415. @item -M
  8416. @itemx --multi-volume
  8417. Create/list/extract multi-volume archive.
  8418. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  8419. that may be larger than will fit on the medium used to hold it.
  8420. @xref{Multi-Volume Archives}.
  8421. @xopindex{tape-length, short description}
  8422. @item -L @var{num}
  8423. @itemx --tape-length=@var{size}[@var{suf}]
  8424. Change tape after writing @var{size} units of data. Unless @var{suf} is
  8425. given, @var{size} is treated as kilobytes, i.e. @samp{@var{size} x
  8426. 1024} bytes. The following suffixes alter this behavior:
  8427. @float Table, size-suffixes
  8428. @caption{Size Suffixes}
  8429. @multitable @columnfractions 0.2 0.3 0.3
  8430. @headitem Suffix @tab Units @tab Byte Equivalent
  8431. @item b @tab Blocks @tab @var{size} x 512
  8432. @item B @tab Kilobytes @tab @var{size} x 1024
  8433. @item c @tab Bytes @tab @var{size}
  8434. @item G @tab Gigabytes @tab @var{size} x 1024^3
  8435. @item K @tab Kilobytes @tab @var{size} x 1024
  8436. @item k @tab Kilobytes @tab @var{size} x 1024
  8437. @item M @tab Megabytes @tab @var{size} x 1024^2
  8438. @item P @tab Petabytes @tab @var{size} x 1024^5
  8439. @item T @tab Terabytes @tab @var{size} x 1024^4
  8440. @item w @tab Words @tab @var{size} x 2
  8441. @end multitable
  8442. @end float
  8443. This option might be useful when your tape drivers do not properly
  8444. detect end of physical tapes. By being slightly conservative on the
  8445. maximum tape length, you might avoid the problem entirely.
  8446. @xopindex{info-script, short description}
  8447. @xopindex{new-volume-script, short description}
  8448. @item -F @var{file}
  8449. @itemx --info-script=@var{file}
  8450. @itemx --new-volume-script=@var{file}
  8451. Execute @file{file} at end of each tape. This implies
  8452. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  8453. description of this option.
  8454. @end table
  8455. @node Remote Tape Server
  8456. @section Remote Tape Server
  8457. @cindex remote tape drive
  8458. @pindex rmt
  8459. In order to access the tape drive on a remote machine, @command{tar}
  8460. uses the remote tape server written at the University of California at
  8461. Berkeley. The remote tape server must be installed as
  8462. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  8463. want to use. @command{tar} calls @command{rmt} by running an
  8464. @command{rsh} or @command{remsh} to the remote machine, optionally
  8465. using a different login name if one is supplied.
  8466. A copy of the source for the remote tape server is provided. It is
  8467. Copyright @copyright{} 1983 by the Regents of the University of
  8468. California, but can be freely distributed. It is compiled and
  8469. installed by default.
  8470. @cindex absolute file names
  8471. Unless you use the @option{--absolute-names} (@option{-P}) option,
  8472. @GNUTAR{} will not allow you to create an archive that contains
  8473. absolute file names (a file name beginning with @samp{/}.) If you try,
  8474. @command{tar} will automatically remove the leading @samp{/} from the
  8475. file names it stores in the archive. It will also type a warning
  8476. message telling you what it is doing.
  8477. When reading an archive that was created with a different
  8478. @command{tar} program, @GNUTAR{} automatically
  8479. extracts entries in the archive which have absolute file names as if
  8480. the file names were not absolute. This is an important feature. A
  8481. visitor here once gave a @command{tar} tape to an operator to restore;
  8482. the operator used Sun @command{tar} instead of @GNUTAR{},
  8483. and the result was that it replaced large portions of
  8484. our @file{/bin} and friends with versions from the tape; needless to
  8485. say, we were unhappy about having to recover the file system from
  8486. backup tapes.
  8487. For example, if the archive contained a file @file{/usr/bin/computoy},
  8488. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  8489. relative to the current directory. If you want to extract the files in
  8490. an archive to the same absolute names that they had when the archive
  8491. was created, you should do a @samp{cd /} before extracting the files
  8492. from the archive, or you should either use the @option{--absolute-names}
  8493. option, or use the command @samp{tar -C / @dots{}}.
  8494. @cindex Ultrix 3.1 and write failure
  8495. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  8496. can claim that a short write near the end of a tape succeeded,
  8497. when it actually failed. This will result in the -M option not
  8498. working correctly. The best workaround at the moment is to use a
  8499. significantly larger blocking factor than the default 20.
  8500. In order to update an archive, @command{tar} must be able to backspace the
  8501. archive in order to reread or rewrite a record that was just read (or
  8502. written). This is currently possible only on two kinds of files: normal
  8503. disk files (or any other file that can be backspaced with @samp{lseek}),
  8504. and industry-standard 9-track magnetic tape (or any other kind of tape
  8505. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}).
  8506. This means that the @option{--append}, @option{--concatenate}, and
  8507. @option{--delete} commands will not work on any other kind of file.
  8508. Some media simply cannot be backspaced, which means these commands and
  8509. options will never be able to work on them. These non-backspacing
  8510. media include pipes and cartridge tape drives.
  8511. Some other media can be backspaced, and @command{tar} will work on them
  8512. once @command{tar} is modified to do so.
  8513. Archives created with the @option{--multi-volume}, @option{--label}, and
  8514. @option{--incremental} (@option{-G}) options may not be readable by other version
  8515. of @command{tar}. In particular, restoring a file that was split over
  8516. a volume boundary will require some careful work with @command{dd}, if
  8517. it can be done at all. Other versions of @command{tar} may also create
  8518. an empty file whose name is that of the volume header. Some versions
  8519. of @command{tar} may create normal files instead of directories archived
  8520. with the @option{--incremental} (@option{-G}) option.
  8521. @node Common Problems and Solutions
  8522. @section Some Common Problems and their Solutions
  8523. @ifclear PUBLISH
  8524. @format
  8525. errors from system:
  8526. permission denied
  8527. no such file or directory
  8528. not owner
  8529. errors from @command{tar}:
  8530. directory checksum error
  8531. header format error
  8532. errors from media/system:
  8533. i/o error
  8534. device busy
  8535. @end format
  8536. @end ifclear
  8537. @node Blocking
  8538. @section Blocking
  8539. @cindex block
  8540. @cindex record
  8541. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  8542. is also confusing to the expert reader. On the other hand, readers
  8543. who are new to the field have a fresh mind, and they may safely skip
  8544. the next two paragraphs, as the remainder of this manual uses those
  8545. two terms in a quite consistent way.
  8546. John Gilmore, the writer of the public domain @command{tar} from which
  8547. @GNUTAR{} was originally derived, wrote (June 1995):
  8548. @quotation
  8549. The nomenclature of tape drives comes from IBM, where I believe
  8550. they were invented for the IBM 650 or so. On IBM mainframes, what
  8551. is recorded on tape are tape blocks. The logical organization of
  8552. data is into records. There are various ways of putting records into
  8553. blocks, including @code{F} (fixed sized records), @code{V} (variable
  8554. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  8555. to a block), @code{VB} (variable size records, @var{n} to a block),
  8556. @code{VSB} (variable spanned blocked: variable sized records that can
  8557. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  8558. parameter specified this to the operating system.
  8559. The Unix man page on @command{tar} was totally confused about this.
  8560. When I wrote @code{PD TAR}, I used the historically correct terminology
  8561. (@command{tar} writes data records, which are grouped into blocks).
  8562. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  8563. here), and now Fran@,{c}ois has migrated that terminology back
  8564. into the source code too.
  8565. @end quotation
  8566. The term @dfn{physical block} means the basic transfer chunk from or
  8567. to a device, after which reading or writing may stop without anything
  8568. being lost. In this manual, the term @dfn{block} usually refers to
  8569. a disk physical block, @emph{assuming} that each disk block is 512
  8570. bytes in length. It is true that some disk devices have different
  8571. physical blocks, but @command{tar} ignore these differences in its own
  8572. format, which is meant to be portable, so a @command{tar} block is always
  8573. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  8574. The term @dfn{logical block} often represents the basic chunk of
  8575. allocation of many disk blocks as a single entity, which the operating
  8576. system treats somewhat atomically; this concept is only barely used
  8577. in @GNUTAR{}.
  8578. The term @dfn{physical record} is another way to speak of a physical
  8579. block, those two terms are somewhat interchangeable. In this manual,
  8580. the term @dfn{record} usually refers to a tape physical block,
  8581. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  8582. It is true that archives may be put on disk or used with pipes,
  8583. but nevertheless, @command{tar} tries to read and write the archive one
  8584. @dfn{record} at a time, whatever the medium in use. One record is made
  8585. up of an integral number of blocks, and this operation of putting many
  8586. disk blocks into a single tape block is called @dfn{reblocking}, or
  8587. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  8588. the logical organization of many characters into something meaningful
  8589. to the application. The term @dfn{unit record} describes a small set
  8590. of characters which are transmitted whole to or by the application,
  8591. and often refers to a line of text. Those two last terms are unrelated
  8592. to what we call a @dfn{record} in @GNUTAR{}.
  8593. When writing to tapes, @command{tar} writes the contents of the archive
  8594. in chunks known as @dfn{records}. To change the default blocking
  8595. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  8596. @var{512-size}}) option. Each record will then be composed of
  8597. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  8598. @xref{Standard}.) Each file written to the archive uses at least one
  8599. full record. As a result, using a larger record size can result in
  8600. more wasted space for small files. On the other hand, a larger record
  8601. size can often be read and written much more efficiently.
  8602. Further complicating the problem is that some tape drives ignore the
  8603. blocking entirely. For these, a larger record size can still improve
  8604. performance (because the software layers above the tape drive still
  8605. honor the blocking), but not as dramatically as on tape drives that
  8606. honor blocking.
  8607. When reading an archive, @command{tar} can usually figure out the
  8608. record size on itself. When this is the case, and a non-standard
  8609. record size was used when the archive was created, @command{tar} will
  8610. print a message about a non-standard blocking factor, and then operate
  8611. normally. On some tape devices, however, @command{tar} cannot figure
  8612. out the record size itself. On most of those, you can specify a
  8613. blocking factor (with @option{--blocking-factor}) larger than the
  8614. actual blocking factor, and then use the @option{--read-full-records}
  8615. (@option{-B}) option. (If you specify a blocking factor with
  8616. @option{--blocking-factor} and don't use the
  8617. @option{--read-full-records} option, then @command{tar} will not
  8618. attempt to figure out the recording size itself.) On some devices,
  8619. you must always specify the record size exactly with
  8620. @option{--blocking-factor} when reading, because @command{tar} cannot
  8621. figure it out. In any case, use @option{--list} (@option{-t}) before
  8622. doing any extractions to see whether @command{tar} is reading the archive
  8623. correctly.
  8624. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  8625. putting them into records is to put a whole number of them (one or
  8626. more) into each record. @command{tar} records are all the same size;
  8627. at the end of the file there's a block containing all zeros, which
  8628. is how you tell that the remainder of the last record(s) are garbage.
  8629. In a standard @command{tar} file (no options), the block size is 512
  8630. and the record size is 10240, for a blocking factor of 20. What the
  8631. @option{--blocking-factor} option does is sets the blocking factor,
  8632. changing the record size while leaving the block size at 512 bytes.
  8633. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  8634. most tape drives these days prefer much bigger records in order to
  8635. stream and not waste tape. When writing tapes for myself, some tend
  8636. to use a factor of the order of 2048, say, giving a record size of
  8637. around one megabyte.
  8638. If you use a blocking factor larger than 20, older @command{tar}
  8639. programs might not be able to read the archive, so we recommend this
  8640. as a limit to use in practice. @GNUTAR{}, however,
  8641. will support arbitrarily large record sizes, limited only by the
  8642. amount of virtual memory or the physical characteristics of the tape
  8643. device.
  8644. @menu
  8645. * Format Variations:: Format Variations
  8646. * Blocking Factor:: The Blocking Factor of an Archive
  8647. @end menu
  8648. @node Format Variations
  8649. @subsection Format Variations
  8650. @cindex Format Parameters
  8651. @cindex Format Options
  8652. @cindex Options, archive format specifying
  8653. @cindex Options, format specifying
  8654. @UNREVISED
  8655. Format parameters specify how an archive is written on the archive
  8656. media. The best choice of format parameters will vary depending on
  8657. the type and number of files being archived, and on the media used to
  8658. store the archive.
  8659. To specify format parameters when accessing or creating an archive,
  8660. you can use the options described in the following sections.
  8661. If you do not specify any format parameters, @command{tar} uses
  8662. default parameters. You cannot modify a compressed archive.
  8663. If you create an archive with the @option{--blocking-factor} option
  8664. specified (@pxref{Blocking Factor}), you must specify that
  8665. blocking-factor when operating on the archive. @xref{Formats}, for other
  8666. examples of format parameter considerations.
  8667. @node Blocking Factor
  8668. @subsection The Blocking Factor of an Archive
  8669. @cindex Blocking Factor
  8670. @cindex Record Size
  8671. @cindex Number of blocks per record
  8672. @cindex Number of bytes per record
  8673. @cindex Bytes per record
  8674. @cindex Blocks per record
  8675. @UNREVISED
  8676. @opindex blocking-factor
  8677. The data in an archive is grouped into blocks, which are 512 bytes.
  8678. Blocks are read and written in whole number multiples called
  8679. @dfn{records}. The number of blocks in a record (i.e., the size of a
  8680. record in units of 512 bytes) is called the @dfn{blocking factor}.
  8681. The @option{--blocking-factor=@var{512-size}} (@option{-b
  8682. @var{512-size}}) option specifies the blocking factor of an archive.
  8683. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  8684. can be specified at installation. To find out the blocking factor of
  8685. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  8686. This may not work on some devices.
  8687. Records are separated by gaps, which waste space on the archive media.
  8688. If you are archiving on magnetic tape, using a larger blocking factor
  8689. (and therefore larger records) provides faster throughput and allows you
  8690. to fit more data on a tape (because there are fewer gaps). If you are
  8691. archiving on cartridge, a very large blocking factor (say 126 or more)
  8692. greatly increases performance. A smaller blocking factor, on the other
  8693. hand, may be useful when archiving small files, to avoid archiving lots
  8694. of nulls as @command{tar} fills out the archive to the end of the record.
  8695. In general, the ideal record size depends on the size of the
  8696. inter-record gaps on the tape you are using, and the average size of the
  8697. files you are archiving. @xref{create}, for information on
  8698. writing archives.
  8699. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  8700. Archives with blocking factors larger than 20 cannot be read
  8701. by very old versions of @command{tar}, or by some newer versions
  8702. of @command{tar} running on old machines with small address spaces.
  8703. With @GNUTAR{}, the blocking factor of an archive is limited
  8704. only by the maximum record size of the device containing the archive,
  8705. or by the amount of available virtual memory.
  8706. Also, on some systems, not using adequate blocking factors, as sometimes
  8707. imposed by the device drivers, may yield unexpected diagnostics. For
  8708. example, this has been reported:
  8709. @smallexample
  8710. Cannot write to /dev/dlt: Invalid argument
  8711. @end smallexample
  8712. @noindent
  8713. In such cases, it sometimes happen that the @command{tar} bundled by
  8714. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  8715. requires an explicit specification for the block size,
  8716. which it cannot guess. This yields some people to consider
  8717. @GNUTAR{} is misbehaving, because by comparison,
  8718. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  8719. for example, might resolve the problem.
  8720. If you use a non-default blocking factor when you create an archive, you
  8721. must specify the same blocking factor when you modify that archive. Some
  8722. archive devices will also require you to specify the blocking factor when
  8723. reading that archive, however this is not typically the case. Usually, you
  8724. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  8725. reports a non-default record size and then lists the archive members as
  8726. it would normally. To extract files from an archive with a non-standard
  8727. blocking factor (particularly if you're not sure what the blocking factor
  8728. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  8729. specifying a blocking factor larger then the blocking factor of the archive
  8730. (i.e., @samp{tar --extract --read-full-records --blocking-factor=300}).
  8731. @xref{list}, for more information on the @option{--list} (@option{-t})
  8732. operation. @xref{Reading}, for a more detailed explanation of that option.
  8733. @table @option
  8734. @item --blocking-factor=@var{number}
  8735. @itemx -b @var{number}
  8736. Specifies the blocking factor of an archive. Can be used with any
  8737. operation, but is usually not necessary with @option{--list} (@option{-t}).
  8738. @end table
  8739. Device blocking
  8740. @table @option
  8741. @item -b @var{blocks}
  8742. @itemx --blocking-factor=@var{blocks}
  8743. Set record size to @math{@var{blocks}*512} bytes.
  8744. This option is used to specify a @dfn{blocking factor} for the archive.
  8745. When reading or writing the archive, @command{tar}, will do reads and writes
  8746. of the archive in records of @math{@var{block}*512} bytes. This is true
  8747. even when the archive is compressed. Some devices requires that all
  8748. write operations be a multiple of a certain size, and so, @command{tar}
  8749. pads the archive out to the next record boundary.
  8750. The default blocking factor is set when @command{tar} is compiled, and is
  8751. typically 20. Blocking factors larger than 20 cannot be read by very
  8752. old versions of @command{tar}, or by some newer versions of @command{tar}
  8753. running on old machines with small address spaces.
  8754. With a magnetic tape, larger records give faster throughput and fit
  8755. more data on a tape (because there are fewer inter-record gaps).
  8756. If the archive is in a disk file or a pipe, you may want to specify
  8757. a smaller blocking factor, since a large one will result in a large
  8758. number of null bytes at the end of the archive.
  8759. When writing cartridge or other streaming tapes, a much larger
  8760. blocking factor (say 126 or more) will greatly increase performance.
  8761. However, you must specify the same blocking factor when reading or
  8762. updating the archive.
  8763. Apparently, Exabyte drives have a physical block size of 8K bytes.
  8764. If we choose our blocksize as a multiple of 8k bytes, then the problem
  8765. seems to disappear. Id est, we are using block size of 112 right
  8766. now, and we haven't had the problem since we switched@dots{}
  8767. With @GNUTAR{} the blocking factor is limited only
  8768. by the maximum record size of the device containing the archive, or by
  8769. the amount of available virtual memory.
  8770. However, deblocking or reblocking is virtually avoided in a special
  8771. case which often occurs in practice, but which requires all the
  8772. following conditions to be simultaneously true:
  8773. @itemize @bullet
  8774. @item
  8775. the archive is subject to a compression option,
  8776. @item
  8777. the archive is not handled through standard input or output, nor
  8778. redirected nor piped,
  8779. @item
  8780. the archive is directly handled to a local disk, instead of any special
  8781. device,
  8782. @item
  8783. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  8784. invocation.
  8785. @end itemize
  8786. If the output goes directly to a local disk, and not through
  8787. stdout, then the last write is not extended to a full record size.
  8788. Otherwise, reblocking occurs. Here are a few other remarks on this
  8789. topic:
  8790. @itemize @bullet
  8791. @item
  8792. @command{gzip} will complain about trailing garbage if asked to
  8793. uncompress a compressed archive on tape, there is an option to turn
  8794. the message off, but it breaks the regularity of simply having to use
  8795. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  8796. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  8797. Gailly, by sending a copy of this message to him.
  8798. @item
  8799. @command{compress} does not show this problem, but as Jean-loup pointed
  8800. out to Michael, @samp{compress -d} silently adds garbage after
  8801. the result of decompression, which tar ignores because it already
  8802. recognized its end-of-file indicator. So this bug may be safely
  8803. ignored.
  8804. @item
  8805. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  8806. but will still return an exit status of 2 which tar reports in turn.
  8807. @command{tar} might ignore the exit status returned, but I hate doing
  8808. that, as it weakens the protection @command{tar} offers users against
  8809. other possible problems at decompression time. If @command{gzip} was
  8810. silently skipping trailing zeros @emph{and} also avoiding setting the
  8811. exit status in this innocuous case, that would solve this situation.
  8812. @item
  8813. @command{tar} should become more solid at not stopping to read a pipe at
  8814. the first null block encountered. This inelegantly breaks the pipe.
  8815. @command{tar} should rather drain the pipe out before exiting itself.
  8816. @end itemize
  8817. @xopindex{ignore-zeros, short description}
  8818. @item -i
  8819. @itemx --ignore-zeros
  8820. Ignore blocks of zeros in archive (means EOF).
  8821. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  8822. of zeros in the archive. Normally a block of zeros indicates the
  8823. end of the archive, but when reading a damaged archive, or one which
  8824. was created by concatenating several archives together, this option
  8825. allows @command{tar} to read the entire archive. This option is not on
  8826. by default because many versions of @command{tar} write garbage after
  8827. the zeroed blocks.
  8828. Note that this option causes @command{tar} to read to the end of the
  8829. archive file, which may sometimes avoid problems when multiple files
  8830. are stored on a single physical tape.
  8831. @xopindex{read-full-records, short description}
  8832. @item -B
  8833. @itemx --read-full-records
  8834. Reblock as we read (for reading 4.2@acronym{BSD} pipes).
  8835. If @option{--read-full-records} is used, @command{tar}
  8836. will not panic if an attempt to read a record from the archive does
  8837. not return a full record. Instead, @command{tar} will keep reading
  8838. until it has obtained a full
  8839. record.
  8840. This option is turned on by default when @command{tar} is reading
  8841. an archive from standard input, or from a remote machine. This is
  8842. because on @acronym{BSD} Unix systems, a read of a pipe will return however
  8843. much happens to be in the pipe, even if it is less than @command{tar}
  8844. requested. If this option was not used, @command{tar} would fail as
  8845. soon as it read an incomplete record from the pipe.
  8846. This option is also useful with the commands for updating an archive.
  8847. @end table
  8848. Tape blocking
  8849. @FIXME{Appropriate options should be moved here from elsewhere.}
  8850. @cindex blocking factor
  8851. @cindex tape blocking
  8852. When handling various tapes or cartridges, you have to take care of
  8853. selecting a proper blocking, that is, the number of disk blocks you
  8854. put together as a single tape block on the tape, without intervening
  8855. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  8856. with no information on it, used for decelerating the tape to a
  8857. full stop, and for later regaining the reading or writing speed.
  8858. When the tape driver starts reading a record, the record has to
  8859. be read whole without stopping, as a tape gap is needed to stop the
  8860. tape motion without losing information.
  8861. @cindex Exabyte blocking
  8862. @cindex DAT blocking
  8863. Using higher blocking (putting more disk blocks per tape block) will use
  8864. the tape more efficiently as there will be less tape gaps. But reading
  8865. such tapes may be more difficult for the system, as more memory will be
  8866. required to receive at once the whole record. Further, if there is a
  8867. reading error on a huge record, this is less likely that the system will
  8868. succeed in recovering the information. So, blocking should not be too
  8869. low, nor it should be too high. @command{tar} uses by default a blocking of
  8870. 20 for historical reasons, and it does not really matter when reading or
  8871. writing to disk. Current tape technology would easily accommodate higher
  8872. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  8873. We were told that for some DLT drives, the blocking should be a multiple
  8874. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  8875. Other manufacturers may use different recommendations for the same tapes.
  8876. This might also depends of the buffering techniques used inside modern
  8877. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  8878. Others request blocking to be some exponent of two.
  8879. So, there is no fixed rule for blocking. But blocking at read time
  8880. should ideally be the same as blocking used at write time. At one place
  8881. I know, with a wide variety of equipment, they found it best to use a
  8882. blocking of 32 to guarantee that their tapes are fully interchangeable.
  8883. I was also told that, for recycled tapes, prior erasure (by the same
  8884. drive unit that will be used to create the archives) sometimes lowers
  8885. the error rates observed at rewriting time.
  8886. I might also use @option{--number-blocks} instead of
  8887. @option{--block-number}, so @option{--block} will then expand to
  8888. @option{--blocking-factor} unambiguously.
  8889. @node Many
  8890. @section Many Archives on One Tape
  8891. @FIXME{Appropriate options should be moved here from elsewhere.}
  8892. @findex ntape @r{device}
  8893. Most tape devices have two entries in the @file{/dev} directory, or
  8894. entries that come in pairs, which differ only in the minor number for
  8895. this device. Let's take for example @file{/dev/tape}, which often
  8896. points to the only or usual tape device of a given system. There might
  8897. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  8898. name is the @emph{rewinding} version of the device, while the name
  8899. having @samp{nr} in it is the @emph{no rewinding} version of the same
  8900. device.
  8901. A rewinding tape device will bring back the tape to its beginning point
  8902. automatically when this device is opened or closed. Since @command{tar}
  8903. opens the archive file before using it and closes it afterwards, this
  8904. means that a simple:
  8905. @smallexample
  8906. $ @kbd{tar cf /dev/tape @var{directory}}
  8907. @end smallexample
  8908. @noindent
  8909. will reposition the tape to its beginning both prior and after saving
  8910. @var{directory} contents to it, thus erasing prior tape contents and
  8911. making it so that any subsequent write operation will destroy what has
  8912. just been saved.
  8913. @cindex tape positioning
  8914. So, a rewinding device is normally meant to hold one and only one file.
  8915. If you want to put more than one @command{tar} archive on a given tape, you
  8916. will need to avoid using the rewinding version of the tape device. You
  8917. will also have to pay special attention to tape positioning. Errors in
  8918. positioning may overwrite the valuable data already on your tape. Many
  8919. people, burnt by past experiences, will only use rewinding devices and
  8920. limit themselves to one file per tape, precisely to avoid the risk of
  8921. such errors. Be fully aware that writing at the wrong position on a
  8922. tape loses all information past this point and most probably until the
  8923. end of the tape, and this destroyed information @emph{cannot} be
  8924. recovered.
  8925. To save @var{directory-1} as a first archive at the beginning of a
  8926. tape, and leave that tape ready for a second archive, you should use:
  8927. @smallexample
  8928. $ @kbd{mt -f /dev/nrtape rewind}
  8929. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  8930. @end smallexample
  8931. @cindex tape marks
  8932. @dfn{Tape marks} are special magnetic patterns written on the tape
  8933. media, which are later recognizable by the reading hardware. These
  8934. marks are used after each file, when there are many on a single tape.
  8935. An empty file (that is to say, two tape marks in a row) signal the
  8936. logical end of the tape, after which no file exist. Usually,
  8937. non-rewinding tape device drivers will react to the close request issued
  8938. by @command{tar} by first writing two tape marks after your archive, and by
  8939. backspacing over one of these. So, if you remove the tape at that time
  8940. from the tape drive, it is properly terminated. But if you write
  8941. another file at the current position, the second tape mark will be
  8942. erased by the new information, leaving only one tape mark between files.
  8943. So, you may now save @var{directory-2} as a second archive after the
  8944. first on the same tape by issuing the command:
  8945. @smallexample
  8946. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  8947. @end smallexample
  8948. @noindent
  8949. and so on for all the archives you want to put on the same tape.
  8950. Another usual case is that you do not write all the archives the same
  8951. day, and you need to remove and store the tape between two archive
  8952. sessions. In general, you must remember how many files are already
  8953. saved on your tape. Suppose your tape already has 16 files on it, and
  8954. that you are ready to write the 17th. You have to take care of skipping
  8955. the first 16 tape marks before saving @var{directory-17}, say, by using
  8956. these commands:
  8957. @smallexample
  8958. $ @kbd{mt -f /dev/nrtape rewind}
  8959. $ @kbd{mt -f /dev/nrtape fsf 16}
  8960. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  8961. @end smallexample
  8962. In all the previous examples, we put aside blocking considerations, but
  8963. you should do the proper things for that as well. @xref{Blocking}.
  8964. @menu
  8965. * Tape Positioning:: Tape Positions and Tape Marks
  8966. * mt:: The @command{mt} Utility
  8967. @end menu
  8968. @node Tape Positioning
  8969. @subsection Tape Positions and Tape Marks
  8970. @UNREVISED
  8971. Just as archives can store more than one file from the file system,
  8972. tapes can store more than one archive file. To keep track of where
  8973. archive files (or any other type of file stored on tape) begin and
  8974. end, tape archive devices write magnetic @dfn{tape marks} on the
  8975. archive media. Tape drives write one tape mark between files,
  8976. two at the end of all the file entries.
  8977. If you think of data as a series of records "rrrr"'s, and tape marks as
  8978. "*"'s, a tape might look like the following:
  8979. @smallexample
  8980. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  8981. @end smallexample
  8982. Tape devices read and write tapes using a read/write @dfn{tape
  8983. head}---a physical part of the device which can only access one
  8984. point on the tape at a time. When you use @command{tar} to read or
  8985. write archive data from a tape device, the device will begin reading
  8986. or writing from wherever on the tape the tape head happens to be,
  8987. regardless of which archive or what part of the archive the tape
  8988. head is on. Before writing an archive, you should make sure that no
  8989. data on the tape will be overwritten (unless it is no longer needed).
  8990. Before reading an archive, you should make sure the tape head is at
  8991. the beginning of the archive you want to read. You can do it manually
  8992. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  8993. that automatically (@pxref{Scripted Restoration}).
  8994. If you want to add new archive file entries to a tape, you should
  8995. advance the tape to the end of the existing file entries, backspace
  8996. over the last tape mark, and write the new archive file. If you were
  8997. to add two archives to the example above, the tape might look like the
  8998. following:
  8999. @smallexample
  9000. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  9001. @end smallexample
  9002. @node mt
  9003. @subsection The @command{mt} Utility
  9004. @UNREVISED
  9005. @FIXME{Is it true that this only works on non-block devices?
  9006. should explain the difference, (fixed or variable).}
  9007. @xref{Blocking Factor}.
  9008. You can use the @command{mt} utility to advance or rewind a tape past a
  9009. specified number of archive files on the tape. This will allow you
  9010. to move to the beginning of an archive before extracting or reading
  9011. it, or to the end of all the archives before writing a new one.
  9012. @FIXME{Why isn't there an "advance 'til you find two tape marks
  9013. together"?}
  9014. The syntax of the @command{mt} command is:
  9015. @smallexample
  9016. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  9017. @end smallexample
  9018. where @var{tapename} is the name of the tape device, @var{number} is
  9019. the number of times an operation is performed (with a default of one),
  9020. and @var{operation} is one of the following:
  9021. @FIXME{is there any use for record operations?}
  9022. @table @option
  9023. @item eof
  9024. @itemx weof
  9025. Writes @var{number} tape marks at the current position on the tape.
  9026. @item fsf
  9027. Moves tape position forward @var{number} files.
  9028. @item bsf
  9029. Moves tape position back @var{number} files.
  9030. @item rewind
  9031. Rewinds the tape. (Ignores @var{number}.)
  9032. @item offline
  9033. @itemx rewoff1
  9034. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}.)
  9035. @item status
  9036. Prints status information about the tape unit.
  9037. @end table
  9038. If you don't specify a @var{tapename}, @command{mt} uses the environment
  9039. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} will use
  9040. the default device specified in your @file{sys/mtio.h} file
  9041. (@code{DEFTAPE} variable). If this is not defined, the program will
  9042. display a descriptive error message and exit with code 1.
  9043. @command{mt} returns a 0 exit status when the operation(s) were
  9044. successful, 1 if the command was unrecognized, and 2 if an operation
  9045. failed.
  9046. @node Using Multiple Tapes
  9047. @section Using Multiple Tapes
  9048. Often you might want to write a large archive, one larger than will fit
  9049. on the actual tape you are using. In such a case, you can run multiple
  9050. @command{tar} commands, but this can be inconvenient, particularly if you
  9051. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  9052. Therefore, @command{tar} provides a special mode for creating
  9053. multi-volume archives.
  9054. @dfn{Multi-volume} archive is a single @command{tar} archive, stored
  9055. on several media volumes of fixed size. Although in this section we will
  9056. often call @samp{volume} a @dfn{tape}, there is absolutely no
  9057. requirement for multi-volume archives to be stored on tapes. Instead,
  9058. they can use whatever media type the user finds convenient, they can
  9059. even be located on files.
  9060. When creating a multi-volume archive, @GNUTAR{} continues to fill
  9061. current volume until it runs out of space, then it switches to
  9062. next volume (usually the operator is queried to replace the tape on
  9063. this point), and continues working on the new volume. This operation
  9064. continues until all requested files are dumped. If @GNUTAR{} detects
  9065. end of media while dumping a file, such a file is archived in split
  9066. form. Some very big files can even be split across several volumes.
  9067. Each volume is itself a valid @GNUTAR{} archive, so it can be read
  9068. without any special options. Consequently any file member residing
  9069. entirely on one volume can be extracted or otherwise operated upon
  9070. without needing the other volume. Sure enough, to extract a split
  9071. member you would need all volumes its parts reside on.
  9072. Multi-volume archives suffer from several limitations. In particular,
  9073. they cannot be compressed.
  9074. @GNUTAR{} is able to create multi-volume archives of two formats
  9075. (@pxref{Formats}): @samp{GNU} and @samp{POSIX}.
  9076. @menu
  9077. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  9078. * Tape Files:: Tape Files
  9079. * Tarcat:: Concatenate Volumes into a Single Archive
  9080. @end menu
  9081. @node Multi-Volume Archives
  9082. @subsection Archives Longer than One Tape or Disk
  9083. @cindex Multi-volume archives
  9084. @opindex multi-volume
  9085. To create an archive that is larger than will fit on a single unit of
  9086. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  9087. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  9088. archive can be manipulated like any other archive (provided the
  9089. @option{--multi-volume} option is specified), but is stored on more
  9090. than one tape or file.
  9091. When you specify @option{--multi-volume}, @command{tar} does not report an
  9092. error when it comes to the end of an archive volume (when reading), or
  9093. the end of the media (when writing). Instead, it prompts you to load
  9094. a new storage volume. If the archive is on a magnetic tape, you
  9095. should change tapes when you see the prompt; if the archive is on a
  9096. floppy disk, you should change disks; etc.
  9097. @table @option
  9098. @item --multi-volume
  9099. @itemx -M
  9100. Creates a multi-volume archive, when used in conjunction with
  9101. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  9102. archive, specify @option{--multi-volume} in conjunction with that
  9103. operation.
  9104. For example:
  9105. @smallexample
  9106. $ @kbd{tar --create --multi-volume --file=/dev/tape @var{files}}
  9107. @end smallexample
  9108. @end table
  9109. The method @command{tar} uses to detect end of tape is not perfect, and
  9110. fails on some operating systems or on some devices. If @command{tar}
  9111. cannot detect the end of the tape itself, you can use
  9112. @option{--tape-length} option to inform it about the capacity of the
  9113. tape:
  9114. @anchor{tape-length}
  9115. @table @option
  9116. @opindex tape-length
  9117. @item --tape-length=@var{size}[@var{suf}]
  9118. @itemx -L @var{size}[@var{suf}]
  9119. Set maximum length of a volume. The @var{suf}, if given, specifies
  9120. units in which @var{size} is expressed, e.g. @samp{2M} mean 2
  9121. megabytes (@pxref{size-suffixes}, for a list of allowed size
  9122. suffixes). Without @var{suf}, units of 1024 bytes (kilobyte) are
  9123. assumed.
  9124. This option selects @option{--multi-volume} automatically. For example:
  9125. @smallexample
  9126. $ @kbd{tar --create --tape-length=41943040 --file=/dev/tape @var{files}}
  9127. @end smallexample
  9128. @noindent
  9129. or, which is equivalent:
  9130. @smallexample
  9131. $ @kbd{tar --create --tape-length=4G --file=/dev/tape @var{files}}
  9132. @end smallexample
  9133. @end table
  9134. @anchor{change volume prompt}
  9135. When @GNUTAR{} comes to the end of a storage media, it asks you to
  9136. change the volume. The built-in prompt for POSIX locale
  9137. is@footnote{If you run @GNUTAR{} under a different locale, the
  9138. translation to the locale's language will be used.}:
  9139. @smallexample
  9140. Prepare volume #@var{n} for `@var{archive}' and hit return:
  9141. @end smallexample
  9142. @noindent
  9143. where @var{n} is the ordinal number of the volume to be created and
  9144. @var{archive} is archive file or device name.
  9145. When prompting for a new tape, @command{tar} accepts any of the following
  9146. responses:
  9147. @table @kbd
  9148. @item ?
  9149. Request @command{tar} to explain possible responses.
  9150. @item q
  9151. Request @command{tar} to exit immediately.
  9152. @item n @var{file-name}
  9153. Request @command{tar} to write the next volume on the file @var{file-name}.
  9154. @item !
  9155. Request @command{tar} to run a subshell. This option can be disabled
  9156. by giving @option{--restrict} command line option to
  9157. @command{tar}@footnote{@xref{--restrict}, for more information about
  9158. this option.}.
  9159. @item y
  9160. Request @command{tar} to begin writing the next volume.
  9161. @end table
  9162. (You should only type @samp{y} after you have changed the tape;
  9163. otherwise @command{tar} will write over the volume it just finished.)
  9164. @cindex Volume number file
  9165. @cindex volno file
  9166. @anchor{volno-file}
  9167. @opindex volno-file
  9168. The volume number used by @command{tar} in its tape-changing prompt
  9169. can be changed; if you give the
  9170. @option{--volno-file=@var{file-of-number}} option, then
  9171. @var{file-of-number} should be an non-existing file to be created, or
  9172. else, a file already containing a decimal number. That number will be
  9173. used as the volume number of the first volume written. When
  9174. @command{tar} is finished, it will rewrite the file with the
  9175. now-current volume number. (This does not change the volume number
  9176. written on a tape label, as per @ref{label}, it @emph{only} affects
  9177. the number used in the prompt.)
  9178. @cindex End-of-archive info script
  9179. @cindex Info script
  9180. @anchor{info-script}
  9181. @opindex info-script
  9182. @opindex new-volume-script
  9183. If you want more elaborate behavior than this, you can write a special
  9184. @dfn{new volume script}, that will be responsible for changing the
  9185. volume, and instruct @command{tar} to use it instead of its normal
  9186. prompting procedure:
  9187. @table @option
  9188. @item --info-script=@var{script-name}
  9189. @itemx --new-volume-script=@var{script-name}
  9190. @itemx -F @var{script-name}
  9191. Specify the full name of the volume script to use. The script can be
  9192. used to eject cassettes, or to broadcast messages such as
  9193. @samp{Someone please come change my tape} when performing unattended
  9194. backups.
  9195. @end table
  9196. The @var{script-name} is executed without any command line
  9197. arguments. It inherits @command{tar}'s shell environment.
  9198. Additional data is passed to it via the following
  9199. environment variables:
  9200. @table @env
  9201. @vrindex TAR_VERSION, info script environment variable
  9202. @item TAR_VERSION
  9203. @GNUTAR{} version number.
  9204. @vrindex TAR_ARCHIVE, info script environment variable
  9205. @item TAR_ARCHIVE
  9206. The name of the archive @command{tar} is processing.
  9207. @vrindex TAR_BLOCKING_FACTOR, info script environment variable
  9208. @item TAR_BLOCKING_FACTOR
  9209. Current blocking factor (@pxref{Blocking}).
  9210. @vrindex TAR_VOLUME, info script environment variable
  9211. @item TAR_VOLUME
  9212. Ordinal number of the volume @command{tar} is about to start.
  9213. @vrindex TAR_SUBCOMMAND, info script environment variable
  9214. @item TAR_SUBCOMMAND
  9215. A short option describing the operation @command{tar} is executing.
  9216. @xref{Operations}, for a complete list of subcommand options.
  9217. @vrindex TAR_FORMAT, info script environment variable
  9218. @item TAR_FORMAT
  9219. Format of the archive being processed. @xref{Formats}, for a complete
  9220. list of archive format names.
  9221. @vrindex TAR_FD, info script environment variable
  9222. @item TAR_FD
  9223. File descriptor which can be used to communicate the new volume
  9224. name to @command{tar}.
  9225. @end table
  9226. The volume script can instruct @command{tar} to use new archive name,
  9227. by writing in to file descriptor @env{$TAR_FD} (see below for an example).
  9228. If the info script fails, @command{tar} exits; otherwise, it begins
  9229. writing the next volume.
  9230. If you want @command{tar} to cycle through a series of files or tape
  9231. drives, there are three approaches to choose from. First of all, you
  9232. can give @command{tar} multiple @option{--file} options. In this case
  9233. the specified files will be used, in sequence, as the successive
  9234. volumes of the archive. Only when the first one in the sequence needs
  9235. to be used again will @command{tar} prompt for a tape change (or run
  9236. the info script). For example, suppose someone has two tape drives on
  9237. a system named @file{/dev/tape0} and @file{/dev/tape1}. For having
  9238. @GNUTAR{} to switch to the second drive when it needs to write the
  9239. second tape, and then back to the first tape, etc., just do either of:
  9240. @smallexample
  9241. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  9242. $ @kbd{tar -cM -f /dev/tape0 -f /dev/tape1 @var{files}}
  9243. @end smallexample
  9244. The second method is to use the @samp{n} response to the tape-change
  9245. prompt.
  9246. Finally, the most flexible approach is to use a volume script, that
  9247. writes new archive name to the file descriptor @env{$TAR_FD}. For example, the
  9248. following volume script will create a series of archive files, named
  9249. @file{@var{archive}-@var{vol}}, where @var{archive} is the name of the
  9250. archive being created (as given by @option{--file} option) and
  9251. @var{vol} is the ordinal number of the archive being created:
  9252. @smallexample
  9253. @group
  9254. #! /bin/sh
  9255. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  9256. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  9257. case $TAR_SUBCOMMAND in
  9258. -c) ;;
  9259. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  9260. ;;
  9261. *) exit 1
  9262. esac
  9263. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&$TAR_FD
  9264. @end group
  9265. @end smallexample
  9266. The same script can be used while listing, comparing or extracting
  9267. from the created archive. For example:
  9268. @smallexample
  9269. @group
  9270. # @r{Create a multi-volume archive:}
  9271. $ @kbd{tar -c -L1024 -f archive.tar -F new-volume .}
  9272. # @r{Extract from the created archive:}
  9273. $ @kbd{tar -x -f archive.tar -F new-volume .}
  9274. @end group
  9275. @end smallexample
  9276. @noindent
  9277. Notice, that the first command had to use @option{-L} option, since
  9278. otherwise @GNUTAR{} will end up writing everything to file
  9279. @file{archive.tar}.
  9280. You can read each individual volume of a multi-volume archive as if it
  9281. were an archive by itself. For example, to list the contents of one
  9282. volume, use @option{--list}, without @option{--multi-volume} specified.
  9283. To extract an archive member from one volume (assuming it is described
  9284. that volume), use @option{--extract}, again without
  9285. @option{--multi-volume}.
  9286. If an archive member is split across volumes (i.e., its entry begins on
  9287. one volume of the media and ends on another), you need to specify
  9288. @option{--multi-volume} to extract it successfully. In this case, you
  9289. should load the volume where the archive member starts, and use
  9290. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  9291. volumes as it needs them. @xref{extracting archives}, for more
  9292. information about extracting archives.
  9293. Multi-volume archives can be modified like any other archive. To add
  9294. files to a multi-volume archive, you need to only mount the last
  9295. volume of the archive media (and new volumes, if needed). For all
  9296. other operations, you need to use the entire archive.
  9297. If a multi-volume archive was labeled using
  9298. @option{--label=@var{archive-label}} (@pxref{label}) when it was
  9299. created, @command{tar} will not automatically label volumes which are
  9300. added later. To label subsequent volumes, specify
  9301. @option{--label=@var{archive-label}} again in conjunction with the
  9302. @option{--append}, @option{--update} or @option{--concatenate} operation.
  9303. Notice that multi-volume support is a GNU extension and the archives
  9304. created in this mode should be read only using @GNUTAR{}. If you
  9305. absolutely have to process such archives using a third-party @command{tar}
  9306. implementation, read @ref{Split Recovery}.
  9307. @node Tape Files
  9308. @subsection Tape Files
  9309. @cindex labeling archives
  9310. @opindex label
  9311. @UNREVISED
  9312. To give the archive a name which will be recorded in it, use the
  9313. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  9314. option. This will write a special block identifying
  9315. @var{volume-label} as the name of the archive to the front of the
  9316. archive which will be displayed when the archive is listed with
  9317. @option{--list}. If you are creating a multi-volume archive with
  9318. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  9319. volume label will have @samp{Volume @var{nnn}} appended to the name
  9320. you give, where @var{nnn} is the number of the volume of the archive.
  9321. If you use the @option{--label=@var{volume-label}} option when
  9322. reading an archive, it checks to make sure the label on the tape
  9323. matches the one you gave. @xref{label}.
  9324. When @command{tar} writes an archive to tape, it creates a single
  9325. tape file. If multiple archives are written to the same tape, one
  9326. after the other, they each get written as separate tape files. When
  9327. extracting, it is necessary to position the tape at the right place
  9328. before running @command{tar}. To do this, use the @command{mt} command.
  9329. For more information on the @command{mt} command and on the organization
  9330. of tapes into a sequence of tape files, see @ref{mt}.
  9331. People seem to often do:
  9332. @smallexample
  9333. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  9334. @end smallexample
  9335. or such, for pushing a common date in all volumes or an archive set.
  9336. @node Tarcat
  9337. @subsection Concatenate Volumes into a Single Archive
  9338. @pindex tarcat
  9339. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  9340. archive to a single @command{tar} archive. Simply concatenating all
  9341. volumes into one will not work, since each volume carries an additional
  9342. information at the beginning. @GNUTAR{} is shipped with the shell
  9343. script @command{tarcat} designed for this purpose.
  9344. The script takes a list of files comprising a multi-volume archive
  9345. and creates the resulting archive at the standard output. For example:
  9346. @smallexample
  9347. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  9348. @end smallexample
  9349. The script implements a simple heuristics to determine the format of
  9350. the first volume file and to decide how to process the rest of the
  9351. files. However, it makes no attempt to verify whether the files are
  9352. given in order or even if they are valid @command{tar} archives.
  9353. It uses @command{dd} and does not filter its standard error, so you
  9354. will usually see lots of spurious messages.
  9355. @FIXME{The script is not installed. Should we install it?}
  9356. @node label
  9357. @section Including a Label in the Archive
  9358. @cindex Labeling an archive
  9359. @cindex Labels on the archive media
  9360. @cindex Labeling multi-volume archives
  9361. @opindex label
  9362. To avoid problems caused by misplaced paper labels on the archive
  9363. media, you can include a @dfn{label} entry --- an archive member which
  9364. contains the name of the archive --- in the archive itself. Use the
  9365. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  9366. option@footnote{Until version 1.10, that option was called
  9367. @option{--volume}, but is not available under that name anymore.} in
  9368. conjunction with the @option{--create} operation to include a label
  9369. entry in the archive as it is being created.
  9370. @table @option
  9371. @item --label=@var{archive-label}
  9372. @itemx -V @var{archive-label}
  9373. Includes an @dfn{archive-label} at the beginning of the archive when
  9374. the archive is being created, when used in conjunction with the
  9375. @option{--create} operation. Checks to make sure the archive label
  9376. matches the one specified (when used in conjunction with any other
  9377. operation).
  9378. @end table
  9379. If you create an archive using both
  9380. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  9381. and @option{--multi-volume} (@option{-M}), each volume of the archive
  9382. will have an archive label of the form @samp{@var{archive-label}
  9383. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  9384. next, and so on. @xref{Using Multiple Tapes}, for information on
  9385. creating multiple volume archives.
  9386. @cindex Volume label, listing
  9387. @cindex Listing volume label
  9388. The volume label will be displayed by @option{--list} along with
  9389. the file contents. If verbose display is requested, it will also be
  9390. explicitly marked as in the example below:
  9391. @smallexample
  9392. @group
  9393. $ @kbd{tar --verbose --list --file=iamanarchive}
  9394. V--------- 0/0 0 1992-03-07 12:01 iamalabel--Volume Header--
  9395. -rw-r--r-- ringo/user 40 1990-05-21 13:30 iamafilename
  9396. @end group
  9397. @end smallexample
  9398. @opindex test-label
  9399. @anchor{--test-label option}
  9400. However, @option{--list} option will cause listing entire
  9401. contents of the archive, which may be undesirable (for example, if the
  9402. archive is stored on a tape). You can request checking only the volume
  9403. label by specifying @option{--test-label} option. This option reads only the
  9404. first block of an archive, so it can be used with slow storage
  9405. devices. For example:
  9406. @smallexample
  9407. @group
  9408. $ @kbd{tar --test-label --file=iamanarchive}
  9409. iamalabel
  9410. @end group
  9411. @end smallexample
  9412. If @option{--test-label} is used with one or more command line
  9413. arguments, @command{tar} compares the volume label with each
  9414. argument. It exits with code 0 if a match is found, and with code 1
  9415. otherwise@footnote{Note that @GNUTAR{} versions up to 1.23 indicated
  9416. mismatch with an exit code 2 and printed a spurious diagnostics on
  9417. stderr.}. No output is displayed, unless you also used the
  9418. @option{--verbose} option. For example:
  9419. @smallexample
  9420. @group
  9421. $ @kbd{tar --test-label --file=iamanarchive 'iamalabel'}
  9422. @result{} 0
  9423. $ @kbd{tar --test-label --file=iamanarchive 'alabel'}
  9424. @result{} 1
  9425. @end group
  9426. @end smallexample
  9427. When used with the @option{--verbose} option, @command{tar}
  9428. prints the actual volume label (if any), and a verbose diagnostics in
  9429. case of a mismatch:
  9430. @smallexample
  9431. @group
  9432. $ @kbd{tar --test-label --verbose --file=iamanarchive 'iamalabel'}
  9433. iamalabel
  9434. @result{} 0
  9435. $ @kbd{tar --test-label --verbose --file=iamanarchive 'alabel'}
  9436. iamalabel
  9437. tar: Archive label mismatch
  9438. @result{} 1
  9439. @end group
  9440. @end smallexample
  9441. If you request any operation, other than @option{--create}, along
  9442. with using @option{--label} option, @command{tar} will first check if
  9443. the archive label matches the one specified and will refuse to proceed
  9444. if it does not. Use this as a safety precaution to avoid accidentally
  9445. overwriting existing archives. For example, if you wish to add files
  9446. to @file{archive}, presumably labeled with string @samp{My volume},
  9447. you will get:
  9448. @smallexample
  9449. @group
  9450. $ @kbd{tar -rf archive --label 'My volume' .}
  9451. tar: Archive not labeled to match `My volume'
  9452. @end group
  9453. @end smallexample
  9454. @noindent
  9455. in case its label does not match. This will work even if
  9456. @file{archive} is not labeled at all.
  9457. Similarly, @command{tar} will refuse to list or extract the
  9458. archive if its label doesn't match the @var{archive-label}
  9459. specified. In those cases, @var{archive-label} argument is interpreted
  9460. as a globbing-style pattern which must match the actual magnetic
  9461. volume label. @xref{exclude}, for a precise description of how match
  9462. is attempted@footnote{Previous versions of @command{tar} used full
  9463. regular expression matching, or before that, only exact string
  9464. matching, instead of wildcard matchers. We decided for the sake of
  9465. simplicity to use a uniform matching device through
  9466. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  9467. the volume label matcher will also suffix @var{archive-label} by
  9468. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  9469. up. Since the volume numbering is automatically added in labels at
  9470. creation time, it sounded logical to equally help the user taking care
  9471. of it when the archive is being read.
  9472. You can also use @option{--label} to get a common information on
  9473. all tapes of a series. For having this information different in each
  9474. series created through a single script used on a regular basis, just
  9475. manage to get some date string as part of the label. For example:
  9476. @smallexample
  9477. @group
  9478. $ @kbd{tar -cM -f /dev/tape -V "Daily backup for `date +%Y-%m-%d`"}
  9479. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  9480. --label="Daily backup for `date +%Y-%m-%d`"}
  9481. @end group
  9482. @end smallexample
  9483. Some more notes about volume labels:
  9484. @itemize @bullet
  9485. @item Each label has its own date and time, which corresponds
  9486. to the time when @GNUTAR{} initially attempted to write it,
  9487. often soon after the operator launches @command{tar} or types the
  9488. carriage return telling that the next tape is ready.
  9489. @item Comparing date labels to get an idea of tape throughput is
  9490. unreliable. It gives correct results only if the delays for rewinding
  9491. tapes and the operator switching them were negligible, which is
  9492. usually not the case.
  9493. @end itemize
  9494. @node verify
  9495. @section Verifying Data as It is Stored
  9496. @cindex Verifying a write operation
  9497. @cindex Double-checking a write operation
  9498. @table @option
  9499. @item -W
  9500. @itemx --verify
  9501. @opindex verify, short description
  9502. Attempt to verify the archive after writing.
  9503. @end table
  9504. This option causes @command{tar} to verify the archive after writing it.
  9505. Each volume is checked after it is written, and any discrepancies
  9506. are recorded on the standard error output.
  9507. Verification requires that the archive be on a back-space-able medium.
  9508. This means pipes, some cartridge tape drives, and some other devices
  9509. cannot be verified.
  9510. You can insure the accuracy of an archive by comparing files in the
  9511. system with archive members. @command{tar} can compare an archive to the
  9512. file system as the archive is being written, to verify a write
  9513. operation, or can compare a previously written archive, to insure that
  9514. it is up to date.
  9515. @xopindex{verify, using with @option{--create}}
  9516. @xopindex{create, using with @option{--verify}}
  9517. To check for discrepancies in an archive immediately after it is
  9518. written, use the @option{--verify} (@option{-W}) option in conjunction with
  9519. the @option{--create} operation. When this option is
  9520. specified, @command{tar} checks archive members against their counterparts
  9521. in the file system, and reports discrepancies on the standard error.
  9522. To verify an archive, you must be able to read it from before the end
  9523. of the last written entry. This option is useful for detecting data
  9524. errors on some tapes. Archives written to pipes, some cartridge tape
  9525. drives, and some other devices cannot be verified.
  9526. One can explicitly compare an already made archive with the file
  9527. system by using the @option{--compare} (@option{--diff}, @option{-d})
  9528. option, instead of using the more automatic @option{--verify} option.
  9529. @xref{compare}.
  9530. Note that these two options have a slightly different intent. The
  9531. @option{--compare} option checks how identical are the logical contents of some
  9532. archive with what is on your disks, while the @option{--verify} option is
  9533. really for checking if the physical contents agree and if the recording
  9534. media itself is of dependable quality. So, for the @option{--verify}
  9535. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  9536. the archive, while it lets the speed optimization undisturbed for the
  9537. @option{--compare} option. If you nevertheless use @option{--compare} for
  9538. media verification, you may have to defeat the in-memory cache yourself,
  9539. maybe by opening and reclosing the door latch of your recording unit,
  9540. forcing some doubt in your operating system about the fact this is really
  9541. the same volume as the one just written or read.
  9542. The @option{--verify} option would not be necessary if drivers were indeed
  9543. able to detect dependably all write failures. This sometimes require many
  9544. magnetic heads, some able to read after the writes occurred. One would
  9545. not say that drivers unable to detect all cases are necessarily flawed,
  9546. as long as programming is concerned.
  9547. The @option{--verify} (@option{-W}) option will not work in
  9548. conjunction with the @option{--multi-volume} (@option{-M}) option or
  9549. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  9550. and @option{--delete} operations. @xref{Operations}, for more
  9551. information on these operations.
  9552. Also, since @command{tar} normally strips leading @samp{/} from file
  9553. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  9554. /tmp/foo.tar /etc} will work as desired only if the working directory is
  9555. @file{/}, as @command{tar} uses the archive's relative member names
  9556. (e.g., @file{etc/motd}) when verifying the archive.
  9557. @node Write Protection
  9558. @section Write Protection
  9559. Almost all tapes and diskettes, and in a few rare cases, even disks can
  9560. be @dfn{write protected}, to protect data on them from being changed.
  9561. Once an archive is written, you should write protect the media to prevent
  9562. the archive from being accidentally overwritten or deleted. (This will
  9563. protect the archive from being changed with a tape or floppy drive---it
  9564. will not protect it from magnet fields or other physical hazards.)
  9565. The write protection device itself is usually an integral part of the
  9566. physical media, and can be a two position (write enabled/write
  9567. disabled) switch, a notch which can be popped out or covered, a ring
  9568. which can be removed from the center of a tape reel, or some other
  9569. changeable feature.
  9570. @node Reliability and security
  9571. @chapter Reliability and Security
  9572. The @command{tar} command reads and writes files as any other
  9573. application does, and is subject to the usual caveats about
  9574. reliability and security. This section contains some commonsense
  9575. advice on the topic.
  9576. @menu
  9577. * Reliability::
  9578. * Security::
  9579. @end menu
  9580. @node Reliability
  9581. @section Reliability
  9582. Ideally, when @command{tar} is creating an archive, it reads from a
  9583. file system that is not being modified, and encounters no errors or
  9584. inconsistencies while reading and writing. If this is the case, the
  9585. archive should faithfully reflect what was read. Similarly, when
  9586. extracting from an archive, ideally @command{tar} ideally encounters
  9587. no errors and the extracted files faithfully reflect what was in the
  9588. archive.
  9589. However, when reading or writing real-world file systems, several
  9590. things can go wrong; these include permissions problems, corruption of
  9591. data, and race conditions.
  9592. @menu
  9593. * Permissions problems::
  9594. * Data corruption and repair::
  9595. * Race conditions::
  9596. @end menu
  9597. @node Permissions problems
  9598. @subsection Permissions Problems
  9599. If @command{tar} encounters errors while reading or writing files, it
  9600. normally reports an error and exits with nonzero status. The work it
  9601. does may therefore be incomplete. For example, when creating an
  9602. archive, if @command{tar} cannot read a file then it cannot copy the
  9603. file into the archive.
  9604. @node Data corruption and repair
  9605. @subsection Data Corruption and Repair
  9606. If an archive becomes corrupted by an I/O error, this may corrupt the
  9607. data in an extracted file. Worse, it may corrupt the file's metadata,
  9608. which may cause later parts of the archive to become misinterpreted.
  9609. An tar-format archive contains a checksum that most likely will detect
  9610. errors in the metadata, but it will not detect errors in the data.
  9611. If data corruption is a concern, you can compute and check your own
  9612. checksums of an archive by using other programs, such as
  9613. @command{cksum}.
  9614. When attempting to recover from a read error or data corruption in an
  9615. archive, you may need to skip past the questionable data and read the
  9616. rest of the archive. This requires some expertise in the archive
  9617. format and in other software tools.
  9618. @node Race conditions
  9619. @subsection Race conditions
  9620. If some other process is modifying the file system while @command{tar}
  9621. is reading or writing files, the result may well be inconsistent due
  9622. to race conditions. For example, if another process creates some
  9623. files in a directory while @command{tar} is creating an archive
  9624. containing the directory's files, @command{tar} may see some of the
  9625. files but not others, or it may see a file that is in the process of
  9626. being created. The resulting archive may not be a snapshot of the
  9627. file system at any point in time. If an application such as a
  9628. database system depends on an accurate snapshot, restoring from the
  9629. @command{tar} archive of a live file system may therefore break that
  9630. consistency and may break the application. The simplest way to avoid
  9631. the consistency issues is to avoid making other changes to the file
  9632. system while tar is reading it or writing it.
  9633. When creating an archive, several options are available to avoid race
  9634. conditions. Some hosts have a way of snapshotting a file system, or
  9635. of temporarily suspending all changes to a file system, by (say)
  9636. suspending the only virtual machine that can modify a file system; if
  9637. you use these facilities and have @command{tar -c} read from a
  9638. snapshot when creating an archive, you can avoid inconsistency
  9639. problems. More drastically, before starting @command{tar} you could
  9640. suspend or shut down all processes other than @command{tar} that have
  9641. access to the file system, or you could unmount the file system and
  9642. then mount it read-only.
  9643. When extracting from an archive, one approach to avoid race conditions
  9644. is to create a directory that no other process can write to, and
  9645. extract into that.
  9646. @node Security
  9647. @section Security
  9648. In some cases @command{tar} may be used in an adversarial situation,
  9649. where an untrusted user is attempting to gain information about or
  9650. modify otherwise-inaccessible files. Dealing with untrusted data
  9651. (that is, data generated by an untrusted user) typically requires
  9652. extra care, because even the smallest mistake in the use of
  9653. @command{tar} is more likely to be exploited by an adversary than by a
  9654. race condition.
  9655. @menu
  9656. * Privacy::
  9657. * Integrity::
  9658. * Live untrusted data::
  9659. * Security rules of thumb::
  9660. @end menu
  9661. @node Privacy
  9662. @subsection Privacy
  9663. Standard privacy concerns apply when using @command{tar}. For
  9664. example, suppose you are archiving your home directory into a file
  9665. @file{/archive/myhome.tar}. Any secret information in your home
  9666. directory, such as your SSH secret keys, are copied faithfully into
  9667. the archive. Therefore, if your home directory contains any file that
  9668. should not be read by some other user, the archive itself should be
  9669. not be readable by that user. And even if the archive's data are
  9670. inaccessible to untrusted users, its metadata (such as size or
  9671. last-modified date) may reveal some information about your home
  9672. directory; if the metadata are intended to be private, the archive's
  9673. parent directory should also be inaccessible to untrusted users.
  9674. One precaution is to create @file{/archive} so that it is not
  9675. accessible to any user, unless that user also has permission to access
  9676. all the files in your home directory.
  9677. Similarly, when extracting from an archive, take care that the
  9678. permissions of the extracted files are not more generous than what you
  9679. want. Even if the archive itself is readable only to you, files
  9680. extracted from it have their own permissions that may differ.
  9681. @node Integrity
  9682. @subsection Integrity
  9683. When creating archives, take care that they are not writable by a
  9684. untrusted user; otherwise, that user could modify the archive, and
  9685. when you later extract from the archive you will get incorrect data.
  9686. When @command{tar} extracts from an archive, by default it writes into
  9687. files relative to the working directory. If the archive was generated
  9688. by an untrusted user, that user therefore can write into any file
  9689. under the working directory. If the working directory contains a
  9690. symbolic link to another directory, the untrusted user can also write
  9691. into any file under the referenced directory. When extracting from an
  9692. untrusted archive, it is therefore good practice to create an empty
  9693. directory and run @command{tar} in that directory.
  9694. When extracting from two or more untrusted archives, each one should
  9695. be extracted independently, into different empty directories.
  9696. Otherwise, the first archive could create a symbolic link into an area
  9697. outside the working directory, and the second one could follow the
  9698. link and overwrite data that is not under the working directory. For
  9699. example, when restoring from a series of incremental dumps, the
  9700. archives should have been created by a trusted process, as otherwise
  9701. the incremental restores might alter data outside the working
  9702. directory.
  9703. If you use the @option{--absolute-names} (@option{-P}) option when
  9704. extracting, @command{tar} respects any file names in the archive, even
  9705. file names that begin with @file{/} or contain @file{..}. As this
  9706. lets the archive overwrite any file in your system that you can write,
  9707. the @option{--absolute-names} (@option{-P}) option should be used only
  9708. for trusted archives.
  9709. Conversely, with the @option{--keep-old-files} (@option{-k}) option,
  9710. @command{tar} refuses to replace existing files when extracting; and
  9711. with the @option{--no-overwrite-dir} option, @command{tar} refuses to
  9712. replace the permissions or ownership of already-existing directories.
  9713. These options may help when extracting from untrusted archives.
  9714. @node Live untrusted data
  9715. @subsection Dealing with Live Untrusted Data
  9716. Extra care is required when creating from or extracting into a file
  9717. system that is accessible to untrusted users. For example, superusers
  9718. who invoke @command{tar} must be wary about its actions being hijacked
  9719. by an adversary who is reading or writing the file system at the same
  9720. time that @command{tar} is operating.
  9721. When creating an archive from a live file system, @command{tar} is
  9722. vulnerable to denial-of-service attacks. For example, an adversarial
  9723. user could create the illusion of an indefinitely-deep directory
  9724. hierarchy @file{d/e/f/g/...} by creating directories one step ahead of
  9725. @command{tar}, or the illusion of an indefinitely-long file by
  9726. creating a sparse file but arranging for blocks to be allocated just
  9727. before @command{tar} reads them. There is no easy way for
  9728. @command{tar} to distinguish these scenarios from legitimate uses, so
  9729. you may need to monitor @command{tar}, just as you'd need to monitor
  9730. any other system service, to detect such attacks.
  9731. While a superuser is extracting from an archive into a live file
  9732. system, an untrusted user might replace a directory with a symbolic
  9733. link, in hopes that @command{tar} will follow the symbolic link and
  9734. extract data into files that the untrusted user does not have access
  9735. to. Even if the archive was generated by the superuser, it may
  9736. contain a file such as @file{d/etc/passwd} that the untrusted user
  9737. earlier created in order to break in; if the untrusted user replaces
  9738. the directory @file{d/etc} with a symbolic link to @file{/etc} while
  9739. @command{tar} is running, @command{tar} will overwrite
  9740. @file{/etc/passwd}. This attack can be prevented by extracting into a
  9741. directory that is inaccessible to untrusted users.
  9742. Similar attacks via symbolic links are also possible when creating an
  9743. archive, if the untrusted user can modify an ancestor of a top-level
  9744. argument of @command{tar}. For example, an untrusted user that can
  9745. modify @file{/home/eve} can hijack a running instance of @samp{tar -cf
  9746. - /home/eve/Documents/yesterday} by replacing
  9747. @file{/home/eve/Documents} with a symbolic link to some other
  9748. location. Attacks like these can be prevented by making sure that
  9749. untrusted users cannot modify any files that are top-level arguments
  9750. to @command{tar}, or any ancestor directories of these files.
  9751. @node Security rules of thumb
  9752. @subsection Security Rules of Thumb
  9753. This section briefly summarizes rules of thumb for avoiding security
  9754. pitfalls.
  9755. @itemize @bullet
  9756. @item
  9757. Protect archives at least as much as you protect any of the files
  9758. being archived.
  9759. @item
  9760. Extract from an untrusted archive only into an otherwise-empty
  9761. directory. This directory and its parent should be accessible only to
  9762. trusted users. For example:
  9763. @example
  9764. @group
  9765. $ @kbd{chmod go-rwx .}
  9766. $ @kbd{mkdir -m go-rwx dir}
  9767. $ @kbd{cd dir}
  9768. $ @kbd{tar -xvf /archives/got-it-off-the-net.tar.gz}
  9769. @end group
  9770. @end example
  9771. As a corollary, do not do an incremental restore from an untrusted archive.
  9772. @item
  9773. Do not let untrusted users access files extracted from untrusted
  9774. archives without checking first for problems such as setuid programs.
  9775. @item
  9776. Do not let untrusted users modify directories that are ancestors of
  9777. top-level arguments of @command{tar}. For example, while you are
  9778. executing @samp{tar -cf /archive/u-home.tar /u/home}, do not let an
  9779. untrusted user modify @file{/}, @file{/archive}, or @file{/u}.
  9780. @item
  9781. Pay attention to the diagnostics and exit status of @command{tar}.
  9782. @item
  9783. When archiving live file systems, monitor running instances of
  9784. @command{tar} to detect denial-of-service attacks.
  9785. @item
  9786. Avoid unusual options such as @option{--absolute-names} (@option{-P}),
  9787. @option{--dereference} (@option{-h}), @option{--overwrite},
  9788. @option{--recursive-unlink}, and @option{--remove-files} unless you
  9789. understand their security implications.
  9790. @end itemize
  9791. @node Changes
  9792. @appendix Changes
  9793. This appendix lists some important user-visible changes between
  9794. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  9795. version of this document is available at
  9796. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  9797. @GNUTAR{} documentation page}.
  9798. @table @asis
  9799. @item Use of globbing patterns when listing and extracting.
  9800. Previous versions of GNU tar assumed shell-style globbing when
  9801. extracting from or listing an archive. For example:
  9802. @smallexample
  9803. $ @kbd{tar xf foo.tar '*.c'}
  9804. @end smallexample
  9805. would extract all files whose names end in @samp{.c}. This behavior
  9806. was not documented and was incompatible with traditional tar
  9807. implementations. Therefore, starting from version 1.15.91, GNU tar
  9808. no longer uses globbing by default. For example, the above invocation
  9809. is now interpreted as a request to extract from the archive the file
  9810. named @file{*.c}.
  9811. To facilitate transition to the new behavior for those users who got
  9812. used to the previous incorrect one, @command{tar} will print a warning
  9813. if it finds out that a requested member was not found in the archive
  9814. and its name looks like a globbing pattern. For example:
  9815. @smallexample
  9816. $ @kbd{tar xf foo.tar '*.c'}
  9817. tar: Pattern matching characters used in file names. Please,
  9818. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  9819. tar: suppress this warning.
  9820. tar: *.c: Not found in archive
  9821. tar: Error exit delayed from previous errors
  9822. @end smallexample
  9823. To treat member names as globbing patterns, use the @option{--wildcards} option.
  9824. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  9825. add this option to your @env{TAR_OPTIONS} variable.
  9826. @xref{wildcards}, for the detailed discussion of the use of globbing
  9827. patterns by @GNUTAR{}.
  9828. @item Use of short option @option{-o}.
  9829. Earlier versions of @GNUTAR{} understood @option{-o} command line
  9830. option as a synonym for @option{--old-archive}.
  9831. @GNUTAR{} starting from version 1.13.90 understands this option as
  9832. a synonym for @option{--no-same-owner}. This is compatible with
  9833. UNIX98 @command{tar} implementations.
  9834. However, to facilitate transition, @option{-o} option retains its
  9835. old semantics when it is used with one of archive-creation commands.
  9836. Users are encouraged to use @option{--format=oldgnu} instead.
  9837. It is especially important, since versions of @acronym{GNU} Automake
  9838. up to and including 1.8.4 invoke tar with this option to produce
  9839. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  9840. of this issue and its implications.
  9841. @xref{Options, tar-formats, Changing Automake's Behavior,
  9842. automake, GNU Automake}, for a description on how to use various
  9843. archive formats with @command{automake}.
  9844. Future versions of @GNUTAR{} will understand @option{-o} only as a
  9845. synonym for @option{--no-same-owner}.
  9846. @item Use of short option @option{-l}
  9847. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  9848. synonym for @option{--one-file-system}. Since such usage contradicted
  9849. to UNIX98 specification and harmed compatibility with other
  9850. implementations, it was declared deprecated in version 1.14. However,
  9851. to facilitate transition to its new semantics, it was supported by
  9852. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  9853. variant of @option{--check-links} was introduced in version 1.15.91.
  9854. @item Use of options @option{--portability} and @option{--old-archive}
  9855. These options are deprecated. Please use @option{--format=v7} instead.
  9856. @item Use of option @option{--posix}
  9857. This option is deprecated. Please use @option{--format=posix} instead.
  9858. @end table
  9859. @node Configuring Help Summary
  9860. @appendix Configuring Help Summary
  9861. Running @kbd{tar --help} displays the short @command{tar} option
  9862. summary (@pxref{help}). This summary is organized by @dfn{groups} of
  9863. semantically close options. The options within each group are printed
  9864. in the following order: a short option, eventually followed by a list
  9865. of corresponding long option names, followed by a short description of
  9866. the option. For example, here is an excerpt from the actual @kbd{tar
  9867. --help} output:
  9868. @verbatim
  9869. Main operation mode:
  9870. -A, --catenate, --concatenate append tar files to an archive
  9871. -c, --create create a new archive
  9872. -d, --diff, --compare find differences between archive and
  9873. file system
  9874. --delete delete from the archive
  9875. @end verbatim
  9876. @vrindex ARGP_HELP_FMT, environment variable
  9877. The exact visual representation of the help output is configurable via
  9878. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  9879. is a comma-separated list of @dfn{format variable} assignments. There
  9880. are two kinds of format variables. An @dfn{offset variable} keeps the
  9881. offset of some part of help output text from the leftmost column on
  9882. the screen. A @dfn{boolean} variable is a flag that toggles some
  9883. output feature on or off. Depending on the type of the corresponding
  9884. variable, there are two kinds of assignments:
  9885. @table @asis
  9886. @item Offset assignment
  9887. The assignment to an offset variable has the following syntax:
  9888. @smallexample
  9889. @var{variable}=@var{value}
  9890. @end smallexample
  9891. @noindent
  9892. where @var{variable} is the variable name, and @var{value} is a
  9893. numeric value to be assigned to the variable.
  9894. @item Boolean assignment
  9895. To assign @code{true} value to a variable, simply put this variable name. To
  9896. assign @code{false} value, prefix the variable name with @samp{no-}. For
  9897. example:
  9898. @smallexample
  9899. @group
  9900. # Assign @code{true} value:
  9901. dup-args
  9902. # Assign @code{false} value:
  9903. no-dup-args
  9904. @end group
  9905. @end smallexample
  9906. @end table
  9907. Following variables are declared:
  9908. @deftypevr {Help Output} boolean dup-args
  9909. If true, arguments for an option are shown with both short and long
  9910. options, even when a given option has both forms, for example:
  9911. @smallexample
  9912. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  9913. @end smallexample
  9914. If false, then if an option has both short and long forms, the
  9915. argument is only shown with the long one, for example:
  9916. @smallexample
  9917. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9918. @end smallexample
  9919. @noindent
  9920. and a message indicating that the argument is applicable to both
  9921. forms is printed below the options. This message can be disabled
  9922. using @code{dup-args-note} (see below).
  9923. The default is false.
  9924. @end deftypevr
  9925. @deftypevr {Help Output} boolean dup-args-note
  9926. If this variable is true, which is the default, the following notice
  9927. is displayed at the end of the help output:
  9928. @quotation
  9929. Mandatory or optional arguments to long options are also mandatory or
  9930. optional for any corresponding short options.
  9931. @end quotation
  9932. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  9933. variables @code{dup-args} or @code{dup-args-note} should be set.
  9934. @end deftypevr
  9935. @deftypevr {Help Output} offset short-opt-col
  9936. Column in which short options start. Default is 2.
  9937. @smallexample
  9938. @group
  9939. $ @kbd{tar --help|grep ARCHIVE}
  9940. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9941. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  9942. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9943. @end group
  9944. @end smallexample
  9945. @end deftypevr
  9946. @deftypevr {Help Output} offset long-opt-col
  9947. Column in which long options start. Default is 6. For example:
  9948. @smallexample
  9949. @group
  9950. $ @kbd{tar --help|grep ARCHIVE}
  9951. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9952. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  9953. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9954. @end group
  9955. @end smallexample
  9956. @end deftypevr
  9957. @deftypevr {Help Output} offset doc-opt-col
  9958. Column in which @dfn{doc options} start. A doc option isn't actually
  9959. an option, but rather an arbitrary piece of documentation that is
  9960. displayed in much the same manner as the options. For example, in
  9961. the description of @option{--format} option:
  9962. @smallexample
  9963. @group
  9964. -H, --format=FORMAT create archive of the given format.
  9965. FORMAT is one of the following:
  9966. gnu GNU tar 1.13.x format
  9967. oldgnu GNU format as per tar <= 1.12
  9968. pax POSIX 1003.1-2001 (pax) format
  9969. posix same as pax
  9970. ustar POSIX 1003.1-1988 (ustar) format
  9971. v7 old V7 tar format
  9972. @end group
  9973. @end smallexample
  9974. @noindent
  9975. the format names are doc options. Thus, if you set
  9976. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  9977. will look as follows:
  9978. @smallexample
  9979. @group
  9980. -H, --format=FORMAT create archive of the given format.
  9981. FORMAT is one of the following:
  9982. gnu GNU tar 1.13.x format
  9983. oldgnu GNU format as per tar <= 1.12
  9984. pax POSIX 1003.1-2001 (pax) format
  9985. posix same as pax
  9986. ustar POSIX 1003.1-1988 (ustar) format
  9987. v7 old V7 tar format
  9988. @end group
  9989. @end smallexample
  9990. @end deftypevr
  9991. @deftypevr {Help Output} offset opt-doc-col
  9992. Column in which option description starts. Default is 29.
  9993. @smallexample
  9994. @group
  9995. $ @kbd{tar --help|grep ARCHIVE}
  9996. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9997. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  9998. -f, --file=ARCHIVE use archive file or device ARCHIVE
  9999. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  10000. -f, --file=ARCHIVE
  10001. use archive file or device ARCHIVE
  10002. @end group
  10003. @end smallexample
  10004. @noindent
  10005. Notice, that the description starts on a separate line if
  10006. @code{opt-doc-col} value is too small.
  10007. @end deftypevr
  10008. @deftypevr {Help Output} offset header-col
  10009. Column in which @dfn{group headers} are printed. A group header is a
  10010. descriptive text preceding an option group. For example, in the
  10011. following text:
  10012. @verbatim
  10013. Main operation mode:
  10014. -A, --catenate, --concatenate append tar files to
  10015. an archive
  10016. -c, --create create a new archive
  10017. @end verbatim
  10018. @noindent
  10019. @samp{Main operation mode:} is the group header.
  10020. The default value is 1.
  10021. @end deftypevr
  10022. @deftypevr {Help Output} offset usage-indent
  10023. Indentation of wrapped usage lines. Affects @option{--usage}
  10024. output. Default is 12.
  10025. @end deftypevr
  10026. @deftypevr {Help Output} offset rmargin
  10027. Right margin of the text output. Used for wrapping.
  10028. @end deftypevr
  10029. @node Fixing Snapshot Files
  10030. @appendix Fixing Snapshot Files
  10031. @include tar-snapshot-edit.texi
  10032. @node Tar Internals
  10033. @appendix Tar Internals
  10034. @include intern.texi
  10035. @node Genfile
  10036. @appendix Genfile
  10037. @include genfile.texi
  10038. @node Free Software Needs Free Documentation
  10039. @appendix Free Software Needs Free Documentation
  10040. @include freemanuals.texi
  10041. @node GNU Free Documentation License
  10042. @appendix GNU Free Documentation License
  10043. @include fdl.texi
  10044. @node Index of Command Line Options
  10045. @appendix Index of Command Line Options
  10046. This appendix contains an index of all @GNUTAR{} long command line
  10047. options. The options are listed without the preceding double-dash.
  10048. For a cross-reference of short command line options, see
  10049. @ref{Short Option Summary}.
  10050. @printindex op
  10051. @node Index
  10052. @appendix Index
  10053. @printindex cp
  10054. @summarycontents
  10055. @contents
  10056. @bye
  10057. @c Local variables:
  10058. @c texinfo-column-for-description: 32
  10059. @c End: