tar.texi 381 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294
  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. @include config.texi
  11. @include rendition.texi
  12. @include value.texi
  13. @c Put everything in one index (arbitrarily chosen to be the concept index).
  14. @syncodeindex fn cp
  15. @syncodeindex ky cp
  16. @syncodeindex pg cp
  17. @syncodeindex vr cp
  18. @defindex op
  19. @copying
  20. This manual is for @acronym{GNU} @command{tar} (version
  21. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  22. from archives.
  23. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  24. 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  25. @quotation
  26. Permission is granted to copy, distribute and/or modify this document
  27. under the terms of the GNU Free Documentation License, Version 1.1 or
  28. any later version published by the Free Software Foundation; with no
  29. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  30. and with the Back-Cover Texts as in (a) below. A copy of the license
  31. is included in the section entitled "GNU Free Documentation License".
  32. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  33. this GNU Manual. Buying copies from GNU Press supports the FSF in
  34. developing GNU and promoting software freedom.''
  35. @end quotation
  36. @end copying
  37. @dircategory Archiving
  38. @direntry
  39. * Tar: (tar). Making tape (or disk) archives.
  40. @end direntry
  41. @dircategory Individual utilities
  42. @direntry
  43. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  44. @end direntry
  45. @shorttitlepage @acronym{GNU} @command{tar}
  46. @titlepage
  47. @title @acronym{GNU} tar: an archiver tool
  48. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  49. @author John Gilmore, Jay Fenlason et al.
  50. @page
  51. @vskip 0pt plus 1filll
  52. @insertcopying
  53. @end titlepage
  54. @ifnottex
  55. @node Top
  56. @top @acronym{GNU} tar: an archiver tool
  57. @insertcopying
  58. @cindex file archival
  59. @cindex archiving files
  60. The first part of this master menu lists the major nodes in this Info
  61. document. The rest of the menu lists all the lower level nodes.
  62. @end ifnottex
  63. @c The master menu, created with texinfo-master-menu, goes here.
  64. @c FIXME: Submenus for getdate.texi and intern.texi are interpolated by hand.
  65. @menu
  66. * Introduction::
  67. * Tutorial::
  68. * tar invocation::
  69. * operations::
  70. * Backups::
  71. * Choosing::
  72. * Date input formats::
  73. * Formats::
  74. * Media::
  75. Appendices
  76. * Changes::
  77. * Configuring Help Summary::
  78. * Genfile::
  79. * Tar Internals::
  80. * Free Software Needs Free Documentation::
  81. * Copying This Manual::
  82. * Index of Command Line Options::
  83. * Index::
  84. @detailmenu
  85. --- The Detailed Node Listing ---
  86. Introduction
  87. * Book Contents:: What this Book Contains
  88. * Definitions:: Some Definitions
  89. * What tar Does:: What @command{tar} Does
  90. * Naming tar Archives:: How @command{tar} Archives are Named
  91. * Authors:: @GNUTAR{} Authors
  92. * Reports:: Reporting bugs or suggestions
  93. Tutorial Introduction to @command{tar}
  94. * assumptions::
  95. * stylistic conventions::
  96. * basic tar options:: Basic @command{tar} Operations and Options
  97. * frequent operations::
  98. * Two Frequent Options::
  99. * create:: How to Create Archives
  100. * list:: How to List Archives
  101. * extract:: How to Extract Members from an Archive
  102. * going further::
  103. Two Frequently Used Options
  104. * file tutorial::
  105. * verbose tutorial::
  106. * help tutorial::
  107. How to Create Archives
  108. * prepare for examples::
  109. * Creating the archive::
  110. * create verbose::
  111. * short create::
  112. * create dir::
  113. How to List Archives
  114. * list dir::
  115. How to Extract Members from an Archive
  116. * extracting archives::
  117. * extracting files::
  118. * extract dir::
  119. * extracting untrusted archives::
  120. * failing commands::
  121. Invoking @GNUTAR{}
  122. * Synopsis::
  123. * using tar options::
  124. * Styles::
  125. * All Options::
  126. * help::
  127. * defaults::
  128. * verbose::
  129. * interactive::
  130. The Three Option Styles
  131. * Mnemonic Options:: Mnemonic Option Style
  132. * Short Options:: Short Option Style
  133. * Old Options:: Old Option Style
  134. * Mixing:: Mixing Option Styles
  135. All @command{tar} Options
  136. * Operation Summary::
  137. * Option Summary::
  138. * Short Option Summary::
  139. @GNUTAR{} Operations
  140. * Basic tar::
  141. * Advanced tar::
  142. * create options::
  143. * extract options::
  144. * backup::
  145. * Applications::
  146. * looking ahead::
  147. Advanced @GNUTAR{} Operations
  148. * Operations::
  149. * append::
  150. * update::
  151. * concatenate::
  152. * delete::
  153. * compare::
  154. How to Add Files to Existing Archives: @option{--append}
  155. * appending files:: Appending Files to an Archive
  156. * multiple::
  157. Updating an Archive
  158. * how to update::
  159. Options Used by @option{--create}
  160. * Ignore Failed Read::
  161. Options Used by @option{--extract}
  162. * Reading:: Options to Help Read Archives
  163. * Writing:: Changing How @command{tar} Writes Files
  164. * Scarce:: Coping with Scarce Resources
  165. Options to Help Read Archives
  166. * read full records::
  167. * Ignore Zeros::
  168. Changing How @command{tar} Writes Files
  169. * Dealing with Old Files::
  170. * Overwrite Old Files::
  171. * Keep Old Files::
  172. * Keep Newer Files::
  173. * Unlink First::
  174. * Recursive Unlink::
  175. * Data Modification Times::
  176. * Setting Access Permissions::
  177. * Directory Modification Times and Permissions::
  178. * Writing to Standard Output::
  179. * Writing to an External Program::
  180. * remove files::
  181. Coping with Scarce Resources
  182. * Starting File::
  183. * Same Order::
  184. Performing Backups and Restoring Files
  185. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  186. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  187. * Backup Levels:: Levels of Backups
  188. * Backup Parameters:: Setting Parameters for Backups and Restoration
  189. * Scripted Backups:: Using the Backup Scripts
  190. * Scripted Restoration:: Using the Restore Script
  191. Setting Parameters for Backups and Restoration
  192. * General-Purpose Variables::
  193. * Magnetic Tape Control::
  194. * User Hooks::
  195. * backup-specs example:: An Example Text of @file{Backup-specs}
  196. Choosing Files and Names for @command{tar}
  197. * file:: Choosing the Archive's Name
  198. * Selecting Archive Members::
  199. * files:: Reading Names from a File
  200. * exclude:: Excluding Some Files
  201. * wildcards:: Wildcards Patterns and Matching
  202. * quoting styles:: Ways of Quoting Special Characters in Names
  203. * transform:: Modifying File and Member Names
  204. * after:: Operating Only on New Files
  205. * recurse:: Descending into Directories
  206. * one:: Crossing File System Boundaries
  207. Reading Names from a File
  208. * nul::
  209. Excluding Some Files
  210. * problems with exclude::
  211. Wildcards Patterns and Matching
  212. * controlling pattern-matching::
  213. Crossing File System Boundaries
  214. * directory:: Changing Directory
  215. * absolute:: Absolute File Names
  216. Controlling the Archive Format
  217. * Portability:: Making @command{tar} Archives More Portable
  218. * Compression:: Using Less Space through Compression
  219. * Attributes:: Handling File Attributes
  220. * cpio:: Comparison of @command{tar} and @command{cpio}
  221. Date input formats
  222. * General date syntax:: Common rules.
  223. * Calendar date items:: 19 Dec 1994.
  224. * Time of day items:: 9:20pm.
  225. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  226. * Day of week items:: Monday and others.
  227. * Relative items in date strings:: next tuesday, 2 years ago.
  228. * Pure numbers in date strings:: 19931219, 1440.
  229. * Seconds since the Epoch:: @@1078100502.
  230. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  231. Making @command{tar} Archives More Portable
  232. * Portable Names:: Portable Names
  233. * dereference:: Symbolic Links
  234. * old:: Old V7 Archives
  235. * ustar:: Ustar Archives
  236. * gnu:: GNU and old GNU format archives.
  237. * posix:: @acronym{POSIX} archives
  238. * Checksumming:: Checksumming Problems
  239. * Large or Negative Values:: Large files, negative time stamps, etc.
  240. @GNUTAR{} and @acronym{POSIX} @command{tar}
  241. * PAX keywords:: Controlling Extended Header Keywords.
  242. Using Less Space through Compression
  243. * gzip:: Creating and Reading Compressed Archives
  244. * sparse:: Archiving Sparse Files
  245. Tapes and Other Archive Media
  246. * Device:: Device selection and switching
  247. * Remote Tape Server::
  248. * Common Problems and Solutions::
  249. * Blocking:: Blocking
  250. * Many:: Many archives on one tape
  251. * Using Multiple Tapes:: Using Multiple Tapes
  252. * label:: Including a Label in the Archive
  253. * verify::
  254. * Write Protection::
  255. Blocking
  256. * Format Variations:: Format Variations
  257. * Blocking Factor:: The Blocking Factor of an Archive
  258. Many Archives on One Tape
  259. * Tape Positioning:: Tape Positions and Tape Marks
  260. * mt:: The @command{mt} Utility
  261. Using Multiple Tapes
  262. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  263. * Tape Files:: Tape Files
  264. * Tarcat:: Concatenate Volumes into a Single Archive
  265. GNU tar internals and development
  266. * Genfile::
  267. * Tar Internals::
  268. * Standard::
  269. * Extensions::
  270. * Snapshot Files::
  271. * Dumpdir::
  272. Copying This Manual
  273. * GNU Free Documentation License:: License for copying this manual
  274. @end detailmenu
  275. @end menu
  276. @node Introduction
  277. @chapter Introduction
  278. @GNUTAR{} creates
  279. and manipulates @dfn{archives} which are actually collections of
  280. many other files; the program provides users with an organized and
  281. systematic method for controlling a large amount of data.
  282. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  283. archives need not (and these days, typically do not) reside on tapes.
  284. @menu
  285. * Book Contents:: What this Book Contains
  286. * Definitions:: Some Definitions
  287. * What tar Does:: What @command{tar} Does
  288. * Naming tar Archives:: How @command{tar} Archives are Named
  289. * Authors:: @GNUTAR{} Authors
  290. * Reports:: Reporting bugs or suggestions
  291. @end menu
  292. @node Book Contents
  293. @section What this Book Contains
  294. The first part of this chapter introduces you to various terms that will
  295. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  296. and its documentation, and where you should send bug reports
  297. or comments.
  298. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  299. gentle introduction for people who are new to using @command{tar}. It is
  300. meant to be self contained, not requiring any reading from subsequent
  301. chapters to make sense. It moves from topic to topic in a logical,
  302. progressive order, building on information already explained.
  303. Although the tutorial is paced and structured to allow beginners to
  304. learn how to use @command{tar}, it is not intended solely for beginners.
  305. The tutorial explains how to use the three most frequently used
  306. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  307. two frequently used options (@samp{file} and @samp{verbose}). The other
  308. chapters do not refer to the tutorial frequently; however, if a section
  309. discusses something which is a complex variant of a basic concept, there
  310. may be a cross reference to that basic concept. (The entire book,
  311. including the tutorial, assumes that the reader understands some basic
  312. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  313. The third chapter presents the remaining five operations, and
  314. information about using @command{tar} options and option syntax.
  315. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  316. than the reality. should think about whether this makes sense to say
  317. here, or not.} The other chapters are meant to be used as a
  318. reference. Each chapter presents everything that needs to be said
  319. about a specific topic.
  320. One of the chapters (@pxref{Date input formats}) exists in its
  321. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  322. In addition, one section of this manual (@pxref{Standard}) contains a
  323. big quote which is taken directly from @command{tar} sources.
  324. In general, we give both long and short (abbreviated) option names
  325. at least once in each section where the relevant option is covered, so
  326. that novice readers will become familiar with both styles. (A few
  327. options have no short versions, and the relevant sections will
  328. indicate this.)
  329. @node Definitions
  330. @section Some Definitions
  331. @cindex archive
  332. @cindex tar archive
  333. The @command{tar} program is used to create and manipulate @command{tar}
  334. archives. An @dfn{archive} is a single file which contains the contents
  335. of many files, while still identifying the names of the files, their
  336. owner(s), and so forth. (In addition, archives record access
  337. permissions, user and group, size in bytes, and data modification time.
  338. Some archives also record the file names in each archived directory, as
  339. well as other file and directory information.) You can use @command{tar}
  340. to @dfn{create} a new archive in a specified directory.
  341. @cindex member
  342. @cindex archive member
  343. @cindex file name
  344. @cindex member name
  345. The files inside an archive are called @dfn{members}. Within this
  346. manual, we use the term @dfn{file} to refer only to files accessible in
  347. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  348. @dfn{member} to refer only to the members of an archive. Similarly, a
  349. @dfn{file name} is the name of a file, as it resides in the file system,
  350. and a @dfn{member name} is the name of an archive member within the
  351. archive.
  352. @cindex extraction
  353. @cindex unpacking
  354. The term @dfn{extraction} refers to the process of copying an archive
  355. member (or multiple members) into a file in the file system. Extracting
  356. all the members of an archive is often called @dfn{extracting the
  357. archive}. The term @dfn{unpack} can also be used to refer to the
  358. extraction of many or all the members of an archive. Extracting an
  359. archive does not destroy the archive's structure, just as creating an
  360. archive does not destroy the copies of the files that exist outside of
  361. the archive. You may also @dfn{list} the members in a given archive
  362. (this is often thought of as ``printing'' them to the standard output,
  363. or the command line), or @dfn{append} members to a pre-existing archive.
  364. All of these operations can be performed using @command{tar}.
  365. @node What tar Does
  366. @section What @command{tar} Does
  367. @cindex tar
  368. The @command{tar} program provides the ability to create @command{tar}
  369. archives, as well as various other kinds of manipulation. For example,
  370. you can use @command{tar} on previously created archives to extract files,
  371. to store additional files, or to update or list files which were already
  372. stored.
  373. Initially, @command{tar} archives were used to store files conveniently on
  374. magnetic tape. The name @command{tar} comes from this use; it stands for
  375. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  376. direct its output to available devices, files, or other programs (using
  377. pipes). @command{tar} may even access remote devices or files (as archives).
  378. You can use @command{tar} archives in many ways. We want to stress a few
  379. of them: storage, backup, and transportation.
  380. @FIXME{the following table entries need a bit of work..}
  381. @table @asis
  382. @item Storage
  383. Often, @command{tar} archives are used to store related files for
  384. convenient file transfer over a network. For example, the
  385. @acronym{GNU} Project distributes its software bundled into
  386. @command{tar} archives, so that all the files relating to a particular
  387. program (or set of related programs) can be transferred as a single
  388. unit.
  389. A magnetic tape can store several files in sequence. However, the tape
  390. has no names for these files; it only knows their relative position on
  391. the tape. One way to store several files on one tape and retain their
  392. names is by creating a @command{tar} archive. Even when the basic transfer
  393. mechanism can keep track of names, as FTP can, the nuisance of handling
  394. multiple files, directories, and multiple links makes @command{tar}
  395. archives useful.
  396. Archive files are also used for long-term storage. You can think of
  397. this as transportation from the present into the future. (It is a
  398. science-fiction idiom that you can move through time as well as in
  399. space; the idea here is that @command{tar} can be used to move archives in
  400. all dimensions, even time!)
  401. @item Backup
  402. Because the archive created by @command{tar} is capable of preserving
  403. file information and directory structure, @command{tar} is commonly
  404. used for performing full and incremental backups of disks. A backup
  405. puts a collection of files (possibly pertaining to many users and
  406. projects) together on a disk or a tape. This guards against
  407. accidental destruction of the information in those files.
  408. @GNUTAR{} has special features that allow it to be
  409. used to make incremental and full dumps of all the files in a
  410. file system.
  411. @item Transportation
  412. You can create an archive on one system, transfer it to another system,
  413. and extract the contents there. This allows you to transport a group of
  414. files from one system to another.
  415. @end table
  416. @node Naming tar Archives
  417. @section How @command{tar} Archives are Named
  418. Conventionally, @command{tar} archives are given names ending with
  419. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  420. but this manual follows that convention in order to accustom readers to
  421. it and to make examples more clear.
  422. @cindex tar file
  423. @cindex entry
  424. @cindex tar entry
  425. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  426. archive members as ``files'' or ``entries''. For people familiar with
  427. the operation of @command{tar}, this causes no difficulty. However, in
  428. this manual, we consistently refer to ``archives'' and ``archive
  429. members'' to make learning to use @command{tar} easier for novice users.
  430. @node Authors
  431. @section @GNUTAR{} Authors
  432. @GNUTAR{} was originally written by John Gilmore,
  433. and modified by many people. The @acronym{GNU} enhancements were
  434. written by Jay Fenlason, then Joy Kendall, and the whole package has
  435. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  436. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  437. numerous and kind users.
  438. We wish to stress that @command{tar} is a collective work, and owes much to
  439. all those people who reported problems, offered solutions and other
  440. insights, or shared their thoughts and suggestions. An impressive, yet
  441. partial list of those contributors can be found in the @file{THANKS}
  442. file from the @GNUTAR{} distribution.
  443. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  444. sure i want to spell out the history in this detail, at least not for
  445. the printed book. i'm just not sure it needs to be said this way.
  446. i'll think about it.}
  447. @FIXME{History is more important, and surely more interesting, than
  448. actual names. Quoting names without history would be meaningless. FP}
  449. Jay Fenlason put together a draft of a @GNUTAR{}
  450. manual, borrowing notes from the original man page from John Gilmore.
  451. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  452. Gorin worked on a tutorial and manual for @GNUTAR{}.
  453. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  454. taking information from all these sources and merging them. Melissa
  455. Weisshaus finally edited and redesigned the book to create version
  456. 1.12. The book for versions from 1.14 up to @value{VERSION} were edited
  457. by the current maintainer, Sergey Poznyakoff.
  458. For version 1.12, Daniel Hagerty contributed a great deal of technical
  459. consulting. In particular, he is the primary author of @ref{Backups}.
  460. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  461. (see @url{http://savannah.gnu.org/projects/tar}), and
  462. active development and maintenance work has started
  463. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  464. Poznyakoff and Jeff Bailey.
  465. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  466. @node Reports
  467. @section Reporting bugs or suggestions
  468. @cindex bug reports
  469. @cindex reporting bugs
  470. If you find problems or have suggestions about this program or manual,
  471. please report them to @file{bug-tar@@gnu.org}.
  472. When reporting a bug, please be sure to include as much detail as
  473. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  474. like to make this node as detailed as 'Bug reporting' node in Emacs
  475. manual}.
  476. @node Tutorial
  477. @chapter Tutorial Introduction to @command{tar}
  478. This chapter guides you through some basic examples of three @command{tar}
  479. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  480. you already know how to use some other version of @command{tar}, then you
  481. may not need to read this chapter. This chapter omits most complicated
  482. details about how @command{tar} works.
  483. @menu
  484. * assumptions::
  485. * stylistic conventions::
  486. * basic tar options:: Basic @command{tar} Operations and Options
  487. * frequent operations::
  488. * Two Frequent Options::
  489. * create:: How to Create Archives
  490. * list:: How to List Archives
  491. * extract:: How to Extract Members from an Archive
  492. * going further::
  493. @end menu
  494. @node assumptions
  495. @section Assumptions this Tutorial Makes
  496. This chapter is paced to allow beginners to learn about @command{tar}
  497. slowly. At the same time, we will try to cover all the basic aspects of
  498. these three operations. In order to accomplish both of these tasks, we
  499. have made certain assumptions about your knowledge before reading this
  500. manual, and the hardware you will be using:
  501. @itemize @bullet
  502. @item
  503. Before you start to work through this tutorial, you should understand
  504. what the terms ``archive'' and ``archive member'' mean
  505. (@pxref{Definitions}). In addition, you should understand something
  506. about how Unix-type operating systems work, and you should know how to
  507. use some basic utilities. For example, you should know how to create,
  508. list, copy, rename, edit, and delete files and directories; how to
  509. change between directories; and how to figure out where you are in the
  510. file system. You should have some basic understanding of directory
  511. structure and how files are named according to which directory they are
  512. in. You should understand concepts such as standard output and standard
  513. input, what various definitions of the term ``argument'' mean, and the
  514. differences between relative and absolute path names. @FIXME{and what
  515. else?}
  516. @item
  517. This manual assumes that you are working from your own home directory
  518. (unless we state otherwise). In this tutorial, you will create a
  519. directory to practice @command{tar} commands in. When we show path names,
  520. we will assume that those paths are relative to your home directory.
  521. For example, my home directory path is @file{/home/fsf/melissa}. All of
  522. my examples are in a subdirectory of the directory named by that path
  523. name; the subdirectory is called @file{practice}.
  524. @item
  525. In general, we show examples of archives which exist on (or can be
  526. written to, or worked with from) a directory on a hard disk. In most
  527. cases, you could write those archives to, or work with them on any other
  528. device, such as a tape drive. However, some of the later examples in
  529. the tutorial and next chapter will not work on tape drives.
  530. Additionally, working with tapes is much more complicated than working
  531. with hard disks. For these reasons, the tutorial does not cover working
  532. with tape drives. @xref{Media}, for complete information on using
  533. @command{tar} archives with tape drives.
  534. @FIXME{this is a cop out. need to add some simple tape drive info.}
  535. @end itemize
  536. @node stylistic conventions
  537. @section Stylistic Conventions
  538. In the examples, @samp{$} represents a typical shell prompt. It
  539. precedes lines you should type; to make this more clear, those lines are
  540. shown in @kbd{this font}, as opposed to lines which represent the
  541. computer's response; those lines are shown in @code{this font}, or
  542. sometimes @samp{like this}.
  543. @c When we have lines which are too long to be
  544. @c displayed in any other way, we will show them like this:
  545. @node basic tar options
  546. @section Basic @command{tar} Operations and Options
  547. @command{tar} can take a wide variety of arguments which specify and define
  548. the actions it will have on the particular set of files or the archive.
  549. The main types of arguments to @command{tar} fall into one of two classes:
  550. operations, and options.
  551. Some arguments fall into a class called @dfn{operations}; exactly one of
  552. these is both allowed and required for any instance of using @command{tar};
  553. you may @emph{not} specify more than one. People sometimes speak of
  554. @dfn{operating modes}. You are in a particular operating mode when you
  555. have specified the operation which specifies it; there are eight
  556. operations in total, and thus there are eight operating modes.
  557. The other arguments fall into the class known as @dfn{options}. You are
  558. not required to specify any options, and you are allowed to specify more
  559. than one at a time (depending on the way you are using @command{tar} at
  560. that time). Some options are used so frequently, and are so useful for
  561. helping you type commands more carefully that they are effectively
  562. ``required''. We will discuss them in this chapter.
  563. You can write most of the @command{tar} operations and options in any
  564. of three forms: long (mnemonic) form, short form, and old style. Some
  565. of the operations and options have no short or ``old'' forms; however,
  566. the operations and options which we will cover in this tutorial have
  567. corresponding abbreviations. @FIXME{make sure this is still the case,
  568. at the end}We will indicate those abbreviations appropriately to get
  569. you used to seeing them. (Note that the ``old style'' option forms
  570. exist in @GNUTAR{} for compatibility with Unix
  571. @command{tar}. In this book we present a full discussion of this way
  572. of writing options and operations (@pxref{Old Options}), and we discuss
  573. the other two styles of writing options (@xref{Mnemonic Options}, and
  574. @pxref{Short Options}).
  575. In the examples and in the text of this tutorial, we usually use the
  576. long forms of operations and options; but the ``short'' forms produce
  577. the same result and can make typing long @command{tar} commands easier.
  578. For example, instead of typing
  579. @smallexample
  580. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  581. @end smallexample
  582. @noindent
  583. you can type
  584. @smallexample
  585. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  586. @end smallexample
  587. @noindent
  588. or even
  589. @smallexample
  590. @kbd{tar -cvf afiles.tar apple angst aspic}
  591. @end smallexample
  592. @noindent
  593. For more information on option syntax, see @ref{Advanced tar}. In
  594. discussions in the text, when we name an option by its long form, we
  595. also give the corresponding short option in parentheses.
  596. The term, ``option'', can be confusing at times, since ``operations''
  597. are often lumped in with the actual, @emph{optional} ``options'' in certain
  598. general class statements. For example, we just talked about ``short and
  599. long forms of options and operations''. However, experienced @command{tar}
  600. users often refer to these by shorthand terms such as, ``short and long
  601. options''. This term assumes that the ``operations'' are included, also.
  602. Context will help you determine which definition of ``options'' to use.
  603. Similarly, the term ``command'' can be confusing, as it is often used in
  604. two different ways. People sometimes refer to @command{tar} ``commands''.
  605. A @command{tar} @dfn{command} is the entire command line of user input
  606. which tells @command{tar} what to do --- including the operation, options,
  607. and any arguments (file names, pipes, other commands, etc). However,
  608. you will also sometimes hear the term ``the @command{tar} command''. When
  609. the word ``command'' is used specifically like this, a person is usually
  610. referring to the @command{tar} @emph{operation}, not the whole line.
  611. Again, use context to figure out which of the meanings the speaker
  612. intends.
  613. @node frequent operations
  614. @section The Three Most Frequently Used Operations
  615. Here are the three most frequently used operations (both short and long
  616. forms), as well as a brief description of their meanings. The rest of
  617. this chapter will cover how to use these operations in detail. We will
  618. present the rest of the operations in the next chapter.
  619. @table @option
  620. @item --create
  621. @itemx -c
  622. Create a new @command{tar} archive.
  623. @item --list
  624. @itemx -t
  625. List the contents of an archive.
  626. @item --extract
  627. @itemx -x
  628. Extract one or more members from an archive.
  629. @end table
  630. @node Two Frequent Options
  631. @section Two Frequently Used Options
  632. To understand how to run @command{tar} in the three operating modes listed
  633. previously, you also need to understand how to use two of the options to
  634. @command{tar}: @option{--file} (which takes an archive file as an argument)
  635. and @option{--verbose}. (You are usually not @emph{required} to specify
  636. either of these options when you run @command{tar}, but they can be very
  637. useful in making things more clear and helping you avoid errors.)
  638. @menu
  639. * file tutorial::
  640. * verbose tutorial::
  641. * help tutorial::
  642. @end menu
  643. @node file tutorial
  644. @unnumberedsubsec The @option{--file} Option
  645. @table @option
  646. @opindex file, tutorial
  647. @item --file=@var{archive-name}
  648. @itemx -f @var{archive-name}
  649. Specify the name of an archive file.
  650. @end table
  651. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  652. use @command{tar}; this option determines the name of the archive file
  653. that @command{tar} will work on.
  654. @vrindex TAPE
  655. If you don't specify this argument, then @command{tar} will examine
  656. the environment variable @env{TAPE}. If it is set, its value will be
  657. used as the archive name. Otherwise, @command{tar} will use the
  658. default archive, determined at the compile time. Usually it is
  659. standard output or some physical tape drive attached to your machine
  660. (you can verify what the default is by running @kbd{tar
  661. --show-defaults}, @pxref{defaults}). If there is no tape drive
  662. attached, or the default is not meaningful, then @command{tar} will
  663. print an error message. The error message might look roughly like one
  664. of the following:
  665. @smallexample
  666. tar: can't open /dev/rmt8 : No such device or address
  667. tar: can't open /dev/rsmt0 : I/O error
  668. @end smallexample
  669. @noindent
  670. To avoid confusion, we recommend that you always specify an archive file
  671. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  672. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  673. @ref{file}.
  674. @node verbose tutorial
  675. @unnumberedsubsec The @option{--verbose} Option
  676. @table @option
  677. @opindex verbose, introduced
  678. @item --verbose
  679. @itemx -v
  680. Show the files being worked on as @command{tar} is running.
  681. @end table
  682. @option{--verbose} (@option{-v}) shows details about the results of running
  683. @command{tar}. This can be especially useful when the results might not be
  684. obvious. For example, if you want to see the progress of @command{tar} as
  685. it writes files into the archive, you can use the @option{--verbose}
  686. option. In the beginning, you may find it useful to use
  687. @option{--verbose} at all times; when you are more accustomed to
  688. @command{tar}, you will likely want to use it at certain times but not at
  689. others. We will use @option{--verbose} at times to help make something
  690. clear, and we will give many examples both using and not using
  691. @option{--verbose} to show the differences.
  692. Each instance of @option{--verbose} on the command line increases the
  693. verbosity level by one, so if you need more details on the output,
  694. specify it twice.
  695. When reading archives (@option{--list}, @option{--extract},
  696. @option{--diff}), @command{tar} by default prints only the names of
  697. the members being extracted. Using @option{--verbose} will show a full,
  698. @command{ls} style member listing.
  699. In contrast, when writing archives (@option{--create}, @option{--append},
  700. @option{--update}), @command{tar} does not print file names by
  701. default. So, a single @option{--verbose} option shows the file names
  702. being added to the archive, while two @option{--verbose} options
  703. enable the full listing.
  704. For example, to create an archive in verbose mode:
  705. @smallexample
  706. $ @kbd{tar -cvf afiles.tar apple angst aspic}
  707. apple
  708. angst
  709. aspic
  710. @end smallexample
  711. @noindent
  712. Creating the same archive with the verbosity level 2 could give:
  713. @smallexample
  714. $ @kbd{tar -cvvf afiles.tar apple angst aspic}
  715. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  716. -rw-r--r-- gray/staff 11481 2006-06-09 12:06 angst
  717. -rw-r--r-- gray/staff 23152 2006-06-09 12:06 aspic
  718. @end smallexample
  719. @noindent
  720. This works equally well using short or long forms of options. Using
  721. long forms, you would simply write out the mnemonic form of the option
  722. twice, like this:
  723. @smallexample
  724. $ @kbd{tar --create --verbose --verbose @dots{}}
  725. @end smallexample
  726. @noindent
  727. Note that you must double the hyphens properly each time.
  728. Later in the tutorial, we will give examples using @w{@option{--verbose
  729. --verbose}}.
  730. The full output consists of six fields:
  731. @itemize @bullet
  732. @item File type and permissions in symbolic form.
  733. These are displayed in the same format as the first column of
  734. @command{ls -l} output (@pxref{What information is listed,
  735. format=verbose, Verbose listing, fileutils, GNU file utilities}).
  736. @item Owner name and group separated by a slash character.
  737. If these data are not available (for example, when listing a @samp{v7} format
  738. archive), numeric ID values are printed instead.
  739. @item Size of the file, in bytes.
  740. @item File modification date in ISO 8601 format.
  741. @item File modification time.
  742. @item File name.
  743. If the name contains any special characters (white space, newlines,
  744. etc.) these are displayed in an unambiguous form using so called
  745. @dfn{quoting style}. For the detailed discussion of available styles
  746. and on how to use them, see @ref{quoting styles}.
  747. Depending on the file type, the name can be followed by some
  748. additional information, described in the following table:
  749. @table @samp
  750. @item -> @var{link-name}
  751. The file or archive member is a @dfn{symbolic link} and
  752. @var{link-name} is the name of file it links to.
  753. @item link to @var{link-name}
  754. The file or archive member is a @dfn{hard link} and @var{link-name} is
  755. the name of file it links to.
  756. @item --Long Link--
  757. The archive member is an old GNU format long link. You will normally
  758. not encounter this.
  759. @item --Long Name--
  760. The archive member is an old GNU format long name. You will normally
  761. not encounter this.
  762. @item --Volume Header--
  763. The archive member is a GNU @dfn{volume header} (@pxref{Tape Files}).
  764. @item --Continued at byte @var{n}--
  765. Encountered only at the beginning of a multy-volume archive
  766. (@pxref{Using Multiple Tapes}). This archive member is a continuation
  767. from the previous volume. The number @var{n} gives the offset where
  768. the original file was split.
  769. @item --Mangled file names--
  770. This archive member contains @dfn{mangled file names} declarations,
  771. a special member type that was used by early versions of @GNUTAR{}.
  772. You probably will never encounter this, unless you are reading a very
  773. old archive.
  774. @item unknown file type @var{c}
  775. An archive member of unknown type. @var{c} is the type character from
  776. the archive header. If you encounter such a message, it means that
  777. either your archive contains proprietary member types @GNUTAR{} is not
  778. able to handle, or the archive is corrupted.
  779. @end table
  780. @end itemize
  781. For example, here is an archive listing containing most of the special
  782. suffixes explained above:
  783. @smallexample
  784. @group
  785. V--------- 0/0 1536 2006-06-09 13:07 MyVolume--Volume Header--
  786. -rw-r--r-- gray/staff 456783 2006-06-09 12:06 aspic--Continued at
  787. byte 32456--
  788. -rw-r--r-- gray/staff 62373 2006-06-09 12:06 apple
  789. lrwxrwxrwx gray/staff 0 2006-06-09 13:01 angst -> apple
  790. -rw-r--r-- gray/staff 35793 2006-06-09 12:06 blues
  791. hrw-r--r-- gray/staff 0 2006-06-09 12:06 music link to blues
  792. @end group
  793. @end smallexample
  794. @smallexample
  795. @end smallexample
  796. @node help tutorial
  797. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  798. @table @option
  799. @opindex help
  800. @item --help
  801. The @option{--help} option to @command{tar} prints out a very brief list of
  802. all operations and option available for the current version of
  803. @command{tar} available on your system.
  804. @end table
  805. @node create
  806. @section How to Create Archives
  807. @UNREVISED
  808. @cindex Creation of the archive
  809. @cindex Archive, creation of
  810. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  811. you use to create a @command{tar} archive. We will explain
  812. @option{--create} first because, in order to learn about the other
  813. operations, you will find it useful to have an archive available to
  814. practice on.
  815. To make this easier, in this section you will first create a directory
  816. containing three files. Then, we will show you how to create an
  817. @emph{archive} (inside the new directory). Both the directory, and
  818. the archive are specifically for you to practice on. The rest of this
  819. chapter and the next chapter will show many examples using this
  820. directory and the files you will create: some of those files may be
  821. other directories and other archives.
  822. The three files you will archive in this example are called
  823. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  824. @file{collection.tar}.
  825. This section will proceed slowly, detailing how to use @option{--create}
  826. in @code{verbose} mode, and showing examples using both short and long
  827. forms. In the rest of the tutorial, and in the examples in the next
  828. chapter, we will proceed at a slightly quicker pace. This section
  829. moves more slowly to allow beginning users to understand how
  830. @command{tar} works.
  831. @menu
  832. * prepare for examples::
  833. * Creating the archive::
  834. * create verbose::
  835. * short create::
  836. * create dir::
  837. @end menu
  838. @node prepare for examples
  839. @subsection Preparing a Practice Directory for Examples
  840. To follow along with this and future examples, create a new directory
  841. called @file{practice} containing files called @file{blues}, @file{folk}
  842. and @file{jazz}. The files can contain any information you like:
  843. ideally, they should contain information which relates to their names,
  844. and be of different lengths. Our examples assume that @file{practice}
  845. is a subdirectory of your home directory.
  846. Now @command{cd} to the directory named @file{practice}; @file{practice}
  847. is now your @dfn{working directory}. (@emph{Please note}: Although
  848. the full path name of this directory is
  849. @file{/@var{homedir}/practice}, in our examples we will refer to
  850. this directory as @file{practice}; the @var{homedir} is presumed.
  851. In general, you should check that the files to be archived exist where
  852. you think they do (in the working directory) by running @command{ls}.
  853. Because you just created the directory and the files and have changed to
  854. that directory, you probably don't need to do that this time.
  855. It is very important to make sure there isn't already a file in the
  856. working directory with the archive name you intend to use (in this case,
  857. @samp{collection.tar}), or that you don't care about its contents.
  858. Whenever you use @samp{create}, @command{tar} will erase the current
  859. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  860. will not tell you if you are about to overwrite an archive unless you
  861. specify an option which does this (@pxref{backup}, for the
  862. information on how to do so). To add files to an existing archive,
  863. you need to use a different option, such as @option{--append} (@option{-r}); see
  864. @ref{append} for information on how to do this.
  865. @node Creating the archive
  866. @subsection Creating the Archive
  867. @opindex create, introduced
  868. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  869. archive named @file{collection.tar}, use the following command:
  870. @smallexample
  871. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  872. @end smallexample
  873. The order of the arguments is not very important, @emph{when using long
  874. option forms}. You could also say:
  875. @smallexample
  876. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  877. @end smallexample
  878. @noindent
  879. However, you can see that this order is harder to understand; this is
  880. why we will list the arguments in the order that makes the commands
  881. easiest to understand (and we encourage you to do the same when you use
  882. @command{tar}, to avoid errors).
  883. Note that the part of the command which says,
  884. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  885. If you substituted any other string of characters for
  886. @kbd{collection.tar}, then that string would become the name of the
  887. archive file you create.
  888. The order of the options becomes more important when you begin to use
  889. short forms. With short forms, if you type commands in the wrong order
  890. (even if you type them correctly in all other ways), you may end up with
  891. results you don't expect. For this reason, it is a good idea to get
  892. into the habit of typing options in the order that makes inherent sense.
  893. @xref{short create}, for more information on this.
  894. In this example, you type the command as shown above: @option{--create}
  895. is the operation which creates the new archive
  896. (@file{collection.tar}), and @option{--file} is the option which lets
  897. you give it the name you chose. The files, @file{blues}, @file{folk},
  898. and @file{jazz}, are now members of the archive, @file{collection.tar}
  899. (they are @dfn{file name arguments} to the @option{--create} operation.
  900. @xref{Choosing}, for the detailed discussion on these.) Now that they are
  901. in the archive, they are called @emph{archive members}, not files.
  902. (@pxref{Definitions,members}).
  903. When you create an archive, you @emph{must} specify which files you
  904. want placed in the archive. If you do not specify any archive
  905. members, @GNUTAR{} will complain.
  906. If you now list the contents of the working directory (@command{ls}), you will
  907. find the archive file listed as well as the files you saw previously:
  908. @smallexample
  909. blues folk jazz collection.tar
  910. @end smallexample
  911. @noindent
  912. Creating the archive @samp{collection.tar} did not destroy the copies of
  913. the files in the directory.
  914. Keep in mind that if you don't indicate an operation, @command{tar} will not
  915. run and will prompt you for one. If you don't name any files, @command{tar}
  916. will complain. You must have write access to the working directory,
  917. or else you will not be able to create an archive in that directory.
  918. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  919. an existing archive; it will delete the archive and write a new one.
  920. Use @option{--append} (@option{-r}) instead. @xref{append}.
  921. @node create verbose
  922. @subsection Running @option{--create} with @option{--verbose}
  923. @opindex create, using with @option{--verbose}
  924. @opindex verbose, using with @option{--create}
  925. If you include the @option{--verbose} (@option{-v}) option on the command line,
  926. @command{tar} will list the files it is acting on as it is working. In
  927. verbose mode, the @code{create} example above would appear as:
  928. @smallexample
  929. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  930. blues
  931. folk
  932. jazz
  933. @end smallexample
  934. This example is just like the example we showed which did not use
  935. @option{--verbose}, except that @command{tar} generated the remaining lines
  936. @iftex
  937. (note the different font styles).
  938. @end iftex
  939. @ifinfo
  940. .
  941. @end ifinfo
  942. In the rest of the examples in this chapter, we will frequently use
  943. @code{verbose} mode so we can show actions or @command{tar} responses that
  944. you would otherwise not see, and which are important for you to
  945. understand.
  946. @node short create
  947. @subsection Short Forms with @samp{create}
  948. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  949. basic uses of @command{tar}, and you will use it countless times.
  950. Eventually, you will probably want to use abbreviated (or ``short'')
  951. forms of options. A full discussion of the three different forms that
  952. options can take appears in @ref{Styles}; for now, here is what the
  953. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  954. using short option forms:
  955. @smallexample
  956. $ @kbd{tar -cvf collection.tar blues folk jazz}
  957. blues
  958. folk
  959. jazz
  960. @end smallexample
  961. @noindent
  962. As you can see, the system responds the same no matter whether you use
  963. long or short option forms.
  964. @FIXME{i don't like how this is worded:} One difference between using
  965. short and long option forms is that, although the exact placement of
  966. arguments following options is no more specific when using short forms,
  967. it is easier to become confused and make a mistake when using short
  968. forms. For example, suppose you attempted the above example in the
  969. following way:
  970. @smallexample
  971. $ @kbd{tar -cfv collection.tar blues folk jazz}
  972. @end smallexample
  973. @noindent
  974. In this case, @command{tar} will make an archive file called @file{v},
  975. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  976. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  977. is thus taken to be the chosen archive file name. @command{tar} will try
  978. to add a file called @file{collection.tar} to the @file{v} archive file;
  979. if the file @file{collection.tar} did not already exist, @command{tar} will
  980. report an error indicating that this file does not exist. If the file
  981. @file{collection.tar} does already exist (e.g., from a previous command
  982. you may have run), then @command{tar} will add this file to the archive.
  983. Because the @option{-v} option did not get registered, @command{tar} will not
  984. run under @samp{verbose} mode, and will not report its progress.
  985. The end result is that you may be quite confused about what happened,
  986. and possibly overwrite a file. To illustrate this further, we will show
  987. you how an example we showed previously would look using short forms.
  988. This example,
  989. @smallexample
  990. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  991. @end smallexample
  992. @noindent
  993. is confusing as it is. When shown using short forms, however, it
  994. becomes much more so:
  995. @smallexample
  996. $ @kbd{tar blues -c folk -f collection.tar jazz}
  997. @end smallexample
  998. @noindent
  999. It would be very easy to put the wrong string of characters
  1000. immediately following the @option{-f}, but doing that could sacrifice
  1001. valuable data.
  1002. For this reason, we recommend that you pay very careful attention to
  1003. the order of options and placement of file and archive names,
  1004. especially when using short option forms. Not having the option name
  1005. written out mnemonically can affect how well you remember which option
  1006. does what, and therefore where different names have to be placed.
  1007. @node create dir
  1008. @subsection Archiving Directories
  1009. @cindex Archiving Directories
  1010. @cindex Directories, Archiving
  1011. You can archive a directory by specifying its directory name as a
  1012. file name argument to @command{tar}. The files in the directory will be
  1013. archived relative to the working directory, and the directory will be
  1014. re-created along with its contents when the archive is extracted.
  1015. To archive a directory, first move to its superior directory. If you
  1016. have followed the previous instructions in this tutorial, you should
  1017. type:
  1018. @smallexample
  1019. $ @kbd{cd ..}
  1020. $
  1021. @end smallexample
  1022. @noindent
  1023. This will put you into the directory which contains @file{practice},
  1024. i.e., your home directory. Once in the superior directory, you can
  1025. specify the subdirectory, @file{practice}, as a file name argument. To
  1026. store @file{practice} in the new archive file @file{music.tar}, type:
  1027. @smallexample
  1028. $ @kbd{tar --create --verbose --file=music.tar practice}
  1029. @end smallexample
  1030. @noindent
  1031. @command{tar} should output:
  1032. @smallexample
  1033. practice/
  1034. practice/blues
  1035. practice/folk
  1036. practice/jazz
  1037. practice/collection.tar
  1038. @end smallexample
  1039. Note that the archive thus created is not in the subdirectory
  1040. @file{practice}, but rather in the current working directory---the
  1041. directory from which @command{tar} was invoked. Before trying to archive a
  1042. directory from its superior directory, you should make sure you have
  1043. write access to the superior directory itself, not only the directory
  1044. you are trying archive with @command{tar}. For example, you will probably
  1045. not be able to store your home directory in an archive by invoking
  1046. @command{tar} from the root directory; @xref{absolute}. (Note
  1047. also that @file{collection.tar}, the original archive file, has itself
  1048. been archived. @command{tar} will accept any file as a file to be
  1049. archived, regardless of its content. When @file{music.tar} is
  1050. extracted, the archive file @file{collection.tar} will be re-written
  1051. into the file system).
  1052. If you give @command{tar} a command such as
  1053. @smallexample
  1054. $ @kbd{tar --create --file=foo.tar .}
  1055. @end smallexample
  1056. @noindent
  1057. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1058. dumped}. This happens because @command{tar} creates the archive
  1059. @file{foo.tar} in the current directory before putting any files into
  1060. it. Then, when @command{tar} attempts to add all the files in the
  1061. directory @file{.} to the archive, it notices that the file
  1062. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1063. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1064. will continue in this case, and create the archive
  1065. normally, except for the exclusion of that one file. (@emph{Please
  1066. note:} Other implementations of @command{tar} may not be so clever;
  1067. they will enter an infinite loop when this happens, so you should not
  1068. depend on this behavior unless you are certain you are running
  1069. @GNUTAR{}. In general, it is wise to always place the archive outside
  1070. of the directory being dumped.
  1071. @node list
  1072. @section How to List Archives
  1073. @opindex list
  1074. Frequently, you will find yourself wanting to determine exactly what a
  1075. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  1076. to get the member names as they currently appear in the archive, as well
  1077. as various attributes of the files at the time they were archived. For
  1078. example, you can examine the archive @file{collection.tar} that you
  1079. created in the last section with the command,
  1080. @smallexample
  1081. $ @kbd{tar --list --file=collection.tar}
  1082. @end smallexample
  1083. @noindent
  1084. The output of @command{tar} would then be:
  1085. @smallexample
  1086. blues
  1087. folk
  1088. jazz
  1089. @end smallexample
  1090. @noindent
  1091. The archive @file{bfiles.tar} would list as follows:
  1092. @smallexample
  1093. ./birds
  1094. baboon
  1095. ./box
  1096. @end smallexample
  1097. @noindent
  1098. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1099. @var{archive-name}}) option just as with @option{--create}
  1100. (@option{-c}) to specify the name of the archive.
  1101. @opindex list, using with @option{--verbose}
  1102. @opindex verbose, using with @option{--list}
  1103. If you use the @option{--verbose} (@option{-v}) option with
  1104. @option{--list}, then @command{tar} will print out a listing
  1105. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so forth.
  1106. If you had used @option{--verbose} (@option{-v}) mode, the example
  1107. above would look like:
  1108. @smallexample
  1109. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1110. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1111. @end smallexample
  1112. @cindex listing member and file names
  1113. @anchor{listing member and file names}
  1114. It is important to notice that the output of @kbd{tar --list
  1115. --verbose} does not necessarily match that produced by @kbd{tar
  1116. --create --verbose} while creating the archive. It is because
  1117. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1118. prefixes from file names before storing them in the archive
  1119. (@xref{absolute}, for more information). In other
  1120. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1121. an archive and @dfn{member names} when listing it. Consider this
  1122. example:
  1123. @smallexample
  1124. @group
  1125. $ @kbd{tar cfv archive /etc/mail}
  1126. tar: Removing leading `/' from member names
  1127. /etc/mail/
  1128. /etc/mail/sendmail.cf
  1129. /etc/mail/aliases
  1130. $ @kbd{tar tf archive}
  1131. etc/mail/
  1132. etc/mail/sendmail.cf
  1133. etc/mail/aliases
  1134. @end group
  1135. @end smallexample
  1136. @opindex show-stored-names
  1137. This default behavior can sometimes be inconvenient. You can force
  1138. @GNUTAR{} show member names when creating archive by supplying
  1139. @option{--show-stored-names} option.
  1140. @table @option
  1141. @item --show-stored-names
  1142. Print member (as opposed to @emph{file}) names when creating the archive.
  1143. @end table
  1144. @cindex File name arguments, using @option{--list} with
  1145. @opindex list, using with file name arguments
  1146. You can specify one or more individual member names as arguments when
  1147. using @samp{list}. In this case, @command{tar} will only list the
  1148. names of members you identify. For example, @w{@kbd{tar --list
  1149. --file=afiles.tar apple}} would only print @file{apple}.
  1150. Because @command{tar} preserves paths, file names must be specified as
  1151. they appear in the archive (ie., relative to the directory from which
  1152. the archive was created). Therefore, it is essential when specifying
  1153. member names to @command{tar} that you give the exact member names.
  1154. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1155. error message something like @samp{tar: birds: Not found in archive},
  1156. because there is no member named @file{birds}, only one named
  1157. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1158. the same file, @emph{member} names by default are compared verbatim.
  1159. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1160. with @file{baboon}, because this exact member name is in the archive file
  1161. @file{bfiles.tar}. If you are not sure of the exact file name,
  1162. use @dfn{globbing patterns}, for example:
  1163. @smallexample
  1164. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1165. @end smallexample
  1166. @noindent
  1167. will list all members whose name contains @samp{b}. @xref{wildcards},
  1168. for a detailed discussion of globbing patterns and related
  1169. @command{tar} command line options.
  1170. @menu
  1171. * list dir::
  1172. @end menu
  1173. @node list dir
  1174. @unnumberedsubsec Listing the Contents of a Stored Directory
  1175. To get information about the contents of an archived directory,
  1176. use the directory name as a file name argument in conjunction with
  1177. @option{--list} (@option{-t}). To find out file attributes, include the
  1178. @option{--verbose} (@option{-v}) option.
  1179. For example, to find out about files in the directory @file{practice}, in
  1180. the archive file @file{music.tar}, type:
  1181. @smallexample
  1182. $ @kbd{tar --list --verbose --file=music.tar practice}
  1183. @end smallexample
  1184. @command{tar} responds:
  1185. @smallexample
  1186. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1187. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1188. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1189. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1190. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1191. @end smallexample
  1192. When you use a directory name as a file name argument, @command{tar} acts on
  1193. all the files (including sub-directories) in that directory.
  1194. @node extract
  1195. @section How to Extract Members from an Archive
  1196. @UNREVISED
  1197. @cindex Extraction
  1198. @cindex Retrieving files from an archive
  1199. @cindex Resurrecting files from an archive
  1200. @opindex extract
  1201. Creating an archive is only half the job---there is no point in storing
  1202. files in an archive if you can't retrieve them. The act of retrieving
  1203. members from an archive so they can be used and manipulated as
  1204. unarchived files again is called @dfn{extraction}. To extract files
  1205. from an archive, use the @option{--extract} (@option{--get} or
  1206. @option{-x}) operation. As with @option{--create}, specify the name
  1207. of the archive with @option{--file} (@option{-f}) option. Extracting
  1208. an archive does not modify the archive in any way; you can extract it
  1209. multiple times if you want or need to.
  1210. Using @option{--extract}, you can extract an entire archive, or specific
  1211. files. The files can be directories containing other files, or not. As
  1212. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1213. long form of the operation without affecting the performance.
  1214. @menu
  1215. * extracting archives::
  1216. * extracting files::
  1217. * extract dir::
  1218. * extracting untrusted archives::
  1219. * failing commands::
  1220. @end menu
  1221. @node extracting archives
  1222. @subsection Extracting an Entire Archive
  1223. To extract an entire archive, specify the archive file name only, with
  1224. no individual file names as arguments. For example,
  1225. @smallexample
  1226. $ @kbd{tar -xvf collection.tar}
  1227. @end smallexample
  1228. @noindent
  1229. produces this:
  1230. @smallexample
  1231. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1232. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1233. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1234. @end smallexample
  1235. @node extracting files
  1236. @subsection Extracting Specific Files
  1237. To extract specific archive members, give their exact member names as
  1238. arguments, as printed by @option{--list} (@option{-t}). If you had
  1239. mistakenly deleted one of the files you had placed in the archive
  1240. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1241. from the archive without changing the archive's structure. Its
  1242. contents will be identical to the original file @file{blues} that you
  1243. deleted.
  1244. First, make sure you are in the @file{practice} directory, and list the
  1245. files in the directory. Now, delete the file, @samp{blues}, and list
  1246. the files in the directory again.
  1247. You can now extract the member @file{blues} from the archive file
  1248. @file{collection.tar} like this:
  1249. @smallexample
  1250. $ @kbd{tar --extract --file=collection.tar blues}
  1251. @end smallexample
  1252. @noindent
  1253. If you list the files in the directory again, you will see that the file
  1254. @file{blues} has been restored, with its original permissions, data
  1255. modification times, and owner.@footnote{This is only accidentally
  1256. true, but not in general. Whereas modification times are always
  1257. restored, in most cases, one has to be root for restoring the owner,
  1258. and use a special option for restoring permissions. Here, it just
  1259. happens that the restoring user is also the owner of the archived
  1260. members, and that the current @code{umask} is compatible with original
  1261. permissions.} (These parameters will be identical to those which
  1262. the file had when you originally placed it in the archive; any changes
  1263. you may have made before deleting the file from the file system,
  1264. however, will @emph{not} have been made to the archive member.) The
  1265. archive file, @samp{collection.tar}, is the same as it was before you
  1266. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1267. @option{--list} (@option{-t}).
  1268. Remember that as with other operations, specifying the exact member
  1269. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1270. will fail, because there is no member named @file{birds}. To extract
  1271. the member named @file{./birds}, you must specify @w{@kbd{tar
  1272. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1273. exact member names, use @option{--list} (@option{-t}) option
  1274. (@pxref{list}). You can also extract those members that match a
  1275. specific @dfn{globbing pattern}. For example, to extract from
  1276. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1277. directory prefix, you could type:
  1278. @smallexample
  1279. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1280. @end smallexample
  1281. @noindent
  1282. Here, @option{--wildcards} instructs @command{tar} to treat
  1283. command line arguments as globbing patterns and @option{--no-anchored}
  1284. informs it that the patterns apply to member names after any @samp{/}
  1285. delimiter. The use of globbing patterns is discussed in detail in
  1286. @xref{wildcards}.
  1287. You can extract a file to standard output by combining the above options
  1288. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1289. Output}).
  1290. If you give the @option{--verbose} option, then @option{--extract}
  1291. will print the names of the archive members as it extracts them.
  1292. @node extract dir
  1293. @subsection Extracting Files that are Directories
  1294. Extracting directories which are members of an archive is similar to
  1295. extracting other files. The main difference to be aware of is that if
  1296. the extracted directory has the same name as any directory already in
  1297. the working directory, then files in the extracted directory will be
  1298. placed into the directory of the same name. Likewise, if there are
  1299. files in the pre-existing directory with the same names as the members
  1300. which you extract, the files from the extracted archive will replace
  1301. the files already in the working directory (and possible
  1302. subdirectories). This will happen regardless of whether or not the
  1303. files in the working directory were more recent than those extracted
  1304. (there exist, however, special options that alter this behavior
  1305. @pxref{Writing}).
  1306. However, if a file was stored with a directory name as part of its file
  1307. name, and that directory does not exist under the working directory when
  1308. the file is extracted, @command{tar} will create the directory.
  1309. We can demonstrate how to use @option{--extract} to extract a directory
  1310. file with an example. Change to the @file{practice} directory if you
  1311. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1312. go back to the parent directory and extract the archive
  1313. @file{music.tar}. You may either extract the entire archive, or you may
  1314. extract only the files you just deleted. To extract the entire archive,
  1315. don't give any file names as arguments after the archive name
  1316. @file{music.tar}. To extract only the files you deleted, use the
  1317. following command:
  1318. @smallexample
  1319. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1320. practice/folk
  1321. practice/jazz
  1322. @end smallexample
  1323. @noindent
  1324. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1325. would have displayed more detail about the extracted files, as shown
  1326. in the example below:
  1327. @smallexample
  1328. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1329. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1330. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1331. @end smallexample
  1332. @noindent
  1333. Because you created the directory with @file{practice} as part of the
  1334. file names of each of the files by archiving the @file{practice}
  1335. directory as @file{practice}, you must give @file{practice} as part
  1336. of the file names when you extract those files from the archive.
  1337. @node extracting untrusted archives
  1338. @subsection Extracting Archives from Untrusted Sources
  1339. Extracting files from archives can overwrite files that already exist.
  1340. If you receive an archive from an untrusted source, you should make a
  1341. new directory and extract into that directory, so that you don't have
  1342. to worry about the extraction overwriting one of your existing files.
  1343. For example, if @file{untrusted.tar} came from somewhere else on the
  1344. Internet, and you don't necessarily trust its contents, you can
  1345. extract it as follows:
  1346. @smallexample
  1347. $ @kbd{mkdir newdir}
  1348. $ @kbd{cd newdir}
  1349. $ @kbd{tar -xvf ../untrusted.tar}
  1350. @end smallexample
  1351. It is also a good practice to examine contents of the archive
  1352. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1353. with @option{--verbose} (@option{-v}).
  1354. @node failing commands
  1355. @subsection Commands That Will Fail
  1356. Here are some sample commands you might try which will not work, and why
  1357. they won't work.
  1358. If you try to use this command,
  1359. @smallexample
  1360. $ @kbd{tar -xvf music.tar folk jazz}
  1361. @end smallexample
  1362. @noindent
  1363. you will get the following response:
  1364. @smallexample
  1365. tar: folk: Not found in archive
  1366. tar: jazz: Not found in archive
  1367. $
  1368. @end smallexample
  1369. @noindent
  1370. This is because these files were not originally @emph{in} the parent
  1371. directory @file{..}, where the archive is located; they were in the
  1372. @file{practice} directory, and their file names reflect this:
  1373. @smallexample
  1374. $ @kbd{tar -tvf music.tar}
  1375. practice/folk
  1376. practice/jazz
  1377. practice/rock
  1378. @end smallexample
  1379. @FIXME{make sure the above works when going through the examples in
  1380. order...}
  1381. @noindent
  1382. Likewise, if you try to use this command,
  1383. @smallexample
  1384. $ @kbd{tar -tvf music.tar folk jazz}
  1385. @end smallexample
  1386. @noindent
  1387. you would get a similar response. Members with those names are not in the
  1388. archive. You must use the correct member names, or wildcards, in order
  1389. to extract the files from the archive.
  1390. If you have forgotten the correct names of the files in the archive,
  1391. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1392. @FIXME{more examples, here? hag thinks it's a good idea.}
  1393. @node going further
  1394. @section Going Further Ahead in this Manual
  1395. @FIXME{need to write up a node here about the things that are going to
  1396. be in the rest of the manual.}
  1397. @node tar invocation
  1398. @chapter Invoking @GNUTAR{}
  1399. @UNREVISED
  1400. This chapter is about how one invokes the @GNUTAR{}
  1401. command, from the command synopsis (@pxref{Synopsis}). There are
  1402. numerous options, and many styles for writing them. One mandatory
  1403. option specifies the operation @command{tar} should perform
  1404. (@pxref{Operation Summary}), other options are meant to detail how
  1405. this operation should be performed (@pxref{Option Summary}).
  1406. Non-option arguments are not always interpreted the same way,
  1407. depending on what the operation is.
  1408. You will find in this chapter everything about option styles and rules for
  1409. writing them (@pxref{Styles}). On the other hand, operations and options
  1410. are fully described elsewhere, in other chapters. Here, you will find
  1411. only synthetic descriptions for operations and options, together with
  1412. pointers to other parts of the @command{tar} manual.
  1413. Some options are so special they are fully described right in this
  1414. chapter. They have the effect of inhibiting the normal operation of
  1415. @command{tar} or else, they globally alter the amount of feedback the user
  1416. receives about what is going on. These are the @option{--help} and
  1417. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1418. and @option{--interactive} options (@pxref{interactive}).
  1419. @menu
  1420. * Synopsis::
  1421. * using tar options::
  1422. * Styles::
  1423. * All Options::
  1424. * help::
  1425. * defaults::
  1426. * verbose::
  1427. * interactive::
  1428. @end menu
  1429. @node Synopsis
  1430. @section General Synopsis of @command{tar}
  1431. The @GNUTAR{} program is invoked as either one of:
  1432. @smallexample
  1433. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1434. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1435. @end smallexample
  1436. The second form is for when old options are being used.
  1437. You can use @command{tar} to store files in an archive, to extract them from
  1438. an archive, and to do other types of archive manipulation. The primary
  1439. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1440. which action to take. The other arguments to @command{tar} are either
  1441. @dfn{options}, which change the way @command{tar} performs an operation,
  1442. or file names or archive members, which specify the files or members
  1443. @command{tar} is to act on.
  1444. You can actually type in arguments in any order, even if in this manual
  1445. the options always precede the other arguments, to make examples easier
  1446. to understand. Further, the option stating the main operation mode
  1447. (the @command{tar} main command) is usually given first.
  1448. Each @var{name} in the synopsis above is interpreted as an archive member
  1449. name when the main command is one of @option{--compare}
  1450. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1451. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1452. @option{--update} (@option{-u}). When naming archive members, you
  1453. must give the exact name of the member in the archive, as it is
  1454. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1455. @option{--create} (@option{-c}), these @var{name} arguments specify
  1456. the names of either files or directory hierarchies to place in the archive.
  1457. These files or hierarchies should already exist in the file system,
  1458. prior to the execution of the @command{tar} command.
  1459. @command{tar} interprets relative file names as being relative to the
  1460. working directory. @command{tar} will make all file names relative
  1461. (by removing leading slashes when archiving or restoring files),
  1462. unless you specify otherwise (using the @option{--absolute-names}
  1463. option). @xref{absolute}, for more information about
  1464. @option{--absolute-names}.
  1465. If you give the name of a directory as either a file name or a member
  1466. name, then @command{tar} acts recursively on all the files and directories
  1467. beneath that directory. For example, the name @file{/} identifies all
  1468. the files in the file system to @command{tar}.
  1469. The distinction between file names and archive member names is especially
  1470. important when shell globbing is used, and sometimes a source of confusion
  1471. for newcomers. @xref{wildcards}, for more information about globbing.
  1472. The problem is that shells may only glob using existing files in the
  1473. file system. Only @command{tar} itself may glob on archive members, so when
  1474. needed, you must ensure that wildcard characters reach @command{tar} without
  1475. being interpreted by the shell first. Using a backslash before @samp{*}
  1476. or @samp{?}, or putting the whole argument between quotes, is usually
  1477. sufficient for this.
  1478. Even if @var{name}s are often specified on the command line, they
  1479. can also be read from a text file in the file system, using the
  1480. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1481. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1482. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1483. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1484. will usually yield a diagnostic and inhibit @command{tar} execution.
  1485. The other operations of @command{tar} (@option{--list},
  1486. @option{--extract}, @option{--compare}, and @option{--update})
  1487. will act on the entire contents of the archive.
  1488. @cindex exit status
  1489. @cindex return status
  1490. Besides successful exits, @GNUTAR{} may fail for
  1491. many reasons. Some reasons correspond to bad usage, that is, when the
  1492. @command{tar} command is improperly written. Errors may be
  1493. encountered later, while encountering an error processing the archive
  1494. or the files. Some errors are recoverable, in which case the failure
  1495. is delayed until @command{tar} has completed all its work. Some
  1496. errors are such that it would not meaningful, or at least risky, to
  1497. continue processing: @command{tar} then aborts processing immediately.
  1498. All abnormal exits, whether immediate or delayed, should always be
  1499. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1500. the error.
  1501. @GNUTAR{} returns only a few exit statuses. I'm really
  1502. aiming simplicity in that area, for now. If you are not using the
  1503. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1504. that everything went well, besides maybe innocuous warnings. Nonzero
  1505. means that something went wrong. Right now, as of today, ``nonzero''
  1506. is almost always 2, except for remote operations, where it may be
  1507. 128.
  1508. @node using tar options
  1509. @section Using @command{tar} Options
  1510. @GNUTAR{} has a total of eight operating modes which
  1511. allow you to perform a variety of tasks. You are required to choose
  1512. one operating mode each time you employ the @command{tar} program by
  1513. specifying one, and only one operation as an argument to the
  1514. @command{tar} command (two lists of four operations each may be found
  1515. at @ref{frequent operations} and @ref{Operations}). Depending on
  1516. circumstances, you may also wish to customize how the chosen operating
  1517. mode behaves. For example, you may wish to change the way the output
  1518. looks, or the format of the files that you wish to archive may require
  1519. you to do something special in order to make the archive look right.
  1520. You can customize and control @command{tar}'s performance by running
  1521. @command{tar} with one or more options (such as @option{--verbose}
  1522. (@option{-v}), which we used in the tutorial). As we said in the
  1523. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1524. their name suggests) optional. Depending on the operating mode, you
  1525. may specify one or more options. Different options will have different
  1526. effects, but in general they all change details of the operation, such
  1527. as archive format, archive name, or level of user interaction. Some
  1528. options make sense with all operating modes, while others are
  1529. meaningful only with particular modes. You will likely use some
  1530. options frequently, while you will only use others infrequently, or
  1531. not at all. (A full list of options is available in @pxref{All Options}.)
  1532. @vrindex TAR_OPTIONS, environment variable
  1533. @anchor{TAR_OPTIONS}
  1534. The @env{TAR_OPTIONS} environment variable specifies default options to
  1535. be placed in front of any explicit options. For example, if
  1536. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1537. if the two options @option{-v} and @option{--unlink-first} had been
  1538. specified before any explicit options. Option specifications are
  1539. separated by whitespace. A backslash escapes the next character, so it
  1540. can be used to specify an option containing whitespace or a backslash.
  1541. Note that @command{tar} options are case sensitive. For example, the
  1542. options @option{-T} and @option{-t} are different; the first requires an
  1543. argument for stating the name of a file providing a list of @var{name}s,
  1544. while the second does not require an argument and is another way to
  1545. write @option{--list} (@option{-t}).
  1546. In addition to the eight operations, there are many options to
  1547. @command{tar}, and three different styles for writing both: long (mnemonic)
  1548. form, short form, and old style. These styles are discussed below.
  1549. Both the options and the operations can be written in any of these three
  1550. styles.
  1551. @FIXME{menu at end of this node. need to think of an actual outline
  1552. for this chapter; probably do that after stuff from chapter 4 is
  1553. incorporated.}
  1554. @node Styles
  1555. @section The Three Option Styles
  1556. There are three styles for writing operations and options to the command
  1557. line invoking @command{tar}. The different styles were developed at
  1558. different times during the history of @command{tar}. These styles will be
  1559. presented below, from the most recent to the oldest.
  1560. Some options must take an argument. (For example, @option{--file}
  1561. (@option{-f})) takes the name of an archive file as an argument. If
  1562. you do not supply an archive file name, @command{tar} will use a
  1563. default, but this can be confusing; thus, we recommend that you always
  1564. supply a specific archive file name.) Where you @emph{place} the
  1565. arguments generally depends on which style of options you choose. We
  1566. will detail specific information relevant to each option style in the
  1567. sections on the different option styles, below. The differences are
  1568. subtle, yet can often be very important; incorrect option placement
  1569. can cause you to overwrite a number of important files. We urge you
  1570. to note these differences, and only use the option style(s) which
  1571. makes the most sense to you until you feel comfortable with the others.
  1572. Some options @emph{may} take an argument (currently, there are
  1573. two such options: @option{--backup} and @option{--occurrence}). Such
  1574. options may have at most long and short forms, they do not have old style
  1575. equivalent. The rules for specifying an argument for such options
  1576. are stricter than those for specifying mandatory arguments. Please,
  1577. pay special attention to them.
  1578. @menu
  1579. * Mnemonic Options:: Mnemonic Option Style
  1580. * Short Options:: Short Option Style
  1581. * Old Options:: Old Option Style
  1582. * Mixing:: Mixing Option Styles
  1583. @end menu
  1584. @node Mnemonic Options
  1585. @subsection Mnemonic Option Style
  1586. @FIXME{have to decide whether or not to replace other occurrences of
  1587. "mnemonic" with "long", or *ugh* vice versa.}
  1588. Each option has at least one long (or mnemonic) name starting with two
  1589. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1590. their corresponding short or old names. It sometimes happens that a
  1591. single mnemonic option has many different different names which are
  1592. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1593. long option names can be given unique abbreviations. For example,
  1594. @option{--cre} can be used in place of @option{--create} because there is no
  1595. other mnemonic option which begins with @samp{cre}. (One way to find
  1596. this out is by trying it and seeing what happens; if a particular
  1597. abbreviation could represent more than one option, @command{tar} will tell
  1598. you that that abbreviation is ambiguous and you'll know that that
  1599. abbreviation won't work. You may also choose to run @samp{tar --help}
  1600. to see a list of options. Be aware that if you run @command{tar} with a
  1601. unique abbreviation for the long name of an option you didn't want to
  1602. use, you are stuck; @command{tar} will perform the command as ordered.)
  1603. Mnemonic options are meant to be obvious and easy to remember, and their
  1604. meanings are generally easier to discern than those of their
  1605. corresponding short options (see below). For example:
  1606. @smallexample
  1607. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1608. @end smallexample
  1609. @noindent
  1610. gives a fairly good set of hints about what the command does, even
  1611. for those not fully acquainted with @command{tar}.
  1612. Mnemonic options which require arguments take those arguments
  1613. immediately following the option name. There are two ways of
  1614. specifying a mandatory argument. It can be separated from the
  1615. option name either by an equal sign, or by any amount of
  1616. white space characters. For example, the @option{--file} option (which
  1617. tells the name of the @command{tar} archive) is given a file such as
  1618. @file{archive.tar} as argument by using any of the following notations:
  1619. @option{--file=archive.tar} or @option{--file archive.tar}.
  1620. In contrast, optional arguments must always be introduced using
  1621. an equal sign. For example, the @option{--backup} option takes
  1622. an optional argument specifying backup type. It must be used
  1623. as @option{--backup=@var{backup-type}}.
  1624. @node Short Options
  1625. @subsection Short Option Style
  1626. Most options also have a short option name. Short options start with
  1627. a single dash, and are followed by a single character, e.g., @option{-t}
  1628. (which is equivalent to @option{--list}). The forms are absolutely
  1629. identical in function; they are interchangeable.
  1630. The short option names are faster to type than long option names.
  1631. Short options which require arguments take their arguments immediately
  1632. following the option, usually separated by white space. It is also
  1633. possible to stick the argument right after the short option name, using
  1634. no intervening space. For example, you might write @w{@option{-f
  1635. archive.tar}} or @option{-farchive.tar} instead of using
  1636. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1637. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1638. specific archive, here named @file{archive.tar}.
  1639. Short options which take optional arguments take their arguments
  1640. immediately following the option letter, @emph{without any intervening
  1641. white space characters}.
  1642. Short options' letters may be clumped together, but you are not
  1643. required to do this (as compared to old options; see below). When
  1644. short options are clumped as a set, use one (single) dash for them
  1645. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1646. such a set is allowed to have an argument@footnote{Clustering many
  1647. options, the last of which has an argument, is a rather opaque way to
  1648. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1649. even be made helpful enough for considering such usages as invalid.}.
  1650. When the options are separated, the argument for each option which requires
  1651. an argument directly follows that option, as is usual for Unix programs.
  1652. For example:
  1653. @smallexample
  1654. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1655. @end smallexample
  1656. If you reorder short options' locations, be sure to move any arguments
  1657. that belong to them. If you do not move the arguments properly, you may
  1658. end up overwriting files.
  1659. @node Old Options
  1660. @subsection Old Option Style
  1661. @UNREVISED
  1662. Like short options, old options are single letters. However, old options
  1663. must be written together as a single clumped set, without spaces separating
  1664. them or dashes preceding them@footnote{Beware that if you precede options
  1665. with a dash, you are announcing the short option style instead of the
  1666. old option style; short options are decoded differently.}. This set
  1667. of letters must be the first to appear on the command line, after the
  1668. @command{tar} program name and some white space; old options cannot appear
  1669. anywhere else. The letter of an old option is exactly the same letter as
  1670. the corresponding short option. For example, the old option @samp{t} is
  1671. the same as the short option @option{-t}, and consequently, the same as the
  1672. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1673. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1674. When options that need arguments are given together with the command,
  1675. all the associated arguments follow, in the same order as the options.
  1676. Thus, the example given previously could also be written in the old
  1677. style as follows:
  1678. @smallexample
  1679. $ @kbd{tar cvbf 20 /dev/rmt0}
  1680. @end smallexample
  1681. @noindent
  1682. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1683. the argument of @option{-f}.
  1684. On the other hand, this old style syntax makes it difficult to match
  1685. option letters with their corresponding arguments, and is often
  1686. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1687. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1688. argument for @option{-f}, and @option{-v} does not have a corresponding
  1689. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1690. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1691. pertain to.
  1692. If you want to reorder the letters in the old option argument, be
  1693. sure to reorder any corresponding argument appropriately.
  1694. This old way of writing @command{tar} options can surprise even experienced
  1695. users. For example, the two commands:
  1696. @smallexample
  1697. @kbd{tar cfz archive.tar.gz file}
  1698. @kbd{tar -cfz archive.tar.gz file}
  1699. @end smallexample
  1700. @noindent
  1701. are quite different. The first example uses @file{archive.tar.gz} as
  1702. the value for option @samp{f} and recognizes the option @samp{z}. The
  1703. second example, however, uses @file{z} as the value for option
  1704. @samp{f} --- probably not what was intended.
  1705. Old options are kept for compatibility with old versions of @command{tar}.
  1706. This second example could be corrected in many ways, among which the
  1707. following are equivalent:
  1708. @smallexample
  1709. @kbd{tar -czf archive.tar.gz file}
  1710. @kbd{tar -cf archive.tar.gz -z file}
  1711. @kbd{tar cf archive.tar.gz -z file}
  1712. @end smallexample
  1713. @cindex option syntax, traditional
  1714. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1715. non-@acronym{GNU}, support old options. @GNUTAR{}
  1716. supports them not only for historical reasons, but also because many
  1717. people are used to them. For compatibility with Unix @command{tar},
  1718. the first argument is always treated as containing command and option
  1719. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1720. equivalent to @w{@samp{tar -c}:} both of them specify the
  1721. @option{--create} (@option{-c}) command to create an archive.
  1722. @node Mixing
  1723. @subsection Mixing Option Styles
  1724. All three styles may be intermixed in a single @command{tar} command,
  1725. so long as the rules for each style are fully
  1726. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1727. a bug prevented intermixing old style options with mnemonic options in
  1728. some cases.}. Old style options and either of the modern styles of
  1729. options may be mixed within a single @command{tar} command. However,
  1730. old style options must be introduced as the first arguments only,
  1731. following the rule for old options (old options must appear directly
  1732. after the @command{tar} command and some white space). Modern options
  1733. may be given only after all arguments to the old options have been
  1734. collected. If this rule is not respected, a modern option might be
  1735. falsely interpreted as the value of the argument to one of the old
  1736. style options.
  1737. For example, all the following commands are wholly equivalent, and
  1738. illustrate the many combinations and orderings of option styles.
  1739. @smallexample
  1740. @kbd{tar --create --file=archive.tar}
  1741. @kbd{tar --create -f archive.tar}
  1742. @kbd{tar --create -farchive.tar}
  1743. @kbd{tar --file=archive.tar --create}
  1744. @kbd{tar --file=archive.tar -c}
  1745. @kbd{tar -c --file=archive.tar}
  1746. @kbd{tar -c -f archive.tar}
  1747. @kbd{tar -c -farchive.tar}
  1748. @kbd{tar -cf archive.tar}
  1749. @kbd{tar -cfarchive.tar}
  1750. @kbd{tar -f archive.tar --create}
  1751. @kbd{tar -f archive.tar -c}
  1752. @kbd{tar -farchive.tar --create}
  1753. @kbd{tar -farchive.tar -c}
  1754. @kbd{tar c --file=archive.tar}
  1755. @kbd{tar c -f archive.tar}
  1756. @kbd{tar c -farchive.tar}
  1757. @kbd{tar cf archive.tar}
  1758. @kbd{tar f archive.tar --create}
  1759. @kbd{tar f archive.tar -c}
  1760. @kbd{tar fc archive.tar}
  1761. @end smallexample
  1762. On the other hand, the following commands are @emph{not} equivalent to
  1763. the previous set:
  1764. @smallexample
  1765. @kbd{tar -f -c archive.tar}
  1766. @kbd{tar -fc archive.tar}
  1767. @kbd{tar -fcarchive.tar}
  1768. @kbd{tar -farchive.tarc}
  1769. @kbd{tar cfarchive.tar}
  1770. @end smallexample
  1771. @noindent
  1772. These last examples mean something completely different from what the
  1773. user intended (judging based on the example in the previous set which
  1774. uses long options, whose intent is therefore very clear). The first
  1775. four specify that the @command{tar} archive would be a file named
  1776. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1777. respectively. The first two examples also specify a single non-option,
  1778. @var{name} argument having the value @samp{archive.tar}. The last
  1779. example contains only old style option letters (repeating option
  1780. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1781. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1782. the first sentence of this paragraph..}
  1783. @node All Options
  1784. @section All @command{tar} Options
  1785. The coming manual sections contain an alphabetical listing of all
  1786. @command{tar} operations and options, with brief descriptions and cross
  1787. references to more in-depth explanations in the body of the manual.
  1788. They also contain an alphabetically arranged table of the short option
  1789. forms with their corresponding long option. You can use this table as
  1790. a reference for deciphering @command{tar} commands in scripts.
  1791. @menu
  1792. * Operation Summary::
  1793. * Option Summary::
  1794. * Short Option Summary::
  1795. @end menu
  1796. @node Operation Summary
  1797. @subsection Operations
  1798. @table @option
  1799. @opindex append, summary
  1800. @item --append
  1801. @itemx -r
  1802. Appends files to the end of the archive. @xref{append}.
  1803. @opindex catenate, summary
  1804. @item --catenate
  1805. @itemx -A
  1806. Same as @option{--concatenate}. @xref{concatenate}.
  1807. @opindex compare, summary
  1808. @item --compare
  1809. @itemx -d
  1810. Compares archive members with their counterparts in the file
  1811. system, and reports differences in file size, mode, owner,
  1812. modification date and contents. @xref{compare}.
  1813. @opindex concatenate, summary
  1814. @item --concatenate
  1815. @itemx -A
  1816. Appends other @command{tar} archives to the end of the archive.
  1817. @xref{concatenate}.
  1818. @opindex create, summary
  1819. @item --create
  1820. @itemx -c
  1821. Creates a new @command{tar} archive. @xref{create}.
  1822. @opindex delete, summary
  1823. @item --delete
  1824. Deletes members from the archive. Don't try this on a archive on a
  1825. tape! @xref{delete}.
  1826. @opindex diff, summary
  1827. @item --diff
  1828. @itemx -d
  1829. Same @option{--compare}. @xref{compare}.
  1830. @opindex extract, summary
  1831. @item --extract
  1832. @itemx -x
  1833. Extracts members from the archive into the file system. @xref{extract}.
  1834. @opindex get, summary
  1835. @item --get
  1836. @itemx -x
  1837. Same as @option{--extract}. @xref{extract}.
  1838. @opindex list, summary
  1839. @item --list
  1840. @itemx -t
  1841. Lists the members in an archive. @xref{list}.
  1842. @opindex update, summary
  1843. @item --update
  1844. @itemx -u
  1845. Adds files to the end of the archive, but only if they are newer than
  1846. their counterparts already in the archive, or if they do not already
  1847. exist in the archive. @xref{update}.
  1848. @end table
  1849. @node Option Summary
  1850. @subsection @command{tar} Options
  1851. @table @option
  1852. @opindex absolute-names, summary
  1853. @item --absolute-names
  1854. @itemx -P
  1855. Normally when creating an archive, @command{tar} strips an initial
  1856. @samp{/} from member names. This option disables that behavior.
  1857. @xref{absolute}.
  1858. @opindex after-date, summary
  1859. @item --after-date
  1860. (See @option{--newer}, @pxref{after})
  1861. @opindex anchored, summary
  1862. @item --anchored
  1863. A pattern must match an initial subsequence of the name's components.
  1864. @xref{controlling pattern-matching}.
  1865. @opindex atime-preserve, summary
  1866. @item --atime-preserve
  1867. @itemx --atime-preserve=replace
  1868. @itemx --atime-preserve=system
  1869. Attempt to preserve the access time of files when reading them. This
  1870. option currently is effective only on files that you own, unless you
  1871. have superuser privileges.
  1872. @option{--atime-preserve=replace} remembers the access time of a file
  1873. before reading it, and then restores the access time afterwards. This
  1874. may cause problems if other programs are reading the file at the same
  1875. time, as the times of their accesses will be lost. On most platforms
  1876. restoring the access time also requires @command{tar} to restore the
  1877. data modification time too, so this option may also cause problems if
  1878. other programs are writing the file at the same time. (Tar attempts
  1879. to detect this situation, but cannot do so reliably due to race
  1880. conditions.) Worse, on most platforms restoring the access time also
  1881. updates the status change time, which means that this option is
  1882. incompatible with incremental backups.
  1883. @option{--atime-preserve=system} avoids changing time stamps on files,
  1884. without interfering with time stamp updates
  1885. caused by other programs, so it works better with incremental backups.
  1886. However, it requires a special @code{O_NOATIME} option from the
  1887. underlying operating and file system implementation, and it also requires
  1888. that searching directories does not update their access times. As of
  1889. this writing (November 2005) this works only with Linux, and only with
  1890. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1891. way to know whether this feature actually works. Sometimes
  1892. @command{tar} knows that it does not work, and if you use
  1893. @option{--atime-preserve=system} then @command{tar} complains and
  1894. exits right away. But other times @command{tar} might think that the
  1895. option works when it actually does not.
  1896. Currently @option{--atime-preserve} with no operand defaults to
  1897. @option{--atime-preserve=replace}, but this may change in the future
  1898. as support for @option{--atime-preserve=system} improves.
  1899. If your operating system does not support
  1900. @option{--atime-preserve=system}, you might be able to preserve access
  1901. times reliably by by using the @command{mount} command. For example,
  1902. you can mount the file system read-only, or access the file system via
  1903. a read-only loopback mount, or use the @samp{noatime} mount option
  1904. available on some systems. However, mounting typically requires
  1905. superuser privileges and can be a pain to manage.
  1906. @opindex backup, summary
  1907. @item --backup=@var{backup-type}
  1908. Rather than deleting files from the file system, @command{tar} will
  1909. back them up using simple or numbered backups, depending upon
  1910. @var{backup-type}. @xref{backup}.
  1911. @opindex block-number, summary
  1912. @item --block-number
  1913. @itemx -R
  1914. With this option present, @command{tar} prints error messages for read errors
  1915. with the block number in the archive file. @xref{block-number}.
  1916. @opindex blocking-factor, summary
  1917. @item --blocking-factor=@var{blocking}
  1918. @itemx -b @var{blocking}
  1919. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1920. record. @xref{Blocking Factor}.
  1921. @opindex bzip2, summary
  1922. @item --bzip2
  1923. @itemx -j
  1924. This option tells @command{tar} to read or write archives through
  1925. @code{bzip2}. @xref{gzip}.
  1926. @opindex checkpoint, summary
  1927. @item --checkpoint[=@var{number}]
  1928. This option directs @command{tar} to print periodic checkpoint
  1929. messages as it reads through the archive. It is intended for when you
  1930. want a visual indication that @command{tar} is still running, but
  1931. don't want to see @option{--verbose} output. For a detailed
  1932. description, see @ref{Progress information}.
  1933. @opindex check-links, summary
  1934. @item --check-links
  1935. @itemx -l
  1936. If this option was given, @command{tar} will check the number of links
  1937. dumped for each processed file. If this number does not match the
  1938. total number of hard links for the file, a warning message will be
  1939. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1940. synonym for @option{--one-file-system}. The current semantics, which
  1941. complies to UNIX98, was introduced with version
  1942. 1.15.91. @xref{Changes}, for more information.}.
  1943. @opindex compress, summary
  1944. @opindex uncompress, summary
  1945. @item --compress
  1946. @itemx --uncompress
  1947. @itemx -Z
  1948. @command{tar} will use the @command{compress} program when reading or
  1949. writing the archive. This allows you to directly act on archives
  1950. while saving space. @xref{gzip}.
  1951. @opindex confirmation, summary
  1952. @item --confirmation
  1953. (See @option{--interactive}.) @xref{interactive}.
  1954. @opindex delay-directory-restore, summary
  1955. @item --delay-directory-restore
  1956. Delay setting modification times and permissions of extracted
  1957. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1958. @opindex dereference, summary
  1959. @item --dereference
  1960. @itemx -h
  1961. When creating a @command{tar} archive, @command{tar} will archive the
  1962. file that a symbolic link points to, rather than archiving the
  1963. symlink. @xref{dereference}.
  1964. @opindex directory, summary
  1965. @item --directory=@var{dir}
  1966. @itemx -C @var{dir}
  1967. When this option is specified, @command{tar} will change its current directory
  1968. to @var{dir} before performing any operations. When this option is used
  1969. during archive creation, it is order sensitive. @xref{directory}.
  1970. @opindex exclude, summary
  1971. @item --exclude=@var{pattern}
  1972. When performing operations, @command{tar} will skip files that match
  1973. @var{pattern}. @xref{exclude}.
  1974. @opindex exclude-from, summary
  1975. @item --exclude-from=@var{file}
  1976. @itemx -X @var{file}
  1977. Similar to @option{--exclude}, except @command{tar} will use the list of
  1978. patterns in the file @var{file}. @xref{exclude}.
  1979. @opindex exclude-caches, summary
  1980. @item --exclude-caches
  1981. Automatically excludes all directories
  1982. containing a cache directory tag. @xref{exclude}.
  1983. @opindex file, summary
  1984. @item --file=@var{archive}
  1985. @itemx -f @var{archive}
  1986. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1987. performs operations on, rather than @command{tar}'s compilation dependent
  1988. default. @xref{file tutorial}.
  1989. @opindex files-from, summary
  1990. @item --files-from=@var{file}
  1991. @itemx -T @var{file}
  1992. @command{tar} will use the contents of @var{file} as a list of archive members
  1993. or files to operate on, in addition to those specified on the
  1994. command-line. @xref{files}.
  1995. @opindex force-local, summary
  1996. @item --force-local
  1997. Forces @command{tar} to interpret the filename given to @option{--file}
  1998. as a local file, even if it looks like a remote tape drive name.
  1999. @xref{local and remote archives}.
  2000. @opindex format, summary
  2001. @item --format=@var{format}
  2002. Selects output archive format. @var{Format} may be one of the
  2003. following:
  2004. @table @samp
  2005. @item v7
  2006. Creates an archive that is compatible with Unix V7 @command{tar}.
  2007. @item oldgnu
  2008. Creates an archive that is compatible with GNU @command{tar} version
  2009. 1.12 or earlier.
  2010. @item gnu
  2011. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2012. @samp{oldgnu} with the only difference in the way it handles long
  2013. numeric fields.
  2014. @item ustar
  2015. Creates a @acronym{POSIX.1-1988} compatible archive.
  2016. @item posix
  2017. Creates a @acronym{POSIX.1-2001 archive}.
  2018. @end table
  2019. @xref{Formats}, for a detailed discussion of these formats.
  2020. @opindex group, summary
  2021. @item --group=@var{group}
  2022. Files added to the @command{tar} archive will have a group id of @var{group},
  2023. rather than the group from the source file. @var{group} is first decoded
  2024. as a group symbolic name, but if this interpretation fails, it has to be
  2025. a decimal numeric group ID. @FIXME-xref{}
  2026. Also see the comments for the @option{--owner=@var{user}} option.
  2027. @opindex gzip, summary
  2028. @opindex gunzip, summary
  2029. @opindex ungzip, summary
  2030. @item --gzip
  2031. @itemx --gunzip
  2032. @itemx --ungzip
  2033. @itemx -z
  2034. This option tells @command{tar} to read or write archives through
  2035. @command{gzip}, allowing @command{tar} to directly operate on several
  2036. kinds of compressed archives transparently. @xref{gzip}.
  2037. @opindex help, summary
  2038. @item --help
  2039. @command{tar} will print out a short message summarizing the operations and
  2040. options to @command{tar} and exit. @xref{help}.
  2041. @opindex ignore-case, summary
  2042. @item --ignore-case
  2043. Ignore case when matching member or file names with
  2044. patterns. @xref{controlling pattern-matching}.
  2045. @opindex ignore-command-error, summary
  2046. @item --ignore-command-error
  2047. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  2048. @opindex ignore-failed-read, summary
  2049. @item --ignore-failed-read
  2050. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2051. @xref{Reading}.
  2052. @opindex ignore-zeros, summary
  2053. @item --ignore-zeros
  2054. @itemx -i
  2055. With this option, @command{tar} will ignore zeroed blocks in the
  2056. archive, which normally signals EOF. @xref{Reading}.
  2057. @opindex incremental, summary
  2058. @item --incremental
  2059. @itemx -G
  2060. Used to inform @command{tar} that it is working with an old
  2061. @acronym{GNU}-format incremental backup archive. It is intended
  2062. primarily for backwards compatibility only. @xref{Incremental Dumps},
  2063. for a detailed discussion of incremental archives.
  2064. @opindex index-file, summary
  2065. @item --index-file=@var{file}
  2066. Send verbose output to @var{file} instead of to standard output.
  2067. @opindex info-script, summary
  2068. @opindex new-volume-script, summary
  2069. @item --info-script=@var{script-file}
  2070. @itemx --new-volume-script=@var{script-file}
  2071. @itemx -F @var{script-file}
  2072. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2073. at the end of each tape. If @var{script-file} exits with nonzero status,
  2074. @command{tar} fails immediately. @xref{info-script}, for a detailed
  2075. discussion of @var{script-file}.
  2076. @opindex interactive, summary
  2077. @item --interactive
  2078. @itemx --confirmation
  2079. @itemx -w
  2080. Specifies that @command{tar} should ask the user for confirmation before
  2081. performing potentially destructive options, such as overwriting files.
  2082. @xref{interactive}.
  2083. @opindex keep-newer-files, summary
  2084. @item --keep-newer-files
  2085. Do not replace existing files that are newer than their archive copies
  2086. when extracting files from an archive.
  2087. @opindex keep-old-files, summary
  2088. @item --keep-old-files
  2089. @itemx -k
  2090. Do not overwrite existing files when extracting files from an archive.
  2091. @xref{Keep Old Files}.
  2092. @opindex label, summary
  2093. @item --label=@var{name}
  2094. @itemx -V @var{name}
  2095. When creating an archive, instructs @command{tar} to write @var{name}
  2096. as a name record in the archive. When extracting or listing archives,
  2097. @command{tar} will only operate on archives that have a label matching
  2098. the pattern specified in @var{name}. @xref{Tape Files}.
  2099. @opindex listed-incremental, summary
  2100. @item --listed-incremental=@var{snapshot-file}
  2101. @itemx -g @var{snapshot-file}
  2102. During a @option{--create} operation, specifies that the archive that
  2103. @command{tar} creates is a new @acronym{GNU}-format incremental
  2104. backup, using @var{snapshot-file} to determine which files to backup.
  2105. With other operations, informs @command{tar} that the archive is in
  2106. incremental format. @xref{Incremental Dumps}.
  2107. @opindex mode, summary
  2108. @item --mode=@var{permissions}
  2109. When adding files to an archive, @command{tar} will use
  2110. @var{permissions} for the archive members, rather than the permissions
  2111. from the files. The program @command{chmod} and this @command{tar}
  2112. option share the same syntax for what @var{permissions} might be.
  2113. @xref{File permissions, Permissions, File permissions, fileutils,
  2114. @acronym{GNU} file utilities}. This reference also has useful
  2115. information for those not being overly familiar with the Unix
  2116. permission system.
  2117. Of course, @var{permissions} might be plainly specified as an octal number.
  2118. However, by using generic symbolic modifications to mode bits, this allows
  2119. more flexibility. For example, the value @samp{a+rw} adds read and write
  2120. permissions for everybody, while retaining executable bits on directories
  2121. or on any other file already marked as executable.
  2122. @opindex multi-volume, summary
  2123. @item --multi-volume
  2124. @itemx -M
  2125. Informs @command{tar} that it should create or otherwise operate on a
  2126. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2127. @opindex new-volume-script, summary
  2128. @item --new-volume-script
  2129. (see --info-script)
  2130. @opindex seek, summary
  2131. @item --seek
  2132. @itemx -n
  2133. Assume that the archive media supports seeks to arbitrary
  2134. locations. Usually @command{tar} determines automatically whether
  2135. the archive can be seeked or not. This option is intended for use
  2136. in cases when such recognition fails.
  2137. @opindex newer, summary
  2138. @item --newer=@var{date}
  2139. @itemx --after-date=@var{date}
  2140. @itemx -N
  2141. When creating an archive, @command{tar} will only add files that have changed
  2142. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2143. is taken to be the name of a file whose data modification time specifies
  2144. the date. @xref{after}.
  2145. @opindex newer-mtime, summary
  2146. @item --newer-mtime=@var{date}
  2147. Like @option{--newer}, but add only files whose
  2148. contents have changed (as opposed to just @option{--newer}, which will
  2149. also back up files for which any status information has changed).
  2150. @opindex no-anchored, summary
  2151. @item --no-anchored
  2152. An exclude pattern can match any subsequence of the name's components.
  2153. @xref{controlling pattern-matching}.
  2154. @opindex no-delay-directory-restore, summary
  2155. @item --no-delay-directory-restore
  2156. Setting modification times and permissions of extracted
  2157. directories when all files from this directory has been
  2158. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2159. @opindex no-ignore-case, summary
  2160. @item --no-ignore-case
  2161. Use case-sensitive matching.
  2162. @xref{controlling pattern-matching}.
  2163. @opindex no-ignore-command-error, summary
  2164. @item --no-ignore-command-error
  2165. Print warnings about subprocesses terminated with a non-zero exit
  2166. code. @xref{Writing to an External Program}.
  2167. @opindex no-quote-chars, summary
  2168. @item --no-quote-chars=@var{string}
  2169. Remove characters listed in @var{string} from the list of quoted
  2170. characters set by the previous @option{--quote-chars} option
  2171. (@pxref{quoting styles}).
  2172. @opindex no-recursion, summary
  2173. @item --no-recursion
  2174. With this option, @command{tar} will not recurse into directories.
  2175. @xref{recurse}.
  2176. @opindex no-same-owner, summary
  2177. @item --no-same-owner
  2178. @itemx -o
  2179. When extracting an archive, do not attempt to preserve the owner
  2180. specified in the @command{tar} archive. This the default behavior
  2181. for ordinary users.
  2182. @opindex no-same-permissions, summary
  2183. @item --no-same-permissions
  2184. When extracting an archive, subtract the user's umask from files from
  2185. the permissions specified in the archive. This is the default behavior
  2186. for ordinary users.
  2187. @opindex no-wildcards, summary
  2188. @item --no-wildcards
  2189. Do not use wildcards.
  2190. @xref{controlling pattern-matching}.
  2191. @opindex no-wildcards-match-slash, summary
  2192. @item --no-wildcards-match-slash
  2193. Wildcards do not match @samp{/}.
  2194. @xref{controlling pattern-matching}.
  2195. @opindex null, summary
  2196. @item --null
  2197. When @command{tar} is using the @option{--files-from} option, this option
  2198. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2199. @command{tar} can correctly work with file names that contain newlines.
  2200. @xref{nul}.
  2201. @opindex numeric-owner, summary
  2202. @item --numeric-owner
  2203. This option will notify @command{tar} that it should use numeric user
  2204. and group IDs when creating a @command{tar} file, rather than names.
  2205. @xref{Attributes}.
  2206. @item -o
  2207. When extracting files, this option is a synonym for
  2208. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2209. restoring ownership of files being extracted.
  2210. When creating an archive, @option{-o} is a synonym for
  2211. @option{--old-archive}. This behavior is for compatibility
  2212. with previous versions of @GNUTAR{}, and will be
  2213. removed in the future releases.
  2214. @xref{Changes}, for more information.
  2215. @opindex occurrence, summary
  2216. @item --occurrence[=@var{number}]
  2217. This option can be used in conjunction with one of the subcommands
  2218. @option{--delete}, @option{--diff}, @option{--extract} or
  2219. @option{--list} when a list of files is given either on the command
  2220. line or via @option{-T} option.
  2221. This option instructs @command{tar} to process only the @var{number}th
  2222. occurrence of each named file. @var{Number} defaults to 1, so
  2223. @smallexample
  2224. tar -x -f archive.tar --occurrence filename
  2225. @end smallexample
  2226. @noindent
  2227. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2228. and will terminate without scanning to the end of the archive.
  2229. @opindex old-archive, summary
  2230. @item --old-archive
  2231. Synonym for @option{--format=v7}.
  2232. @opindex one-file-system, summary
  2233. @item --one-file-system
  2234. Used when creating an archive. Prevents @command{tar} from recursing into
  2235. directories that are on different file systems from the current
  2236. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2237. synonym for @option{--one-file-system}. This has changed in version
  2238. 1.15.91. @xref{Changes}, for more information.}.
  2239. @opindex overwrite, summary
  2240. @item --overwrite
  2241. Overwrite existing files and directory metadata when extracting files
  2242. from an archive. @xref{Overwrite Old Files}.
  2243. @opindex overwrite-dir, summary
  2244. @item --overwrite-dir
  2245. Overwrite the metadata of existing directories when extracting files
  2246. from an archive. @xref{Overwrite Old Files}.
  2247. @opindex owner, summary
  2248. @item --owner=@var{user}
  2249. Specifies that @command{tar} should use @var{user} as the owner of members
  2250. when creating archives, instead of the user associated with the source
  2251. file. @var{user} is first decoded as a user symbolic name, but if
  2252. this interpretation fails, it has to be a decimal numeric user ID.
  2253. @FIXME-xref{}
  2254. There is no value indicating a missing number, and @samp{0} usually means
  2255. @code{root}. Some people like to force @samp{0} as the value to offer in
  2256. their distributions for the owner of files, because the @code{root} user is
  2257. anonymous anyway, so that might as well be the owner of anonymous archives.
  2258. This option does not affect extraction from archives.
  2259. @opindex transform, summary
  2260. @item --transform=@var{sed-expr}
  2261. Transform file or member names using @command{sed} replacement expression
  2262. @var{sed-expr}. For example,
  2263. @smallexample
  2264. $ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
  2265. @end smallexample
  2266. @noindent
  2267. will add to @file{archive} files from the current working directory,
  2268. replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
  2269. discussion, @xref{transform}.
  2270. To see transformed member names in verbose listings, use
  2271. @option{--show-transformed-names} option
  2272. (@pxref{show-transformed-names}).
  2273. @opindex quote-chars, summary
  2274. @item --quote-chars=@var{string}
  2275. Always quote characters from @var{string}, even if the selected
  2276. quoting style would not quote them (@pxref{quoting styles}).
  2277. @opindex quoting-style, summary
  2278. @item --quoting-style=@var{style}
  2279. Set quoting style to use when printing member and file names
  2280. (@pxref{quoting styles}). Valid @var{style} values are:
  2281. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2282. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2283. style is @code{escape}, unless overridden while configuring the
  2284. package.
  2285. @opindex pax-option, summary
  2286. @item --pax-option=@var{keyword-list}
  2287. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2288. (@pxref{posix}). It modifies the way @command{tar} handles the
  2289. extended header keywords. @var{Keyword-list} is a comma-separated
  2290. list of keyword options. @xref{PAX keywords}, for a detailed
  2291. discussion.
  2292. @opindex portability, summary
  2293. @item --portability
  2294. @itemx --old-archive
  2295. Synonym for @option{--format=v7}.
  2296. @opindex posix, summary
  2297. @item --posix
  2298. Same as @option{--format=posix}.
  2299. @opindex preserve, summary
  2300. @item --preserve
  2301. Synonymous with specifying both @option{--preserve-permissions} and
  2302. @option{--same-order}. @xref{Setting Access Permissions}.
  2303. @opindex preserve-order, summary
  2304. @item --preserve-order
  2305. (See @option{--same-order}; @pxref{Reading}.)
  2306. @opindex preserve-permissions, summary
  2307. @opindex same-permissions, summary
  2308. @item --preserve-permissions
  2309. @itemx --same-permissions
  2310. @itemx -p
  2311. When @command{tar} is extracting an archive, it normally subtracts the
  2312. users' umask from the permissions specified in the archive and uses
  2313. that number as the permissions to create the destination file.
  2314. Specifying this option instructs @command{tar} that it should use the
  2315. permissions directly from the archive. @xref{Setting Access Permissions}.
  2316. @opindex read-full-records, summary
  2317. @item --read-full-records
  2318. @itemx -B
  2319. Specifies that @command{tar} should reblock its input, for reading
  2320. from pipes on systems with buggy implementations. @xref{Reading}.
  2321. @opindex record-size, summary
  2322. @item --record-size=@var{size}
  2323. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2324. archive. @xref{Blocking Factor}.
  2325. @opindex recursion, summary
  2326. @item --recursion
  2327. With this option, @command{tar} recurses into directories.
  2328. @xref{recurse}.
  2329. @opindex recursive-unlink, summary
  2330. @item --recursive-unlink
  2331. Remove existing
  2332. directory hierarchies before extracting directories of the same name
  2333. from the archive. @xref{Recursive Unlink}.
  2334. @opindex remove-files, summary
  2335. @item --remove-files
  2336. Directs @command{tar} to remove the source file from the file system after
  2337. appending it to an archive. @xref{remove files}.
  2338. @opindex restrict, summary
  2339. @item --restrict
  2340. Disable use of some potentially harmful @command{tar} options.
  2341. Currently this option disables shell invocaton from multi-volume menu
  2342. (@pxref{Using Multiple Tapes}).
  2343. @opindex rmt-command, summary
  2344. @item --rmt-command=@var{cmd}
  2345. Notifies @command{tar} that it should use @var{cmd} instead of
  2346. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2347. @opindex rsh-command, summary
  2348. @item --rsh-command=@var{cmd}
  2349. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2350. devices. @xref{Device}.
  2351. @opindex same-order, summary
  2352. @item --same-order
  2353. @itemx --preserve-order
  2354. @itemx -s
  2355. This option is an optimization for @command{tar} when running on machines with
  2356. small amounts of memory. It informs @command{tar} that the list of file
  2357. arguments has already been sorted to match the order of files in the
  2358. archive. @xref{Reading}.
  2359. @opindex same-owner, summary
  2360. @item --same-owner
  2361. When extracting an archive, @command{tar} will attempt to preserve the owner
  2362. specified in the @command{tar} archive with this option present.
  2363. This is the default behavior for the superuser; this option has an
  2364. effect only for ordinary users. @xref{Attributes}.
  2365. @opindex same-permissions, summary
  2366. @item --same-permissions
  2367. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2368. @opindex show-defaults, summary
  2369. @item --show-defaults
  2370. Displays the default options used by @command{tar} and exits
  2371. successfully. This option is intended for use in shell scripts.
  2372. Here is an example of what you can see using this option:
  2373. @smallexample
  2374. $ tar --show-defaults
  2375. --format=gnu -f- -b20 --quoting-style=escape \
  2376. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2377. @end smallexample
  2378. @opindex show-omitted-dirs, summary
  2379. @item --show-omitted-dirs
  2380. Instructs @command{tar} to mention directories its skipping over when
  2381. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2382. @opindex show-transformed-names, summary
  2383. @opindex show-stored-names, summary
  2384. @item --show-transformed-names
  2385. @itemx --show-stored-names
  2386. Display file or member names after applying any transformations
  2387. (@pxref{transform}). In particular, when used in conjunction with one of
  2388. archive creation operations it instructs tar to list the member names
  2389. stored in the archive, as opposed to the actual file
  2390. names. @xref{listing member and file names}.
  2391. @opindex sparse, summary
  2392. @item --sparse
  2393. @itemx -S
  2394. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2395. sparse files efficiently. @xref{sparse}.
  2396. @opindex starting-file, summary
  2397. @item --starting-file=@var{name}
  2398. @itemx -K @var{name}
  2399. This option affects extraction only; @command{tar} will skip extracting
  2400. files in the archive until it finds one that matches @var{name}.
  2401. @xref{Scarce}.
  2402. @opindex strip-components, summary
  2403. @item --strip-components=@var{number}
  2404. Strip given @var{number} of leading components from file names before
  2405. extraction.@footnote{This option was called @option{--strip-path} in
  2406. version 1.14.} For example, if archive @file{archive.tar} contained
  2407. @file{/some/file/name}, then running
  2408. @smallexample
  2409. tar --extract --file archive.tar --strip-components=2
  2410. @end smallexample
  2411. @noindent
  2412. would extract this file to file @file{name}.
  2413. @opindex suffix, summary
  2414. @item --suffix=@var{suffix}
  2415. Alters the suffix @command{tar} uses when backing up files from the default
  2416. @samp{~}. @xref{backup}.
  2417. @opindex tape-length, summary
  2418. @item --tape-length=@var{num}
  2419. @itemx -L @var{num}
  2420. Specifies the length of tapes that @command{tar} is writing as being
  2421. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2422. @opindex test-label, summary
  2423. @item --test-label
  2424. Reads the volume label. If an argument is specified, test whether it
  2425. matches the volume label. @xref{--test-label option}.
  2426. @opindex to-command, summary
  2427. @item --to-command=@var{command}
  2428. During extraction @command{tar} will pipe extracted files to the
  2429. standard input of @var{command}. @xref{Writing to an External Program}.
  2430. @opindex to-stdout, summary
  2431. @item --to-stdout
  2432. @itemx -O
  2433. During extraction, @command{tar} will extract files to stdout rather
  2434. than to the file system. @xref{Writing to Standard Output}.
  2435. @opindex totals, summary
  2436. @item --totals
  2437. Displays the total number of bytes written after creating an archive.
  2438. @xref{verbose}.
  2439. @opindex touch, summary
  2440. @item --touch
  2441. @itemx -m
  2442. Sets the data modification time of extracted files to the extraction time,
  2443. rather than the data modification time stored in the archive.
  2444. @xref{Data Modification Times}.
  2445. @opindex uncompress, summary
  2446. @item --uncompress
  2447. (See @option{--compress}. @pxref{gzip})
  2448. @opindex ungzip, summary
  2449. @item --ungzip
  2450. (See @option{--gzip}. @pxref{gzip})
  2451. @opindex unlink-first, summary
  2452. @item --unlink-first
  2453. @itemx -U
  2454. Directs @command{tar} to remove the corresponding file from the file
  2455. system before extracting it from the archive. @xref{Unlink First}.
  2456. @opindex use-compress-program, summary
  2457. @item --use-compress-program=@var{prog}
  2458. Instructs @command{tar} to access the archive through @var{prog}, which is
  2459. presumed to be a compression program of some sort. @xref{gzip}.
  2460. @opindex utc, summary
  2461. @item --utc
  2462. Display file modification dates in @acronym{UTC}. This option implies
  2463. @option{--verbose}.
  2464. @opindex verbose, summary
  2465. @item --verbose
  2466. @itemx -v
  2467. Specifies that @command{tar} should be more verbose about the operations its
  2468. performing. This option can be specified multiple times for some
  2469. operations to increase the amount of information displayed.
  2470. @xref{verbose}.
  2471. @opindex verify, summary
  2472. @item --verify
  2473. @itemx -W
  2474. Verifies that the archive was correctly written when creating an
  2475. archive. @xref{verify}.
  2476. @opindex version, summary
  2477. @item --version
  2478. Print information about the program's name, version, origin and legal
  2479. status, all on standard output, and then exit successfully.
  2480. @xref{help}.
  2481. @opindex volno-file, summary
  2482. @item --volno-file=@var{file}
  2483. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2484. of which volume of a multi-volume archive its working in @var{file}.
  2485. @xref{volno-file}.
  2486. @opindex wildcards, summary
  2487. @item --wildcards
  2488. Use wildcards when matching member names with patterns.
  2489. @xref{controlling pattern-matching}.
  2490. @opindex wildcards-match-slash, summary
  2491. @item --wildcards-match-slash
  2492. Wildcards match @samp{/}.
  2493. @xref{controlling pattern-matching}.
  2494. @end table
  2495. @node Short Option Summary
  2496. @subsection Short Options Cross Reference
  2497. Here is an alphabetized list of all of the short option forms, matching
  2498. them with the equivalent long option.
  2499. @table @option
  2500. @item -A
  2501. @option{--concatenate}
  2502. @item -B
  2503. @option{--read-full-records}
  2504. @item -C
  2505. @option{--directory}
  2506. @item -F
  2507. @option{--info-script}
  2508. @item -G
  2509. @option{--incremental}
  2510. @item -K
  2511. @option{--starting-file}
  2512. @item -L
  2513. @option{--tape-length}
  2514. @item -M
  2515. @option{--multi-volume}
  2516. @item -N
  2517. @option{--newer}
  2518. @item -O
  2519. @option{--to-stdout}
  2520. @item -P
  2521. @option{--absolute-names}
  2522. @item -R
  2523. @option{--block-number}
  2524. @item -S
  2525. @option{--sparse}
  2526. @item -T
  2527. @option{--files-from}
  2528. @item -U
  2529. @option{--unlink-first}
  2530. @item -V
  2531. @option{--label}
  2532. @item -W
  2533. @option{--verify}
  2534. @item -X
  2535. @option{--exclude-from}
  2536. @item -Z
  2537. @option{--compress}
  2538. @item -b
  2539. @option{--blocking-factor}
  2540. @item -c
  2541. @option{--create}
  2542. @item -d
  2543. @option{--compare}
  2544. @item -f
  2545. @option{--file}
  2546. @item -g
  2547. @option{--listed-incremental}
  2548. @item -h
  2549. @option{--dereference}
  2550. @item -i
  2551. @option{--ignore-zeros}
  2552. @item -j
  2553. @option{--bzip2}
  2554. @item -k
  2555. @option{--keep-old-files}
  2556. @item -l
  2557. @option{--one-file-system}. Use of this short option is deprecated. It
  2558. is retained for compatibility with the earlier versions of GNU
  2559. @command{tar}, and will be changed in future releases.
  2560. @xref{Changes}, for more information.
  2561. @item -m
  2562. @option{--touch}
  2563. @item -o
  2564. When creating --- @option{--no-same-owner}, when extracting ---
  2565. @option{--portability}.
  2566. The later usage is deprecated. It is retained for compatibility with
  2567. the earlier versions of @GNUTAR{}. In the future releases
  2568. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2569. @item -p
  2570. @option{--preserve-permissions}
  2571. @item -r
  2572. @option{--append}
  2573. @item -s
  2574. @option{--same-order}
  2575. @item -t
  2576. @option{--list}
  2577. @item -u
  2578. @option{--update}
  2579. @item -v
  2580. @option{--verbose}
  2581. @item -w
  2582. @option{--interactive}
  2583. @item -x
  2584. @option{--extract}
  2585. @item -z
  2586. @option{--gzip}
  2587. @end table
  2588. @node help
  2589. @section @GNUTAR{} documentation
  2590. @cindex Getting program version number
  2591. @opindex version
  2592. @cindex Version of the @command{tar} program
  2593. Being careful, the first thing is really checking that you are using
  2594. @GNUTAR{}, indeed. The @option{--version} option
  2595. causes @command{tar} to print information about its name, version,
  2596. origin and legal status, all on standard output, and then exit
  2597. successfully. For example, @w{@samp{tar --version}} might print:
  2598. @smallexample
  2599. tar (GNU tar) 1.15.2
  2600. Copyright (C) 2006 Free Software Foundation, Inc.
  2601. This is free software. You may redistribute copies of it under the terms of
  2602. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2603. There is NO WARRANTY, to the extent permitted by law.
  2604. Written by John Gilmore and Jay Fenlason.
  2605. @end smallexample
  2606. @noindent
  2607. The first occurrence of @samp{tar} in the result above is the program
  2608. name in the package (for example, @command{rmt} is another program),
  2609. while the second occurrence of @samp{tar} is the name of the package
  2610. itself, containing possibly many programs. The package is currently
  2611. named @samp{tar}, after the name of the main program it
  2612. contains@footnote{There are plans to merge the @command{cpio} and
  2613. @command{tar} packages into a single one which would be called
  2614. @code{paxutils}. So, who knows if, one of this days, the
  2615. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2616. paxutils) 3.2}}}.
  2617. @cindex Obtaining help
  2618. @cindex Listing all @command{tar} options
  2619. @opindex help, introduction
  2620. Another thing you might want to do is checking the spelling or meaning
  2621. of some particular @command{tar} option, without resorting to this
  2622. manual, for once you have carefully read it. @GNUTAR{}
  2623. has a short help feature, triggerable through the
  2624. @option{--help} option. By using this option, @command{tar} will
  2625. print a usage message listing all available options on standard
  2626. output, then exit successfully, without doing anything else and
  2627. ignoring all other options. Even if this is only a brief summary, it
  2628. may be several screens long. So, if you are not using some kind of
  2629. scrollable window, you might prefer to use something like:
  2630. @smallexample
  2631. $ @kbd{tar --help | less}
  2632. @end smallexample
  2633. @noindent
  2634. presuming, here, that you like using @command{less} for a pager. Other
  2635. popular pagers are @command{more} and @command{pg}. If you know about some
  2636. @var{keyword} which interests you and do not want to read all the
  2637. @option{--help} output, another common idiom is doing:
  2638. @smallexample
  2639. tar --help | grep @var{keyword}
  2640. @end smallexample
  2641. @noindent
  2642. for getting only the pertinent lines. Notice, however, that some
  2643. @command{tar} options have long description lines and the above
  2644. command will list only the first of them.
  2645. The exact look of the option summary displayed by @kbd{tar --help} is
  2646. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2647. @opindex usage
  2648. If you only wish to check the spelling of an option, running @kbd{tar
  2649. --usage} may be a better choice. This will display a terse list of
  2650. @command{tar} option without accompanying explanations.
  2651. The short help output is quite succinct, and you might have to get
  2652. back to the full documentation for precise points. If you are reading
  2653. this paragraph, you already have the @command{tar} manual in some
  2654. form. This manual is available in a variety of forms from
  2655. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2656. distribution, provided you have @TeX{} already installed somewhere,
  2657. and a laser printer around. Just configure the distribution, execute
  2658. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2659. usual way (contact your local guru to know how). If @GNUTAR{}
  2660. has been conveniently installed at your place, this
  2661. manual is also available in interactive, hypertextual form as an Info
  2662. file. Just call @w{@samp{info tar}} or, if you do not have the
  2663. @command{info} program handy, use the Info reader provided within
  2664. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2665. There is currently no @code{man} page for @GNUTAR{}.
  2666. If you observe such a @code{man} page on the system you are running,
  2667. either it does not belong to @GNUTAR{}, or it has not
  2668. been produced by @acronym{GNU}. Some package maintainers convert
  2669. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2670. any case, please bear in mind that the authoritative source of
  2671. information about @GNUTAR{} is this Texinfo documentation.
  2672. @node defaults
  2673. @section Obtaining @GNUTAR{} default values
  2674. @opindex show-defaults
  2675. @GNUTAR{} has some predefined defaults that are used when you do not
  2676. explicitely specify another values. To obtain a list of such
  2677. defaults, use @option{--show-defaults} option. This will output the
  2678. values in the form of @command{tar} command line options:
  2679. @smallexample
  2680. @group
  2681. @kbd{tar --show-defaults}
  2682. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2683. @end group
  2684. @end smallexample
  2685. @noindent
  2686. The above output shows that this version of @GNUTAR{} defaults to
  2687. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2688. output as the archive, if no @option{--file} option has been given
  2689. (@pxref{file tutorial}), the default blocking factor is 20
  2690. (@pxref{Blocking Factor}). It also shows the default locations where
  2691. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2692. @node verbose
  2693. @section Checking @command{tar} progress
  2694. Typically, @command{tar} performs most operations without reporting any
  2695. information to the user except error messages. When using @command{tar}
  2696. with many options, particularly ones with complicated or
  2697. difficult-to-predict behavior, it is possible to make serious mistakes.
  2698. @command{tar} provides several options that make observing @command{tar}
  2699. easier. These options cause @command{tar} to print information as it
  2700. progresses in its job, and you might want to use them just for being
  2701. more careful about what is going on, or merely for entertaining
  2702. yourself. If you have encountered a problem when operating on an
  2703. archive, however, you may need more information than just an error
  2704. message in order to solve the problem. The following options can be
  2705. helpful diagnostic tools.
  2706. @cindex Verbose operation
  2707. @opindex verbose
  2708. Normally, the @option{--list} (@option{-t}) command to list an archive
  2709. prints just the file names (one per line) and the other commands are
  2710. silent. When used with most operations, the @option{--verbose}
  2711. (@option{-v}) option causes @command{tar} to print the name of each
  2712. file or archive member as it is processed. This and the other options
  2713. which make @command{tar} print status information can be useful in
  2714. monitoring @command{tar}.
  2715. With @option{--create} or @option{--extract}, @option{--verbose} used
  2716. once just prints the names of the files or members as they are processed.
  2717. Using it twice causes @command{tar} to print a longer listing
  2718. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2719. already prints the names of the members, @option{--verbose} used once
  2720. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2721. type listing of the files in the archive. The following examples both
  2722. extract members with long list output:
  2723. @smallexample
  2724. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2725. $ @kbd{tar xvvf archive.tar}
  2726. @end smallexample
  2727. Verbose output appears on the standard output except when an archive is
  2728. being written to the standard output, as with @samp{tar --create
  2729. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2730. installer let standard output be the default archive). In that case
  2731. @command{tar} writes verbose output to the standard error stream.
  2732. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2733. verbose output to @var{file} rather than to standard output or standard
  2734. error.
  2735. @cindex Obtaining total status information
  2736. @opindex totals
  2737. The @option{--totals} option---which is only meaningful when used with
  2738. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2739. amount written to the archive, after it has been fully created.
  2740. @anchor{Progress information}
  2741. @cindex Progress information
  2742. @opindex checkpoint
  2743. The @option{--checkpoint} option prints an occasional message
  2744. as @command{tar} reads or writes the archive. It is designed for
  2745. those who don't need the more detailed (and voluminous) output of
  2746. @option{--block-number} (@option{-R}), but do want visual confirmation
  2747. that @command{tar} is actually making forward progress. By default it
  2748. prints a message each 10 records read or written. This can be changed
  2749. by giving it a numeric argument after an equal sign:
  2750. @smallexample
  2751. $ @kbd{tar -c --checkpoint=1000} /var
  2752. tar: Write checkpoint 1000
  2753. tar: Write checkpoint 2000
  2754. tar: Write checkpoint 3000
  2755. @end smallexample
  2756. This example shows the default checkpoint message used by
  2757. @command{tar}. If you place a dot immediately after the equal
  2758. sign, it will print a @samp{.} at each checkpoint. For example:
  2759. @smallexample
  2760. $ @kbd{tar -c --checkpoint=.1000} /var
  2761. ...
  2762. @end smallexample
  2763. @opindex show-omitted-dirs
  2764. @anchor{show-omitted-dirs}
  2765. The @option{--show-omitted-dirs} option, when reading an archive---with
  2766. @option{--list} or @option{--extract}, for example---causes a message
  2767. to be printed for each directory in the archive which is skipped.
  2768. This happens regardless of the reason for skipping: the directory might
  2769. not have been named on the command line (implicitly or explicitly),
  2770. it might be excluded by the use of the
  2771. @option{--exclude=@var{pattern}} option, or some other reason.
  2772. @opindex block-number
  2773. @cindex Block number where error occurred
  2774. @anchor{block-number}
  2775. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2776. every message it would normally produce, the block number within the
  2777. archive where the message was triggered. Also, supplementary messages
  2778. are triggered when reading blocks full of NULs, or when hitting end of
  2779. file on the archive. As of now, if the archive if properly terminated
  2780. with a NUL block, the reading of the file may stop before end of file
  2781. is met, so the position of end of file will not usually show when
  2782. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2783. drains the archive before exiting when reading the
  2784. archive from a pipe.
  2785. @cindex Error message, block number of
  2786. This option is especially useful when reading damaged archives, since
  2787. it helps pinpoint the damaged sections. It can also be used with
  2788. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2789. choose among several backup tapes when retrieving a file later, in
  2790. favor of the tape where the file appears earliest (closest to the
  2791. front of the tape). @xref{backup}.
  2792. @node interactive
  2793. @section Asking for Confirmation During Operations
  2794. @cindex Interactive operation
  2795. Typically, @command{tar} carries out a command without stopping for
  2796. further instructions. In some situations however, you may want to
  2797. exclude some files and archive members from the operation (for instance
  2798. if disk or storage space is tight). You can do this by excluding
  2799. certain files automatically (@pxref{Choosing}), or by performing
  2800. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2801. @command{tar} also accepts @option{--confirmation} for this option.
  2802. @opindex interactive
  2803. When the @option{--interactive} (@option{-w}) option is specified, before
  2804. reading, writing, or deleting files, @command{tar} first prints a message
  2805. for each such file, telling what operation it intends to take, then asks
  2806. for confirmation on the terminal. The actions which require
  2807. confirmation include adding a file to the archive, extracting a file
  2808. from the archive, deleting a file from the archive, and deleting a file
  2809. from disk. To confirm the action, you must type a line of input
  2810. beginning with @samp{y}. If your input line begins with anything other
  2811. than @samp{y}, @command{tar} skips that file.
  2812. If @command{tar} is reading the archive from the standard input,
  2813. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2814. communications.
  2815. Verbose output is normally sent to standard output, separate from
  2816. other error messages. However, if the archive is produced directly
  2817. on standard output, then verbose output is mixed with errors on
  2818. @code{stderr}. Producing the archive on standard output may be used
  2819. as a way to avoid using disk space, when the archive is soon to be
  2820. consumed by another process reading it, say. Some people felt the need
  2821. of producing an archive on stdout, still willing to segregate between
  2822. verbose output and error output. A possible approach would be using a
  2823. named pipe to receive the archive, and having the consumer process to
  2824. read from that named pipe. This has the advantage of letting standard
  2825. output free to receive verbose output, all separate from errors.
  2826. @node operations
  2827. @chapter @GNUTAR{} Operations
  2828. @menu
  2829. * Basic tar::
  2830. * Advanced tar::
  2831. * create options::
  2832. * extract options::
  2833. * backup::
  2834. * Applications::
  2835. * looking ahead::
  2836. @end menu
  2837. @node Basic tar
  2838. @section Basic @GNUTAR{} Operations
  2839. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2840. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2841. @option{-x}), are currently presented and described in the tutorial
  2842. chapter of this manual. This section provides some complementary notes
  2843. for these operations.
  2844. @table @option
  2845. @opindex create, complementary notes
  2846. @item --create
  2847. @itemx -c
  2848. Creating an empty archive would have some kind of elegance. One can
  2849. initialize an empty archive and later use @option{--append}
  2850. (@option{-r}) for adding all members. Some applications would not
  2851. welcome making an exception in the way of adding the first archive
  2852. member. On the other hand, many people reported that it is
  2853. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2854. an empty archive@footnote{This is well described in @cite{Unix-haters
  2855. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2856. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2857. @enumerate
  2858. @item
  2859. Mistakingly using @code{create} instead of @code{extract}, when the
  2860. intent was to extract the full contents of an archive. This error
  2861. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2862. the QWERTY keyboard. Instead of being unpacked, the archive then
  2863. gets wholly destroyed. When users speak about @dfn{exploding} an
  2864. archive, they usually mean something else :-).
  2865. @item
  2866. Forgetting the argument to @code{file}, when the intent was to create
  2867. an archive with a single file in it. This error is likely because a
  2868. tired user can easily add the @kbd{f} key to the cluster of option
  2869. letters, by the mere force of habit, without realizing the full
  2870. consequence of doing so. The usual consequence is that the single
  2871. file, which was meant to be saved, is rather destroyed.
  2872. @end enumerate
  2873. So, recognizing the likelihood and the catastrophical nature of these
  2874. errors, @GNUTAR{} now takes some distance from elegance, and
  2875. cowardly refuses to create an archive when @option{--create} option is
  2876. given, there are no arguments besides options, and
  2877. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2878. around the cautiousness of @GNUTAR{} and nevertheless create an
  2879. archive with nothing in it, one may still use, as the value for the
  2880. @option{--files-from} option, a file with no names in it, as shown in
  2881. the following commands:
  2882. @smallexample
  2883. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2884. @kbd{tar cfT empty-archive.tar /dev/null}
  2885. @end smallexample
  2886. @opindex extract, complementary notes
  2887. @item --extract
  2888. @itemx --get
  2889. @itemx -x
  2890. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2891. @item @option{--list} (@option{-t})
  2892. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2893. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2894. people should get used to ISO 8601 dates. Local American dates should
  2895. be made available again with full date localization support, once
  2896. ready. In the meantime, programs not being localizable for dates
  2897. should prefer international dates, that's really the way to go.
  2898. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2899. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2900. @end table
  2901. @node Advanced tar
  2902. @section Advanced @GNUTAR{} Operations
  2903. Now that you have learned the basics of using @GNUTAR{}, you may want
  2904. to learn about further ways in which @command{tar} can help you.
  2905. This chapter presents five, more advanced operations which you probably
  2906. won't use on a daily basis, but which serve more specialized functions.
  2907. We also explain the different styles of options and why you might want
  2908. to use one or another, or a combination of them in your @command{tar}
  2909. commands. Additionally, this chapter includes options which allow you to
  2910. define the output from @command{tar} more carefully, and provide help and
  2911. error correction in special circumstances.
  2912. @FIXME{check this after the chapter is actually revised to make sure
  2913. it still introduces the info in the chapter correctly : ).}
  2914. @menu
  2915. * Operations::
  2916. * append::
  2917. * update::
  2918. * concatenate::
  2919. * delete::
  2920. * compare::
  2921. @end menu
  2922. @node Operations
  2923. @subsection The Five Advanced @command{tar} Operations
  2924. @UNREVISED
  2925. In the last chapter, you learned about the first three operations to
  2926. @command{tar}. This chapter presents the remaining five operations to
  2927. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2928. @option{--delete}, and @option{--compare}.
  2929. You are not likely to use these operations as frequently as those
  2930. covered in the last chapter; however, since they perform specialized
  2931. functions, they are quite useful when you do need to use them. We
  2932. will give examples using the same directory and files that you created
  2933. in the last chapter. As you may recall, the directory is called
  2934. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2935. @samp{rock}, and the two archive files you created are
  2936. @samp{collection.tar} and @samp{music.tar}.
  2937. We will also use the archive files @samp{afiles.tar} and
  2938. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2939. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2940. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2941. Unless we state otherwise, all practicing you do and examples you follow
  2942. in this chapter will take place in the @file{practice} directory that
  2943. you created in the previous chapter; see @ref{prepare for examples}.
  2944. (Below in this section, we will remind you of the state of the examples
  2945. where the last chapter left them.)
  2946. The five operations that we will cover in this chapter are:
  2947. @table @option
  2948. @item --append
  2949. @itemx -r
  2950. Add new entries to an archive that already exists.
  2951. @item --update
  2952. @itemx -r
  2953. Add more recent copies of archive members to the end of an archive, if
  2954. they exist.
  2955. @item --concatenate
  2956. @itemx --catenate
  2957. @itemx -A
  2958. Add one or more pre-existing archives to the end of another archive.
  2959. @item --delete
  2960. Delete items from an archive (does not work on tapes).
  2961. @item --compare
  2962. @itemx --diff
  2963. @itemx -d
  2964. Compare archive members to their counterparts in the file system.
  2965. @end table
  2966. @node append
  2967. @subsection How to Add Files to Existing Archives: @option{--append}
  2968. @UNREVISED
  2969. @opindex append
  2970. If you want to add files to an existing archive, you don't need to
  2971. create a new archive; you can use @option{--append} (@option{-r}).
  2972. The archive must already exist in order to use @option{--append}. (A
  2973. related operation is the @option{--update} operation; you can use this
  2974. to add newer versions of archive members to an existing archive. To learn how to
  2975. do this with @option{--update}, @pxref{update}.)
  2976. If you use @option{--append} to add a file that has the same name as an
  2977. archive member to an archive containing that archive member, then the
  2978. old member is not deleted. What does happen, however, is somewhat
  2979. complex. @command{tar} @emph{allows} you to have infinite number of files
  2980. with the same name. Some operations treat these same-named members no
  2981. differently than any other set of archive members: for example, if you
  2982. view an archive with @option{--list} (@option{-t}), you will see all
  2983. of those members listed, with their data modification times, owners, etc.
  2984. Other operations don't deal with these members as perfectly as you might
  2985. prefer; if you were to use @option{--extract} to extract the archive,
  2986. only the most recently added copy of a member with the same name as four
  2987. other members would end up in the working directory. This is because
  2988. @option{--extract} extracts an archive in the order the members appeared
  2989. in the archive; the most recently archived members will be extracted
  2990. last. Additionally, an extracted member will @emph{replace} a file of
  2991. the same name which existed in the directory already, and @command{tar}
  2992. will not prompt you about this@footnote{Unless you give it
  2993. @option{--keep-old-files} option, or the disk copy is newer than the
  2994. the one in the archive and you invoke @command{tar} with
  2995. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2996. member will end up being extracted, as it will replace the one
  2997. extracted before it, and so on.
  2998. There exists a special option that allows you to get around this
  2999. behavior and extract (or list) only a particular copy of the file.
  3000. This is @option{--occurrence} option. If you run @command{tar} with
  3001. this option, it will extract only the first copy of the file. You
  3002. may also give this option an argument specifying the number of
  3003. copy to be extracted. Thus, for example if the archive
  3004. @file{archive.tar} contained three copies of file @file{myfile}, then
  3005. the command
  3006. @smallexample
  3007. tar --extract --file archive.tar --occurrence=2 myfile
  3008. @end smallexample
  3009. @noindent
  3010. would extract only the second copy. @xref{Option
  3011. Summary,---occurrence}, for the description of @option{--occurrence}
  3012. option.
  3013. @FIXME{ hag -- you might want to incorporate some of the above into the
  3014. MMwtSN node; not sure. i didn't know how to make it simpler...
  3015. There are a few ways to get around this. (maybe xref Multiple Members
  3016. with the Same Name.}
  3017. @cindex Members, replacing with other members
  3018. @cindex Replacing members with other members
  3019. If you want to replace an archive member, use @option{--delete} to
  3020. delete the member you want to remove from the archive, , and then use
  3021. @option{--append} to add the member you want to be in the archive. Note
  3022. that you can not change the order of the archive; the most recently
  3023. added member will still appear last. In this sense, you cannot truly
  3024. ``replace'' one member with another. (Replacing one member with another
  3025. will not work on certain types of media, such as tapes; see @ref{delete}
  3026. and @ref{Media}, for more information.)
  3027. @menu
  3028. * appending files:: Appending Files to an Archive
  3029. * multiple::
  3030. @end menu
  3031. @node appending files
  3032. @subsubsection Appending Files to an Archive
  3033. @UNREVISED
  3034. @cindex Adding files to an Archive
  3035. @cindex Appending files to an Archive
  3036. @cindex Archives, Appending files to
  3037. The simplest way to add a file to an already existing archive is the
  3038. @option{--append} (@option{-r}) operation, which writes specified
  3039. files into the archive whether or not they are already among the
  3040. archived files.
  3041. When you use @option{--append}, you @emph{must} specify file name
  3042. arguments, as there is no default. If you specify a file that already
  3043. exists in the archive, another copy of the file will be added to the
  3044. end of the archive. As with other operations, the member names of the
  3045. newly added files will be exactly the same as their names given on the
  3046. command line. The @option{--verbose} (@option{-v}) option will print
  3047. out the names of the files as they are written into the archive.
  3048. @option{--append} cannot be performed on some tape drives, unfortunately,
  3049. due to deficiencies in the formats those tape drives use. The archive
  3050. must be a valid @command{tar} archive, or else the results of using this
  3051. operation will be unpredictable. @xref{Media}.
  3052. To demonstrate using @option{--append} to add a file to an archive,
  3053. create a file called @file{rock} in the @file{practice} directory.
  3054. Make sure you are in the @file{practice} directory. Then, run the
  3055. following @command{tar} command to add @file{rock} to
  3056. @file{collection.tar}:
  3057. @smallexample
  3058. $ @kbd{tar --append --file=collection.tar rock}
  3059. @end smallexample
  3060. @noindent
  3061. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3062. @file{rock} has been added to the archive:
  3063. @smallexample
  3064. $ @kbd{tar --list --file=collection.tar}
  3065. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3066. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3067. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3068. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3069. @end smallexample
  3070. @node multiple
  3071. @subsubsection Multiple Files with the Same Name
  3072. You can use @option{--append} (@option{-r}) to add copies of files
  3073. which have been updated since the archive was created. (However, we
  3074. do not recommend doing this since there is another @command{tar}
  3075. option called @option{--update}; @xref{update}, for more information.
  3076. We describe this use of @option{--append} here for the sake of
  3077. completeness.) When you extract the archive, the older version will
  3078. be effectively lost. This works because files are extracted from an
  3079. archive in the order in which they were archived. Thus, when the
  3080. archive is extracted, a file archived later in time will replace a
  3081. file of the same name which was archived earlier, even though the
  3082. older version of the file will remain in the archive unless you delete
  3083. all versions of the file.
  3084. Supposing you change the file @file{blues} and then append the changed
  3085. version to @file{collection.tar}. As you saw above, the original
  3086. @file{blues} is in the archive @file{collection.tar}. If you change the
  3087. file and append the new version of the file to the archive, there will
  3088. be two copies in the archive. When you extract the archive, the older
  3089. version of the file will be extracted first, and then replaced by the
  3090. newer version when it is extracted.
  3091. You can append the new, changed copy of the file @file{blues} to the
  3092. archive in this way:
  3093. @smallexample
  3094. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3095. blues
  3096. @end smallexample
  3097. @noindent
  3098. Because you specified the @option{--verbose} option, @command{tar} has
  3099. printed the name of the file being appended as it was acted on. Now
  3100. list the contents of the archive:
  3101. @smallexample
  3102. $ @kbd{tar --list --verbose --file=collection.tar}
  3103. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3104. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3105. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3106. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3107. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3108. @end smallexample
  3109. @noindent
  3110. The newest version of @file{blues} is now at the end of the archive
  3111. (note the different creation dates and file sizes). If you extract
  3112. the archive, the older version of the file @file{blues} will be
  3113. replaced by the newer version. You can confirm this by extracting
  3114. the archive and running @samp{ls} on the directory.
  3115. If you wish to extract the first occurrence of the file @file{blues}
  3116. from the archive, use @option{--occurrence} option, as shown in
  3117. the following example:
  3118. @smallexample
  3119. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3120. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3121. @end smallexample
  3122. @xref{Writing}, for more information on @option{--extract} and
  3123. @xref{Option Summary, --occurrence}, for the description of
  3124. @option{--occurrence} option.
  3125. @node update
  3126. @subsection Updating an Archive
  3127. @UNREVISED
  3128. @cindex Updating an archive
  3129. @opindex update
  3130. In the previous section, you learned how to use @option{--append} to
  3131. add a file to an existing archive. A related operation is
  3132. @option{--update} (@option{-u}). The @option{--update} operation
  3133. updates a @command{tar} archive by comparing the date of the specified
  3134. archive members against the date of the file with the same name. If
  3135. the file has been modified more recently than the archive member, then
  3136. the newer version of the file is added to the archive (as with
  3137. @option{--append}).
  3138. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3139. The operation will fail.
  3140. @FIXME{other examples of media on which --update will fail? need to ask
  3141. charles and/or mib/thomas/dave shevett..}
  3142. Both @option{--update} and @option{--append} work by adding to the end
  3143. of the archive. When you extract a file from the archive, only the
  3144. version stored last will wind up in the file system, unless you use
  3145. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3146. Same Name}
  3147. @menu
  3148. * how to update::
  3149. @end menu
  3150. @node how to update
  3151. @subsubsection How to Update an Archive Using @option{--update}
  3152. You must use file name arguments with the @option{--update}
  3153. (@option{-u}) operation. If you don't specify any files,
  3154. @command{tar} won't act on any files and won't tell you that it didn't
  3155. do anything (which may end up confusing you).
  3156. @c note: the above parenthetical added because in fact, this
  3157. @c behavior just confused the author. :-)
  3158. To see the @option{--update} option at work, create a new file,
  3159. @file{classical}, in your practice directory, and some extra text to the
  3160. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3161. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3162. option specified, using the names of all the files in the practice
  3163. directory as file name arguments:
  3164. @smallexample
  3165. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3166. blues
  3167. classical
  3168. $
  3169. @end smallexample
  3170. @noindent
  3171. Because we have specified verbose mode, @command{tar} prints out the names
  3172. of the files it is working on, which in this case are the names of the
  3173. files that needed to be updated. If you run @samp{tar --list} and look
  3174. at the archive, you will see @file{blues} and @file{classical} at its
  3175. end. There will be a total of two versions of the member @samp{blues};
  3176. the one at the end will be newer and larger, since you added text before
  3177. updating it.
  3178. (The reason @command{tar} does not overwrite the older file when updating
  3179. it is because writing to the middle of a section of tape is a difficult
  3180. process. Tapes are not designed to go backward. @xref{Media}, for more
  3181. information about tapes.
  3182. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3183. reasons: it does not change directory content entries, and it
  3184. lengthens the archive every time it is used. The @GNUTAR{}
  3185. options intended specifically for backups are more
  3186. efficient. If you need to run backups, please consult @ref{Backups}.
  3187. @node concatenate
  3188. @subsection Combining Archives with @option{--concatenate}
  3189. @cindex Adding archives to an archive
  3190. @cindex Concatenating Archives
  3191. @opindex concatenate
  3192. @opindex catenate
  3193. @c @cindex @option{-A} described
  3194. Sometimes it may be convenient to add a second archive onto the end of
  3195. an archive rather than adding individual files to the archive. To add
  3196. one or more archives to the end of another archive, you should use the
  3197. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3198. To use @option{--concatenate}, give the first archive with
  3199. @option{--file} option and name the rest of archives to be
  3200. concatenated on the command line. The members, and their member
  3201. names, will be copied verbatim from those archives to the first one.
  3202. @FIXME-ref{This can cause multiple members to have the same name, for
  3203. information on how this affects reading the archive, Multiple
  3204. Members with the Same Name.}
  3205. The new, concatenated archive will be called by the same name as the
  3206. one given with the @option{--file} option. As usual, if you omit
  3207. @option{--file}, @command{tar} will use the value of the environment
  3208. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3209. @FIXME{There is no way to specify a new name...}
  3210. To demonstrate how @option{--concatenate} works, create two small archives
  3211. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3212. files from @file{practice}:
  3213. @smallexample
  3214. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3215. blues
  3216. rock
  3217. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3218. folk
  3219. jazz
  3220. @end smallexample
  3221. @noindent
  3222. If you like, You can run @samp{tar --list} to make sure the archives
  3223. contain what they are supposed to:
  3224. @smallexample
  3225. $ @kbd{tar -tvf bluesrock.tar}
  3226. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3227. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3228. $ @kbd{tar -tvf jazzfolk.tar}
  3229. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3230. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3231. @end smallexample
  3232. We can concatenate these two archives with @command{tar}:
  3233. @smallexample
  3234. $ @kbd{cd ..}
  3235. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3236. @end smallexample
  3237. If you now list the contents of the @file{bluesrock.tar}, you will see
  3238. that now it also contains the archive members of @file{jazzfolk.tar}:
  3239. @smallexample
  3240. $ @kbd{tar --list --file=bluesrock.tar}
  3241. blues
  3242. rock
  3243. folk
  3244. jazz
  3245. @end smallexample
  3246. When you use @option{--concatenate}, the source and target archives must
  3247. already exist and must have been created using compatible format
  3248. parameters. Notice, that @command{tar} does not check whether the
  3249. archives it concatenates have compatible formats, it does not
  3250. even check if the files are really tar archives.
  3251. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3252. tape drives, due to deficiencies in the formats those tape drives use.
  3253. @cindex @code{concatenate} vs @command{cat}
  3254. @cindex @command{cat} vs @code{concatenate}
  3255. It may seem more intuitive to you to want or try to use @command{cat} to
  3256. concatenate two archives instead of using the @option{--concatenate}
  3257. operation; after all, @command{cat} is the utility for combining files.
  3258. However, @command{tar} archives incorporate an end-of-file marker which
  3259. must be removed if the concatenated archives are to be read properly as
  3260. one archive. @option{--concatenate} removes the end-of-archive marker
  3261. from the target archive before each new archive is appended. If you use
  3262. @command{cat} to combine the archives, the result will not be a valid
  3263. @command{tar} format archive. If you need to retrieve files from an
  3264. archive that was added to using the @command{cat} utility, use the
  3265. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3266. information on dealing with archives improperly combined using the
  3267. @command{cat} shell utility.
  3268. @node delete
  3269. @subsection Removing Archive Members Using @option{--delete}
  3270. @UNREVISED
  3271. @cindex Deleting files from an archive
  3272. @cindex Removing files from an archive
  3273. @opindex delete
  3274. You can remove members from an archive by using the @option{--delete}
  3275. option. Specify the name of the archive with @option{--file}
  3276. (@option{-f}) and then specify the names of the members to be deleted;
  3277. if you list no member names, nothing will be deleted. The
  3278. @option{--verbose} option will cause @command{tar} to print the names
  3279. of the members as they are deleted. As with @option{--extract}, you
  3280. must give the exact member names when using @samp{tar --delete}.
  3281. @option{--delete} will remove all versions of the named file from the
  3282. archive. The @option{--delete} operation can run very slowly.
  3283. Unlike other operations, @option{--delete} has no short form.
  3284. @cindex Tapes, using @option{--delete} and
  3285. @cindex Deleting from tape archives
  3286. This operation will rewrite the archive. You can only use
  3287. @option{--delete} on an archive if the archive device allows you to
  3288. write to any point on the media, such as a disk; because of this, it
  3289. does not work on magnetic tapes. Do not try to delete an archive member
  3290. from a magnetic tape; the action will not succeed, and you will be
  3291. likely to scramble the archive and damage your tape. There is no safe
  3292. way (except by completely re-writing the archive) to delete files from
  3293. most kinds of magnetic tape. @xref{Media}.
  3294. To delete all versions of the file @file{blues} from the archive
  3295. @file{collection.tar} in the @file{practice} directory, make sure you
  3296. are in that directory, and then,
  3297. @smallexample
  3298. $ @kbd{tar --list --file=collection.tar}
  3299. blues
  3300. folk
  3301. jazz
  3302. rock
  3303. $ @kbd{tar --delete --file=collection.tar blues}
  3304. $ @kbd{tar --list --file=collection.tar}
  3305. folk
  3306. jazz
  3307. rock
  3308. $
  3309. @end smallexample
  3310. @FIXME{Check if the above listing is actually produced after running
  3311. all the examples on collection.tar.}
  3312. The @option{--delete} option has been reported to work properly when
  3313. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3314. @node compare
  3315. @subsection Comparing Archive Members with the File System
  3316. @cindex Verifying the currency of an archive
  3317. @UNREVISED
  3318. @opindex compare
  3319. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3320. specified archive members against files with the same names, and then
  3321. reports differences in file size, mode, owner, modification date and
  3322. contents. You should @emph{only} specify archive member names, not file
  3323. names. If you do not name any members, then @command{tar} will compare the
  3324. entire archive. If a file is represented in the archive but does not
  3325. exist in the file system, @command{tar} reports a difference.
  3326. You have to specify the record size of the archive when modifying an
  3327. archive with a non-default record size.
  3328. @command{tar} ignores files in the file system that do not have
  3329. corresponding members in the archive.
  3330. The following example compares the archive members @file{rock},
  3331. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3332. files of the same name in the file system. (Note that there is no file,
  3333. @file{funk}; @command{tar} will report an error message.)
  3334. @smallexample
  3335. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3336. rock
  3337. blues
  3338. tar: funk not found in archive
  3339. @end smallexample
  3340. The spirit behind the @option{--compare} (@option{--diff},
  3341. @option{-d}) option is to check whether the archive represents the
  3342. current state of files on disk, more than validating the integrity of
  3343. the archive media. For this later goal, @xref{verify}.
  3344. @node create options
  3345. @section Options Used by @option{--create}
  3346. @opindex create, additional options
  3347. The previous chapter described the basics of how to use
  3348. @option{--create} (@option{-c}) to create an archive from a set of files.
  3349. @xref{create}. This section described advanced options to be used with
  3350. @option{--create}.
  3351. @menu
  3352. * Ignore Failed Read::
  3353. @end menu
  3354. @node Ignore Failed Read
  3355. @subsection Ignore Fail Read
  3356. @table @option
  3357. @item --ignore-failed-read
  3358. Do not exit with nonzero on unreadable files or directories.
  3359. @end table
  3360. @node extract options
  3361. @section Options Used by @option{--extract}
  3362. @UNREVISED
  3363. @opindex extract, additional options
  3364. The previous chapter showed how to use @option{--extract} to extract
  3365. an archive into the file system. Various options cause @command{tar} to
  3366. extract more information than just file contents, such as the owner,
  3367. the permissions, the modification date, and so forth. This section
  3368. presents options to be used with @option{--extract} when certain special
  3369. considerations arise. You may review the information presented in
  3370. @ref{extract} for more basic information about the
  3371. @option{--extract} operation.
  3372. @menu
  3373. * Reading:: Options to Help Read Archives
  3374. * Writing:: Changing How @command{tar} Writes Files
  3375. * Scarce:: Coping with Scarce Resources
  3376. @end menu
  3377. @node Reading
  3378. @subsection Options to Help Read Archives
  3379. @cindex Options when reading archives
  3380. @UNREVISED
  3381. @cindex Reading incomplete records
  3382. @cindex Records, incomplete
  3383. @opindex read-full-records
  3384. Normally, @command{tar} will request data in full record increments from
  3385. an archive storage device. If the device cannot return a full record,
  3386. @command{tar} will report an error. However, some devices do not always
  3387. return full records, or do not require the last record of an archive to
  3388. be padded out to the next record boundary. To keep reading until you
  3389. obtain a full record, or to accept an incomplete record if it contains
  3390. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3391. in conjunction with the @option{--extract} or @option{--list} operations.
  3392. @xref{Blocking}.
  3393. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3394. @command{tar} reads an archive from standard input, or from a remote
  3395. machine. This is because on BSD Unix systems, attempting to read a
  3396. pipe returns however much happens to be in the pipe, even if it is
  3397. less than was requested. If this option were not enabled, @command{tar}
  3398. would fail as soon as it read an incomplete record from the pipe.
  3399. If you're not sure of the blocking factor of an archive, you can
  3400. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3401. @option{--blocking-factor=@var{512-size}} (@option{-b
  3402. @var{512-size}}), using a blocking factor larger than what the archive
  3403. uses. This lets you avoid having to determine the blocking factor
  3404. of an archive. @xref{Blocking Factor}.
  3405. @menu
  3406. * read full records::
  3407. * Ignore Zeros::
  3408. @end menu
  3409. @node read full records
  3410. @unnumberedsubsubsec Reading Full Records
  3411. @FIXME{need sentence or so of intro here}
  3412. @table @option
  3413. @opindex read-full-records
  3414. @item --read-full-records
  3415. @item -B
  3416. Use in conjunction with @option{--extract} (@option{--get},
  3417. @option{-x}) to read an archive which contains incomplete records, or
  3418. one which has a blocking factor less than the one specified.
  3419. @end table
  3420. @node Ignore Zeros
  3421. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3422. @cindex End-of-archive blocks, ignoring
  3423. @cindex Ignoring end-of-archive blocks
  3424. @opindex ignore-zeros
  3425. Normally, @command{tar} stops reading when it encounters a block of zeros
  3426. between file entries (which usually indicates the end of the archive).
  3427. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3428. completely read an archive which contains a block of zeros before the
  3429. end (i.e., a damaged archive, or one that was created by concatenating
  3430. several archives together).
  3431. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3432. versions of @command{tar} write garbage after the end-of-archive entry,
  3433. since that part of the media is never supposed to be read. @GNUTAR{}
  3434. does not write after the end of an archive, but seeks to
  3435. maintain compatiblity among archiving utilities.
  3436. @table @option
  3437. @item --ignore-zeros
  3438. @itemx -i
  3439. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3440. encountered while reading an archive. Use in conjunction with
  3441. @option{--extract} or @option{--list}.
  3442. @end table
  3443. @node Writing
  3444. @subsection Changing How @command{tar} Writes Files
  3445. @UNREVISED
  3446. @FIXME{Introductory paragraph}
  3447. @menu
  3448. * Dealing with Old Files::
  3449. * Overwrite Old Files::
  3450. * Keep Old Files::
  3451. * Keep Newer Files::
  3452. * Unlink First::
  3453. * Recursive Unlink::
  3454. * Data Modification Times::
  3455. * Setting Access Permissions::
  3456. * Directory Modification Times and Permissions::
  3457. * Writing to Standard Output::
  3458. * Writing to an External Program::
  3459. * remove files::
  3460. @end menu
  3461. @node Dealing with Old Files
  3462. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3463. @opindex overwrite-dir, introduced
  3464. When extracting files, if @command{tar} discovers that the extracted
  3465. file already exists, it normally replaces the file by removing it before
  3466. extracting it, to prevent confusion in the presence of hard or symbolic
  3467. links. (If the existing file is a symbolic link, it is removed, not
  3468. followed.) However, if a directory cannot be removed because it is
  3469. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3470. permission, etc.). The @option{--overwrite-dir} option enables this
  3471. default behavior. To be more cautious and preserve the metadata of
  3472. such a directory, use the @option{--no-overwrite-dir} option.
  3473. @cindex Overwriting old files, prevention
  3474. @opindex keep-old-files, introduced
  3475. To be even more cautious and prevent existing files from being replaced, use
  3476. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3477. to replace or update a file that already exists, i.e., a file with the
  3478. same name as an archive member prevents extraction of that archive
  3479. member. Instead, it reports an error.
  3480. @opindex overwrite, introduced
  3481. To be more aggressive about altering existing files, use the
  3482. @option{--overwrite} option. It causes @command{tar} to overwrite
  3483. existing files and to follow existing symbolic links when extracting.
  3484. @cindex Protecting old files
  3485. Some people argue that @GNUTAR{} should not hesitate
  3486. to overwrite files with other files when extracting. When extracting
  3487. a @command{tar} archive, they expect to see a faithful copy of the
  3488. state of the file system when the archive was created. It is debatable
  3489. that this would always be a proper behavior. For example, suppose one
  3490. has an archive in which @file{usr/local} is a link to
  3491. @file{usr/local2}. Since then, maybe the site removed the link and
  3492. renamed the whole hierarchy from @file{/usr/local2} to
  3493. @file{/usr/local}. Such things happen all the time. I guess it would
  3494. not be welcome at all that @GNUTAR{} removes the
  3495. whole hierarchy just to make room for the link to be reinstated
  3496. (unless it @emph{also} simultaneously restores the full
  3497. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3498. able to remove a whole hierarchy to reestablish a symbolic link, for
  3499. example, but @emph{only if} @option{--recursive-unlink} is specified
  3500. to allow this behavior. In any case, single files are silently
  3501. removed.
  3502. @opindex unlink-first, introduced
  3503. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3504. some cases by causing @command{tar} to remove files unconditionally
  3505. before extracting them.
  3506. @node Overwrite Old Files
  3507. @unnumberedsubsubsec Overwrite Old Files
  3508. @table @option
  3509. @opindex overwrite
  3510. @item --overwrite
  3511. Overwrite existing files and directory metadata when extracting files
  3512. from an archive.
  3513. This causes @command{tar} to write extracted files into the file system without
  3514. regard to the files already on the system; i.e., files with the same
  3515. names as archive members are overwritten when the archive is extracted.
  3516. It also causes @command{tar} to extract the ownership, permissions,
  3517. and time stamps onto any preexisting files or directories.
  3518. If the name of a corresponding file name is a symbolic link, the file
  3519. pointed to by the symbolic link will be overwritten instead of the
  3520. symbolic link itself (if this is possible). Moreover, special devices,
  3521. empty directories and even symbolic links are automatically removed if
  3522. they are in the way of extraction.
  3523. Be careful when using the @option{--overwrite} option, particularly when
  3524. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3525. can change the contents, ownership or permissions of any file on your
  3526. system. Also, many systems do not take kindly to overwriting files that
  3527. are currently being executed.
  3528. @opindex overwrite-dir
  3529. @item --overwrite-dir
  3530. Overwrite the metadata of directories when extracting files from an
  3531. archive, but remove other files before extracting.
  3532. @end table
  3533. @node Keep Old Files
  3534. @unnumberedsubsubsec Keep Old Files
  3535. @table @option
  3536. @opindex keep-old-files
  3537. @item --keep-old-files
  3538. @itemx -k
  3539. Do not replace existing files from archive. The
  3540. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3541. from replacing existing files with files with the same name from the
  3542. archive. The @option{--keep-old-files} option is meaningless with
  3543. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3544. files in the file system during extraction.
  3545. @end table
  3546. @node Keep Newer Files
  3547. @unnumberedsubsubsec Keep Newer Files
  3548. @table @option
  3549. @opindex keep-newer-files
  3550. @item --keep-newer-files
  3551. Do not replace existing files that are newer than their archive
  3552. copies. This option is meaningless with @option{--list} (@option{-t}).
  3553. @end table
  3554. @node Unlink First
  3555. @unnumberedsubsubsec Unlink First
  3556. @table @option
  3557. @opindex unlink-first
  3558. @item --unlink-first
  3559. @itemx -U
  3560. Remove files before extracting over them.
  3561. This can make @command{tar} run a bit faster if you know in advance
  3562. that the extracted files all need to be removed. Normally this option
  3563. slows @command{tar} down slightly, so it is disabled by default.
  3564. @end table
  3565. @node Recursive Unlink
  3566. @unnumberedsubsubsec Recursive Unlink
  3567. @table @option
  3568. @opindex recursive-unlink
  3569. @item --recursive-unlink
  3570. When this option is specified, try removing files and directory hierarchies
  3571. before extracting over them. @emph{This is a dangerous option!}
  3572. @end table
  3573. If you specify the @option{--recursive-unlink} option,
  3574. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3575. as far as current permissions will allow it. This could include removal
  3576. of the contents of a full directory hierarchy.
  3577. @node Data Modification Times
  3578. @unnumberedsubsubsec Setting Data Modification Times
  3579. @cindex Data modification times of extracted files
  3580. @cindex Modification times of extracted files
  3581. Normally, @command{tar} sets the data modification times of extracted
  3582. files to the corresponding times recorded for the files in the archive, but
  3583. limits the permissions of extracted files by the current @code{umask}
  3584. setting.
  3585. To set the data modification times of extracted files to the time when
  3586. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3587. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3588. @table @option
  3589. @opindex touch
  3590. @item --touch
  3591. @itemx -m
  3592. Sets the data modification time of extracted archive members to the time
  3593. they were extracted, not the time recorded for them in the archive.
  3594. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3595. @end table
  3596. @node Setting Access Permissions
  3597. @unnumberedsubsubsec Setting Access Permissions
  3598. @cindex Permissions of extracted files
  3599. @cindex Modes of extracted files
  3600. To set the modes (access permissions) of extracted files to those
  3601. recorded for those files in the archive, use @option{--same-permissions}
  3602. in conjunction with the @option{--extract} (@option{--get},
  3603. @option{-x}) operation.
  3604. @table @option
  3605. @opindex preserve-permission
  3606. @opindex same-permission
  3607. @item --preserve-permission
  3608. @itemx --same-permission
  3609. @c @itemx --ignore-umask
  3610. @itemx -p
  3611. Set modes of extracted archive members to those recorded in the
  3612. archive, instead of current umask settings. Use in conjunction with
  3613. @option{--extract} (@option{--get}, @option{-x}).
  3614. @end table
  3615. @node Directory Modification Times and Permissions
  3616. @unnumberedsubsubsec Directory Modification Times and Permissions
  3617. After sucessfully extracting a file member, @GNUTAR{} normally
  3618. restores its permissions and modification times, as described in the
  3619. previous sections. This cannot be done for directories, because
  3620. after extracting a directory @command{tar} will almost certainly
  3621. extract files into that directory and this will cause the directory
  3622. modification time to be updated. Moreover, restoring that directory
  3623. permissions may not permit file creation within it. Thus, restoring
  3624. directory permissions and modification times must be delayed at least
  3625. until all files have been extracted into that directory. @GNUTAR{}
  3626. restores directories using the following approach.
  3627. The extracted directories are created with the mode specified in the
  3628. archive, as modified by the umask of the user, which gives sufficient
  3629. permissions to allow file creation. The meta-information about the
  3630. directory is recorded in the temporary list of directories. When
  3631. preparing to extract next archive member, @GNUTAR{} checks if the
  3632. directory prefix of this file contains the remembered directory. If
  3633. it does not, the program assumes that all files have been extracted
  3634. into that directory, restores its modification time and permissions
  3635. and removes its entry from the internal list. This approach allows
  3636. to correctly restore directory meta-information in the majority of
  3637. cases, while keeping memory requirements sufficiently small. It is
  3638. based on the fact, that most @command{tar} archives use the predefined
  3639. order of members: first the directory, then all the files and
  3640. subdirectories in that directory.
  3641. However, this is not always true. The most important exception are
  3642. incremental archives (@pxref{Incremental Dumps}). The member order in
  3643. an incremental archive is reversed: first all directory members are
  3644. stored, followed by other (non-directory) members. So, when extracting
  3645. from incremental archives, @GNUTAR{} alters the above procedure. It
  3646. remebers all restored directories, and restores their meta-data
  3647. only after the entire archive has been processed. Notice, that you do
  3648. not need to specity any special options for that, as @GNUTAR{}
  3649. automatically detects archives in incremental format.
  3650. There may be cases, when such processing is required for normal archives
  3651. too. Consider the following example:
  3652. @smallexample
  3653. @group
  3654. $ @kbd{tar --no-recursion -cvf archive \
  3655. foo foo/file1 bar bar/file foo/file2}
  3656. foo/
  3657. foo/file1
  3658. bar/
  3659. bar/file
  3660. foo/file2
  3661. @end group
  3662. @end smallexample
  3663. During the normal operation, after encountering @file{bar}
  3664. @GNUTAR{} will assume that all files from the directory @file{foo}
  3665. were already extracted and will therefore restore its timestamp and
  3666. permission bits. However, after extracting @file{foo/file2} the
  3667. directory timestamp will be offset again.
  3668. To correctly restore directory meta-information in such cases, use
  3669. @option{delay-directory-restore} command line option:
  3670. @table @option
  3671. @opindex delay-directory-restore
  3672. @item --delay-directory-restore
  3673. Delays restoring of the modification times and permissions of extracted
  3674. directories until the end of extraction. This way, correct
  3675. meta-information is restored even if the archive has unusual member
  3676. ordering.
  3677. @opindex no-delay-directory-restore
  3678. @item --no-delay-directory-restore
  3679. Cancel the effect of the previous @option{--delay-directory-restore}.
  3680. Use this option if you have used @option{--delay-directory-restore} in
  3681. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3682. temporarily disable it.
  3683. @end table
  3684. @node Writing to Standard Output
  3685. @unnumberedsubsubsec Writing to Standard Output
  3686. @cindex Writing extracted files to standard output
  3687. @cindex Standard output, writing extracted files to
  3688. To write the extracted files to the standard output, instead of
  3689. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3690. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3691. extracting files to send them through a pipe, and do not need to
  3692. preserve them in the file system. If you extract multiple members,
  3693. they appear on standard output concatenated, in the order they are
  3694. found in the archive.
  3695. @table @option
  3696. @opindex to-stdout
  3697. @item --to-stdout
  3698. @itemx -O
  3699. Writes files to the standard output. Use only in conjunction with
  3700. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3701. used, instead of creating the files specified, @command{tar} writes
  3702. the contents of the files extracted to its standard output. This may
  3703. be useful if you are only extracting the files in order to send them
  3704. through a pipe. This option is meaningless with @option{--list}
  3705. (@option{-t}).
  3706. @end table
  3707. This can be useful, for example, if you have a tar archive containing
  3708. a big file and don't want to store the file on disk before processing
  3709. it. You can use a command like this:
  3710. @smallexample
  3711. tar -xOzf foo.tgz bigfile | process
  3712. @end smallexample
  3713. or even like this if you want to process the concatenation of the files:
  3714. @smallexample
  3715. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3716. @end smallexample
  3717. Hovewer, @option{--to-command} may be more convenient for use with
  3718. multiple files. See the next section.
  3719. @node Writing to an External Program
  3720. @unnumberedsubsubsec Writing to an External Program
  3721. You can instruct @command{tar} to send the contents of each extracted
  3722. file to the standard input of an external program:
  3723. @table @option
  3724. @opindex to-command
  3725. @item --to-command=@var{command}
  3726. Extract files and pipe their contents to the standard input of
  3727. @var{command}. When this option is used, instead of creating the
  3728. files specified, @command{tar} invokes @var{command} and pipes the
  3729. contents of the files to its standard output. @var{Command} may
  3730. contain command line arguments. The program is executed via
  3731. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3732. extracted. Non-regular files (directories, etc.) are ignored when this
  3733. option is used.
  3734. @end table
  3735. The command can obtain the information about the file it processes
  3736. from the following environment variables:
  3737. @table @var
  3738. @vrindex TAR_FILETYPE, to-command environment
  3739. @item TAR_FILETYPE
  3740. Type of the file. It is a single letter with the following meaning:
  3741. @multitable @columnfractions 0.10 0.90
  3742. @item f @tab Regular file
  3743. @item d @tab Directory
  3744. @item l @tab Symbolic link
  3745. @item h @tab Hard link
  3746. @item b @tab Block device
  3747. @item c @tab Character device
  3748. @end multitable
  3749. Currently only regular files are supported.
  3750. @vrindex TAR_MODE, to-command environment
  3751. @item TAR_MODE
  3752. File mode, an octal number.
  3753. @vrindex TAR_FILENAME, to-command environment
  3754. @item TAR_FILENAME
  3755. The name of the file.
  3756. @vrindex TAR_REALNAME, to-command environment
  3757. @item TAR_REALNAME
  3758. Name of the file as stored in the archive.
  3759. @vrindex TAR_UNAME, to-command environment
  3760. @item TAR_UNAME
  3761. Name of the file owner.
  3762. @vrindex TAR_GNAME, to-command environment
  3763. @item TAR_GNAME
  3764. Name of the file owner group.
  3765. @vrindex TAR_ATIME, to-command environment
  3766. @item TAR_ATIME
  3767. Time of last access. It is a decimal number, representing seconds
  3768. since the epoch. If the archive provides times with nanosecond
  3769. precision, the nanoseconds are appended to the timestamp after a
  3770. decimal point.
  3771. @vrindex TAR_MTIME, to-command environment
  3772. @item TAR_MTIME
  3773. Time of last modification.
  3774. @vrindex TAR_CTIME, to-command environment
  3775. @item TAR_CTIME
  3776. Time of last status change.
  3777. @vrindex TAR_SIZE, to-command environment
  3778. @item TAR_SIZE
  3779. Size of the file.
  3780. @vrindex TAR_UID, to-command environment
  3781. @item TAR_UID
  3782. UID of the file owner.
  3783. @vrindex TAR_GID, to-command environment
  3784. @item TAR_GID
  3785. GID of the file owner.
  3786. @end table
  3787. In addition to these variables, @env{TAR_VERSION} contains the
  3788. @GNUTAR{} version number.
  3789. If @var{command} exits with a non-0 status, @command{tar} will print
  3790. an error message similar to the following:
  3791. @smallexample
  3792. tar: 2345: Child returned status 1
  3793. @end smallexample
  3794. Here, @samp{2345} is the PID of the finished process.
  3795. If this behavior is not wanted, use @option{--ignore-command-error}:
  3796. @table @option
  3797. @opindex ignore-command-error
  3798. @item --ignore-command-error
  3799. Ignore exit codes of subprocesses. Notice that if the program
  3800. exits on signal or otherwise terminates abnormally, the error message
  3801. will be printed even if this option is used.
  3802. @opindex no-ignore-command-error
  3803. @item --no-ignore-command-error
  3804. Cancel the effect of any previous @option{--ignore-command-error}
  3805. option. This option is useful if you have set
  3806. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3807. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3808. @end table
  3809. @node remove files
  3810. @unnumberedsubsubsec Removing Files
  3811. @FIXME{The section is too terse. Something more to add? An example,
  3812. maybe?}
  3813. @table @option
  3814. @opindex remove-files
  3815. @item --remove-files
  3816. Remove files after adding them to the archive.
  3817. @end table
  3818. @node Scarce
  3819. @subsection Coping with Scarce Resources
  3820. @UNREVISED
  3821. @cindex Small memory
  3822. @cindex Running out of space
  3823. @menu
  3824. * Starting File::
  3825. * Same Order::
  3826. @end menu
  3827. @node Starting File
  3828. @unnumberedsubsubsec Starting File
  3829. @table @option
  3830. @opindex starting-file
  3831. @item --starting-file=@var{name}
  3832. @itemx -K @var{name}
  3833. Starts an operation in the middle of an archive. Use in conjunction
  3834. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3835. @end table
  3836. @cindex Middle of the archive, starting in the
  3837. If a previous attempt to extract files failed due to lack of disk
  3838. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3839. @var{name}}) to start extracting only after member @var{name} of the
  3840. archive. This assumes, of course, that there is now free space, or
  3841. that you are now extracting into a different file system. (You could
  3842. also choose to suspend @command{tar}, remove unnecessary files from
  3843. the file system, and then restart the same @command{tar} operation.
  3844. In this case, @option{--starting-file} is not necessary.
  3845. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3846. @node Same Order
  3847. @unnumberedsubsubsec Same Order
  3848. @table @option
  3849. @cindex Large lists of file names on small machines
  3850. @opindex same-order
  3851. @opindex preserve-order
  3852. @item --same-order
  3853. @itemx --preserve-order
  3854. @itemx -s
  3855. To process large lists of file names on machines with small amounts of
  3856. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3857. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3858. (@option{--get}, @option{-x}).
  3859. @end table
  3860. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3861. names to be listed or extracted is sorted in the same order as the
  3862. files in the archive. This allows a large list of names to be used,
  3863. even on a small machine that would not otherwise be able to hold all
  3864. the names in memory at the same time. Such a sorted list can easily be
  3865. created by running @samp{tar -t} on the archive and editing its output.
  3866. This option is probably never needed on modern computer systems.
  3867. @node backup
  3868. @section Backup options
  3869. @cindex backup options
  3870. @GNUTAR{} offers options for making backups of files
  3871. before writing new versions. These options control the details of
  3872. these backups. They may apply to the archive itself before it is
  3873. created or rewritten, as well as individual extracted members. Other
  3874. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3875. and @command{mv}, for example) offer similar options.
  3876. Backup options may prove unexpectedly useful when extracting archives
  3877. containing many members having identical name, or when extracting archives
  3878. on systems having file name limitations, making different members appear
  3879. has having similar names through the side-effect of name truncation.
  3880. (This is true only if we have a good scheme for truncated backup names,
  3881. which I'm not sure at all: I suspect work is needed in this area.)
  3882. When any existing file is backed up before being overwritten by extraction,
  3883. then clashing files are automatically be renamed to be unique, and the
  3884. true name is kept for only the last file of a series of clashing files.
  3885. By using verbose mode, users may track exactly what happens.
  3886. At the detail level, some decisions are still experimental, and may
  3887. change in the future, we are waiting comments from our users. So, please
  3888. do not learn to depend blindly on the details of the backup features.
  3889. For example, currently, directories themselves are never renamed through
  3890. using these options, so, extracting a file over a directory still has
  3891. good chances to fail. Also, backup options apply to created archives,
  3892. not only to extracted members. For created archives, backups will not
  3893. be attempted when the archive is a block or character device, or when it
  3894. refers to a remote file.
  3895. For the sake of simplicity and efficiency, backups are made by renaming old
  3896. files prior to creation or extraction, and not by copying. The original
  3897. name is restored if the file creation fails. If a failure occurs after a
  3898. partial extraction of a file, both the backup and the partially extracted
  3899. file are kept.
  3900. @table @samp
  3901. @item --backup[=@var{method}]
  3902. @opindex backup
  3903. @vindex VERSION_CONTROL
  3904. @cindex backups
  3905. Back up files that are about to be overwritten or removed.
  3906. Without this option, the original versions are destroyed.
  3907. Use @var{method} to determine the type of backups made.
  3908. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3909. environment variable. And if @env{VERSION_CONTROL} is not set,
  3910. use the @samp{existing} method.
  3911. @vindex version-control @r{Emacs variable}
  3912. This option corresponds to the Emacs variable @samp{version-control};
  3913. the same values for @var{method} are accepted as in Emacs. This option
  3914. also allows more descriptive names. The valid @var{method}s are:
  3915. @table @samp
  3916. @item t
  3917. @itemx numbered
  3918. @cindex numbered @r{backup method}
  3919. Always make numbered backups.
  3920. @item nil
  3921. @itemx existing
  3922. @cindex existing @r{backup method}
  3923. Make numbered backups of files that already have them, simple backups
  3924. of the others.
  3925. @item never
  3926. @itemx simple
  3927. @cindex simple @r{backup method}
  3928. Always make simple backups.
  3929. @end table
  3930. @item --suffix=@var{suffix}
  3931. @opindex suffix
  3932. @cindex backup suffix
  3933. @vindex SIMPLE_BACKUP_SUFFIX
  3934. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3935. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3936. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3937. set, the default is @samp{~}, just as in Emacs.
  3938. @end table
  3939. Some people express the desire to @emph{always} use the @option{--backup}
  3940. option, by defining some kind of alias or script. This is not as easy
  3941. as one may think, due to the fact that old style options should appear first
  3942. and consume arguments a bit unpredictably for an alias or script. But,
  3943. if you are ready to give up using old style options, you may resort to
  3944. using something like (a Bourne shell function here):
  3945. @smallexample
  3946. tar () @{ /usr/local/bin/tar --backup $*; @}
  3947. @end smallexample
  3948. @node Applications
  3949. @section Notable @command{tar} Usages
  3950. @UNREVISED
  3951. @FIXME{Using Unix file linking capability to recreate directory
  3952. structures---linking files into one subdirectory and then
  3953. @command{tar}ring that directory.}
  3954. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3955. @findex uuencode
  3956. You can easily use archive files to transport a group of files from
  3957. one system to another: put all relevant files into an archive on one
  3958. computer system, transfer the archive to another system, and extract
  3959. the contents there. The basic transfer medium might be magnetic tape,
  3960. Internet FTP, or even electronic mail (though you must encode the
  3961. archive with @command{uuencode} in order to transport it properly by
  3962. mail). Both machines do not have to use the same operating system, as
  3963. long as they both support the @command{tar} program.
  3964. For example, here is how you might copy a directory's contents from
  3965. one disk to another, while preserving the dates, modes, owners and
  3966. link-structure of all the files therein. In this case, the transfer
  3967. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3968. @smallexample
  3969. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  3970. @end smallexample
  3971. @noindent
  3972. You can avoid subshells by using @option{-C} option:
  3973. @smallexample
  3974. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  3975. @end smallexample
  3976. @noindent
  3977. The command also works using short option forms:
  3978. @smallexample
  3979. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  3980. | (cd targetdir; tar --extract --file=-)}
  3981. # Or:
  3982. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  3983. | tar --directory targetdir --extract --file=-}
  3984. @end smallexample
  3985. @noindent
  3986. This is one of the easiest methods to transfer a @command{tar} archive.
  3987. @node looking ahead
  3988. @section Looking Ahead: The Rest of this Manual
  3989. You have now seen how to use all eight of the operations available to
  3990. @command{tar}, and a number of the possible options. The next chapter
  3991. explains how to choose and change file and archive names, how to use
  3992. files to store names of other files which you can then call as
  3993. arguments to @command{tar} (this can help you save time if you expect to
  3994. archive the same list of files a number of times), and so forth.
  3995. @FIXME{in case it's not obvious, i'm making this up in some sense
  3996. based on my limited memory of what the next chapter *really* does. i
  3997. just wanted to flesh out this final section a little bit so i'd
  3998. remember to stick it in here. :-)}
  3999. If there are too many files to conveniently list on the command line,
  4000. you can list the names in a file, and @command{tar} will read that file.
  4001. @xref{files}.
  4002. There are various ways of causing @command{tar} to skip over some files,
  4003. and not archive them. @xref{Choosing}.
  4004. @node Backups
  4005. @chapter Performing Backups and Restoring Files
  4006. @UNREVISED
  4007. @GNUTAR{} is distributed along with the scripts
  4008. which the Free Software Foundation uses for performing backups. There
  4009. is no corresponding scripts available yet for doing restoration of
  4010. files. Even if there is a good chance those scripts may be satisfying
  4011. to you, they are not the only scripts or methods available for doing
  4012. backups and restore. You may well create your own, or use more
  4013. sophisticated packages dedicated to that purpose.
  4014. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4015. Automatic Network Disk Archiver), a backup system developed by James
  4016. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4017. This is free software, and it is available at these places:
  4018. @smallexample
  4019. http://www.cs.umd.edu/projects/amanda/amanda.html
  4020. ftp://ftp.cs.umd.edu/pub/amanda
  4021. @end smallexample
  4022. @FIXME{
  4023. Here is a possible plan for a future documentation about the backuping
  4024. scripts which are provided within the @GNUTAR{}
  4025. distribution.
  4026. @itemize @bullet
  4027. @item dumps
  4028. @itemize @minus
  4029. @item what are dumps
  4030. @item different levels of dumps
  4031. @itemize +
  4032. @item full dump = dump everything
  4033. @item level 1, level 2 dumps etc
  4034. A level @var{n} dump dumps everything changed since the last level
  4035. @var{n}-1 dump (?)
  4036. @end itemize
  4037. @item how to use scripts for dumps (ie, the concept)
  4038. @itemize +
  4039. @item scripts to run after editing backup specs (details)
  4040. @end itemize
  4041. @item Backup Specs, what is it.
  4042. @itemize +
  4043. @item how to customize
  4044. @item actual text of script [/sp/dump/backup-specs]
  4045. @end itemize
  4046. @item Problems
  4047. @itemize +
  4048. @item rsh doesn't work
  4049. @item rtape isn't installed
  4050. @item (others?)
  4051. @end itemize
  4052. @item the @option{--incremental} option of tar
  4053. @item tapes
  4054. @itemize +
  4055. @item write protection
  4056. @item types of media, different sizes and types, useful for different things
  4057. @item files and tape marks
  4058. one tape mark between files, two at end.
  4059. @item positioning the tape
  4060. MT writes two at end of write,
  4061. backspaces over one when writing again.
  4062. @end itemize
  4063. @end itemize
  4064. @end itemize
  4065. }
  4066. This chapter documents both the provided shell scripts and @command{tar}
  4067. options which are more specific to usage as a backup tool.
  4068. To @dfn{back up} a file system means to create archives that contain
  4069. all the files in that file system. Those archives can then be used to
  4070. restore any or all of those files (for instance if a disk crashes or a
  4071. file is accidentally deleted). File system @dfn{backups} are also
  4072. called @dfn{dumps}.
  4073. @menu
  4074. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4075. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4076. * Backup Levels:: Levels of Backups
  4077. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4078. * Scripted Backups:: Using the Backup Scripts
  4079. * Scripted Restoration:: Using the Restore Script
  4080. @end menu
  4081. @node Full Dumps
  4082. @section Using @command{tar} to Perform Full Dumps
  4083. @UNREVISED
  4084. @cindex full dumps
  4085. @cindex dumps, full
  4086. @cindex corrupted archives
  4087. Full dumps should only be made when no other people or programs
  4088. are modifying files in the file system. If files are modified while
  4089. @command{tar} is making the backup, they may not be stored properly in
  4090. the archive, in which case you won't be able to restore them if you
  4091. have to. (Files not being modified are written with no trouble, and do
  4092. not corrupt the entire archive.)
  4093. You will want to use the @option{--label=@var{archive-label}}
  4094. (@option{-V @var{archive-label}}) option to give the archive a
  4095. volume label, so you can tell what this archive is even if the label
  4096. falls off the tape, or anything like that.
  4097. Unless the file system you are dumping is guaranteed to fit on
  4098. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4099. Make sure you have enough tapes on hand to complete the backup.
  4100. If you want to dump each file system separately you will need to use
  4101. the @option{--one-file-system} option to prevent
  4102. @command{tar} from crossing file system boundaries when storing
  4103. (sub)directories.
  4104. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4105. option is not needed, since this is a complete copy of everything in
  4106. the file system, and a full restore from this backup would only be
  4107. done onto a completely
  4108. empty disk.
  4109. Unless you are in a hurry, and trust the @command{tar} program (and your
  4110. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4111. option, to make sure your files really made it onto the dump properly.
  4112. This will also detect cases where the file was modified while (or just
  4113. after) it was being archived. Not all media (notably cartridge tapes)
  4114. are capable of being verified, unfortunately.
  4115. @node Incremental Dumps
  4116. @section Using @command{tar} to Perform Incremental Dumps
  4117. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4118. stores additional metadata so that exact state of the file system
  4119. can be restored when extracting the archive.
  4120. @GNUTAR{} currently offers two options for handling incremental
  4121. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4122. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4123. @opindex listed-incremental
  4124. The option @option{--listed-incremental} instructs tar to operate on
  4125. an incremental archive with additional metadata stored in a standalone
  4126. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4127. determine which files have been changed, added or deleted since the
  4128. last backup, so that the next incremental backup will contain only
  4129. modified files. The name of the snapshot file is given as an argument
  4130. to the option:
  4131. @table @option
  4132. @item --listed-incremental=@var{file}
  4133. @itemx -g @var{file}
  4134. Handle incremental backups with snapshot data in @var{file}.
  4135. @end table
  4136. To create an incremental backup, you would use
  4137. @option{--listed-incremental} together with @option{--create}
  4138. (@pxref{create}). For example:
  4139. @smallexample
  4140. $ @kbd{tar --create \
  4141. --file=archive.1.tar \
  4142. --listed-incremental=/var/log/usr.snar \
  4143. /usr}
  4144. @end smallexample
  4145. This will create in @file{archive.1.tar} an incremental backup of
  4146. the @file{/usr} file system, storing additional metadata in the file
  4147. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4148. created. The created archive will then be a @dfn{level 0 backup};
  4149. please see the next section for more on backup levels.
  4150. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4151. determines which files are modified. In this case only these files will be
  4152. stored in the archive. Suppose, for example, that after running the
  4153. above command, you delete file @file{/usr/doc/old} and create
  4154. directory @file{/usr/local/db} with the following contents:
  4155. @smallexample
  4156. $ @kbd{ls /usr/local/db}
  4157. /usr/local/db/data
  4158. /usr/local/db/index
  4159. @end smallexample
  4160. Some time later you create another incremental backup. You will
  4161. then see:
  4162. @smallexample
  4163. $ @kbd{tar --create \
  4164. --file=archive.2.tar \
  4165. --listed-incremental=/var/log/usr.snar \
  4166. /usr}
  4167. tar: usr/local/db: Directory is new
  4168. usr/local/db/
  4169. usr/local/db/data
  4170. usr/local/db/index
  4171. @end smallexample
  4172. @noindent
  4173. The created archive @file{archive.2.tar} will contain only these
  4174. three members. This archive is called a @dfn{level 1 backup}. Notice
  4175. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4176. you plan to create more @samp{level 1} backups, it is necessary to
  4177. create a working copy of the snapshot file before running
  4178. @command{tar}. The above example will then be modified as follows:
  4179. @smallexample
  4180. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4181. $ @kbd{tar --create \
  4182. --file=archive.2.tar \
  4183. --listed-incremental=/var/log/usr.snar-1 \
  4184. /usr}
  4185. @end smallexample
  4186. Incremental dumps depend crucially on time stamps, so the results are
  4187. unreliable if you modify a file's time stamps during dumping (e.g.,
  4188. with the @option{--atime-preserve=replace} option), or if you set the clock
  4189. backwards.
  4190. Metadata stored in snapshot files include device numbers, which,
  4191. obviously is supposed to be a non-volatile value. However, it turns
  4192. out that NFS devices have undependable values when an automounter
  4193. gets in the picture. This can lead to a great deal of spurious
  4194. redumping in incremental dumps, so it is somewhat useless to compare
  4195. two NFS devices numbers over time. The solution implemented currently
  4196. is to considers all NFS devices as being equal when it comes to
  4197. comparing directories; this is fairly gross, but there does not seem
  4198. to be a better way to go.
  4199. Note that incremental archives use @command{tar} extensions and may
  4200. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4201. @opindex listed-incremental, using with @option{--extract}
  4202. @opindex extract, using with @option{--listed-incremental}
  4203. To extract from the incremental dumps, use
  4204. @option{--listed-incremental} together with @option{--extract}
  4205. option (@pxref{extracting files}). In this case, @command{tar} does
  4206. not need to access snapshot file, since all the data necessary for
  4207. extraction are stored in the archive itself. So, when extracting, you
  4208. can give whatever argument to @option{--listed-incremental}, the usual
  4209. practice is to use @option{--listed-incremental=/dev/null}.
  4210. Alternatively, you can use @option{--incremental}, which needs no
  4211. arguments. In general, @option{--incremental} (@option{-G}) can be
  4212. used as a shortcut for @option{--listed-incremental} when listing or
  4213. extracting incremental backups (for more information, regarding this
  4214. option, @pxref{incremental-op}).
  4215. When extracting from the incremental backup @GNUTAR{} attempts to
  4216. restore the exact state the file system had when the archive was
  4217. created. In particular, it will @emph{delete} those files in the file
  4218. system that did not exist in their directories when the archive was
  4219. created. If you have created several levels of incremental files,
  4220. then in order to restore the exact contents the file system had when
  4221. the last level was created, you will need to restore from all backups
  4222. in turn. Continuing our example, to restore the state of @file{/usr}
  4223. file system, one would do@footnote{Notice, that since both archives
  4224. were created withouth @option{-P} option (@pxref{absolute}), these
  4225. commands should be run from the root file system.}:
  4226. @smallexample
  4227. $ @kbd{tar --extract \
  4228. --listed-incremental=/dev/null \
  4229. --file archive.1.tar}
  4230. $ @kbd{tar --extract \
  4231. --listed-incremental=/dev/null \
  4232. --file archive.2.tar}
  4233. @end smallexample
  4234. To list the contents of an incremental archive, use @option{--list}
  4235. (@pxref{list}), as usual. To obtain more information about the
  4236. archive, use @option{--listed-incremental} or @option{--incremental}
  4237. combined with two @option{--verbose} options@footnote{Two
  4238. @option{--verbose} options were selected to avoid breaking usual
  4239. verbose listing output (@option{--list --verbose}) when using in
  4240. scripts.
  4241. @opindex incremental, using with @option{--list}
  4242. @opindex listed-incremental, using with @option{--list}
  4243. @opindex list, using with @option{--incremental}
  4244. @opindex list, using with @option{--listed-incremental}
  4245. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4246. contents of the DUMPDIR header (with terminating nulls) when
  4247. @option{--incremental} or @option{--listed-incremental} option was
  4248. given, no matter what the verbosity level. This behavior, and,
  4249. especially, the binary output it produced were considered incovenient
  4250. and were changed in version 1.16}:
  4251. @smallexample
  4252. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4253. @end smallexample
  4254. This command will print, for each directory in the archive, the list
  4255. of files in that directory at the time the archive was created. This
  4256. information is put out in a format which is both human-readable and
  4257. unambiguous for a program: each file name is printed as
  4258. @smallexample
  4259. @var{x} @var{file}
  4260. @end smallexample
  4261. @noindent
  4262. where @var{x} is a letter describing the status of the file: @samp{Y}
  4263. if the file is present in the archive, @samp{N} if the file is not
  4264. included in the archive, or a @samp{D} if the file is a directory (and
  4265. is included in the archive). @xref{Dumpdir}, for the detailed
  4266. description of dumpdirs and status codes. Each such
  4267. line is terminated by a newline character. The last line is followed
  4268. by an additional newline to indicate the end of the data.
  4269. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4270. gives the same behavior as @option{--listed-incremental} when used
  4271. with @option{--list} and @option{--extract} options. When used with
  4272. @option{--create} option, it creates an incremental archive without
  4273. creating snapshot file. Thus, it is impossible to create several
  4274. levels of incremental backups with @option{--incremental} option.
  4275. @node Backup Levels
  4276. @section Levels of Backups
  4277. An archive containing all the files in the file system is called a
  4278. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4279. creating a full dump every day. This strategy, however, would waste a
  4280. substantial amount of archive media and user time, as unchanged files
  4281. are daily re-archived.
  4282. It is more efficient to do a full dump only occasionally. To back up
  4283. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4284. one} dump archives all the files that have changed since the last full
  4285. dump.
  4286. A typical dump strategy would be to perform a full dump once a week,
  4287. and a level one dump once a day. This means some versions of files
  4288. will in fact be archived more than once, but this dump strategy makes
  4289. it possible to restore a file system to within one day of accuracy by
  4290. only extracting two archives---the last weekly (full) dump and the
  4291. last daily (level one) dump. The only information lost would be in
  4292. files changed or created since the last daily backup. (Doing dumps
  4293. more than once a day is usually not worth the trouble).
  4294. @GNUTAR{} comes with scripts you can use to do full
  4295. and level-one (actually, even level-two and so on) dumps. Using
  4296. scripts (shell programs) to perform backups and restoration is a
  4297. convenient and reliable alternative to typing out file name lists
  4298. and @command{tar} commands by hand.
  4299. Before you use these scripts, you need to edit the file
  4300. @file{backup-specs}, which specifies parameters used by the backup
  4301. scripts and by the restore script. This file is usually located
  4302. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4303. detailed description. Once the backup parameters are set, you can
  4304. perform backups or restoration by running the appropriate script.
  4305. The name of the backup script is @code{backup}. The name of the
  4306. restore script is @code{restore}. The following sections describe
  4307. their use in detail.
  4308. @emph{Please Note:} The backup and restoration scripts are
  4309. designed to be used together. While it is possible to restore files by
  4310. hand from an archive which was created using a backup script, and to create
  4311. an archive by hand which could then be extracted using the restore script,
  4312. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4313. making such an attempt.
  4314. @node Backup Parameters
  4315. @section Setting Parameters for Backups and Restoration
  4316. The file @file{backup-specs} specifies backup parameters for the
  4317. backup and restoration scripts provided with @command{tar}. You must
  4318. edit @file{backup-specs} to fit your system configuration and schedule
  4319. before using these scripts.
  4320. Syntactically, @file{backup-specs} is a shell script, containing
  4321. mainly variable assignments. However, any valid shell construct
  4322. is allowed in this file. Particularly, you may wish to define
  4323. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4324. For more information about shell script syntax, please refer to
  4325. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4326. g_02, the definition of the Shell Command Language}. See also
  4327. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4328. The shell variables controlling behavior of @code{backup} and
  4329. @code{restore} are described in the following subsections.
  4330. @menu
  4331. * General-Purpose Variables::
  4332. * Magnetic Tape Control::
  4333. * User Hooks::
  4334. * backup-specs example:: An Example Text of @file{Backup-specs}
  4335. @end menu
  4336. @node General-Purpose Variables
  4337. @subsection General-Purpose Variables
  4338. @defvr {Backup variable} ADMINISTRATOR
  4339. The user name of the backup administrator. @code{Backup} scripts
  4340. sends a backup report to this address.
  4341. @end defvr
  4342. @defvr {Backup variable} BACKUP_HOUR
  4343. The hour at which the backups are done. This can be a number from 0
  4344. to 23, or the time specification in form @var{hours}:@var{minutes},
  4345. or the string @samp{now}.
  4346. This variable is used by @code{backup}. Its value may be overridden
  4347. using @option{--time} option (@pxref{Scripted Backups}).
  4348. @end defvr
  4349. @defvr {Backup variable} TAPE_FILE
  4350. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4351. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4352. that your @command{mt} is able to access remote devices. If @var{RSH}
  4353. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4354. invocations of @command{mt}.
  4355. @end defvr
  4356. @defvr {Backup variable} BLOCKING
  4357. The blocking factor @command{tar} will use when writing the dump archive.
  4358. @xref{Blocking Factor}.
  4359. @end defvr
  4360. @defvr {Backup variable} BACKUP_DIRS
  4361. A list of file systems to be dumped (for @code{backup}), or restored
  4362. (for @code{restore}). You can include any directory
  4363. name in the list --- subdirectories on that file system will be
  4364. included, regardless of how they may look to other networked machines.
  4365. Subdirectories on other file systems will be ignored.
  4366. The host name specifies which host to run @command{tar} on, and should
  4367. normally be the host that actually contains the file system. However,
  4368. the host machine must have @GNUTAR{} installed, and
  4369. must be able to access the directory containing the backup scripts and
  4370. their support files using the same file name that is used on the
  4371. machine where the scripts are run (ie. what @command{pwd} will print
  4372. when in that directory on that machine). If the host that contains
  4373. the file system does not have this capability, you can specify another
  4374. host as long as it can access the file system through NFS.
  4375. If the list of file systems is very long you may wish to put it
  4376. in a separate file. This file is usually named
  4377. @file{/etc/backup/dirs}, but this name may be overridden in
  4378. @file{backup-specs} using @code{DIRLIST} variable.
  4379. @end defvr
  4380. @defvr {Backup variable} DIRLIST
  4381. A path to the file containing the list of the file systems to backup
  4382. or restore. By default it is @file{/etc/backup/dirs}.
  4383. @end defvr
  4384. @defvr {Backup variable} BACKUP_FILES
  4385. A list of individual files to be dumped (for @code{backup}), or restored
  4386. (for @code{restore}). These should be accessible from the machine on
  4387. which the backup script is run.
  4388. If the list of file systems is very long you may wish to store it
  4389. in a separate file. This file is usually named
  4390. @file{/etc/backup/files}, but this name may be overridden in
  4391. @file{backup-specs} using @code{FILELIST} variable.
  4392. @end defvr
  4393. @defvr {Backup variable} FILELIST
  4394. A path to the file containing the list of the individual files to backup
  4395. or restore. By default it is @file{/etc/backup/files}.
  4396. @end defvr
  4397. @defvr {Backup variable} MT
  4398. Full file name of @command{mt} binary.
  4399. @end defvr
  4400. @defvr {Backup variable} RSH
  4401. @anchor{RSH}
  4402. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4403. set it to @code{ssh}, to improve security. In this case you will have
  4404. to use public key authentication.
  4405. @end defvr
  4406. @defvr {Backup variable} RSH_COMMAND
  4407. Full file name of @command{rsh} binary on remote mashines. This will
  4408. be passed via @option{--rsh-command} option to the remote invocation
  4409. of @GNUTAR{}.
  4410. @end defvr
  4411. @defvr {Backup variable} VOLNO_FILE
  4412. Name of temporary file to hold volume numbers. This needs to be accessible
  4413. by all the machines which have file systems to be dumped.
  4414. @end defvr
  4415. @defvr {Backup variable} XLIST
  4416. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4417. located on the remote machine and containing the list of files to
  4418. be excluded from the backup. Exclude file lists are searched in
  4419. /etc/tar-backup directory. A common use for exclude file lists
  4420. is to exclude files containing security-sensitive information
  4421. (e.g., @file{/etc/shadow} from backups).
  4422. This variable affects only @code{backup}.
  4423. @end defvr
  4424. @defvr {Backup variable} SLEEP_TIME
  4425. Time to sleep between dumps of any two successive file systems
  4426. This variable affects only @code{backup}.
  4427. @end defvr
  4428. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4429. Script to be run when it's time to insert a new tape in for the next
  4430. volume. Administrators may want to tailor this script for their site.
  4431. If this variable isn't set, @GNUTAR{} will display its built-in
  4432. prompt, and will expect confirmation from the console.
  4433. The built-in prompt for POSIX locale is:
  4434. @smallexample
  4435. Prepare volume #@var{n} for `@var{archive}' and hit return:
  4436. @end smallexample
  4437. @noindent
  4438. where @var{n} is the ordinal number of the volume to be created and
  4439. @var{archive} is archive file or device name.
  4440. If you run @GNUTAR{} under a different locale, the translation of
  4441. the above prompt to the locale's language will be used.
  4442. @end defvr
  4443. @defvr {Backup variable} SLEEP_MESSAGE
  4444. Message to display on the terminal while waiting for dump time. Usually
  4445. this will just be some literal text.
  4446. @end defvr
  4447. @defvr {Backup variable} TAR
  4448. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4449. scripts will search @command{tar} in the current shell path.
  4450. @end defvr
  4451. @node Magnetic Tape Control
  4452. @subsection Magnetic Tape Control
  4453. Backup scripts access tape device using special @dfn{hook functions}.
  4454. These functions take a single argument -- the name of the tape
  4455. device. Their names are kept in the following variables:
  4456. @defvr {Backup variable} MT_BEGIN
  4457. The name of @dfn{begin} function. This function is called before
  4458. accessing the drive. By default it retensions the tape:
  4459. @smallexample
  4460. MT_BEGIN=mt_begin
  4461. mt_begin() @{
  4462. mt -f "$1" retension
  4463. @}
  4464. @end smallexample
  4465. @end defvr
  4466. @defvr {Backup variable} MT_REWIND
  4467. The name of @dfn{rewind} function. The default definition is as
  4468. follows:
  4469. @smallexample
  4470. MT_REWIND=mt_rewind
  4471. mt_rewind() @{
  4472. mt -f "$1" rewind
  4473. @}
  4474. @end smallexample
  4475. @end defvr
  4476. @defvr {Backup variable} MT_OFFLINE
  4477. The name of the function switching the tape off line. By default
  4478. it is defined as follows:
  4479. @smallexample
  4480. MT_OFFLINE=mt_offline
  4481. mt_offline() @{
  4482. mt -f "$1" offl
  4483. @}
  4484. @end smallexample
  4485. @end defvr
  4486. @defvr {Backup variable} MT_STATUS
  4487. The name of the function used to obtain the status of the archive device,
  4488. including error count. Default definition:
  4489. @smallexample
  4490. MT_STATUS=mt_status
  4491. mt_status() @{
  4492. mt -f "$1" status
  4493. @}
  4494. @end smallexample
  4495. @end defvr
  4496. @node User Hooks
  4497. @subsection User Hooks
  4498. @dfn{User hooks} are shell functions executed before and after
  4499. each @command{tar} invocation. Thus, there are @dfn{backup
  4500. hooks}, which are executed before and after dumping each file
  4501. system, and @dfn{restore hooks}, executed before and
  4502. after restoring a file system. Each user hook is a shell function
  4503. taking four arguments:
  4504. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4505. Its arguments are:
  4506. @table @var
  4507. @item level
  4508. Current backup or restore level.
  4509. @item host
  4510. Name or IP address of the host machine being dumped or restored.
  4511. @item fs
  4512. Full path name to the file system being dumped or restored.
  4513. @item fsname
  4514. File system name with directory separators replaced with colons. This
  4515. is useful, e.g., for creating unique files.
  4516. @end table
  4517. @end deffn
  4518. Following variables keep the names of user hook functions
  4519. @defvr {Backup variable} DUMP_BEGIN
  4520. Dump begin function. It is executed before dumping the file system.
  4521. @end defvr
  4522. @defvr {Backup variable} DUMP_END
  4523. Executed after dumping the file system.
  4524. @end defvr
  4525. @defvr {Backup variable} RESTORE_BEGIN
  4526. Executed before restoring the file system.
  4527. @end defvr
  4528. @defvr {Backup variable} RESTORE_END
  4529. Executed after restoring the file system.
  4530. @end defvr
  4531. @node backup-specs example
  4532. @subsection An Example Text of @file{Backup-specs}
  4533. The following is an example of @file{backup-specs}:
  4534. @smallexample
  4535. # site-specific parameters for file system backup.
  4536. ADMINISTRATOR=friedman
  4537. BACKUP_HOUR=1
  4538. TAPE_FILE=/dev/nrsmt0
  4539. # Use @code{ssh} instead of the less secure @code{rsh}
  4540. RSH=/usr/bin/ssh
  4541. RSH_COMMAND=/usr/bin/ssh
  4542. # Override MT_STATUS function:
  4543. my_status() @{
  4544. mts -t $TAPE_FILE
  4545. @}
  4546. MT_STATUS=my_status
  4547. # Disable MT_OFFLINE function
  4548. MT_OFFLINE=:
  4549. BLOCKING=124
  4550. BACKUP_DIRS="
  4551. albert:/fs/fsf
  4552. apple-gunkies:/gd
  4553. albert:/fs/gd2
  4554. albert:/fs/gp
  4555. geech:/usr/jla
  4556. churchy:/usr/roland
  4557. albert:/
  4558. albert:/usr
  4559. apple-gunkies:/
  4560. apple-gunkies:/usr
  4561. gnu:/hack
  4562. gnu:/u
  4563. apple-gunkies:/com/mailer/gnu
  4564. apple-gunkies:/com/archive/gnu"
  4565. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4566. @end smallexample
  4567. @node Scripted Backups
  4568. @section Using the Backup Scripts
  4569. The syntax for running a backup script is:
  4570. @smallexample
  4571. backup --level=@var{level} --time=@var{time}
  4572. @end smallexample
  4573. The @option{level} option requests the dump level. Thus, to produce
  4574. a full dump, specify @code{--level=0} (this is the default, so
  4575. @option{--level} may be omitted if its value is @code{0}).
  4576. @footnote{For backward compatibility, the @code{backup} will also
  4577. try to deduce the requested dump level from the name of the
  4578. script itself. If the name consists of a string @samp{level-}
  4579. followed by a single decimal digit, that digit is taken as
  4580. the dump level number. Thus, you may create a link from @code{backup}
  4581. to @code{level-1} and then run @code{level-1} whenever you need to
  4582. create a level one dump.}
  4583. The @option{--time} option determines when should the backup be
  4584. run. @var{Time} may take three forms:
  4585. @table @asis
  4586. @item @var{hh}:@var{mm}
  4587. The dump must be run at @var{hh} hours @var{mm} minutes.
  4588. @item @var{hh}
  4589. The dump must be run at @var{hh} hours
  4590. @item now
  4591. The dump must be run immediately.
  4592. @end table
  4593. You should start a script with a tape or disk mounted. Once you
  4594. start a script, it prompts you for new tapes or disks as it
  4595. needs them. Media volumes don't have to correspond to archive
  4596. files --- a multi-volume archive can be started in the middle of a
  4597. tape that already contains the end of another multi-volume archive.
  4598. The @code{restore} script prompts for media by its archive volume,
  4599. so to avoid an error message you should keep track of which tape
  4600. (or disk) contains which volume of the archive (@pxref{Scripted
  4601. Restoration}).
  4602. The backup scripts write two files on the file system. The first is a
  4603. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4604. to store and retrieve information about which files were dumped. This
  4605. file is not meant to be read by humans, and should not be deleted by
  4606. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4607. file.
  4608. The second file is a log file containing the names of the file systems
  4609. and files dumped, what time the backup was made, and any error
  4610. messages that were generated, as well as how much space was left in
  4611. the media volume after the last volume of the archive was written.
  4612. You should check this log file after every backup. The file name is
  4613. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4614. represents current date, and @var{n} represents current dump level number.
  4615. The script also prints the name of each system being dumped to the
  4616. standard output.
  4617. Following is the full list of options accepted by @code{backup}
  4618. script:
  4619. @table @option
  4620. @item -l @var{level}
  4621. @itemx --level=@var{level}
  4622. Do backup level @var{level} (default 0).
  4623. @item -f
  4624. @itemx --force
  4625. Force backup even if today's log file already exists.
  4626. @item -v[@var{level}]
  4627. @itemx --verbose[=@var{level}]
  4628. Set verbosity level. The higher the level is, the more debugging
  4629. information will be output during execution. Devault @var{level}
  4630. is 100, which means the highest debugging level.
  4631. @item -t @var{start-time}
  4632. @itemx --time=@var{start-time}
  4633. Wait till @var{time}, then do backup.
  4634. @item -h
  4635. @itemx --help
  4636. Display short help message and exit.
  4637. @item -V
  4638. @itemx --version
  4639. Display information about the program's name, version, origin and legal
  4640. status, all on standard output, and then exit successfully.
  4641. @end table
  4642. @node Scripted Restoration
  4643. @section Using the Restore Script
  4644. To restore files that were archived using a scripted backup, use the
  4645. @code{restore} script. Its usage is quite straightforward. In the
  4646. simplest form, invoke @code{restore --all}, it will
  4647. then restore all the file systems and files specified in
  4648. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4649. You may select the file systems (and/or files) to restore by
  4650. giving @code{restore} list of @dfn{patterns} in its command
  4651. line. For example, running
  4652. @smallexample
  4653. restore 'albert:*'
  4654. @end smallexample
  4655. @noindent
  4656. will restore all file systems on the machine @samp{albert}. A more
  4657. complicated example:
  4658. @smallexample
  4659. restore 'albert:*' '*:/var'
  4660. @end smallexample
  4661. @noindent
  4662. This command will restore all file systems on the machine @samp{albert}
  4663. as well as @file{/var} file system on all machines.
  4664. By default @code{restore} will start restoring files from the lowest
  4665. available dump level (usually zero) and will continue through
  4666. all available dump levels. There may be situations where such a
  4667. thorough restore is not necessary. For example, you may wish to
  4668. restore only files from the recent level one backup. To do so,
  4669. use @option{--level} option, as shown in the example below:
  4670. @smallexample
  4671. restore --level=1
  4672. @end smallexample
  4673. The full list of options accepted by @code{restore} follows:
  4674. @table @option
  4675. @item -a
  4676. @itemx --all
  4677. Restore all file systems and files specified in @file{backup-specs}
  4678. @item -l @var{level}
  4679. @itemx --level=@var{level}
  4680. Start restoring from the given backup level, instead of the default 0.
  4681. @item -v[@var{level}]
  4682. @itemx --verbose[=@var{level}]
  4683. Set verbosity level. The higher the level is, the more debugging
  4684. information will be output during execution. Devault @var{level}
  4685. is 100, which means the highest debugging level.
  4686. @item -h
  4687. @itemx --help
  4688. Display short help message and exit.
  4689. @item -V
  4690. @itemx --version
  4691. Display information about the program's name, version, origin and legal
  4692. status, all on standard output, and then exit successfully.
  4693. @end table
  4694. You should start the restore script with the media containing the
  4695. first volume of the archive mounted. The script will prompt for other
  4696. volumes as they are needed. If the archive is on tape, you don't need
  4697. to rewind the tape to to its beginning---if the tape head is
  4698. positioned past the beginning of the archive, the script will rewind
  4699. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4700. positioning.}
  4701. @quotation
  4702. @strong{Warning:} The script will delete files from the active file
  4703. system if they were not in the file system when the archive was made.
  4704. @end quotation
  4705. @xref{Incremental Dumps}, for an explanation of how the script makes
  4706. that determination.
  4707. @node Choosing
  4708. @chapter Choosing Files and Names for @command{tar}
  4709. @UNREVISED
  4710. Certain options to @command{tar} enable you to specify a name for your
  4711. archive. Other options let you decide which files to include or exclude
  4712. from the archive, based on when or whether files were modified, whether
  4713. the file names do or don't match specified patterns, or whether files
  4714. are in specified directories.
  4715. This chapter discusses these options in detail.
  4716. @menu
  4717. * file:: Choosing the Archive's Name
  4718. * Selecting Archive Members::
  4719. * files:: Reading Names from a File
  4720. * exclude:: Excluding Some Files
  4721. * wildcards:: Wildcards Patterns and Matching
  4722. * quoting styles:: Ways of Quoting Special Characters in Names
  4723. * transform:: Modifying File and Member Names
  4724. * after:: Operating Only on New Files
  4725. * recurse:: Descending into Directories
  4726. * one:: Crossing File System Boundaries
  4727. @end menu
  4728. @node file
  4729. @section Choosing and Naming Archive Files
  4730. @UNREVISED
  4731. @cindex Naming an archive
  4732. @cindex Archive Name
  4733. @cindex Choosing an archive file
  4734. @cindex Where is the archive?
  4735. By default, @command{tar} uses an archive file name that was compiled when
  4736. it was built on the system; usually this name refers to some physical
  4737. tape drive on the machine. However, the person who installed @command{tar}
  4738. on the system may not have set the default to a meaningful value as far as
  4739. most users are concerned. As a result, you will usually want to tell
  4740. @command{tar} where to find (or create) the archive. The
  4741. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4742. option allows you to either specify or name a file to use as the archive
  4743. instead of the default archive file location.
  4744. @table @option
  4745. @opindex file, short description
  4746. @item --file=@var{archive-name}
  4747. @itemx -f @var{archive-name}
  4748. Name the archive to create or operate on. Use in conjunction with
  4749. any operation.
  4750. @end table
  4751. For example, in this @command{tar} command,
  4752. @smallexample
  4753. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4754. @end smallexample
  4755. @noindent
  4756. @file{collection.tar} is the name of the archive. It must directly
  4757. follow the @option{-f} option, since whatever directly follows @option{-f}
  4758. @emph{will} end up naming the archive. If you neglect to specify an
  4759. archive name, you may end up overwriting a file in the working directory
  4760. with the archive you create since @command{tar} will use this file's name
  4761. for the archive name.
  4762. An archive can be saved as a file in the file system, sent through a
  4763. pipe or over a network, or written to an I/O device such as a tape,
  4764. floppy disk, or CD write drive.
  4765. @cindex Writing new archives
  4766. @cindex Archive creation
  4767. If you do not name the archive, @command{tar} uses the value of the
  4768. environment variable @env{TAPE} as the file name for the archive. If
  4769. that is not available, @command{tar} uses a default, compiled-in archive
  4770. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4771. @cindex Standard input and output
  4772. @cindex tar to standard input and output
  4773. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4774. archive from standard input (when listing or extracting files), or
  4775. writes it to standard output (when creating an archive). If you use
  4776. @file{-} as an @var{archive-name} when modifying an archive,
  4777. @command{tar} reads the original archive from its standard input and
  4778. writes the entire new archive to its standard output.
  4779. The following example is a convenient way of copying directory
  4780. hierarchy from @file{sourcedir} to @file{targetdir}.
  4781. @smallexample
  4782. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4783. @end smallexample
  4784. The @option{-C} option allows to avoid using subshells:
  4785. @smallexample
  4786. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4787. @end smallexample
  4788. In both examples above, the leftmost @command{tar} invocation archives
  4789. the contents of @file{sourcedir} to the standard output, while the
  4790. rightmost one reads this archive from its standard input and
  4791. extracts it. The @option{-p} option tells it to restore permissions
  4792. of the extracted files.
  4793. @cindex Remote devices
  4794. @cindex tar to a remote device
  4795. @anchor{remote-dev}
  4796. To specify an archive file on a device attached to a remote machine,
  4797. use the following:
  4798. @smallexample
  4799. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4800. @end smallexample
  4801. @noindent
  4802. @command{tar} will complete the remote connection, if possible, and
  4803. prompt you for a username and password. If you use
  4804. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  4805. will complete the remote connection, if possible, using your username
  4806. as the username on the remote machine.
  4807. @cindex Local and remote archives
  4808. @anchor{local and remote archives}
  4809. If the archive file name includes a colon (@samp{:}), then it is assumed
  4810. to be a file on another machine. If the archive file is
  4811. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4812. host @var{host}. The remote host is accessed using the @command{rsh}
  4813. program, with a username of @var{user}. If the username is omitted
  4814. (along with the @samp{@@} sign), then your user name will be used.
  4815. (This is the normal @command{rsh} behavior.) It is necessary for the
  4816. remote machine, in addition to permitting your @command{rsh} access, to
  4817. have the @file{rmt} program installed (This command is included in
  4818. the @GNUTAR{} distribution and by default is installed under
  4819. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4820. installation prefix). If you need to use a file whose name includes a
  4821. colon, then the remote tape drive behavior
  4822. can be inhibited by using the @option{--force-local} option.
  4823. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4824. tries to minimize input and output operations. The Amanda backup
  4825. system, when used with @GNUTAR{}, has an initial sizing pass which
  4826. uses this feature.
  4827. @node Selecting Archive Members
  4828. @section Selecting Archive Members
  4829. @cindex Specifying files to act on
  4830. @cindex Specifying archive members
  4831. @dfn{File Name arguments} specify which files in the file system
  4832. @command{tar} operates on, when creating or adding to an archive, or which
  4833. archive members @command{tar} operates on, when reading or deleting from
  4834. an archive. @xref{Operations}.
  4835. To specify file names, you can include them as the last arguments on
  4836. the command line, as follows:
  4837. @smallexample
  4838. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4839. @end smallexample
  4840. If a file name begins with dash (@samp{-}), precede it with
  4841. @option{--add-file} option to prevent it from being treated as an
  4842. option.
  4843. If you specify a directory name as a file name argument, all the files
  4844. in that directory are operated on by @command{tar}.
  4845. If you do not specify files, @command{tar} behavior differs depending
  4846. on the operation mode as described below:
  4847. When @command{tar} is invoked with @option{--create} (@option{-c}),
  4848. @command{tar} will stop immediately, reporting the following:
  4849. @smallexample
  4850. @group
  4851. $ @kbd{tar cf a.tar}
  4852. tar: Cowardly refusing to create an empty archive
  4853. Try `tar --help' or `tar --usage' for more information.
  4854. @end group
  4855. @end smallexample
  4856. If you specify either @option{--list} (@option{-t}) or
  4857. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  4858. operates on all the archive members in the archive.
  4859. If run with @option{--diff} option, tar will compare the archive with
  4860. the contents of the current working directory.
  4861. If you specify any other operation, @command{tar} does nothing.
  4862. By default, @command{tar} takes file names from the command line. However,
  4863. there are other ways to specify file or member names, or to modify the
  4864. manner in which @command{tar} selects the files or members upon which to
  4865. operate. In general, these methods work both for specifying the names
  4866. of files and archive members.
  4867. @node files
  4868. @section Reading Names from a File
  4869. @cindex Reading file names from a file
  4870. @cindex Lists of file names
  4871. @cindex File Name arguments, alternatives
  4872. Instead of giving the names of files or archive members on the command
  4873. line, you can put the names into a file, and then use the
  4874. @option{--files-from=@var{file-of-names}} (@option{-T
  4875. @var{file-of-names}}) option to @command{tar}. Give the name of the
  4876. file which contains the list of files to include as the argument to
  4877. @option{--files-from}. In the list, the file names should be separated by
  4878. newlines. You will frequently use this option when you have generated
  4879. the list of files to archive with the @command{find} utility.
  4880. @table @option
  4881. @opindex files-from
  4882. @item --files-from=@var{file-name}
  4883. @itemx -T @var{file-name}
  4884. Get names to extract or create from file @var{file-name}.
  4885. @end table
  4886. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4887. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4888. names are read from standard input.
  4889. Unless you are running @command{tar} with @option{--create}, you can not use
  4890. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4891. command.
  4892. Any number of @option{-T} options can be given in the command line.
  4893. The following example shows how to use @command{find} to generate a list of
  4894. files smaller than 400K in length and put that list into a file
  4895. called @file{small-files}. You can then use the @option{-T} option to
  4896. @command{tar} to specify the files from that file, @file{small-files}, to
  4897. create the archive @file{little.tgz}. (The @option{-z} option to
  4898. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4899. more information.)
  4900. @smallexample
  4901. $ @kbd{find . -size -400 -print > small-files}
  4902. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4903. @end smallexample
  4904. @noindent
  4905. In the file list given by @option{-T} option, any file name beginning
  4906. with @samp{-} character is considered a @command{tar} option and is
  4907. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4908. recognized only @option{-C} option in file lists, and only if the
  4909. option and its argument occupied two consecutive lines.} For example,
  4910. the common use of this feature is to change to another directory by
  4911. specifying @option{-C} option:
  4912. @smallexample
  4913. @group
  4914. $ @kbd{cat list}
  4915. -C/etc
  4916. passwd
  4917. hosts
  4918. -C/lib
  4919. libc.a
  4920. $ @kbd{tar -c -f foo.tar --files-from list}
  4921. @end group
  4922. @end smallexample
  4923. @noindent
  4924. In this example, @command{tar} will first switch to @file{/etc}
  4925. directory and add files @file{passwd} and @file{hosts} to the
  4926. archive. Then it will change to @file{/lib} directory and will archive
  4927. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4928. contain:
  4929. @smallexample
  4930. @group
  4931. $ @kbd{tar tf foo.tar}
  4932. passwd
  4933. hosts
  4934. libc.a
  4935. @end group
  4936. @end smallexample
  4937. @noindent
  4938. @opindex directory, using in @option{--files-from} argument
  4939. Notice that the option parsing algorithm used with @option{-T} is
  4940. stricter than the one used by shell. Namely, when specifying option
  4941. arguments, you should observe the following rules:
  4942. @itemize @bullet
  4943. @item
  4944. When using short (single-letter) option form, its argument must
  4945. immediately follow the option letter, without any intervening
  4946. whitespace. For example: @code{-Cdir}.
  4947. @item
  4948. When using long option form, the option argument must be separated
  4949. from the option by a single equal sign. No whitespace is allowed on
  4950. any side of the equal sign. For example: @code{--directory=dir}.
  4951. @item
  4952. For both short and long option forms, the option argument can be given
  4953. on the next line after the option name, e.g.:
  4954. @smallexample
  4955. @group
  4956. --directory
  4957. dir
  4958. @end group
  4959. @end smallexample
  4960. @noindent
  4961. and
  4962. @smallexample
  4963. @group
  4964. -C
  4965. dir
  4966. @end group
  4967. @end smallexample
  4968. @end itemize
  4969. @opindex add-file
  4970. If you happen to have a file whose name starts with @samp{-},
  4971. precede it with @option{--add-file} option to prevent it from
  4972. being recognized as an option. For example: @code{--add-file=--my-file}.
  4973. @menu
  4974. * nul::
  4975. @end menu
  4976. @node nul
  4977. @subsection @code{NUL} Terminated File Names
  4978. @cindex File names, terminated by @code{NUL}
  4979. @cindex @code{NUL} terminated file names
  4980. The @option{--null} option causes
  4981. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  4982. to read file names terminated by a @code{NUL} instead of a newline, so
  4983. files whose names contain newlines can be archived using
  4984. @option{--files-from}.
  4985. @table @option
  4986. @opindex null
  4987. @item --null
  4988. Only consider @code{NUL} terminated file names, instead of files that
  4989. terminate in a newline.
  4990. @end table
  4991. The @option{--null} option is just like the one in @acronym{GNU}
  4992. @command{xargs} and @command{cpio}, and is useful with the
  4993. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4994. @command{tar}, @option{--null} also disables special handling for
  4995. file names that begin with dash.
  4996. This example shows how to use @command{find} to generate a list of files
  4997. larger than 800K in length and put that list into a file called
  4998. @file{long-files}. The @option{-print0} option to @command{find} is just
  4999. like @option{-print}, except that it separates files with a @code{NUL}
  5000. rather than with a newline. You can then run @command{tar} with both the
  5001. @option{--null} and @option{-T} options to specify that @command{tar} get the
  5002. files from that file, @file{long-files}, to create the archive
  5003. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5004. @command{tar} to recognize the @code{NUL} separator between files.
  5005. @smallexample
  5006. $ @kbd{find . -size +800 -print0 > long-files}
  5007. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5008. @end smallexample
  5009. @FIXME{say anything else here to conclude the section?}
  5010. @node exclude
  5011. @section Excluding Some Files
  5012. @UNREVISED
  5013. @cindex File names, excluding files by
  5014. @cindex Excluding files by name and pattern
  5015. @cindex Excluding files by file system
  5016. To avoid operating on files whose names match a particular pattern,
  5017. use the @option{--exclude} or @option{--exclude-from} options.
  5018. @table @option
  5019. @opindex exclude
  5020. @item --exclude=@var{pattern}
  5021. Causes @command{tar} to ignore files that match the @var{pattern}.
  5022. @end table
  5023. @findex exclude
  5024. The @option{--exclude=@var{pattern}} option prevents any file or
  5025. member whose name matches the shell wildcard (@var{pattern}) from
  5026. being operated on.
  5027. For example, to create an archive with all the contents of the directory
  5028. @file{src} except for files whose names end in @file{.o}, use the
  5029. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5030. You may give multiple @option{--exclude} options.
  5031. @table @option
  5032. @opindex exclude-from
  5033. @item --exclude-from=@var{file}
  5034. @itemx -X @var{file}
  5035. Causes @command{tar} to ignore files that match the patterns listed in
  5036. @var{file}.
  5037. @end table
  5038. @findex exclude-from
  5039. Use the @option{--exclude-from} option to read a
  5040. list of patterns, one per line, from @var{file}; @command{tar} will
  5041. ignore files matching those patterns. Thus if @command{tar} is
  5042. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5043. single line @file{*.o}, no files whose names end in @file{.o} will be
  5044. added to the archive.
  5045. @table @option
  5046. @opindex exclude-caches
  5047. @item --exclude-caches
  5048. Causes @command{tar} to ignore directories containing a cache directory tag.
  5049. @end table
  5050. @findex exclude-caches
  5051. When creating an archive, the @option{--exclude-caches} option causes
  5052. @command{tar} to exclude all directories that contain a @dfn{cache
  5053. directory tag}. A cache directory tag is a short file with the
  5054. well-known name @file{CACHEDIR.TAG} and having a standard header
  5055. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5056. Various applications write cache directory tags into directories they
  5057. use to hold regenerable, non-precious data, so that such data can be
  5058. more easily excluded from backups.
  5059. @menu
  5060. * problems with exclude::
  5061. @end menu
  5062. @node problems with exclude
  5063. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5064. @opindex exclude, potential problems with
  5065. Some users find @samp{exclude} options confusing. Here are some common
  5066. pitfalls:
  5067. @itemize @bullet
  5068. @item
  5069. The main operating mode of @command{tar} does not act on a path name
  5070. explicitly listed on the command line if one of its file name
  5071. components is excluded. In the example above, if
  5072. you create an archive and exclude files that end with @samp{*.o}, but
  5073. explicitly name the file @samp{dir.o/foo} after all the options have been
  5074. listed, @samp{dir.o/foo} will be excluded from the archive.
  5075. @item
  5076. You can sometimes confuse the meanings of @option{--exclude} and
  5077. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5078. to be excluded are given as a pattern on the command line. Use
  5079. @option{--exclude-from} to introduce the name of a file which contains
  5080. a list of patterns, one per line; each of these patterns can exclude
  5081. zero, one, or many files.
  5082. @item
  5083. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5084. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5085. like @samp{*}. If you do not do this, the shell might expand the
  5086. @samp{*} itself using files at hand, so @command{tar} might receive a
  5087. list of files instead of one pattern, or none at all, making the
  5088. command somewhat illegal. This might not correspond to what you want.
  5089. For example, write:
  5090. @smallexample
  5091. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5092. @end smallexample
  5093. @noindent
  5094. rather than:
  5095. @smallexample
  5096. # @emph{Wrong!}
  5097. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5098. @end smallexample
  5099. @item
  5100. You must use use shell syntax, or globbing, rather than @code{regexp}
  5101. syntax, when using exclude options in @command{tar}. If you try to use
  5102. @code{regexp} syntax to describe files to be excluded, your command
  5103. might fail.
  5104. @item
  5105. @FIXME{The change in semantics must have occurred before 1.11,
  5106. so I doubt if it is worth mentioning at all. Anyway, should at
  5107. least specify in which version the semantics changed.}
  5108. In earlier versions of @command{tar}, what is now the
  5109. @option{--exclude-from} option was called @option{--exclude} instead.
  5110. Now, @option{--exclude} applies to patterns listed on the command
  5111. line and @option{--exclude-from} applies to patterns listed in a
  5112. file.
  5113. @end itemize
  5114. @node wildcards
  5115. @section Wildcards Patterns and Matching
  5116. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5117. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5118. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5119. patterns for matching (or globbing) archive members when extracting
  5120. from or listing an archive. Wildcard patterns are also used for
  5121. verifying volume labels of @command{tar} archives. This section has the
  5122. purpose of explaining wildcard syntax for @command{tar}.
  5123. @FIXME{the next few paragraphs need work.}
  5124. A @var{pattern} should be written according to shell syntax, using wildcard
  5125. characters to effect globbing. Most characters in the pattern stand
  5126. for themselves in the matched string, and case is significant: @samp{a}
  5127. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5128. pattern matches any single character in the matched string. The character
  5129. @samp{*} in the pattern matches zero, one, or more single characters in
  5130. the matched string. The character @samp{\} says to take the following
  5131. character of the pattern @emph{literally}; it is useful when one needs to
  5132. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5133. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5134. class. A @dfn{character class} is a list of acceptable characters
  5135. for the next single character of the matched string. For example,
  5136. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5137. Note that within a character class, all of the ``special characters''
  5138. listed above other than @samp{\} lose their special meaning; for example,
  5139. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5140. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5141. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5142. @emph{last} in a character class.)
  5143. @cindex Excluding characters from a character class
  5144. @cindex Character class, excluding characters from
  5145. If the first character of the class after the opening @samp{[}
  5146. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5147. Rather than listing character to match, it lists those characters which
  5148. are @emph{forbidden} as the next single character of the matched string.
  5149. Other characters of the class stand for themselves. The special
  5150. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5151. letters, is meant to represent all characters between @var{a} and
  5152. @var{e}, inclusive.
  5153. @FIXME{need to add a sentence or so here to make this clear for those
  5154. who don't have dan around.}
  5155. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5156. special for wildcard matches. However, if a pattern completely matches
  5157. a directory prefix of a matched string, then it matches the full matched
  5158. string: thus, excluding a directory also excludes all the files beneath it.
  5159. @menu
  5160. * controlling pattern-matching::
  5161. @end menu
  5162. @node controlling pattern-matching
  5163. @unnumberedsubsec Controlling Pattern-Matching
  5164. For the purposes of this section, we call @dfn{exclusion members} all
  5165. member names obtained while processing @option{--exclude} and
  5166. @option{--exclude-from} options, and @dfn{inclusion members} those
  5167. member names that were given in the command line or read from the file
  5168. specified with @option{--files-from} option.
  5169. These two pairs of member lists are used in the following operations:
  5170. @option{--diff}, @option{--extract}, @option{--list},
  5171. @option{--update}.
  5172. There are no inclusion members in create mode (@option{--create} and
  5173. @option{--append}), since in this mode the names obtained from the
  5174. command line refer to @emph{files}, not archive members.
  5175. By default, inclusion members are compared with archive members
  5176. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5177. globbing for inclusion members, which contradicted to UNIX98
  5178. specification and was not documented. @xref{Changes}, for more
  5179. information on this and other changes.} and exclusion members are
  5180. treated as globbing patterns. For example:
  5181. @smallexample
  5182. @group
  5183. $ @kbd{tar tf foo.tar}
  5184. a.c
  5185. b.c
  5186. a.txt
  5187. [remarks]
  5188. # @i{Member names are used verbatim:}
  5189. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5190. [remarks]
  5191. # @i{Exclude member names are globbed:}
  5192. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5193. a.txt
  5194. [remarks]
  5195. @end group
  5196. @end smallexample
  5197. This behavior can be altered by using the following options:
  5198. @table @option
  5199. @opindex wildcards
  5200. @item --wildcards
  5201. Treat all member names as wildcards.
  5202. @opindex no-wildcards
  5203. @item --no-wildcards
  5204. Treat all member names as literal strings.
  5205. @end table
  5206. Thus, to extract files whose names end in @samp{.c}, you can use:
  5207. @smallexample
  5208. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5209. a.c
  5210. b.c
  5211. @end smallexample
  5212. @noindent
  5213. Notice quoting of the pattern to prevent the shell from interpreting
  5214. it.
  5215. The effect of @option{--wildcards} option is cancelled by
  5216. @option{--no-wildcards}. This can be used to pass part of
  5217. the command line arguments verbatim and other part as globbing
  5218. patterns. For example, the following invocation:
  5219. @smallexample
  5220. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5221. @end smallexample
  5222. @noindent
  5223. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5224. names end in @samp{.txt} and the file named @file{[remarks]}.
  5225. Normally, a pattern matches a name if an initial subsequence of the
  5226. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5227. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5228. and wildcards can match @samp{/}.
  5229. Other than optionally stripping leading @samp{/} from names
  5230. (@pxref{absolute}), patterns and names are used as-is. For
  5231. example, trailing @samp{/} is not trimmed from a user-specified name
  5232. before deciding whether to exclude it.
  5233. However, this matching procedure can be altered by the options listed
  5234. below. These options accumulate. For example:
  5235. @smallexample
  5236. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5237. @end smallexample
  5238. @noindent
  5239. ignores case when excluding @samp{makefile}, but not when excluding
  5240. @samp{readme}.
  5241. @table @option
  5242. @opindex anchored
  5243. @opindex no-anchored
  5244. @item --anchored
  5245. @itemx --no-anchored
  5246. If anchored, a pattern must match an initial subsequence
  5247. of the name's components. Otherwise, the pattern can match any
  5248. subsequence. Default is @option{--no-anchored} for exclusion members
  5249. and @option{--anchored} inclusion members.
  5250. @opindex ignore-case
  5251. @opindex no-ignore-case
  5252. @item --ignore-case
  5253. @itemx --no-ignore-case
  5254. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5255. When not ignoring case (the default), matching is case-sensitive.
  5256. @opindex wildcards-match-slash
  5257. @opindex no-wildcards-match-slash
  5258. @item --wildcards-match-slash
  5259. @itemx --no-wildcards-match-slash
  5260. When wildcards match slash (the default for exclusion members), a
  5261. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5262. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5263. @end table
  5264. The @option{--recursion} and @option{--no-recursion} options
  5265. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5266. recursion is in effect, a pattern matches a name if it matches any of
  5267. the name's parent directories.
  5268. The following table summarizes pattern-matching default values:
  5269. @multitable @columnfractions .3 .7
  5270. @headitem Members @tab Default settings
  5271. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5272. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5273. @end multitable
  5274. @node quoting styles
  5275. @section Quoting Member Names
  5276. When displaying member names, @command{tar} takes care to avoid
  5277. ambiguities caused by certain characters. This is called @dfn{name
  5278. quoting}. The characters in question are:
  5279. @itemize @bullet
  5280. @item Non-printable control characters:
  5281. @multitable @columnfractions 0.20 0.10 0.60
  5282. @headitem Character @tab ASCII @tab Character name
  5283. @item \a @tab 7 @tab Audible bell
  5284. @item \b @tab 8 @tab Backspace
  5285. @item \f @tab 12 @tab Form feed
  5286. @item \n @tab 10 @tab New line
  5287. @item \r @tab 13 @tab Carriage return
  5288. @item \t @tab 9 @tab Horizontal tabulation
  5289. @item \v @tab 11 @tab Vertical tabulation
  5290. @end multitable
  5291. @item Space (ASCII 32)
  5292. @item Single and double quotes (@samp{'} and @samp{"})
  5293. @item Backslash (@samp{\})
  5294. @end itemize
  5295. The exact way @command{tar} uses to quote these characters depends on
  5296. the @dfn{quoting style}. The default quoting style, called
  5297. @dfn{escape} (see below), uses backslash notation to represent control
  5298. characters, space and backslash. Using this quoting style, control
  5299. characters are represented as listed in column @samp{Character} in the
  5300. above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
  5301. @GNUTAR{} offers seven distinct quoting styles, which can be selected
  5302. using @option{--quoting-style} option:
  5303. @table @option
  5304. @item --quoting-style=@var{style}
  5305. @opindex quoting-style
  5306. Sets quoting style. Valid values for @var{style} argument are:
  5307. literal, shell, shell-always, c, escape, locale, clocale.
  5308. @end table
  5309. These styles are described in detail below. To illustrate their
  5310. effect, we will use an imaginary tar archive @file{arch.tar}
  5311. containing the following members:
  5312. @smallexample
  5313. @group
  5314. # 1. Contains horizontal tabulation character.
  5315. a tab
  5316. # 2. Contains newline character
  5317. a
  5318. newline
  5319. # 3. Contains a space
  5320. a space
  5321. # 4. Contains double quotes
  5322. a"double"quote
  5323. # 5. Contains single quotes
  5324. a'single'quote
  5325. # 6. Contains a backslash character:
  5326. a\backslash
  5327. @end group
  5328. @end smallexample
  5329. Here is how usual @command{ls} command would have listed them, if they
  5330. had existed in the current working directory:
  5331. @smallexample
  5332. @group
  5333. $ @kbd{ls}
  5334. a\ttab
  5335. a\nnewline
  5336. a\ space
  5337. a"double"quote
  5338. a'single'quote
  5339. a\\backslash
  5340. @end group
  5341. @end smallexample
  5342. Quoting styles:
  5343. @table @samp
  5344. @item literal
  5345. No quoting, display each character as is:
  5346. @smallexample
  5347. @group
  5348. $ @kbd{tar tf arch.tar --quoting-style=literal}
  5349. ./
  5350. ./a space
  5351. ./a'single'quote
  5352. ./a"double"quote
  5353. ./a\backslash
  5354. ./a tab
  5355. ./a
  5356. newline
  5357. @end group
  5358. @end smallexample
  5359. @item shell
  5360. Display characters the same way Bourne shell does:
  5361. control characters, except @samp{\t} and @samp{\n}, are printed using
  5362. backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
  5363. single quote is printed as @samp{\'}. If a name contains any quoted
  5364. characters, it is enclosed in single quotes. In particular, if a name
  5365. contains single quotes, it is printed as several single-quoted strings:
  5366. @smallexample
  5367. @group
  5368. $ @kbd{tar tf arch.tar --quoting-style=shell}
  5369. ./
  5370. './a space'
  5371. './a'\''single'\''quote'
  5372. './a"double"quote'
  5373. './a\backslash'
  5374. './a tab'
  5375. './a
  5376. newline'
  5377. @end group
  5378. @end smallexample
  5379. @item shell-always
  5380. Same as @samp{shell}, but the names are always enclosed in single
  5381. quotes:
  5382. @smallexample
  5383. @group
  5384. $ @kbd{tar tf arch.tar --quoting-style=shell-always}
  5385. './'
  5386. './a space'
  5387. './a'\''single'\''quote'
  5388. './a"double"quote'
  5389. './a\backslash'
  5390. './a tab'
  5391. './a
  5392. newline'
  5393. @end group
  5394. @end smallexample
  5395. @item c
  5396. Use the notation of the C programming language. All names are
  5397. enclosed in double quotes. Control characters are quoted using
  5398. backslash notations, double quotes are represented as @samp{\"},
  5399. backslash characters are represented as @samp{\\}. Single quotes and
  5400. spaces are not quoted:
  5401. @smallexample
  5402. @group
  5403. $ @kbd{tar tf arch.tar --quoting-style=c}
  5404. "./"
  5405. "./a space"
  5406. "./a'single'quote"
  5407. "./a\"double\"quote"
  5408. "./a\\backslash"
  5409. "./a\ttab"
  5410. "./a\nnewline"
  5411. @end group
  5412. @end smallexample
  5413. @item escape
  5414. Control characters are printed using backslash notation, a space is
  5415. printed as @samp{\ } and a backslash as @samp{\\}. This is the
  5416. default quoting style, unless it was changed when configured the
  5417. package.
  5418. @smallexample
  5419. @group
  5420. $ @kbd{tar tf arch.tar --quoting-style=escape}
  5421. ./
  5422. ./a space
  5423. ./a'single'quote
  5424. ./a"double"quote
  5425. ./a\\backslash
  5426. ./a\ttab
  5427. ./a\nnewline
  5428. @end group
  5429. @end smallexample
  5430. @item locale
  5431. Control characters, single quote and backslash are printed using
  5432. backslash notation. All names are quoted using left and right
  5433. quotation marks, appropriate to the current locale. If it does not
  5434. define quotation marks, use @samp{`} as left and @samp{'} as right
  5435. quotation marks. Any occurrences of the right quotation mark in a
  5436. name are escaped with @samp{\}, for example:
  5437. For example:
  5438. @smallexample
  5439. @group
  5440. $ @kbd{tar tf arch.tar --quoting-style=locale}
  5441. `./'
  5442. `./a space'
  5443. `./a\'single\'quote'
  5444. `./a"double"quote'
  5445. `./a\\backslash'
  5446. `./a\ttab'
  5447. `./a\nnewline'
  5448. @end group
  5449. @end smallexample
  5450. @item clocale
  5451. Same as @samp{locale}, but @samp{"} is used for both left and right
  5452. quotation marks, if not provided by the currently selected locale:
  5453. @smallexample
  5454. @group
  5455. $ @kbd{tar tf arch.tar --quoting-style=clocale}
  5456. "./"
  5457. "./a space"
  5458. "./a'single'quote"
  5459. "./a\"double\"quote"
  5460. "./a\\backslash"
  5461. "./a\ttab"
  5462. "./a\nnewline"
  5463. @end group
  5464. @end smallexample
  5465. @end table
  5466. You can specify which characters should be quoted in addition to those
  5467. implied by the current quoting style:
  5468. @table @option
  5469. @item --quote-chars=@var{string}
  5470. Always quote characters from @var{string}, even if the selected
  5471. quoting style would not quote them.
  5472. @end table
  5473. For example, using @samp{escape} quoting (compare with the usual
  5474. escape listing above):
  5475. @smallexample
  5476. @group
  5477. $ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
  5478. ./
  5479. ./a\ space
  5480. ./a'single'quote
  5481. ./a\"double\"quote
  5482. ./a\\backslash
  5483. ./a\ttab
  5484. ./a\nnewline
  5485. @end group
  5486. @end smallexample
  5487. To disable quoting of such additional characters, use the following
  5488. option:
  5489. @table @option
  5490. @item --no-quote-chars=@var{string}
  5491. Remove characters listed in @var{string} from the list of quoted
  5492. characters set by the previous @option{--quote-chars} option.
  5493. @end table
  5494. This option is particularly useful if you have added
  5495. @option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
  5496. and wish to disable it for the current invocation.
  5497. Note, that @option{--no-quote-chars} does @emph{not} disable those
  5498. characters that are quoted by default in the selected quoting style.
  5499. @node transform
  5500. @section Modifying File and Member Names
  5501. @command{Tar} archives contain detailed information about files stored
  5502. in them and full file names are part of that information. When
  5503. storing file to an archive, its file name is recorded in the archive
  5504. along with the actual file contents. When restoring from an archive,
  5505. a file is created on disk with exactly the same name as that stored
  5506. in the archive. In the majority of cases this is the desired behavior
  5507. of a file archiver. However, there are some cases when it is not.
  5508. First of all, it is often unsafe to extract archive members with
  5509. absolute file names or those that begin with a @file{../}. @GNUTAR{}
  5510. takes special precautions when extracting such names and provides a
  5511. special option for handling them, which is described in
  5512. @ref{absolute}.
  5513. Secondly, you may wish to extract file names without some leading
  5514. directory components, or with otherwise modified names. In other
  5515. cases it is desirable to store files under differing names in the
  5516. archive.
  5517. @GNUTAR{} provides two options for these needs.
  5518. @table @option
  5519. @opindex strip-components
  5520. @item --strip-components=@var{number}
  5521. Strip given @var{number} of leading components from file names before
  5522. extraction.
  5523. @end table
  5524. For example, suppose you have archived whole @file{/usr} hierarchy to
  5525. a tar archive named @file{usr.tar}. Among other files, this archive
  5526. contains @file{usr/include/stdlib.h}, which you wish to extract to
  5527. the current working directory. To do so, you type:
  5528. @smallexample
  5529. $ @kbd{tar -xf usr.tar --strip=2 usr/include/stdlib.h}
  5530. @end smallexample
  5531. The option @option{--strip=2} instructs @command{tar} to strip the
  5532. two leading components (@file{usr/} and @file{include/}) off the file
  5533. name.
  5534. If you add to the above invocation @option{--verbose} (@option{-v})
  5535. option, you will note that the verbose listing still contains the
  5536. full file name, with the two removed components still in place. This
  5537. can be inconvenient, so @command{tar} provides a special option for
  5538. altering this behavior:
  5539. @anchor{show-transformed-names}
  5540. @table @option
  5541. @opindex --show-transformed-names
  5542. @item --show-transformed-names
  5543. Display file or member names with all requested transformations
  5544. applied.
  5545. @end table
  5546. @noindent
  5547. For example:
  5548. @smallexample
  5549. @group
  5550. $ @kbd{tar -xf usr.tar -v --strip=2 usr/include/stdlib.h}
  5551. usr/include/stdlib.h
  5552. $ @kbd{tar -xf usr.tar -v --strip=2 --show-transformed usr/include/stdlib.h}
  5553. stdlib.h
  5554. @end group
  5555. @end smallexample
  5556. Notice that in both cases the file is @file{stdlib.h} extracted to the
  5557. current working directory, @option{--show-transformed-names} affects
  5558. only the way its name is displayed.
  5559. This option is especially useful for verifying whether the invocation
  5560. will have the desired effect. Thus, before running
  5561. @smallexample
  5562. $ @kbd{tar -x --strip=@var{n}}
  5563. @end smallexample
  5564. @noindent
  5565. it is often advisable to run
  5566. @smallexample
  5567. $ @kbd{tar -t -v --show-transformed --strip=@var{n}}
  5568. @end smallexample
  5569. @noindent
  5570. to make sure the command will produce the intended results.
  5571. In case you need to apply more complex modifications to the file name,
  5572. @GNUTAR{} provides a general-purpose transformation option:
  5573. @table @option
  5574. @opindex --transform
  5575. @item --transform=@var{expression}
  5576. Modify file names using supplied @var{expression}.
  5577. @end table
  5578. @noindent
  5579. The @var{expression} is a @command{sed}-like replace expression of the
  5580. form:
  5581. @smallexample
  5582. s/@var{regexp}/@var{replace}/[@var{flags}]
  5583. @end smallexample
  5584. @noindent
  5585. where @var{regexp} is a @dfn{regular expression}, @var{replace} is a
  5586. replacement for each file name part that matches @var{regexp}. Both
  5587. @var{regexp} and @var{replace} are described in detail in
  5588. @ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}.
  5589. Supported @var{flags} are:
  5590. @table @samp
  5591. @item g
  5592. Apply the replacement to @emph{all} matches to the @var{regexp}, not
  5593. just the first.
  5594. @item i
  5595. Use case-insensitive matching
  5596. @item x
  5597. @var{regexp} is an @dfn{extended regular expression} (@pxref{Extended
  5598. regexps, Extended regular expressions, Extended regular expressions,
  5599. sed, GNU sed}).
  5600. @item @var{number}
  5601. Only replace the @var{number}th match of the @var{regexp}.
  5602. Note: the @var{posix} standard does not specify what should happen
  5603. when you mix the @samp{g} and @var{number} modifiers. @GNUTAR{}
  5604. follows the GNU @command{sed} implementation in this regard, so
  5605. the the interaction is defined to be: ignore matches before the
  5606. @var{number}th, and then match and replace all matches from the
  5607. @var{number}th on.
  5608. @end table
  5609. Any delimiter can be used in lieue of @samp{/}, the only requirement being
  5610. that it be used consistently throughout the expression. For example,
  5611. the following two expressions are equivalent:
  5612. @smallexample
  5613. @group
  5614. s/one/two/
  5615. s,one,two,
  5616. @end group
  5617. @end smallexample
  5618. Changing delimiters is often useful when the @var{regex} contains
  5619. slashes. For example, it is more convenient to write @code{s,/,-,} than
  5620. @code{s/\//-/}.
  5621. Here are several examples of @option{--transform} usage:
  5622. @enumerate
  5623. @item Extract @file{usr/} hierarchy into @file{usr/local/}:
  5624. @smallexample
  5625. $ @kbd{tar --transform='s,usr/,usr/local/,' -x -f arch.tar}
  5626. @end smallexample
  5627. @item Strip two leading directory components (equivalent to
  5628. @option{--strip-components=2}):
  5629. @smallexample
  5630. $ @kbd{tar --transform='s,/*[^/]*/[^/]*/,,' -x -f arch.tar}
  5631. @end smallexample
  5632. @item Prepend @file{/prefix/} to each file name:
  5633. @smallexample
  5634. $ @kbd{tar --transform 's,^,/prefix/,' -x -f arch.tar}
  5635. @end smallexample
  5636. @item Convert each file name to lower case:
  5637. @smallexample
  5638. $ @kbd{tar --transform 's/.*/\L&/' -x -f arch.tar}
  5639. @end smallexample
  5640. @end enumerate
  5641. Unlike @option{--strip-components}, @option{--transform} can be used
  5642. in any @GNUTAR{} operation mode. For example, the following command
  5643. adds files to the archive while replacing the leading @file{usr/}
  5644. component with @file{var/}:
  5645. @smallexample
  5646. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' /}
  5647. @end smallexample
  5648. To test @option{--transform} effect we suggest using
  5649. @option{--show-transformed-names} option:
  5650. @smallexample
  5651. $ @kbd{tar -cf arch.tar --transform='s,^usr/,var/,' \
  5652. --verbose --show-transformed-names /}
  5653. @end smallexample
  5654. If both @option{--strip-components} and @option{--transform} are used
  5655. together, then @option{--transform} is applied first, and the required
  5656. number of components is then stripped from its result.
  5657. @node after
  5658. @section Operating Only on New Files
  5659. @UNREVISED
  5660. @cindex Excluding file by age
  5661. @cindex Data Modification time, excluding files by
  5662. @cindex Modification time, excluding files by
  5663. @cindex Age, excluding files by
  5664. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5665. @option{-N @var{date}}) option causes @command{tar} to only work on
  5666. files whose data modification or status change times are newer than
  5667. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5668. it is taken to be a file name; the data modification time of that file
  5669. is used as the date. If you use this option when creating or appending
  5670. to an archive, the archive will only include new files. If you use
  5671. @option{--after-date} when extracting an archive, @command{tar} will
  5672. only extract files newer than the @var{date} you specify.
  5673. If you only want @command{tar} to make the date comparison based on
  5674. modification of the file's data (rather than status
  5675. changes), then use the @option{--newer-mtime=@var{date}} option.
  5676. You may use these options with any operation. Note that these options
  5677. differ from the @option{--update} (@option{-u}) operation in that they
  5678. allow you to specify a particular date against which @command{tar} can
  5679. compare when deciding whether or not to archive the files.
  5680. @table @option
  5681. @opindex after-date
  5682. @opindex newer
  5683. @item --after-date=@var{date}
  5684. @itemx --newer=@var{date}
  5685. @itemx -N @var{date}
  5686. Only store files newer than @var{date}.
  5687. Acts on files only if their data modification or status change times are
  5688. later than @var{date}. Use in conjunction with any operation.
  5689. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5690. name; the data modification time of that file is used as the date.
  5691. @opindex newer-mtime
  5692. @item --newer-mtime=@var{date}
  5693. Acts like @option{--after-date}, but only looks at data modification times.
  5694. @end table
  5695. These options limit @command{tar} to operate only on files which have
  5696. been modified after the date specified. A file's status is considered to have
  5697. changed if its contents have been modified, or if its owner,
  5698. permissions, and so forth, have been changed. (For more information on
  5699. how to specify a date, see @ref{Date input formats}; remember that the
  5700. entire date argument must be quoted if it contains any spaces.)
  5701. Gurus would say that @option{--after-date} tests both the data
  5702. modification time (@code{mtime}, the time the contents of the file
  5703. were last modified) and the status change time (@code{ctime}, the time
  5704. the file's status was last changed: owner, permissions, etc.@:)
  5705. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5706. field.
  5707. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5708. @code{ctime} and processes the file if either one is more recent than
  5709. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5710. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5711. contents of the file were looked at).
  5712. Date specifiers can have embedded spaces. Because of this, you may need
  5713. to quote date arguments to keep the shell from parsing them as separate
  5714. arguments. For example, the following command will add to the archive
  5715. all the files modified less than two days ago:
  5716. @smallexample
  5717. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  5718. @end smallexample
  5719. @quotation
  5720. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5721. should not be used for incremental backups. @xref{Incremental Dumps},
  5722. for proper way of creating incremental backups.
  5723. @end quotation
  5724. @node recurse
  5725. @section Descending into Directories
  5726. @UNREVISED
  5727. @cindex Avoiding recursion in directories
  5728. @cindex Descending directories, avoiding
  5729. @cindex Directories, avoiding recursion
  5730. @cindex Recursion in directories, avoiding
  5731. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5732. Usually, @command{tar} will recursively explore all directories (either
  5733. those given on the command line or through the @option{--files-from}
  5734. option) for the various files they contain. However, you may not always
  5735. want @command{tar} to act this way.
  5736. @opindex no-recursion
  5737. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5738. into specified directories. If you specify @option{--no-recursion}, you can
  5739. use the @command{find} utility for hunting through levels of directories to
  5740. construct a list of file names which you could then pass to @command{tar}.
  5741. @command{find} allows you to be more selective when choosing which files to
  5742. archive; see @ref{files}, for more information on using @command{find} with
  5743. @command{tar}, or look.
  5744. @table @option
  5745. @item --no-recursion
  5746. Prevents @command{tar} from recursively descending directories.
  5747. @opindex recursion
  5748. @item --recursion
  5749. Requires @command{tar} to recursively descend directories.
  5750. This is the default.
  5751. @end table
  5752. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5753. directory entries themselves, but does not descend on them
  5754. recursively. Many people use @command{find} for locating files they
  5755. want to back up, and since @command{tar} @emph{usually} recursively
  5756. descends on directories, they have to use the @samp{@w{-not -type d}}
  5757. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  5758. find, Finding Files}), as they usually do not want all the files in a
  5759. directory. They then use the @option{--files-from} option to archive
  5760. the files located via @command{find}.
  5761. The problem when restoring files archived in this manner is that the
  5762. directories themselves are not in the archive; so the
  5763. @option{--same-permissions} (@option{--preserve-permissions},
  5764. @option{-p}) option does not affect them---while users might really
  5765. like it to. Specifying @option{--no-recursion} is a way to tell
  5766. @command{tar} to grab only the directory entries given to it, adding
  5767. no new files on its own. To summarize, if you use @command{find} to
  5768. create a list of files to be stored in an archive, use it as follows:
  5769. @smallexample
  5770. @group
  5771. $ @kbd{find @var{dir} @var{tests} | \
  5772. tar -cf @var{archive} -T - --no-recursion}
  5773. @end group
  5774. @end smallexample
  5775. The @option{--no-recursion} option also applies when extracting: it
  5776. causes @command{tar} to extract only the matched directory entries, not
  5777. the files under those directories.
  5778. The @option{--no-recursion} option also affects how globbing patterns
  5779. are interpreted (@pxref{controlling pattern-matching}).
  5780. The @option{--no-recursion} and @option{--recursion} options apply to
  5781. later options and operands, and can be overridden by later occurrences
  5782. of @option{--no-recursion} and @option{--recursion}. For example:
  5783. @smallexample
  5784. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5785. @end smallexample
  5786. @noindent
  5787. creates an archive with one entry for @file{grape}, and the recursive
  5788. contents of @file{grape/concord}, but no entries under @file{grape}
  5789. other than @file{grape/concord}.
  5790. @node one
  5791. @section Crossing File System Boundaries
  5792. @cindex File system boundaries, not crossing
  5793. @UNREVISED
  5794. @command{tar} will normally automatically cross file system boundaries in
  5795. order to archive files which are part of a directory tree. You can
  5796. change this behavior by running @command{tar} and specifying
  5797. @option{--one-file-system}. This option only affects files that are
  5798. archived because they are in a directory that is being archived;
  5799. @command{tar} will still archive files explicitly named on the command line
  5800. or through @option{--files-from}, regardless of where they reside.
  5801. @table @option
  5802. @opindex one-file-system
  5803. @item --one-file-system
  5804. Prevents @command{tar} from crossing file system boundaries when
  5805. archiving. Use in conjunction with any write operation.
  5806. @end table
  5807. The @option{--one-file-system} option causes @command{tar} to modify its
  5808. normal behavior in archiving the contents of directories. If a file in
  5809. a directory is not on the same file system as the directory itself, then
  5810. @command{tar} will not archive that file. If the file is a directory
  5811. itself, @command{tar} will not archive anything beneath it; in other words,
  5812. @command{tar} will not cross mount points.
  5813. This option is useful for making full or incremental archival backups of
  5814. a file system. If this option is used in conjunction with
  5815. @option{--verbose} (@option{-v}), files that are excluded are
  5816. mentioned by name on the standard error.
  5817. @menu
  5818. * directory:: Changing Directory
  5819. * absolute:: Absolute File Names
  5820. @end menu
  5821. @node directory
  5822. @subsection Changing the Working Directory
  5823. @UNREVISED
  5824. @FIXME{need to read over this node now for continuity; i've switched
  5825. things around some.}
  5826. @cindex Changing directory mid-stream
  5827. @cindex Directory, changing mid-stream
  5828. @cindex Working directory, specifying
  5829. To change the working directory in the middle of a list of file names,
  5830. either on the command line or in a file specified using
  5831. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5832. This will change the working directory to the specified directory
  5833. after that point in the list.
  5834. @table @option
  5835. @opindex directory
  5836. @item --directory=@var{directory}
  5837. @itemx -C @var{directory}
  5838. Changes the working directory in the middle of a command line.
  5839. @end table
  5840. For example,
  5841. @smallexample
  5842. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5843. @end smallexample
  5844. @noindent
  5845. will place the files @file{grape} and @file{prune} from the current
  5846. directory into the archive @file{jams.tar}, followed by the file
  5847. @file{cherry} from the directory @file{food}. This option is especially
  5848. useful when you have several widely separated files that you want to
  5849. store in the same archive.
  5850. Note that the file @file{cherry} is recorded in the archive under the
  5851. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5852. archive will contain three files that all appear to have come from the
  5853. same directory; if the archive is extracted with plain @samp{tar
  5854. --extract}, all three files will be written in the current directory.
  5855. Contrast this with the command,
  5856. @smallexample
  5857. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5858. @end smallexample
  5859. @noindent
  5860. which records the third file in the archive under the name
  5861. @file{red/cherry} so that, if the archive is extracted using
  5862. @samp{tar --extract}, the third file will be written in a subdirectory
  5863. named @file{orange-colored}.
  5864. You can use the @option{--directory} option to make the archive
  5865. independent of the original name of the directory holding the files.
  5866. The following command places the files @file{/etc/passwd},
  5867. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5868. @file{foo.tar}:
  5869. @smallexample
  5870. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5871. @end smallexample
  5872. @noindent
  5873. However, the names of the archive members will be exactly what they were
  5874. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5875. They will not appear to be related by file name to the original
  5876. directories where those files were located.
  5877. Note that @option{--directory} options are interpreted consecutively. If
  5878. @option{--directory} specifies a relative file name, it is interpreted
  5879. relative to the then current directory, which might not be the same as
  5880. the original current working directory of @command{tar}, due to a previous
  5881. @option{--directory} option.
  5882. When using @option{--files-from} (@pxref{files}), you can put various
  5883. @command{tar} options (including @option{-C}) in the file list. Notice,
  5884. however, that in this case the option and its argument may not be
  5885. separated by whitespace. If you use short option, its argument must
  5886. either follow the option letter immediately, without any intervening
  5887. whitespace, or occupy the next line. Otherwise, if you use long
  5888. option, separate its argument by an equal sign.
  5889. For instance, the file list for the above example will be:
  5890. @smallexample
  5891. @group
  5892. -C
  5893. /etc
  5894. passwd
  5895. hosts
  5896. -C
  5897. /lib
  5898. libc.a
  5899. @end group
  5900. @end smallexample
  5901. @noindent
  5902. To use it, you would invoke @command{tar} as follows:
  5903. @smallexample
  5904. $ @kbd{tar -c -f foo.tar --files-from list}
  5905. @end smallexample
  5906. Notice also that you can only use the short option variant in the file
  5907. list, i.e., always use @option{-C}, not @option{--directory}.
  5908. The interpretation of @option{--directory} is disabled by
  5909. @option{--null} option.
  5910. @node absolute
  5911. @subsection Absolute File Names
  5912. @UNREVISED
  5913. @table @option
  5914. @opindex absolute-names
  5915. @item --absolute-names
  5916. @itemx -P
  5917. Do not strip leading slashes from file names, and permit file names
  5918. containing a @file{..} file name component.
  5919. @end table
  5920. By default, @GNUTAR{} drops a leading @samp{/} on
  5921. input or output, and complains about file names containing a @file{..}
  5922. component. This option turns off this behavior.
  5923. When @command{tar} extracts archive members from an archive, it strips any
  5924. leading slashes (@samp{/}) from the member name. This causes absolute
  5925. member names in the archive to be treated as relative file names. This
  5926. allows you to have such members extracted wherever you want, instead of
  5927. being restricted to extracting the member in the exact directory named
  5928. in the archive. For example, if the archive member has the name
  5929. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5930. really @file{etc/passwd}.
  5931. File names containing @file{..} can cause problems when extracting, so
  5932. @command{tar} normally warns you about such files when creating an
  5933. archive, and rejects attempts to extracts such files.
  5934. Other @command{tar} programs do not do this. As a result, if you
  5935. create an archive whose member names start with a slash, they will be
  5936. difficult for other people with a non-@GNUTAR{}
  5937. program to use. Therefore, @GNUTAR{} also strips
  5938. leading slashes from member names when putting members into the
  5939. archive. For example, if you ask @command{tar} to add the file
  5940. @file{/bin/ls} to an archive, it will do so, but the member name will
  5941. be @file{bin/ls}.@footnote{A side effect of this is that when
  5942. @option{--create} is used with @option{--verbose} the resulting output
  5943. is not, generally speaking, the same as the one you'd get running
  5944. @kbd{tar --list} command. This may be important if you use some
  5945. scripts for comparing both outputs. @xref{listing member and file names},
  5946. for the information on how to handle this case.}
  5947. If you use the @option{--absolute-names} (@option{-P}) option,
  5948. @command{tar} will do none of these transformations.
  5949. To archive or extract files relative to the root directory, specify
  5950. the @option{--absolute-names} (@option{-P}) option.
  5951. Normally, @command{tar} acts on files relative to the working
  5952. directory---ignoring superior directory names when archiving, and
  5953. ignoring leading slashes when extracting.
  5954. When you specify @option{--absolute-names} (@option{-P}),
  5955. @command{tar} stores file names including all superior directory
  5956. names, and preserves leading slashes. If you only invoked
  5957. @command{tar} from the root directory you would never need the
  5958. @option{--absolute-names} option, but using this option
  5959. may be more convenient than switching to root.
  5960. @FIXME{Should be an example in the tutorial/wizardry section using this
  5961. to transfer files between systems.}
  5962. @FIXME{Is write access an issue?}
  5963. @table @option
  5964. @item --absolute-names
  5965. Preserves full file names (including superior directory names) when
  5966. archiving files. Preserves leading slash when extracting files.
  5967. @end table
  5968. @FIXME{this is still horrible; need to talk with dan on monday.}
  5969. @command{tar} prints out a message about removing the @samp{/} from
  5970. file names. This message appears once per @GNUTAR{}
  5971. invocation. It represents something which ought to be told; ignoring
  5972. what it means can cause very serious surprises, later.
  5973. Some people, nevertheless, do not want to see this message. Wanting to
  5974. play really dangerously, one may of course redirect @command{tar} standard
  5975. error to the sink. For example, under @command{sh}:
  5976. @smallexample
  5977. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5978. @end smallexample
  5979. @noindent
  5980. Another solution, both nicer and simpler, would be to change to
  5981. the @file{/} directory first, and then avoid absolute notation.
  5982. For example:
  5983. @smallexample
  5984. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5985. # @i{or}:
  5986. $ @kbd{tar -c -f archive.tar -C / home}
  5987. @end smallexample
  5988. @include getdate.texi
  5989. @node Formats
  5990. @chapter Controlling the Archive Format
  5991. @cindex Tar archive formats
  5992. Due to historical reasons, there are several formats of tar archives.
  5993. All of them are based on the same principles, but have some subtle
  5994. differences that often make them incompatible with each other.
  5995. GNU tar is able to create and handle archives in a variety of formats.
  5996. The most frequently used formats are (in alphabetical order):
  5997. @table @asis
  5998. @item gnu
  5999. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  6000. from an early @acronym{POSIX} standard, adding some improvements such as
  6001. sparse file handling and incremental archives. Unfortunately these
  6002. features were implemented in a way incompatible with other archive
  6003. formats.
  6004. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  6005. length.
  6006. @item oldgnu
  6007. Format used by @GNUTAR{} of versions prior to 1.12.
  6008. @item v7
  6009. Archive format, compatible with the V7 implementation of tar. This
  6010. format imposes a number of limitations. The most important of them
  6011. are:
  6012. @enumerate
  6013. @item The maximum length of a file name is limited to 99 characters.
  6014. @item The maximum length of a symbolic link is limited to 99 characters.
  6015. @item It is impossible to store special files (block and character
  6016. devices, fifos etc.)
  6017. @item Maximum value of user or group ID is limited to 2097151 (7777777
  6018. octal)
  6019. @item V7 archives do not contain symbolic ownership information (user
  6020. and group name of the file owner).
  6021. @end enumerate
  6022. This format has traditionally been used by Automake when producing
  6023. Makefiles. This practice will change in the future, in the meantime,
  6024. however this means that projects containing filenames more than 99
  6025. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  6026. Automake prior to 1.9.
  6027. @item ustar
  6028. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  6029. symbolic ownership information. It is also able to store
  6030. special files. However, it imposes several restrictions as well:
  6031. @enumerate
  6032. @item The maximum length of a file name is limited to 256 characters,
  6033. provided that the filename can be split at directory separator in
  6034. two parts, first of them being at most 155 bytes long. So, in most
  6035. cases the maximum file name length will be shorter than 256
  6036. characters.
  6037. @item The maximum length of a symbolic link name is limited to
  6038. 100 characters.
  6039. @item Maximum size of a file the archive is able to accomodate
  6040. is 8GB
  6041. @item Maximum value of UID/GID is 2097151.
  6042. @item Maximum number of bits in device major and minor numbers is 21.
  6043. @end enumerate
  6044. @item star
  6045. Format used by J@"org Schilling @command{star}
  6046. implementation. @GNUTAR{} is able to read @samp{star} archives but
  6047. currently does not produce them.
  6048. @item posix
  6049. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  6050. most flexible and feature-rich format. It does not impose any
  6051. restrictions on file sizes or filename lengths. This format is quite
  6052. recent, so not all tar implementations are able to handle it properly.
  6053. However, this format is designed in such a way that any tar
  6054. implementation able to read @samp{ustar} archives will be able to read
  6055. most @samp{posix} archives as well, with the only exception that any
  6056. additional information (such as long file names etc.) will in such
  6057. case be extracted as plain text files along with the files it refers to.
  6058. This archive format will be the default format for future versions
  6059. of @GNUTAR{}.
  6060. @end table
  6061. The following table summarizes the limitations of each of these
  6062. formats:
  6063. @multitable @columnfractions .10 .20 .20 .20 .20
  6064. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  6065. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6066. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  6067. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  6068. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  6069. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  6070. @end multitable
  6071. The default format for @GNUTAR{} is defined at compilation
  6072. time. You may check it by running @command{tar --help}, and examining
  6073. the last lines of its output. Usually, @GNUTAR{} is configured
  6074. to create archives in @samp{gnu} format, however, future version will
  6075. switch to @samp{posix}.
  6076. @menu
  6077. * Portability:: Making @command{tar} Archives More Portable
  6078. * Compression:: Using Less Space through Compression
  6079. * Attributes:: Handling File Attributes
  6080. * cpio:: Comparison of @command{tar} and @command{cpio}
  6081. @end menu
  6082. @node Portability
  6083. @section Making @command{tar} Archives More Portable
  6084. Creating a @command{tar} archive on a particular system that is meant to be
  6085. useful later on many other machines and with other versions of @command{tar}
  6086. is more challenging than you might think. @command{tar} archive formats
  6087. have been evolving since the first versions of Unix. Many such formats
  6088. are around, and are not always compatible with each other. This section
  6089. discusses a few problems, and gives some advice about making @command{tar}
  6090. archives more portable.
  6091. One golden rule is simplicity. For example, limit your @command{tar}
  6092. archives to contain only regular files and directories, avoiding
  6093. other kind of special files. Do not attempt to save sparse files or
  6094. contiguous files as such. Let's discuss a few more problems, in turn.
  6095. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  6096. archives and archive labels) in GNU and PAX formats.}
  6097. @menu
  6098. * Portable Names:: Portable Names
  6099. * dereference:: Symbolic Links
  6100. * old:: Old V7 Archives
  6101. * ustar:: Ustar Archives
  6102. * gnu:: GNU and old GNU format archives.
  6103. * posix:: @acronym{POSIX} archives
  6104. * Checksumming:: Checksumming Problems
  6105. * Large or Negative Values:: Large files, negative time stamps, etc.
  6106. @end menu
  6107. @node Portable Names
  6108. @subsection Portable Names
  6109. Use portable file and member names. A name is portable if it contains
  6110. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  6111. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  6112. contain @samp{/-}. Avoid deep directory nesting. For portability to
  6113. old Unix hosts, limit your file name components to 14 characters or
  6114. less.
  6115. If you intend to have your @command{tar} archives to be read under
  6116. MSDOS, you should not rely on case distinction for file names, and you
  6117. might use the @acronym{GNU} @command{doschk} program for helping you
  6118. further diagnosing illegal MSDOS names, which are even more limited
  6119. than System V's.
  6120. @node dereference
  6121. @subsection Symbolic Links
  6122. @cindex File names, using symbolic links
  6123. @cindex Symbolic link as file name
  6124. @opindex dereference
  6125. Normally, when @command{tar} archives a symbolic link, it writes a
  6126. block to the archive naming the target of the link. In that way, the
  6127. @command{tar} archive is a faithful record of the file system contents.
  6128. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  6129. @command{tar} to archive the files symbolic links point to, instead of
  6130. the links themselves. When this option is used, when @command{tar}
  6131. encounters a symbolic link, it will archive the linked-to file,
  6132. instead of simply recording the presence of a symbolic link.
  6133. The name under which the file is stored in the file system is not
  6134. recorded in the archive. To record both the symbolic link name and
  6135. the file name in the system, archive the file under both names. If
  6136. all links were recorded automatically by @command{tar}, an extracted file
  6137. might be linked to a file name that no longer exists in the file
  6138. system.
  6139. If a linked-to file is encountered again by @command{tar} while creating
  6140. the same archive, an entire second copy of it will be stored. (This
  6141. @emph{might} be considered a bug.)
  6142. So, for portable archives, do not archive symbolic links as such,
  6143. and use @option{--dereference} (@option{-h}): many systems do not support
  6144. symbolic links, and moreover, your distribution might be unusable if
  6145. it contains unresolved symbolic links.
  6146. @node old
  6147. @subsection Old V7 Archives
  6148. @cindex Format, old style
  6149. @cindex Old style format
  6150. @cindex Old style archives
  6151. @cindex v7 archive format
  6152. Certain old versions of @command{tar} cannot handle additional
  6153. information recorded by newer @command{tar} programs. To create an
  6154. archive in V7 format (not ANSI), which can be read by these old
  6155. versions, specify the @option{--format=v7} option in
  6156. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  6157. accepts @option{--portability} or @samp{op-old-archive} for this
  6158. option). When you specify it,
  6159. @command{tar} leaves out information about directories, pipes, fifos,
  6160. contiguous files, and device files, and specifies file ownership by
  6161. group and user IDs instead of group and user names.
  6162. When updating an archive, do not use @option{--format=v7}
  6163. unless the archive was created using this option.
  6164. In most cases, a @emph{new} format archive can be read by an @emph{old}
  6165. @command{tar} program without serious trouble, so this option should
  6166. seldom be needed. On the other hand, most modern @command{tar}s are
  6167. able to read old format archives, so it might be safer for you to
  6168. always use @option{--format=v7} for your distributions.
  6169. @node ustar
  6170. @subsection Ustar Archive Format
  6171. @cindex ustar archive format
  6172. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  6173. @code{ustar}. Although it is more flexible than the V7 format, it
  6174. still has many restrictions (@xref{Formats,ustar}, for the detailed
  6175. description of @code{ustar} format). Along with V7 format,
  6176. @code{ustar} format is a good choice for archives intended to be read
  6177. with other implementations of @command{tar}.
  6178. To create archive in @code{ustar} format, use @option{--format=ustar}
  6179. option in conjunction with the @option{--create} (@option{-c}).
  6180. @node gnu
  6181. @subsection @acronym{GNU} and old @GNUTAR{} format
  6182. @cindex GNU archive format
  6183. @cindex Old GNU archive format
  6184. @GNUTAR{} was based on an early draft of the
  6185. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  6186. @command{tar}, such as the support for file names longer than 100
  6187. characters, use portions of the @command{tar} header record which were
  6188. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  6189. @acronym{POSIX} have allocated the same parts of the header record for
  6190. other purposes. As a result, @GNUTAR{} format is
  6191. incompatible with the current @acronym{POSIX} specification, and with
  6192. @command{tar} programs that follow it.
  6193. In the majority of cases, @command{tar} will be configured to create
  6194. this format by default. This will change in the future releases, since
  6195. we plan to make @samp{posix} format the default.
  6196. To force creation a @GNUTAR{} archive, use option
  6197. @option{--format=gnu}.
  6198. @node posix
  6199. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  6200. @cindex POSIX archive format
  6201. @cindex PAX archive format
  6202. Starting from version 1.14 @GNUTAR{} features full support for
  6203. @acronym{POSIX.1-2001} archives.
  6204. A @acronym{POSIX} conformant archive will be created if @command{tar}
  6205. was given @option{--format=posix} (@option{--format=pax}) option. No
  6206. special option is required to read and extract from a @acronym{POSIX}
  6207. archive.
  6208. @menu
  6209. * PAX keywords:: Controlling Extended Header Keywords.
  6210. @end menu
  6211. @node PAX keywords
  6212. @subsubsection Controlling Extended Header Keywords
  6213. @table @option
  6214. @opindex pax-option
  6215. @item --pax-option=@var{keyword-list}
  6216. Handle keywords in @acronym{PAX} extended headers. This option is
  6217. equivalent to @option{-o} option of the @command{pax} utility.
  6218. @end table
  6219. @var{Keyword-list} is a comma-separated
  6220. list of keyword options, each keyword option taking one of
  6221. the following forms:
  6222. @table @code
  6223. @item delete=@var{pattern}
  6224. When used with one of archive-creation commands,
  6225. this option instructs @command{tar} to omit from extended header records
  6226. that it produces any keywords matching the string @var{pattern}.
  6227. When used in extract or list mode, this option instructs tar
  6228. to ignore any keywords matching the given @var{pattern} in the extended
  6229. header records. In both cases, matching is performed using the pattern
  6230. matching notation described in @acronym{POSIX 1003.2}, 3.13
  6231. (@pxref{wildcards}). For example:
  6232. @smallexample
  6233. --pax-option delete=security.*
  6234. @end smallexample
  6235. would suppress security-related information.
  6236. @item exthdr.name=@var{string}
  6237. This keyword allows user control over the name that is written into the
  6238. ustar header blocks for the extended headers. The name is obtained
  6239. from @var{string} after making the following substitutions:
  6240. @multitable @columnfractions .25 .55
  6241. @headitem Meta-character @tab Replaced By
  6242. @item %d @tab The directory name of the file, equivalent to the
  6243. result of the @command{dirname} utility on the translated pathname.
  6244. @item %f @tab The filename of the file, equivalent to the result
  6245. of the @command{basename} utility on the translated pathname.
  6246. @item %p @tab The process ID of the @command{tar} process.
  6247. @item %% @tab A @samp{%} character.
  6248. @end multitable
  6249. Any other @samp{%} characters in @var{string} produce undefined
  6250. results.
  6251. If no option @samp{exthdr.name=string} is specified, @command{tar}
  6252. will use the following default value:
  6253. @smallexample
  6254. %d/PaxHeaders.%p/%f
  6255. @end smallexample
  6256. @item globexthdr.name=@var{string}
  6257. This keyword allows user control over the name that is written into
  6258. the ustar header blocks for global extended header records. The name
  6259. is obtained from the contents of @var{string}, after making
  6260. the following substitutions:
  6261. @multitable @columnfractions .25 .55
  6262. @headitem Meta-character @tab Replaced By
  6263. @item %n @tab An integer that represents the
  6264. sequence number of the global extended header record in the archive,
  6265. starting at 1.
  6266. @item %p @tab The process ID of the @command{tar} process.
  6267. @item %% @tab A @samp{%} character.
  6268. @end multitable
  6269. Any other @samp{%} characters in @var{string} produce undefined results.
  6270. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  6271. will use the following default value:
  6272. @smallexample
  6273. $TMPDIR/GlobalHead.%p.%n
  6274. @end smallexample
  6275. @noindent
  6276. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  6277. environment variable. If @var{TMPDIR} is not set, @command{tar}
  6278. uses @samp{/tmp}.
  6279. @item @var{keyword}=@var{value}
  6280. When used with one of archive-creation commands, these keyword/value pairs
  6281. will be included at the beginning of the archive in a global extended
  6282. header record. When used with one of archive-reading commands,
  6283. @command{tar} will behave as if it has encountered these keyword/value
  6284. pairs at the beginning of the archive in a global extended header
  6285. record.
  6286. @item @var{keyword}:=@var{value}
  6287. When used with one of archive-creation commands, these keyword/value pairs
  6288. will be included as records at the beginning of an extended header for
  6289. each file. This is effectively equivalent to @var{keyword}=@var{value}
  6290. form except that it creates no global extended header records.
  6291. When used with one of archive-reading commands, @command{tar} will
  6292. behave as if these keyword/value pairs were included as records at the
  6293. end of each extended header; thus, they will override any global or
  6294. file-specific extended header record keywords of the same names.
  6295. For example, in the command:
  6296. @smallexample
  6297. tar --format=posix --create \
  6298. --file archive --pax-option gname:=user .
  6299. @end smallexample
  6300. the group name will be forced to a new value for all files
  6301. stored in the archive.
  6302. @end table
  6303. @node Checksumming
  6304. @subsection Checksumming Problems
  6305. SunOS and HP-UX @command{tar} fail to accept archives created using
  6306. @GNUTAR{} and containing non-ASCII file names, that
  6307. is, file names having characters with the eight bit set, because they
  6308. use signed checksums, while @GNUTAR{} uses unsigned
  6309. checksums while creating archives, as per @acronym{POSIX} standards. On
  6310. reading, @GNUTAR{} computes both checksums and
  6311. accept any. It is somewhat worrying that a lot of people may go
  6312. around doing backup of their files using faulty (or at least
  6313. non-standard) software, not learning about it until it's time to
  6314. restore their missing files with an incompatible file extractor, or
  6315. vice versa.
  6316. @GNUTAR{} compute checksums both ways, and accept
  6317. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  6318. wrong checksums. @GNUTAR{} produces the standard
  6319. checksum, however, raising incompatibilities with Sun. That is to
  6320. say, @GNUTAR{} has not been modified to
  6321. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  6322. I've been told that more recent Sun @command{tar} now read standard
  6323. archives, so maybe Sun did a similar patch, after all?
  6324. The story seems to be that when Sun first imported @command{tar}
  6325. sources on their system, they recompiled it without realizing that
  6326. the checksums were computed differently, because of a change in
  6327. the default signing of @code{char}'s in their compiler. So they
  6328. started computing checksums wrongly. When they later realized their
  6329. mistake, they merely decided to stay compatible with it, and with
  6330. themselves afterwards. Presumably, but I do not really know, HP-UX
  6331. has chosen that their @command{tar} archives to be compatible with Sun's.
  6332. The current standards do not favor Sun @command{tar} format. In any
  6333. case, it now falls on the shoulders of SunOS and HP-UX users to get
  6334. a @command{tar} able to read the good archives they receive.
  6335. @node Large or Negative Values
  6336. @subsection Large or Negative Values
  6337. @cindex large values
  6338. @cindex future time stamps
  6339. @cindex negative time stamps
  6340. @UNREVISED{}
  6341. The above sections suggest to use @samp{oldest possible} archive
  6342. format if in doubt. However, sometimes it is not possible. If you
  6343. attempt to archive a file whose metadata cannot be represented using
  6344. required format, @GNUTAR{} will print error message and ignore such a
  6345. file. You will than have to switch to a format that is able to
  6346. handle such values. The format summary table (@pxref{Formats}) will
  6347. help you to do so.
  6348. In particular, when trying to archive files larger than 8GB or with
  6349. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  6350. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  6351. @acronym{POSIX} archive formats. When considering which format to
  6352. choose, bear in mind that the @acronym{GNU} format uses
  6353. two's-complement base-256 notation to store values that do not fit
  6354. into standard @acronym{ustar} range. Such archives can generally be
  6355. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  6356. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  6357. example, using two's complement representation for negative time
  6358. stamps that assumes a signed 32-bit @code{time_t} generates archives
  6359. that are not portable to hosts with differing @code{time_t}
  6360. representations.
  6361. On the other hand, @acronym{POSIX} archives, generally speaking, can
  6362. be extracted by any tar implementation that understands older
  6363. @acronym{ustar} format. The only exception are files larger than 8GB.
  6364. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  6365. POSIX-aware tars.}
  6366. @node Compression
  6367. @section Using Less Space through Compression
  6368. @menu
  6369. * gzip:: Creating and Reading Compressed Archives
  6370. * sparse:: Archiving Sparse Files
  6371. @end menu
  6372. @node gzip
  6373. @subsection Creating and Reading Compressed Archives
  6374. @cindex Compressed archives
  6375. @cindex Storing archives in compressed format
  6376. @GNUTAR{} is able to create and read compressed archives. It supports
  6377. @command{gzip} and @command{bzip2} compression programs. For backward
  6378. compatibilty, it also supports @command{compress} command, although
  6379. we strongly recommend against using it, since there is a patent
  6380. covering the algorithm it uses and you could be sued for patent
  6381. infringement merely by running @command{compress}! Besides, it is less
  6382. effective than @command{gzip} and @command{bzip2}.
  6383. Creating a compressed archive is simple: you just specify a
  6384. @dfn{compression option} along with the usual archive creation
  6385. commands. The compression option is @option{-z} (@option{--gzip}) to
  6386. create a @command{gzip} compressed archive, @option{-j}
  6387. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  6388. @option{-Z} (@option{--compress}) to use @command{compress} program.
  6389. For example:
  6390. @smallexample
  6391. $ @kbd{tar cfz archive.tar.gz .}
  6392. @end smallexample
  6393. Reading compressed archive is even simpler: you don't need to specify
  6394. any additional options as @GNUTAR{} recognizes its format
  6395. automatically. Thus, the following commands will list and extract the
  6396. archive created in previous example:
  6397. @smallexample
  6398. # List the compressed archive
  6399. $ @kbd{tar tf archive.tar.gz}
  6400. # Extract the compressed archive
  6401. $ @kbd{tar xf archive.tar.gz}
  6402. @end smallexample
  6403. The only case when you have to specify a decompression option while
  6404. reading the archive is when reading from a pipe or from a tape drive
  6405. that does not support random access. However, in this case @GNUTAR{}
  6406. will indicate which option you should use. For example:
  6407. @smallexample
  6408. $ @kbd{cat archive.tar.gz | tar tf -}
  6409. tar: Archive is compressed. Use -z option
  6410. tar: Error is not recoverable: exiting now
  6411. @end smallexample
  6412. If you see such diagnostics, just add the suggested option to the
  6413. invocation of @GNUTAR{}:
  6414. @smallexample
  6415. $ @kbd{cat archive.tar.gz | tar tfz -}
  6416. @end smallexample
  6417. Notice also, that there are several restrictions on operations on
  6418. compressed archives. First of all, compressed archives cannot be
  6419. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  6420. (@option{--delete}) members from them. Likewise, you cannot append
  6421. another @command{tar} archive to a compressed archive using
  6422. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  6423. compressed.
  6424. The following table summarizes compression options used by @GNUTAR{}.
  6425. @table @option
  6426. @opindex gzip
  6427. @opindex ungzip
  6428. @item -z
  6429. @itemx --gzip
  6430. @itemx --ungzip
  6431. Filter the archive through @command{gzip}.
  6432. You can use @option{--gzip} and @option{--gunzip} on physical devices
  6433. (tape drives, etc.) and remote files as well as on normal files; data
  6434. to or from such devices or remote files is reblocked by another copy
  6435. of the @command{tar} program to enforce the specified (or default) record
  6436. size. The default compression parameters are used; if you need to
  6437. override them, set @env{GZIP} environment variable, e.g.:
  6438. @smallexample
  6439. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  6440. @end smallexample
  6441. @noindent
  6442. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  6443. @command{gzip} explicitly:
  6444. @smallexample
  6445. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  6446. @end smallexample
  6447. @cindex corrupted archives
  6448. About corrupted compressed archives: @command{gzip}'ed files have no
  6449. redundancy, for maximum compression. The adaptive nature of the
  6450. compression scheme means that the compression tables are implicitly
  6451. spread all over the archive. If you lose a few blocks, the dynamic
  6452. construction of the compression tables becomes unsynchronized, and there
  6453. is little chance that you could recover later in the archive.
  6454. There are pending suggestions for having a per-volume or per-file
  6455. compression in @GNUTAR{}. This would allow for viewing the
  6456. contents without decompression, and for resynchronizing decompression at
  6457. every volume or file, in case of corrupted archives. Doing so, we might
  6458. lose some compressibility. But this would have make recovering easier.
  6459. So, there are pros and cons. We'll see!
  6460. @opindex bzip2
  6461. @item -j
  6462. @itemx --bzip2
  6463. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  6464. @opindex compress
  6465. @opindex uncompress
  6466. @item -Z
  6467. @itemx --compress
  6468. @itemx --uncompress
  6469. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  6470. The @acronym{GNU} Project recommends you not use
  6471. @command{compress}, because there is a patent covering the algorithm it
  6472. uses. You could be sued for patent infringement merely by running
  6473. @command{compress}.
  6474. @opindex use-compress-program
  6475. @item --use-compress-program=@var{prog}
  6476. Use external compression program @var{prog}. Use this option if you
  6477. have a compression program that @GNUTAR{} does not support. There
  6478. are two requirements to which @var{prog} should comply:
  6479. First, when called without options, it should read data from standard
  6480. input, compress it and output it on standard output.
  6481. Secondly, if called with @option{-d} argument, it should do exactly
  6482. the opposite, i.e., read the compressed data from the standard input
  6483. and produce uncompressed data on the standard output.
  6484. @end table
  6485. @cindex gpg, using with tar
  6486. @cindex gnupg, using with tar
  6487. @cindex Using encrypted archives
  6488. The @option{--use-compress-program} option, in particular, lets you
  6489. implement your own filters, not necessarily dealing with
  6490. compression/decomression. For example, suppose you wish to implement
  6491. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  6492. gpg, gpg ---- encryption and signing tool, gpg, GNU Privacy Guard
  6493. Manual}). The following script does that:
  6494. @smallexample
  6495. @group
  6496. #! /bin/sh
  6497. case $1 in
  6498. -d) gpg --decrypt - | gzip -d -c;;
  6499. '') gzip -c | gpg -s ;;
  6500. *) echo "Unknown option $1">&2; exit 1;;
  6501. esac
  6502. @end group
  6503. @end smallexample
  6504. Suppose you name it @file{gpgz} and save it somewhere in your
  6505. @env{PATH}. Then the following command will create a commpressed
  6506. archive signed with your private key:
  6507. @smallexample
  6508. $ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .}
  6509. @end smallexample
  6510. @noindent
  6511. Likewise, the following command will list its contents:
  6512. @smallexample
  6513. $ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .}
  6514. @end smallexample
  6515. @ignore
  6516. The above is based on the following discussion:
  6517. I have one question, or maybe it's a suggestion if there isn't a way
  6518. to do it now. I would like to use @option{--gzip}, but I'd also like
  6519. the output to be fed through a program like @acronym{GNU}
  6520. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  6521. to use :-)), basically adding ECC protection on top of compression.
  6522. It seems as if this should be quite easy to do, but I can't work out
  6523. exactly how to go about it. Of course, I can pipe the standard output
  6524. of @command{tar} through @command{ecc}, but then I lose (though I
  6525. haven't started using it yet, I confess) the ability to have
  6526. @command{tar} use @command{rmt} for it's I/O (I think).
  6527. I think the most straightforward thing would be to let me specify a
  6528. general set of filters outboard of compression (preferably ordered,
  6529. so the order can be automatically reversed on input operations, and
  6530. with the options they require specifiable), but beggars shouldn't be
  6531. choosers and anything you decide on would be fine with me.
  6532. By the way, I like @command{ecc} but if (as the comments say) it can't
  6533. deal with loss of block sync, I'm tempted to throw some time at adding
  6534. that capability. Supposing I were to actually do such a thing and
  6535. get it (apparently) working, do you accept contributed changes to
  6536. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6537. Isn't that exactly the role of the
  6538. @option{--use-compress-prog=@var{program}} option?
  6539. I never tried it myself, but I suspect you may want to write a
  6540. @var{prog} script or program able to filter stdin to stdout to
  6541. way you want. It should recognize the @option{-d} option, for when
  6542. extraction is needed rather than creation.
  6543. It has been reported that if one writes compressed data (through the
  6544. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6545. the DLT compression mode, the data will actually get bigger and one will
  6546. end up with less space on the tape.
  6547. @end ignore
  6548. @node sparse
  6549. @subsection Archiving Sparse Files
  6550. @cindex Sparse Files
  6551. @UNREVISED
  6552. @table @option
  6553. @opindex sparse
  6554. @item -S
  6555. @itemx --sparse
  6556. Handle sparse files efficiently.
  6557. @end table
  6558. This option causes all files to be put in the archive to be tested for
  6559. sparseness, and handled specially if they are. The @option{--sparse}
  6560. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  6561. backed up. Using this option dramatically decreases the amount of
  6562. space needed to store such a file.
  6563. In later versions, this option may be removed, and the testing and
  6564. treatment of sparse files may be done automatically with any special
  6565. @acronym{GNU} options. For now, it is an option needing to be specified on
  6566. the command line with the creation or updating of an archive.
  6567. Files in the file system occasionally have ``holes.'' A hole in a file
  6568. is a section of the file's contents which was never written. The
  6569. contents of a hole read as all zeros. On many operating systems,
  6570. actual disk storage is not allocated for holes, but they are counted
  6571. in the length of the file. If you archive such a file, @command{tar}
  6572. could create an archive longer than the original. To have @command{tar}
  6573. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  6574. you use this option, then, for any file using less disk space than
  6575. would be expected from its length, @command{tar} searches the file for
  6576. consecutive stretches of zeros. It then records in the archive for
  6577. the file where the consecutive stretches of zeros are, and only
  6578. archives the ``real contents'' of the file. On extraction (using
  6579. @option{--sparse} is not needed on extraction) any such
  6580. files have holes created wherever the continuous stretches of zeros
  6581. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6582. won't take more space than the original.
  6583. A file is sparse if it contains blocks of zeros whose existence is
  6584. recorded, but that have no space allocated on disk. When you specify
  6585. the @option{--sparse} option in conjunction with the @option{--create}
  6586. (@option{-c}) operation, @command{tar} tests all files for sparseness
  6587. while archiving. If @command{tar} finds a file to be sparse, it uses a
  6588. sparse representation of the file in the archive. @xref{create}, for
  6589. more information about creating archives.
  6590. @option{--sparse} is useful when archiving files, such as dbm files,
  6591. likely to contain many nulls. This option dramatically
  6592. decreases the amount of space needed to store such an archive.
  6593. @quotation
  6594. @strong{Please Note:} Always use @option{--sparse} when performing file
  6595. system backups, to avoid archiving the expanded forms of files stored
  6596. sparsely in the system.
  6597. Even if your system has no sparse files currently, some may be
  6598. created in the future. If you use @option{--sparse} while making file
  6599. system backups as a matter of course, you can be assured the archive
  6600. will never take more space on the media than the files take on disk
  6601. (otherwise, archiving a disk filled with sparse files might take
  6602. hundreds of tapes). @xref{Incremental Dumps}.
  6603. @end quotation
  6604. @command{tar} ignores the @option{--sparse} option when reading an archive.
  6605. @table @option
  6606. @item --sparse
  6607. @itemx -S
  6608. Files stored sparsely in the file system are represented sparsely in
  6609. the archive. Use in conjunction with write operations.
  6610. @end table
  6611. However, users should be well aware that at archive creation time,
  6612. @GNUTAR{} still has to read whole disk file to
  6613. locate the @dfn{holes}, and so, even if sparse files use little space
  6614. on disk and in the archive, they may sometimes require inordinate
  6615. amount of time for reading and examining all-zero blocks of a file.
  6616. Although it works, it's painfully slow for a large (sparse) file, even
  6617. though the resulting tar archive may be small. (One user reports that
  6618. dumping a @file{core} file of over 400 megabytes, but with only about
  6619. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  6620. ELC, with full CPU utilization.)
  6621. This reading is required in all cases and is not related to the fact
  6622. the @option{--sparse} option is used or not, so by merely @emph{not}
  6623. using the option, you are not saving time@footnote{Well! We should say
  6624. the whole truth, here. When @option{--sparse} is selected while creating
  6625. an archive, the current @command{tar} algorithm requires sparse files to be
  6626. read twice, not once. We hope to develop a new archive format for saving
  6627. sparse files in which one pass will be sufficient.}.
  6628. Programs like @command{dump} do not have to read the entire file; by
  6629. examining the file system directly, they can determine in advance
  6630. exactly where the holes are and thus avoid reading through them. The
  6631. only data it need read are the actual allocated data blocks.
  6632. @GNUTAR{} uses a more portable and straightforward
  6633. archiving approach, it would be fairly difficult that it does
  6634. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6635. 1990-12-10:
  6636. @quotation
  6637. What I did say is that you cannot tell the difference between a hole and an
  6638. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6639. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6640. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6641. to name one that does?), they may also care where the holes are (I have
  6642. no examples of this one either, but it's equally imaginable).
  6643. I conclude from this that good archivers are not portable. One can
  6644. arguably conclude that if you want a portable program, you can in good
  6645. conscience restore files with as many holes as possible, since you can't
  6646. get it right.
  6647. @end quotation
  6648. @node Attributes
  6649. @section Handling File Attributes
  6650. @UNREVISED
  6651. When @command{tar} reads files, it updates their access times. To
  6652. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6653. reset the access time retroactively or avoid changing it in the first
  6654. place.
  6655. Handling of file attributes
  6656. @table @option
  6657. @opindex atime-preserve
  6658. @item --atime-preserve
  6659. @itemx --atime-preserve=replace
  6660. @itemx --atime-preserve=system
  6661. Preserve the access times of files that are read. This works only for
  6662. files that you own, unless you have superuser privileges.
  6663. @option{--atime-preserve=replace} works on most systems, but it also
  6664. restores the data modification time and updates the status change
  6665. time. Hence it doesn't interact with incremental dumps nicely
  6666. (@pxref{Backups}), and it can set access or data modification times
  6667. incorrectly if other programs access the file while @command{tar} is
  6668. running.
  6669. @option{--atime-preserve=system} avoids changing the access time in
  6670. the first place, if the operating system supports this.
  6671. Unfortunately, this may or may not work on any given operating system
  6672. or file system. If @command{tar} knows for sure it won't work, it
  6673. complains right away.
  6674. Currently @option{--atime-preserve} with no operand defaults to
  6675. @option{--atime-preserve=replace}, but this is intended to change to
  6676. @option{--atime-preserve=system} when the latter is better-supported.
  6677. @opindex touch
  6678. @item -m
  6679. @itemx --touch
  6680. Do not extract data modification time.
  6681. When this option is used, @command{tar} leaves the data modification times
  6682. of the files it extracts as the times when the files were extracted,
  6683. instead of setting it to the times recorded in the archive.
  6684. This option is meaningless with @option{--list} (@option{-t}).
  6685. @opindex same-owner
  6686. @item --same-owner
  6687. Create extracted files with the same ownership they have in the
  6688. archive.
  6689. This is the default behavior for the superuser,
  6690. so this option is meaningful only for non-root users, when @command{tar}
  6691. is executed on those systems able to give files away. This is
  6692. considered as a security flaw by many people, at least because it
  6693. makes quite difficult to correctly account users for the disk space
  6694. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6695. files are easily and silently lost when files are given away.
  6696. When writing an archive, @command{tar} writes the user id and user name
  6697. separately. If it can't find a user name (because the user id is not
  6698. in @file{/etc/passwd}), then it does not write one. When restoring,
  6699. it tries to look the name (if one was written) up in
  6700. @file{/etc/passwd}. If it fails, then it uses the user id stored in
  6701. the archive instead.
  6702. @opindex no-same-owner
  6703. @item --no-same-owner
  6704. @itemx -o
  6705. Do not attempt to restore ownership when extracting. This is the
  6706. default behavior for ordinary users, so this option has an effect
  6707. only for the superuser.
  6708. @opindex numeric-owner
  6709. @item --numeric-owner
  6710. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6711. without user/group name information or such information to be ignored
  6712. when extracting. It effectively disables the generation and/or use
  6713. of user/group name information. This option forces extraction using
  6714. the numeric ids from the archive, ignoring the names.
  6715. This is useful in certain circumstances, when restoring a backup from
  6716. an emergency floppy with different passwd/group files for example.
  6717. It is otherwise impossible to extract files with the right ownerships
  6718. if the password file in use during the extraction does not match the
  6719. one belonging to the file system(s) being extracted. This occurs,
  6720. for example, if you are restoring your files after a major crash and
  6721. had booted from an emergency floppy with no password file or put your
  6722. disk into another machine to do the restore.
  6723. The numeric ids are @emph{always} saved into @command{tar} archives.
  6724. The identifying names are added at create time when provided by the
  6725. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6726. used when moving archives between a collection of machines using
  6727. a centralized management for attribution of numeric ids to users
  6728. and groups. This is often made through using the NIS capabilities.
  6729. When making a @command{tar} file for distribution to other sites, it
  6730. is sometimes cleaner to use a single owner for all files in the
  6731. distribution, and nicer to specify the write permission bits of the
  6732. files as stored in the archive independently of their actual value on
  6733. the file system. The way to prepare a clean distribution is usually
  6734. to have some Makefile rule creating a directory, copying all needed
  6735. files in that directory, then setting ownership and permissions as
  6736. wanted (there are a lot of possible schemes), and only then making a
  6737. @command{tar} archive out of this directory, before cleaning
  6738. everything out. Of course, we could add a lot of options to
  6739. @GNUTAR{} for fine tuning permissions and ownership.
  6740. This is not the good way, I think. @GNUTAR{} is
  6741. already crowded with options and moreover, the approach just explained
  6742. gives you a great deal of control already.
  6743. @opindex same-permissions, short description
  6744. @opindex preserve-permissions, short description
  6745. @item -p
  6746. @itemx --same-permissions
  6747. @itemx --preserve-permissions
  6748. Extract all protection information.
  6749. This option causes @command{tar} to set the modes (access permissions) of
  6750. extracted files exactly as recorded in the archive. If this option
  6751. is not used, the current @code{umask} setting limits the permissions
  6752. on extracted files. This option is by default enabled when
  6753. @command{tar} is executed by a superuser.
  6754. This option is meaningless with @option{--list} (@option{-t}).
  6755. @opindex preserve
  6756. @item --preserve
  6757. Same as both @option{--same-permissions} and @option{--same-order}.
  6758. The @option{--preserve} option has no equivalent short option name.
  6759. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6760. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)
  6761. Neither do I. --Sergey}
  6762. @end table
  6763. @node cpio
  6764. @section Comparison of @command{tar} and @command{cpio}
  6765. @UNREVISED
  6766. @FIXME{Reorganize the following material}
  6767. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6768. pathname lengths. The binary and old ASCII formats have a max path
  6769. length of 256, and the new ASCII and CRC ASCII formats have a max
  6770. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6771. with arbitrary pathname lengths, but other @command{cpio} implementations
  6772. may crash unexplainedly trying to read them.
  6773. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6774. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6775. in System V prior to SVR4, and some vendors may have added symlinks
  6776. to their system without enhancing @command{cpio} to know about them.
  6777. Others may have enhanced it in a way other than the way I did it
  6778. at Sun, and which was adopted by AT&T (and which is, I think, also
  6779. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6780. into a later BSD release---I think I gave them my changes).
  6781. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6782. can handle @command{tar} format input, and write it on output, and it
  6783. probably handles symbolic links. They may not have bothered doing
  6784. anything to enhance @command{tar} as a result.)
  6785. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6786. @command{tar} comes with V7, System III, System V, and BSD source;
  6787. @command{cpio} comes only with System III, System V, and later BSD
  6788. (4.3-tahoe and later).
  6789. @command{tar}'s way of handling multiple hard links to a file can handle
  6790. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6791. @command{cpio}s way requires you to play some games (in its "binary"
  6792. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6793. they're 18 bits---it would have to play games with the "file system ID"
  6794. field of the header to make sure that the file system ID/i-number pairs
  6795. of different files were always different), and I don't know which
  6796. @command{cpio}s, if any, play those games. Those that don't might get
  6797. confused and think two files are the same file when they're not, and
  6798. make hard links between them.
  6799. @command{tar}s way of handling multiple hard links to a file places only
  6800. one copy of the link on the tape, but the name attached to that copy
  6801. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6802. way puts one copy for every link, but you can retrieve it using any
  6803. of the names.
  6804. @quotation
  6805. What type of check sum (if any) is used, and how is this calculated.
  6806. @end quotation
  6807. See the attached manual pages for @command{tar} and @command{cpio} format.
  6808. @command{tar} uses a checksum which is the sum of all the bytes in the
  6809. @command{tar} header for a file; @command{cpio} uses no checksum.
  6810. @quotation
  6811. If anyone knows why @command{cpio} was made when @command{tar} was present
  6812. at the unix scene,
  6813. @end quotation
  6814. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6815. generally-available version of UNIX had @command{tar} at the time. I don't
  6816. know whether any version that was generally available @emph{within AT&T}
  6817. had @command{tar}, or, if so, whether the people within AT&T who did
  6818. @command{cpio} knew about it.
  6819. On restore, if there is a corruption on a tape @command{tar} will stop at
  6820. that point, while @command{cpio} will skip over it and try to restore the
  6821. rest of the files.
  6822. The main difference is just in the command syntax and header format.
  6823. @command{tar} is a little more tape-oriented in that everything is blocked
  6824. to start on a record boundary.
  6825. @quotation
  6826. Is there any differences between the ability to recover crashed
  6827. archives between the two of them. (Is there any chance of recovering
  6828. crashed archives at all.)
  6829. @end quotation
  6830. Theoretically it should be easier under @command{tar} since the blocking
  6831. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6832. However, modern @command{cpio}'s and variations have an option to just
  6833. search for the next file header after an error with a reasonable chance
  6834. of resyncing. However, lots of tape driver software won't allow you to
  6835. continue past a media error which should be the only reason for getting
  6836. out of sync unless a file changed sizes while you were writing the
  6837. archive.
  6838. @quotation
  6839. If anyone knows why @command{cpio} was made when @command{tar} was present
  6840. at the unix scene, please tell me about this too.
  6841. @end quotation
  6842. Probably because it is more media efficient (by not blocking everything
  6843. and using only the space needed for the headers where @command{tar}
  6844. always uses 512 bytes per file header) and it knows how to archive
  6845. special files.
  6846. You might want to look at the freely available alternatives. The
  6847. major ones are @command{afio}, @GNUTAR{}, and
  6848. @command{pax}, each of which have their own extensions with some
  6849. backwards compatibility.
  6850. Sparse files were @command{tar}red as sparse files (which you can
  6851. easily test, because the resulting archive gets smaller, and
  6852. @acronym{GNU} @command{cpio} can no longer read it).
  6853. @node Media
  6854. @chapter Tapes and Other Archive Media
  6855. @UNREVISED
  6856. A few special cases about tape handling warrant more detailed
  6857. description. These special cases are discussed below.
  6858. Many complexities surround the use of @command{tar} on tape drives. Since
  6859. the creation and manipulation of archives located on magnetic tape was
  6860. the original purpose of @command{tar}, it contains many features making
  6861. such manipulation easier.
  6862. Archives are usually written on dismountable media---tape cartridges,
  6863. mag tapes, or floppy disks.
  6864. The amount of data a tape or disk holds depends not only on its size,
  6865. but also on how it is formatted. A 2400 foot long reel of mag tape
  6866. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6867. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6868. Magnetic media are re-usable---once the archive on a tape is no longer
  6869. needed, the archive can be erased and the tape or disk used over.
  6870. Media quality does deteriorate with use, however. Most tapes or disks
  6871. should be discarded when they begin to produce data errors. EXABYTE
  6872. tape cartridges should be discarded when they generate an @dfn{error
  6873. count} (number of non-usable bits) of more than 10k.
  6874. Magnetic media are written and erased using magnetic fields, and
  6875. should be protected from such fields to avoid damage to stored data.
  6876. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6877. not a good idea.
  6878. @menu
  6879. * Device:: Device selection and switching
  6880. * Remote Tape Server::
  6881. * Common Problems and Solutions::
  6882. * Blocking:: Blocking
  6883. * Many:: Many archives on one tape
  6884. * Using Multiple Tapes:: Using Multiple Tapes
  6885. * label:: Including a Label in the Archive
  6886. * verify::
  6887. * Write Protection::
  6888. @end menu
  6889. @node Device
  6890. @section Device Selection and Switching
  6891. @UNREVISED
  6892. @table @option
  6893. @item -f [@var{hostname}:]@var{file}
  6894. @itemx --file=[@var{hostname}:]@var{file}
  6895. Use archive file or device @var{file} on @var{hostname}.
  6896. @end table
  6897. This option is used to specify the file name of the archive @command{tar}
  6898. works on.
  6899. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6900. input (when listing or extracting), or writes it to standard output
  6901. (when creating). If the @samp{-} file name is given when updating an
  6902. archive, @command{tar} will read the original archive from its standard
  6903. input, and will write the entire new archive to its standard output.
  6904. If the file name contains a @samp{:}, it is interpreted as
  6905. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6906. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6907. either case, @command{tar} will invoke the command @command{rsh} (or
  6908. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6909. machine. If you give an alternate login name, it will be given to the
  6910. @command{rsh}.
  6911. Naturally, the remote machine must have an executable
  6912. @command{/usr/libexec/rmt}. This program is free software from the
  6913. University of California, and a copy of the source code can be found
  6914. with the sources for @command{tar}; it's compiled and installed by default.
  6915. The exact path to this utility is determined when configuring the package.
  6916. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6917. your installation prefix. This location may also be overridden at
  6918. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6919. ---rmt-command}, for detailed description of this option. @xref{Remote
  6920. Tape Server}, for the description of @command{rmt} command).
  6921. If this option is not given, but the environment variable @env{TAPE}
  6922. is set, its value is used; otherwise, old versions of @command{tar}
  6923. used a default archive name (which was picked when @command{tar} was
  6924. compiled). The default is normally set up to be the @dfn{first} tape
  6925. drive or other transportable I/O medium on the system.
  6926. Starting with version 1.11.5, @GNUTAR{} uses
  6927. standard input and standard output as the default device, and I will
  6928. not try anymore supporting automatic device detection at installation
  6929. time. This was failing really in too many cases, it was hopeless.
  6930. This is now completely left to the installer to override standard
  6931. input and standard output for default device, if this seems
  6932. preferable. Further, I think @emph{most} actual usages of
  6933. @command{tar} are done with pipes or disks, not really tapes,
  6934. cartridges or diskettes.
  6935. Some users think that using standard input and output is running
  6936. after trouble. This could lead to a nasty surprise on your screen if
  6937. you forget to specify an output file name---especially if you are going
  6938. through a network or terminal server capable of buffering large amounts
  6939. of output. We had so many bug reports in that area of configuring
  6940. default tapes automatically, and so many contradicting requests, that
  6941. we finally consider the problem to be portably intractable. We could
  6942. of course use something like @samp{/dev/tape} as a default, but this
  6943. is @emph{also} running after various kind of trouble, going from hung
  6944. processes to accidental destruction of real tapes. After having seen
  6945. all this mess, using standard input and output as a default really
  6946. sounds like the only clean choice left, and a very useful one too.
  6947. @GNUTAR{} reads and writes archive in records, I
  6948. suspect this is the main reason why block devices are preferred over
  6949. character devices. Most probably, block devices are more efficient
  6950. too. The installer could also check for @samp{DEFTAPE} in
  6951. @file{<sys/mtio.h>}.
  6952. @table @option
  6953. @opindex force-local, short description
  6954. @item --force-local
  6955. Archive file is local even if it contains a colon.
  6956. @opindex rsh-command
  6957. @item --rsh-command=@var{command}
  6958. Use remote @var{command} instead of @command{rsh}. This option exists
  6959. so that people who use something other than the standard @command{rsh}
  6960. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6961. When this command is not used, the shell command found when
  6962. the @command{tar} program was installed is used instead. This is
  6963. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6964. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6965. The installer may have overridden this by defining the environment
  6966. variable @env{RSH} @emph{at installation time}.
  6967. @item -[0-7][lmh]
  6968. Specify drive and density.
  6969. @opindex multi-volume, short description
  6970. @item -M
  6971. @itemx --multi-volume
  6972. Create/list/extract multi-volume archive.
  6973. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6974. that may be larger than will fit on the medium used to hold it.
  6975. @xref{Multi-Volume Archives}.
  6976. @opindex tape-length, short description
  6977. @item -L @var{num}
  6978. @itemx --tape-length=@var{num}
  6979. Change tape after writing @var{num} x 1024 bytes.
  6980. This option might be useful when your tape drivers do not properly
  6981. detect end of physical tapes. By being slightly conservative on the
  6982. maximum tape length, you might avoid the problem entirely.
  6983. @opindex info-script, short description
  6984. @opindex new-volume-script, short description
  6985. @item -F @var{file}
  6986. @itemx --info-script=@var{file}
  6987. @itemx --new-volume-script=@var{file}
  6988. Execute @file{file} at end of each tape. This implies
  6989. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6990. description of this option.
  6991. @end table
  6992. @node Remote Tape Server
  6993. @section The Remote Tape Server
  6994. @cindex remote tape drive
  6995. @pindex rmt
  6996. In order to access the tape drive on a remote machine, @command{tar}
  6997. uses the remote tape server written at the University of California at
  6998. Berkeley. The remote tape server must be installed as
  6999. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  7000. want to use. @command{tar} calls @command{rmt} by running an
  7001. @command{rsh} or @command{remsh} to the remote machine, optionally
  7002. using a different login name if one is supplied.
  7003. A copy of the source for the remote tape server is provided. It is
  7004. Copyright @copyright{} 1983 by the Regents of the University of
  7005. California, but can be freely distributed. It is compiled and
  7006. installed by default.
  7007. @cindex absolute file names
  7008. Unless you use the @option{--absolute-names} (@option{-P}) option,
  7009. @GNUTAR{} will not allow you to create an archive that contains
  7010. absolute file names (a file name beginning with @samp{/}.) If you try,
  7011. @command{tar} will automatically remove the leading @samp{/} from the
  7012. file names it stores in the archive. It will also type a warning
  7013. message telling you what it is doing.
  7014. When reading an archive that was created with a different
  7015. @command{tar} program, @GNUTAR{} automatically
  7016. extracts entries in the archive which have absolute file names as if
  7017. the file names were not absolute. This is an important feature. A
  7018. visitor here once gave a @command{tar} tape to an operator to restore;
  7019. the operator used Sun @command{tar} instead of @GNUTAR{},
  7020. and the result was that it replaced large portions of
  7021. our @file{/bin} and friends with versions from the tape; needless to
  7022. say, we were unhappy about having to recover the file system from
  7023. backup tapes.
  7024. For example, if the archive contained a file @file{/usr/bin/computoy},
  7025. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  7026. relative to the current directory. If you want to extract the files in
  7027. an archive to the same absolute names that they had when the archive
  7028. was created, you should do a @samp{cd /} before extracting the files
  7029. from the archive, or you should either use the @option{--absolute-names}
  7030. option, or use the command @samp{tar -C / @dots{}}.
  7031. @cindex Ultrix 3.1 and write failure
  7032. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  7033. can claim that a short write near the end of a tape succeeded,
  7034. when it actually failed. This will result in the -M option not
  7035. working correctly. The best workaround at the moment is to use a
  7036. significantly larger blocking factor than the default 20.
  7037. In order to update an archive, @command{tar} must be able to backspace the
  7038. archive in order to reread or rewrite a record that was just read (or
  7039. written). This is currently possible only on two kinds of files: normal
  7040. disk files (or any other file that can be backspaced with @samp{lseek}),
  7041. and industry-standard 9-track magnetic tape (or any other kind of tape
  7042. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  7043. This means that the @option{--append}, @option{--concatenate}, and
  7044. @option{--delete} commands will not work on any other kind of file.
  7045. Some media simply cannot be backspaced, which means these commands and
  7046. options will never be able to work on them. These non-backspacing
  7047. media include pipes and cartridge tape drives.
  7048. Some other media can be backspaced, and @command{tar} will work on them
  7049. once @command{tar} is modified to do so.
  7050. Archives created with the @option{--multi-volume}, @option{--label}, and
  7051. @option{--incremental} (@option{-G}) options may not be readable by other version
  7052. of @command{tar}. In particular, restoring a file that was split over
  7053. a volume boundary will require some careful work with @command{dd}, if
  7054. it can be done at all. Other versions of @command{tar} may also create
  7055. an empty file whose name is that of the volume header. Some versions
  7056. of @command{tar} may create normal files instead of directories archived
  7057. with the @option{--incremental} (@option{-G}) option.
  7058. @node Common Problems and Solutions
  7059. @section Some Common Problems and their Solutions
  7060. @ifclear PUBLISH
  7061. @format
  7062. errors from system:
  7063. permission denied
  7064. no such file or directory
  7065. not owner
  7066. errors from @command{tar}:
  7067. directory checksum error
  7068. header format error
  7069. errors from media/system:
  7070. i/o error
  7071. device busy
  7072. @end format
  7073. @end ifclear
  7074. @node Blocking
  7075. @section Blocking
  7076. @UNREVISED
  7077. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  7078. is also confusing to the expert reader. On the other hand, readers
  7079. who are new to the field have a fresh mind, and they may safely skip
  7080. the next two paragraphs, as the remainder of this manual uses those
  7081. two terms in a quite consistent way.
  7082. John Gilmore, the writer of the public domain @command{tar} from which
  7083. @GNUTAR{} was originally derived, wrote (June 1995):
  7084. @quotation
  7085. The nomenclature of tape drives comes from IBM, where I believe
  7086. they were invented for the IBM 650 or so. On IBM mainframes, what
  7087. is recorded on tape are tape blocks. The logical organization of
  7088. data is into records. There are various ways of putting records into
  7089. blocks, including @code{F} (fixed sized records), @code{V} (variable
  7090. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  7091. to a block), @code{VB} (variable size records, @var{n} to a block),
  7092. @code{VSB} (variable spanned blocked: variable sized records that can
  7093. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  7094. parameter specified this to the operating system.
  7095. The Unix man page on @command{tar} was totally confused about this.
  7096. When I wrote @code{PD TAR}, I used the historically correct terminology
  7097. (@command{tar} writes data records, which are grouped into blocks).
  7098. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  7099. here), and now Fran@,{c}ois has migrated that terminology back
  7100. into the source code too.
  7101. @end quotation
  7102. The term @dfn{physical block} means the basic transfer chunk from or
  7103. to a device, after which reading or writing may stop without anything
  7104. being lost. In this manual, the term @dfn{block} usually refers to
  7105. a disk physical block, @emph{assuming} that each disk block is 512
  7106. bytes in length. It is true that some disk devices have different
  7107. physical blocks, but @command{tar} ignore these differences in its own
  7108. format, which is meant to be portable, so a @command{tar} block is always
  7109. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  7110. The term @dfn{logical block} often represents the basic chunk of
  7111. allocation of many disk blocks as a single entity, which the operating
  7112. system treats somewhat atomically; this concept is only barely used
  7113. in @GNUTAR{}.
  7114. The term @dfn{physical record} is another way to speak of a physical
  7115. block, those two terms are somewhat interchangeable. In this manual,
  7116. the term @dfn{record} usually refers to a tape physical block,
  7117. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  7118. It is true that archives may be put on disk or used with pipes,
  7119. but nevertheless, @command{tar} tries to read and write the archive one
  7120. @dfn{record} at a time, whatever the medium in use. One record is made
  7121. up of an integral number of blocks, and this operation of putting many
  7122. disk blocks into a single tape block is called @dfn{reblocking}, or
  7123. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  7124. the logical organization of many characters into something meaningful
  7125. to the application. The term @dfn{unit record} describes a small set
  7126. of characters which are transmitted whole to or by the application,
  7127. and often refers to a line of text. Those two last terms are unrelated
  7128. to what we call a @dfn{record} in @GNUTAR{}.
  7129. When writing to tapes, @command{tar} writes the contents of the archive
  7130. in chunks known as @dfn{records}. To change the default blocking
  7131. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  7132. @var{512-size}}) option. Each record will then be composed of
  7133. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  7134. @xref{Standard}.) Each file written to the archive uses at least one
  7135. full record. As a result, using a larger record size can result in
  7136. more wasted space for small files. On the other hand, a larger record
  7137. size can often be read and written much more efficiently.
  7138. Further complicating the problem is that some tape drives ignore the
  7139. blocking entirely. For these, a larger record size can still improve
  7140. performance (because the software layers above the tape drive still
  7141. honor the blocking), but not as dramatically as on tape drives that
  7142. honor blocking.
  7143. When reading an archive, @command{tar} can usually figure out the
  7144. record size on itself. When this is the case, and a non-standard
  7145. record size was used when the archive was created, @command{tar} will
  7146. print a message about a non-standard blocking factor, and then operate
  7147. normally. On some tape devices, however, @command{tar} cannot figure
  7148. out the record size itself. On most of those, you can specify a
  7149. blocking factor (with @option{--blocking-factor}) larger than the
  7150. actual blocking factor, and then use the @option{--read-full-records}
  7151. (@option{-B}) option. (If you specify a blocking factor with
  7152. @option{--blocking-factor} and don't use the
  7153. @option{--read-full-records} option, then @command{tar} will not
  7154. attempt to figure out the recording size itself.) On some devices,
  7155. you must always specify the record size exactly with
  7156. @option{--blocking-factor} when reading, because @command{tar} cannot
  7157. figure it out. In any case, use @option{--list} (@option{-t}) before
  7158. doing any extractions to see whether @command{tar} is reading the archive
  7159. correctly.
  7160. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  7161. putting them into records is to put a whole number of them (one or
  7162. more) into each record. @command{tar} records are all the same size;
  7163. at the end of the file there's a block containing all zeros, which
  7164. is how you tell that the remainder of the last record(s) are garbage.
  7165. In a standard @command{tar} file (no options), the block size is 512
  7166. and the record size is 10240, for a blocking factor of 20. What the
  7167. @option{--blocking-factor} option does is sets the blocking factor,
  7168. changing the record size while leaving the block size at 512 bytes.
  7169. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  7170. most tape drives these days prefer much bigger records in order to
  7171. stream and not waste tape. When writing tapes for myself, some tend
  7172. to use a factor of the order of 2048, say, giving a record size of
  7173. around one megabyte.
  7174. If you use a blocking factor larger than 20, older @command{tar}
  7175. programs might not be able to read the archive, so we recommend this
  7176. as a limit to use in practice. @GNUTAR{}, however,
  7177. will support arbitrarily large record sizes, limited only by the
  7178. amount of virtual memory or the physical characteristics of the tape
  7179. device.
  7180. @menu
  7181. * Format Variations:: Format Variations
  7182. * Blocking Factor:: The Blocking Factor of an Archive
  7183. @end menu
  7184. @node Format Variations
  7185. @subsection Format Variations
  7186. @cindex Format Parameters
  7187. @cindex Format Options
  7188. @cindex Options, archive format specifying
  7189. @cindex Options, format specifying
  7190. @UNREVISED
  7191. Format parameters specify how an archive is written on the archive
  7192. media. The best choice of format parameters will vary depending on
  7193. the type and number of files being archived, and on the media used to
  7194. store the archive.
  7195. To specify format parameters when accessing or creating an archive,
  7196. you can use the options described in the following sections.
  7197. If you do not specify any format parameters, @command{tar} uses
  7198. default parameters. You cannot modify a compressed archive.
  7199. If you create an archive with the @option{--blocking-factor} option
  7200. specified (@pxref{Blocking Factor}), you must specify that
  7201. blocking-factor when operating on the archive. @xref{Formats}, for other
  7202. examples of format parameter considerations.
  7203. @node Blocking Factor
  7204. @subsection The Blocking Factor of an Archive
  7205. @cindex Blocking Factor
  7206. @cindex Record Size
  7207. @cindex Number of blocks per record
  7208. @cindex Number of bytes per record
  7209. @cindex Bytes per record
  7210. @cindex Blocks per record
  7211. @UNREVISED
  7212. @opindex blocking-factor
  7213. The data in an archive is grouped into blocks, which are 512 bytes.
  7214. Blocks are read and written in whole number multiples called
  7215. @dfn{records}. The number of blocks in a record (ie. the size of a
  7216. record in units of 512 bytes) is called the @dfn{blocking factor}.
  7217. The @option{--blocking-factor=@var{512-size}} (@option{-b
  7218. @var{512-size}}) option specifies the blocking factor of an archive.
  7219. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  7220. can be specified at installation. To find out the blocking factor of
  7221. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  7222. This may not work on some devices.
  7223. Records are separated by gaps, which waste space on the archive media.
  7224. If you are archiving on magnetic tape, using a larger blocking factor
  7225. (and therefore larger records) provides faster throughput and allows you
  7226. to fit more data on a tape (because there are fewer gaps). If you are
  7227. archiving on cartridge, a very large blocking factor (say 126 or more)
  7228. greatly increases performance. A smaller blocking factor, on the other
  7229. hand, may be useful when archiving small files, to avoid archiving lots
  7230. of nulls as @command{tar} fills out the archive to the end of the record.
  7231. In general, the ideal record size depends on the size of the
  7232. inter-record gaps on the tape you are using, and the average size of the
  7233. files you are archiving. @xref{create}, for information on
  7234. writing archives.
  7235. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  7236. Archives with blocking factors larger than 20 cannot be read
  7237. by very old versions of @command{tar}, or by some newer versions
  7238. of @command{tar} running on old machines with small address spaces.
  7239. With @GNUTAR{}, the blocking factor of an archive is limited
  7240. only by the maximum record size of the device containing the archive,
  7241. or by the amount of available virtual memory.
  7242. Also, on some systems, not using adequate blocking factors, as sometimes
  7243. imposed by the device drivers, may yield unexpected diagnostics. For
  7244. example, this has been reported:
  7245. @smallexample
  7246. Cannot write to /dev/dlt: Invalid argument
  7247. @end smallexample
  7248. @noindent
  7249. In such cases, it sometimes happen that the @command{tar} bundled by
  7250. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  7251. requires an explicit specification for the block size,
  7252. which it cannot guess. This yields some people to consider
  7253. @GNUTAR{} is misbehaving, because by comparison,
  7254. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  7255. for example, might resolve the problem.
  7256. If you use a non-default blocking factor when you create an archive, you
  7257. must specify the same blocking factor when you modify that archive. Some
  7258. archive devices will also require you to specify the blocking factor when
  7259. reading that archive, however this is not typically the case. Usually, you
  7260. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  7261. reports a non-default record size and then lists the archive members as
  7262. it would normally. To extract files from an archive with a non-standard
  7263. blocking factor (particularly if you're not sure what the blocking factor
  7264. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  7265. specifying a blocking factor larger then the blocking factor of the archive
  7266. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  7267. @xref{list}, for more information on the @option{--list} (@option{-t})
  7268. operation. @xref{Reading}, for a more detailed explanation of that option.
  7269. @table @option
  7270. @item --blocking-factor=@var{number}
  7271. @itemx -b @var{number}
  7272. Specifies the blocking factor of an archive. Can be used with any
  7273. operation, but is usually not necessary with @option{--list} (@option{-t}).
  7274. @end table
  7275. Device blocking
  7276. @table @option
  7277. @item -b @var{blocks}
  7278. @itemx --blocking-factor=@var{blocks}
  7279. Set record size to @math{@var{blocks} * 512} bytes.
  7280. This option is used to specify a @dfn{blocking factor} for the archive.
  7281. When reading or writing the archive, @command{tar}, will do reads and writes
  7282. of the archive in records of @math{@var{block}*512} bytes. This is true
  7283. even when the archive is compressed. Some devices requires that all
  7284. write operations be a multiple of a certain size, and so, @command{tar}
  7285. pads the archive out to the next record boundary.
  7286. The default blocking factor is set when @command{tar} is compiled, and is
  7287. typically 20. Blocking factors larger than 20 cannot be read by very
  7288. old versions of @command{tar}, or by some newer versions of @command{tar}
  7289. running on old machines with small address spaces.
  7290. With a magnetic tape, larger records give faster throughput and fit
  7291. more data on a tape (because there are fewer inter-record gaps).
  7292. If the archive is in a disk file or a pipe, you may want to specify
  7293. a smaller blocking factor, since a large one will result in a large
  7294. number of null bytes at the end of the archive.
  7295. When writing cartridge or other streaming tapes, a much larger
  7296. blocking factor (say 126 or more) will greatly increase performance.
  7297. However, you must specify the same blocking factor when reading or
  7298. updating the archive.
  7299. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7300. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7301. seems to disappear. Id est, we are using block size of 112 right
  7302. now, and we haven't had the problem since we switched@dots{}
  7303. With @GNUTAR{} the blocking factor is limited only
  7304. by the maximum record size of the device containing the archive, or by
  7305. the amount of available virtual memory.
  7306. However, deblocking or reblocking is virtually avoided in a special
  7307. case which often occurs in practice, but which requires all the
  7308. following conditions to be simultaneously true:
  7309. @itemize @bullet
  7310. @item
  7311. the archive is subject to a compression option,
  7312. @item
  7313. the archive is not handled through standard input or output, nor
  7314. redirected nor piped,
  7315. @item
  7316. the archive is directly handled to a local disk, instead of any special
  7317. device,
  7318. @item
  7319. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7320. invocation.
  7321. @end itemize
  7322. If the output goes directly to a local disk, and not through
  7323. stdout, then the last write is not extended to a full record size.
  7324. Otherwise, reblocking occurs. Here are a few other remarks on this
  7325. topic:
  7326. @itemize @bullet
  7327. @item
  7328. @command{gzip} will complain about trailing garbage if asked to
  7329. uncompress a compressed archive on tape, there is an option to turn
  7330. the message off, but it breaks the regularity of simply having to use
  7331. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7332. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7333. Gailly, by sending a copy of this message to him.
  7334. @item
  7335. @command{compress} does not show this problem, but as Jean-loup pointed
  7336. out to Michael, @samp{compress -d} silently adds garbage after
  7337. the result of decompression, which tar ignores because it already
  7338. recognized its end-of-file indicator. So this bug may be safely
  7339. ignored.
  7340. @item
  7341. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7342. but will still return an exit status of 2 which tar reports in turn.
  7343. @command{tar} might ignore the exit status returned, but I hate doing
  7344. that, as it weakens the protection @command{tar} offers users against
  7345. other possible problems at decompression time. If @command{gzip} was
  7346. silently skipping trailing zeros @emph{and} also avoiding setting the
  7347. exit status in this innocuous case, that would solve this situation.
  7348. @item
  7349. @command{tar} should become more solid at not stopping to read a pipe at
  7350. the first null block encountered. This inelegantly breaks the pipe.
  7351. @command{tar} should rather drain the pipe out before exiting itself.
  7352. @end itemize
  7353. @opindex ignore-zeros, short description
  7354. @item -i
  7355. @itemx --ignore-zeros
  7356. Ignore blocks of zeros in archive (means EOF).
  7357. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7358. of zeros in the archive. Normally a block of zeros indicates the
  7359. end of the archive, but when reading a damaged archive, or one which
  7360. was created by concatenating several archives together, this option
  7361. allows @command{tar} to read the entire archive. This option is not on
  7362. by default because many versions of @command{tar} write garbage after
  7363. the zeroed blocks.
  7364. Note that this option causes @command{tar} to read to the end of the
  7365. archive file, which may sometimes avoid problems when multiple files
  7366. are stored on a single physical tape.
  7367. @opindex read-full-records, short description
  7368. @item -B
  7369. @itemx --read-full-records
  7370. Reblock as we read (for reading 4.2BSD pipes).
  7371. If @option{--read-full-records} is used, @command{tar}
  7372. will not panic if an attempt to read a record from the archive does
  7373. not return a full record. Instead, @command{tar} will keep reading
  7374. until it has obtained a full
  7375. record.
  7376. This option is turned on by default when @command{tar} is reading
  7377. an archive from standard input, or from a remote machine. This is
  7378. because on BSD Unix systems, a read of a pipe will return however
  7379. much happens to be in the pipe, even if it is less than @command{tar}
  7380. requested. If this option was not used, @command{tar} would fail as
  7381. soon as it read an incomplete record from the pipe.
  7382. This option is also useful with the commands for updating an archive.
  7383. @end table
  7384. Tape blocking
  7385. @FIXME{Appropriate options should be moved here from elsewhere.}
  7386. @cindex blocking factor
  7387. @cindex tape blocking
  7388. When handling various tapes or cartridges, you have to take care of
  7389. selecting a proper blocking, that is, the number of disk blocks you
  7390. put together as a single tape block on the tape, without intervening
  7391. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7392. with no information on it, used for decelerating the tape to a
  7393. full stop, and for later regaining the reading or writing speed.
  7394. When the tape driver starts reading a record, the record has to
  7395. be read whole without stopping, as a tape gap is needed to stop the
  7396. tape motion without loosing information.
  7397. @cindex Exabyte blocking
  7398. @cindex DAT blocking
  7399. Using higher blocking (putting more disk blocks per tape block) will use
  7400. the tape more efficiently as there will be less tape gaps. But reading
  7401. such tapes may be more difficult for the system, as more memory will be
  7402. required to receive at once the whole record. Further, if there is a
  7403. reading error on a huge record, this is less likely that the system will
  7404. succeed in recovering the information. So, blocking should not be too
  7405. low, nor it should be too high. @command{tar} uses by default a blocking of
  7406. 20 for historical reasons, and it does not really matter when reading or
  7407. writing to disk. Current tape technology would easily accommodate higher
  7408. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7409. We were told that for some DLT drives, the blocking should be a multiple
  7410. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7411. Other manufacturers may use different recommendations for the same tapes.
  7412. This might also depends of the buffering techniques used inside modern
  7413. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7414. Others request blocking to be some exponent of two.
  7415. So, there is no fixed rule for blocking. But blocking at read time
  7416. should ideally be the same as blocking used at write time. At one place
  7417. I know, with a wide variety of equipment, they found it best to use a
  7418. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7419. I was also told that, for recycled tapes, prior erasure (by the same
  7420. drive unit that will be used to create the archives) sometimes lowers
  7421. the error rates observed at rewriting time.
  7422. I might also use @option{--number-blocks} instead of
  7423. @option{--block-number}, so @option{--block} will then expand to
  7424. @option{--blocking-factor} unambiguously.
  7425. @node Many
  7426. @section Many Archives on One Tape
  7427. @FIXME{Appropriate options should be moved here from elsewhere.}
  7428. @findex ntape @r{device}
  7429. Most tape devices have two entries in the @file{/dev} directory, or
  7430. entries that come in pairs, which differ only in the minor number for
  7431. this device. Let's take for example @file{/dev/tape}, which often
  7432. points to the only or usual tape device of a given system. There might
  7433. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7434. name is the @emph{rewinding} version of the device, while the name
  7435. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7436. device.
  7437. A rewinding tape device will bring back the tape to its beginning point
  7438. automatically when this device is opened or closed. Since @command{tar}
  7439. opens the archive file before using it and closes it afterwards, this
  7440. means that a simple:
  7441. @smallexample
  7442. $ @kbd{tar cf /dev/tape @var{directory}}
  7443. @end smallexample
  7444. @noindent
  7445. will reposition the tape to its beginning both prior and after saving
  7446. @var{directory} contents to it, thus erasing prior tape contents and
  7447. making it so that any subsequent write operation will destroy what has
  7448. just been saved.
  7449. @cindex tape positioning
  7450. So, a rewinding device is normally meant to hold one and only one file.
  7451. If you want to put more than one @command{tar} archive on a given tape, you
  7452. will need to avoid using the rewinding version of the tape device. You
  7453. will also have to pay special attention to tape positioning. Errors in
  7454. positioning may overwrite the valuable data already on your tape. Many
  7455. people, burnt by past experiences, will only use rewinding devices and
  7456. limit themselves to one file per tape, precisely to avoid the risk of
  7457. such errors. Be fully aware that writing at the wrong position on a
  7458. tape loses all information past this point and most probably until the
  7459. end of the tape, and this destroyed information @emph{cannot} be
  7460. recovered.
  7461. To save @var{directory-1} as a first archive at the beginning of a
  7462. tape, and leave that tape ready for a second archive, you should use:
  7463. @smallexample
  7464. $ @kbd{mt -f /dev/nrtape rewind}
  7465. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7466. @end smallexample
  7467. @cindex tape marks
  7468. @dfn{Tape marks} are special magnetic patterns written on the tape
  7469. media, which are later recognizable by the reading hardware. These
  7470. marks are used after each file, when there are many on a single tape.
  7471. An empty file (that is to say, two tape marks in a row) signal the
  7472. logical end of the tape, after which no file exist. Usually,
  7473. non-rewinding tape device drivers will react to the close request issued
  7474. by @command{tar} by first writing two tape marks after your archive, and by
  7475. backspacing over one of these. So, if you remove the tape at that time
  7476. from the tape drive, it is properly terminated. But if you write
  7477. another file at the current position, the second tape mark will be
  7478. erased by the new information, leaving only one tape mark between files.
  7479. So, you may now save @var{directory-2} as a second archive after the
  7480. first on the same tape by issuing the command:
  7481. @smallexample
  7482. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7483. @end smallexample
  7484. @noindent
  7485. and so on for all the archives you want to put on the same tape.
  7486. Another usual case is that you do not write all the archives the same
  7487. day, and you need to remove and store the tape between two archive
  7488. sessions. In general, you must remember how many files are already
  7489. saved on your tape. Suppose your tape already has 16 files on it, and
  7490. that you are ready to write the 17th. You have to take care of skipping
  7491. the first 16 tape marks before saving @var{directory-17}, say, by using
  7492. these commands:
  7493. @smallexample
  7494. $ @kbd{mt -f /dev/nrtape rewind}
  7495. $ @kbd{mt -f /dev/nrtape fsf 16}
  7496. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7497. @end smallexample
  7498. In all the previous examples, we put aside blocking considerations, but
  7499. you should do the proper things for that as well. @xref{Blocking}.
  7500. @menu
  7501. * Tape Positioning:: Tape Positions and Tape Marks
  7502. * mt:: The @command{mt} Utility
  7503. @end menu
  7504. @node Tape Positioning
  7505. @subsection Tape Positions and Tape Marks
  7506. @UNREVISED
  7507. Just as archives can store more than one file from the file system,
  7508. tapes can store more than one archive file. To keep track of where
  7509. archive files (or any other type of file stored on tape) begin and
  7510. end, tape archive devices write magnetic @dfn{tape marks} on the
  7511. archive media. Tape drives write one tape mark between files,
  7512. two at the end of all the file entries.
  7513. If you think of data as a series of records "rrrr"'s, and tape marks as
  7514. "*"'s, a tape might look like the following:
  7515. @smallexample
  7516. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7517. @end smallexample
  7518. Tape devices read and write tapes using a read/write @dfn{tape
  7519. head}---a physical part of the device which can only access one
  7520. point on the tape at a time. When you use @command{tar} to read or
  7521. write archive data from a tape device, the device will begin reading
  7522. or writing from wherever on the tape the tape head happens to be,
  7523. regardless of which archive or what part of the archive the tape
  7524. head is on. Before writing an archive, you should make sure that no
  7525. data on the tape will be overwritten (unless it is no longer needed).
  7526. Before reading an archive, you should make sure the tape head is at
  7527. the beginning of the archive you want to read. You can do it manually
  7528. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7529. that automatically (@pxref{Scripted Restoration}).
  7530. If you want to add new archive file entries to a tape, you should
  7531. advance the tape to the end of the existing file entries, backspace
  7532. over the last tape mark, and write the new archive file. If you were
  7533. to add two archives to the example above, the tape might look like the
  7534. following:
  7535. @smallexample
  7536. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7537. @end smallexample
  7538. @node mt
  7539. @subsection The @command{mt} Utility
  7540. @UNREVISED
  7541. @FIXME{Is it true that this only works on non-block devices?
  7542. should explain the difference, (fixed or variable).}
  7543. @xref{Blocking Factor}.
  7544. You can use the @command{mt} utility to advance or rewind a tape past a
  7545. specified number of archive files on the tape. This will allow you
  7546. to move to the beginning of an archive before extracting or reading
  7547. it, or to the end of all the archives before writing a new one.
  7548. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7549. together"?}
  7550. The syntax of the @command{mt} command is:
  7551. @smallexample
  7552. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7553. @end smallexample
  7554. where @var{tapename} is the name of the tape device, @var{number} is
  7555. the number of times an operation is performed (with a default of one),
  7556. and @var{operation} is one of the following:
  7557. @FIXME{is there any use for record operations?}
  7558. @table @option
  7559. @item eof
  7560. @itemx weof
  7561. Writes @var{number} tape marks at the current position on the tape.
  7562. @item fsf
  7563. Moves tape position forward @var{number} files.
  7564. @item bsf
  7565. Moves tape position back @var{number} files.
  7566. @item rewind
  7567. Rewinds the tape. (Ignores @var{number}).
  7568. @item offline
  7569. @itemx rewoff1
  7570. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7571. @item status
  7572. Prints status information about the tape unit.
  7573. @end table
  7574. @FIXME{Is there a better way to frob the spacing on the list?}
  7575. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7576. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} will use
  7577. the default device specified in your @file{sys/mtio.h} file
  7578. (@code{DEFTAPE} variable). If this is not defined, the program will
  7579. display a descriptive error message and exit with code 1.
  7580. @command{mt} returns a 0 exit status when the operation(s) were
  7581. successful, 1 if the command was unrecognized, and 2 if an operation
  7582. failed.
  7583. @node Using Multiple Tapes
  7584. @section Using Multiple Tapes
  7585. @UNREVISED
  7586. Often you might want to write a large archive, one larger than will fit
  7587. on the actual tape you are using. In such a case, you can run multiple
  7588. @command{tar} commands, but this can be inconvenient, particularly if you
  7589. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7590. Therefore, @command{tar} supports multiple tapes automatically.
  7591. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7592. then @command{tar} will, when it reaches the end of the tape, prompt
  7593. for another tape, and continue the archive. Each tape will have an
  7594. independent archive, and can be read without needing the other. (As
  7595. an exception to this, the file that @command{tar} was archiving when
  7596. it ran out of tape will usually be split between the two archives; in
  7597. this case you need to extract from the first archive, using
  7598. @option{--multi-volume}, and then put in the second tape when
  7599. prompted, so @command{tar} can restore both halves of the file.)
  7600. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7601. You need @GNUTAR{} at both ends to process them properly.
  7602. When prompting for a new tape, @command{tar} accepts any of the following
  7603. responses:
  7604. @table @kbd
  7605. @item ?
  7606. Request @command{tar} to explain possible responses
  7607. @item q
  7608. Request @command{tar} to exit immediately.
  7609. @item n @var{file-name}
  7610. Request @command{tar} to write the next volume on the file @var{file-name}.
  7611. @item !
  7612. Request @command{tar} to run a subshell. This option can be disabled
  7613. by giving @option{--restrict} command line option to @command{tar}.
  7614. @item y
  7615. Request @command{tar} to begin writing the next volume.
  7616. @end table
  7617. (You should only type @samp{y} after you have changed the tape;
  7618. otherwise @command{tar} will write over the volume it just finished.)
  7619. @cindex End-of-archive info script
  7620. @cindex Info script
  7621. @anchor{info-script}
  7622. @opindex info-script
  7623. @opindex new-volume-script
  7624. If you want more elaborate behavior than this, give @command{tar} the
  7625. @option{--info-script=@var{script-name}}
  7626. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7627. @var{script-name}}) option. The file @var{script-name} is expected to
  7628. be a program (or shell script) to be run instead of the normal
  7629. prompting procedure. It is executed without any command line
  7630. arguments. Additional data is passed to it via the following
  7631. environment variables:
  7632. @table @env
  7633. @vrindex TAR_VERSION, info script environment variable
  7634. @item TAR_VERSION
  7635. @GNUTAR{} version number.
  7636. @vrindex TAR_ARCHIVE, info script environment variable
  7637. @item TAR_ARCHIVE
  7638. The name of the archive @command{tar} is processing.
  7639. @vrindex TAR_VOLUME, info script environment variable
  7640. @item TAR_VOLUME
  7641. Ordinal number of the volume @command{tar} is about to start.
  7642. @vrindex TAR_SUBCOMMAND, info script environment variable
  7643. @item TAR_SUBCOMMAND
  7644. Short option describing the operation @command{tar} is executing
  7645. @xref{Operations}, for a complete list of subcommand options.
  7646. @vrindex TAR_FORMAT, info script environment variable
  7647. @item TAR_FORMAT
  7648. Format of the archive being processed. @xref{Formats}, for a complete
  7649. list of archive format names.
  7650. @end table
  7651. The info script can instruct @command{tar} to use new archive name,
  7652. by writing in to file descriptor 3 (see below for an
  7653. example).
  7654. If the info script fails, @command{tar} exits; otherwise, it begins
  7655. writing the next volume.
  7656. The method @command{tar} uses to detect end of tape is not perfect, and
  7657. fails on some operating systems or on some devices. You can use the
  7658. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7659. @command{tar} can't detect the end of the tape itself. This option
  7660. selects @option{--multi-volume} (@option{-M}) automatically. The
  7661. @var{size} argument should then be the usable size of the tape in
  7662. units of 1024 bytes. But for many devices, and floppy disks in
  7663. particular, this option is never required for real, as far as we know.
  7664. @cindex Volume number file
  7665. @cindex volno file
  7666. @anchor{volno-file}
  7667. @opindex volno-file
  7668. The volume number used by @command{tar} in its tape-change prompt
  7669. can be changed; if you give the
  7670. @option{--volno-file=@var{file-of-number}} option, then
  7671. @var{file-of-number} should be an unexisting file to be created, or
  7672. else, a file already containing a decimal number. That number will be
  7673. used as the volume number of the first volume written. When
  7674. @command{tar} is finished, it will rewrite the file with the
  7675. now-current volume number. (This does not change the volume number
  7676. written on a tape label, as per @ref{label}, it @emph{only} affects
  7677. the number used in the prompt.)
  7678. If you want @command{tar} to cycle through a series of files or tape
  7679. drives, there are three approaches to choose from. First of all, you
  7680. can give @command{tar} multiple @option{--file} options. In this case
  7681. the specified files will be used, in sequence, as the successive
  7682. volumes of the archive. Only when the first one in the sequence needs
  7683. to be used again will @command{tar} prompt for a tape change (or run
  7684. the info script). Secondly, you can use the @samp{n} response to the
  7685. tape-change prompt, and, finally, you can use an info script, that
  7686. writes new archive name to file descriptor. The following example
  7687. illustrates this approach:
  7688. @smallexample
  7689. @group
  7690. #! /bin/sh
  7691. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7692. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7693. case $TAR_SUBCOMMAND in
  7694. -c) ;;
  7695. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7696. ;;
  7697. *) exit 1
  7698. esac
  7699. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7700. @end group
  7701. @end smallexample
  7702. Each volume of a multi-volume archive is an independent @command{tar}
  7703. archive, complete in itself. For example, you can list or extract any
  7704. volume alone; just don't specify @option{--multi-volume}
  7705. (@option{-M}). However, if one file in the archive is split across
  7706. volumes, the only way to extract it successfully is with a
  7707. multi-volume extract command @option{--extract --multi-volume}
  7708. (@option{-xM}) starting on or before the volume where the file begins.
  7709. For example, let's presume someone has two tape drives on a system
  7710. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7711. to switch to the second drive when it needs to write the
  7712. second tape, and then back to the first tape, etc., just do either of:
  7713. @smallexample
  7714. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7715. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7716. @end smallexample
  7717. @menu
  7718. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7719. * Tape Files:: Tape Files
  7720. * Tarcat:: Concatenate Volumes into a Single Archive
  7721. @end menu
  7722. @node Multi-Volume Archives
  7723. @subsection Archives Longer than One Tape or Disk
  7724. @cindex Multi-volume archives
  7725. @UNREVISED
  7726. @opindex multi-volume
  7727. To create an archive that is larger than will fit on a single unit of
  7728. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7729. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7730. archive can be manipulated like any other archive (provided the
  7731. @option{--multi-volume} option is specified), but is stored on more
  7732. than one tape or disk.
  7733. When you specify @option{--multi-volume}, @command{tar} does not report an
  7734. error when it comes to the end of an archive volume (when reading), or
  7735. the end of the media (when writing). Instead, it prompts you to load
  7736. a new storage volume. If the archive is on a magnetic tape, you
  7737. should change tapes when you see the prompt; if the archive is on a
  7738. floppy disk, you should change disks; etc.
  7739. You can read each individual volume of a multi-volume archive as if it
  7740. were an archive by itself. For example, to list the contents of one
  7741. volume, use @option{--list}, without @option{--multi-volume} specified.
  7742. To extract an archive member from one volume (assuming it is described
  7743. that volume), use @option{--extract}, again without
  7744. @option{--multi-volume}.
  7745. If an archive member is split across volumes (ie. its entry begins on
  7746. one volume of the media and ends on another), you need to specify
  7747. @option{--multi-volume} to extract it successfully. In this case, you
  7748. should load the volume where the archive member starts, and use
  7749. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7750. volumes as it needs them. @xref{extracting archives}, for more
  7751. information about extracting archives.
  7752. @option{--info-script=@var{script-name}}
  7753. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7754. @var{script-name}}) (@pxref{info-script}) is like
  7755. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7756. not prompt you directly to change media volumes when a volume is
  7757. full---instead, @command{tar} runs commands you have stored in
  7758. @var{script-name}. For example, this option can be used to eject
  7759. cassettes, or to broadcast messages such as @samp{Someone please come
  7760. change my tape} when performing unattended backups. When
  7761. @var{script-name} is done, @command{tar} will assume that the media
  7762. has been changed.
  7763. Multi-volume archives can be modified like any other archive. To add
  7764. files to a multi-volume archive, you need to only mount the last
  7765. volume of the archive media (and new volumes, if needed). For all
  7766. other operations, you need to use the entire archive.
  7767. If a multi-volume archive was labeled using
  7768. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7769. (@pxref{label}) when it was created, @command{tar} will not
  7770. automatically label volumes which are added later. To label
  7771. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7772. in conjunction with the @option{--append}, @option{--update} or
  7773. @option{--concatenate} operation.
  7774. @cindex Labeling multi-volume archives
  7775. @FIXME{example}
  7776. @FIXME{There should be a sample program here, including an exit
  7777. before end. Is the exit status even checked in tar? :-(}
  7778. @table @option
  7779. @item --multi-volume
  7780. @itemx -M
  7781. Creates a multi-volume archive, when used in conjunction with
  7782. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7783. archive, specify @option{--multi-volume} in conjunction with that
  7784. operation.
  7785. @item --info-script=@var{program-file}
  7786. @itemx --new-volume-script=@var{program-file}
  7787. @itemx -F @var{program-file}
  7788. Creates a multi-volume archive via a script. Used in conjunction with
  7789. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7790. @end table
  7791. Beware that there is @emph{no} real standard about the proper way, for
  7792. a @command{tar} archive, to span volume boundaries. If you have a
  7793. multi-volume created by some vendor's @command{tar}, there is almost
  7794. no chance you could read all the volumes with @GNUTAR{}.
  7795. The converse is also true: you may not expect
  7796. multi-volume archives created by @GNUTAR{} to be
  7797. fully recovered by vendor's @command{tar}. Since there is little
  7798. chance that, in mixed system configurations, some vendor's
  7799. @command{tar} will work on another vendor's machine, and there is a
  7800. great chance that @GNUTAR{} will work on most of
  7801. them, your best bet is to install @GNUTAR{} on all
  7802. machines between which you know exchange of files is possible.
  7803. @node Tape Files
  7804. @subsection Tape Files
  7805. @UNREVISED
  7806. To give the archive a name which will be recorded in it, use the
  7807. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7808. option. This will write a special block identifying
  7809. @var{volume-label} as the name of the archive to the front of the
  7810. archive which will be displayed when the archive is listed with
  7811. @option{--list}. If you are creating a multi-volume archive with
  7812. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7813. volume label will have @samp{Volume @var{nnn}} appended to the name
  7814. you give, where @var{nnn} is the number of the volume of the archive.
  7815. (If you use the @option{--label=@var{volume-label}}) option when
  7816. reading an archive, it checks to make sure the label on the tape
  7817. matches the one you give. @xref{label}.
  7818. When @command{tar} writes an archive to tape, it creates a single
  7819. tape file. If multiple archives are written to the same tape, one
  7820. after the other, they each get written as separate tape files. When
  7821. extracting, it is necessary to position the tape at the right place
  7822. before running @command{tar}. To do this, use the @command{mt} command.
  7823. For more information on the @command{mt} command and on the organization
  7824. of tapes into a sequence of tape files, see @ref{mt}.
  7825. People seem to often do:
  7826. @smallexample
  7827. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7828. @end smallexample
  7829. or such, for pushing a common date in all volumes or an archive set.
  7830. @node Tarcat
  7831. @subsection Concatenate Volumes into a Single Archive
  7832. @pindex tarcat
  7833. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7834. archive to a single @command{tar} archive. Simply concatenating all
  7835. volumes into one will not work, since each volume carries an additional
  7836. information at the beginning. @GNUTAR{} is shipped with the shell
  7837. script @command{tarcat} designed for this purpose.
  7838. The script takes a list of files comprising a multi-volume archive
  7839. and creates the resulting archive at the standard output. For example:
  7840. @smallexample
  7841. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7842. @end smallexample
  7843. The script implements a simple heuristics to determine the format of
  7844. the first volume file and to decide how to process the rest of the
  7845. files. However, it makes no attempt to verify whether the files are
  7846. given in order or even if they are valid @command{tar} archives.
  7847. It uses @command{dd} and does not filter its standard error, so you
  7848. will usually see lots of spurious messages.
  7849. @FIXME{The script is not installed. Should we install it?}
  7850. @node label
  7851. @section Including a Label in the Archive
  7852. @cindex Labeling an archive
  7853. @cindex Labels on the archive media
  7854. @UNREVISED
  7855. @opindex label
  7856. To avoid problems caused by misplaced paper labels on the archive
  7857. media, you can include a @dfn{label} entry---an archive member which
  7858. contains the name of the archive---in the archive itself. Use the
  7859. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7860. option in conjunction with the @option{--create} operation to include
  7861. a label entry in the archive as it is being created.
  7862. @table @option
  7863. @item --label=@var{archive-label}
  7864. @itemx -V @var{archive-label}
  7865. Includes an @dfn{archive-label} at the beginning of the archive when
  7866. the archive is being created, when used in conjunction with the
  7867. @option{--create} operation. Checks to make sure the archive label
  7868. matches the one specified (when used in conjunction with any other
  7869. operation.
  7870. @end table
  7871. If you create an archive using both
  7872. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7873. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7874. will have an archive label of the form @samp{@var{archive-label}
  7875. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7876. next, and so on. @xref{Using Multiple Tapes}, for information on
  7877. creating multiple volume archives.
  7878. @cindex Volume label, listing
  7879. @cindex Listing volume label
  7880. The volume label will be displayed by @option{--list} along with
  7881. the file contents. If verbose display is requested, it will also be
  7882. explicitely marked as in the example below:
  7883. @smallexample
  7884. @group
  7885. $ @kbd{tar --verbose --list --file=iamanarchive}
  7886. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7887. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7888. @end group
  7889. @end smallexample
  7890. @opindex test-label
  7891. @anchor{--test-label option}
  7892. However, @option{--list} option will cause listing entire
  7893. contents of the archive, which may be undesirable (for example, if the
  7894. archive is stored on a tape). You can request checking only the volume
  7895. by specifying @option{--test-label} option. This option reads only the
  7896. first block of an archive, so it can be used with slow storage
  7897. devices. For example:
  7898. @smallexample
  7899. @group
  7900. $ @kbd{tar --test-label --file=iamanarchive}
  7901. iamalabel
  7902. @end group
  7903. @end smallexample
  7904. If @option{--test-label} is used with a single command line
  7905. argument, @command{tar} compares the volume label with the
  7906. argument. It exits with code 0 if the two strings match, and with code
  7907. 2 otherwise. In this case no output is displayed. For example:
  7908. @smallexample
  7909. @group
  7910. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7911. @result{} 0
  7912. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7913. @result{} 1
  7914. @end group
  7915. @end smallexample
  7916. If you request any operation, other than @option{--create}, along
  7917. with using @option{--label} option, @command{tar} will first check if
  7918. the archive label matches the one specified and will refuse to proceed
  7919. if it does not. Use this as a safety precaution to avoid accidentally
  7920. overwriting existing archives. For example, if you wish to add files
  7921. to @file{archive}, presumably labelled with string @samp{My volume},
  7922. you will get:
  7923. @smallexample
  7924. @group
  7925. $ @kbd{tar -rf archive --label 'My volume' .}
  7926. tar: Archive not labeled to match `My volume'
  7927. @end group
  7928. @end smallexample
  7929. @noindent
  7930. in case its label does not match. This will work even if
  7931. @file{archive} is not labelled at all.
  7932. Similarly, @command{tar} will refuse to list or extract the
  7933. archive if its label doesn't match the @var{archive-label}
  7934. specified. In those cases, @var{archive-label} argument is interpreted
  7935. as a globbing-style pattern which must match the actual magnetic
  7936. volume label. @xref{exclude}, for a precise description of how match
  7937. is attempted@footnote{Previous versions of @command{tar} used full
  7938. regular expression matching, or before that, only exact string
  7939. matching, instead of wildcard matchers. We decided for the sake of
  7940. simplicity to use a uniform matching device through
  7941. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7942. the volume label matcher will also suffix @var{archive-label} by
  7943. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7944. up. Since the volume numbering is automatically added in labels at
  7945. creation time, it sounded logical to equally help the user taking care
  7946. of it when the archive is being read.
  7947. The @option{--label} was once called @option{--volume}, but is not
  7948. available under that name anymore.
  7949. You can also use @option{--label} to get a common information on
  7950. all tapes of a series. For having this information different in each
  7951. series created through a single script used on a regular basis, just
  7952. manage to get some date string as part of the label. For example:
  7953. @smallexample
  7954. @group
  7955. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7956. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7957. --volume="Daily backup for `date +%Y-%m-%d`"}
  7958. @end group
  7959. @end smallexample
  7960. Also note that each label has its own date and time, which corresponds
  7961. to when @GNUTAR{} initially attempted to write it,
  7962. often soon after the operator launches @command{tar} or types the
  7963. carriage return telling that the next tape is ready. Comparing date
  7964. labels does give an idea of tape throughput only if the delays for
  7965. rewinding tapes and the operator switching them were negligible, which
  7966. is usually not the case.
  7967. @node verify
  7968. @section Verifying Data as It is Stored
  7969. @cindex Verifying a write operation
  7970. @cindex Double-checking a write operation
  7971. @table @option
  7972. @item -W
  7973. @itemx --verify
  7974. @opindex verify, short description
  7975. Attempt to verify the archive after writing.
  7976. @end table
  7977. This option causes @command{tar} to verify the archive after writing it.
  7978. Each volume is checked after it is written, and any discrepancies
  7979. are recorded on the standard error output.
  7980. Verification requires that the archive be on a back-space-able medium.
  7981. This means pipes, some cartridge tape drives, and some other devices
  7982. cannot be verified.
  7983. You can insure the accuracy of an archive by comparing files in the
  7984. system with archive members. @command{tar} can compare an archive to the
  7985. file system as the archive is being written, to verify a write
  7986. operation, or can compare a previously written archive, to insure that
  7987. it is up to date.
  7988. @opindex verify, using with @option{--create}
  7989. @opindex create, using with @option{--verify}
  7990. To check for discrepancies in an archive immediately after it is
  7991. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7992. the @option{--create} operation. When this option is
  7993. specified, @command{tar} checks archive members against their counterparts
  7994. in the file system, and reports discrepancies on the standard error.
  7995. To verify an archive, you must be able to read it from before the end
  7996. of the last written entry. This option is useful for detecting data
  7997. errors on some tapes. Archives written to pipes, some cartridge tape
  7998. drives, and some other devices cannot be verified.
  7999. One can explicitly compare an already made archive with the file
  8000. system by using the @option{--compare} (@option{--diff}, @option{-d})
  8001. option, instead of using the more automatic @option{--verify} option.
  8002. @xref{compare}.
  8003. Note that these two options have a slightly different intent. The
  8004. @option{--compare} option checks how identical are the logical contents of some
  8005. archive with what is on your disks, while the @option{--verify} option is
  8006. really for checking if the physical contents agree and if the recording
  8007. media itself is of dependable quality. So, for the @option{--verify}
  8008. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  8009. the archive, while it lets the speed optimization undisturbed for the
  8010. @option{--compare} option. If you nevertheless use @option{--compare} for
  8011. media verification, you may have to defeat the in-memory cache yourself,
  8012. maybe by opening and reclosing the door latch of your recording unit,
  8013. forcing some doubt in your operating system about the fact this is really
  8014. the same volume as the one just written or read.
  8015. The @option{--verify} option would not be necessary if drivers were indeed
  8016. able to detect dependably all write failures. This sometimes require many
  8017. magnetic heads, some able to read after the writes occurred. One would
  8018. not say that drivers unable to detect all cases are necessarily flawed,
  8019. as long as programming is concerned.
  8020. The @option{--verify} (@option{-W}) option will not work in
  8021. conjunction with the @option{--multi-volume} (@option{-M}) option or
  8022. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  8023. and @option{--delete} operations. @xref{Operations}, for more
  8024. information on these operations.
  8025. Also, since @command{tar} normally strips leading @samp{/} from file
  8026. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  8027. /tmp/foo.tar /etc} will work as desired only if the working directory is
  8028. @file{/}, as @command{tar} uses the archive's relative member names
  8029. (e.g., @file{etc/motd}) when verifying the archive.
  8030. @node Write Protection
  8031. @section Write Protection
  8032. Almost all tapes and diskettes, and in a few rare cases, even disks can
  8033. be @dfn{write protected}, to protect data on them from being changed.
  8034. Once an archive is written, you should write protect the media to prevent
  8035. the archive from being accidentally overwritten or deleted. (This will
  8036. protect the archive from being changed with a tape or floppy drive---it
  8037. will not protect it from magnet fields or other physical hazards).
  8038. The write protection device itself is usually an integral part of the
  8039. physical media, and can be a two position (write enabled/write
  8040. disabled) switch, a notch which can be popped out or covered, a ring
  8041. which can be removed from the center of a tape reel, or some other
  8042. changeable feature.
  8043. @node Changes
  8044. @appendix Changes
  8045. This appendix lists some important user-visible changes between
  8046. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  8047. version of this document is available at
  8048. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  8049. @GNUTAR{} documentation page}.
  8050. @table @asis
  8051. @item Use of globbing patterns when listing and extracting.
  8052. Previous versions of GNU tar assumed shell-style globbing when
  8053. extracting from or listing an archive. For example:
  8054. @smallexample
  8055. $ @kbd{tar xf foo.tar '*.c'}
  8056. @end smallexample
  8057. would extract all files whose names end in @samp{.c}. This behavior
  8058. was not documented and was incompatible with traditional tar
  8059. implementations. Therefore, starting from version 1.15.91, GNU tar
  8060. no longer uses globbing by default. For example, the above invocation
  8061. is now interpreted as a request to extract from the archive the file
  8062. named @file{*.c}.
  8063. To facilitate transition to the new behavior for those users who got
  8064. used to the previous incorrect one, @command{tar} will print a warning
  8065. if it finds out that a requested member was not found in the archive
  8066. and its name looks like a globbing pattern. For example:
  8067. @smallexample
  8068. $ @kbd{tar xf foo.tar '*.c'}
  8069. tar: Pattern matching characters used in file names. Please,
  8070. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  8071. tar: suppress this warning.
  8072. tar: *.c: Not found in archive
  8073. tar: Error exit delayed from previous errors
  8074. @end smallexample
  8075. To treat member names as globbing patterns, use --wildcards option.
  8076. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  8077. add this option to your @env{TAR_OPTIONS} variable.
  8078. @xref{wildcards}, for the detailed discussion of the use of globbing
  8079. patterns by @GNUTAR{}.
  8080. @item Use of short option @option{-o}.
  8081. Earlier versions of @GNUTAR{} understood @option{-o} command line
  8082. option as a synonym for @option{--old-archive}.
  8083. @GNUTAR{} starting from version 1.13.90 understands this option as
  8084. a synonym for @option{--no-same-owner}. This is compatible with
  8085. UNIX98 @command{tar} implementations.
  8086. However, to facilitate transition, @option{-o} option retains its
  8087. old semantics when it is used with one of archive-creation commands.
  8088. Users are encouraged to use @option{--format=oldgnu} instead.
  8089. It is especially important, since versions of @acronym{GNU} Automake
  8090. up to and including 1.8.4 invoke tar with this option to produce
  8091. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  8092. of this issue and its implications.
  8093. @FIXME{Change the first argument to tar-formats when the new Automake is
  8094. out. The proposition to add @anchor{} to the appropriate place of its
  8095. docs was accepted by Automake people --Sergey 2006-05-25}.
  8096. @xref{Options, tar-v7, Changing Automake's Behavior,
  8097. automake, GNU Automake}, for a description on how to use various
  8098. archive formats with @command{automake}.
  8099. Future versions of @GNUTAR{} will understand @option{-o} only as a
  8100. synonym for @option{--no-same-owner}.
  8101. @item Use of short option @option{-l}
  8102. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  8103. synonym for @option{--one-file-system}. Since such usage contradicted
  8104. to UNIX98 specification and harmed compatibility with other
  8105. implementation, it was declared deprecated in version 1.14. However,
  8106. to facilitate transition to its new semantics, it was supported by
  8107. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  8108. variant of @option{--check-links} was introduced in version 1.15.91.
  8109. @item Use of options @option{--portability} and @option{--old-archive}
  8110. These options are deprecated. Please use @option{--format=v7} instead.
  8111. @item Use of option @option{--posix}
  8112. This option is deprecated. Please use @option{--format=posix} instead.
  8113. @end table
  8114. @node Configuring Help Summary
  8115. @appendix Configuring Help Summary
  8116. Running @kbd{tar --help} displays the short @command{tar} option
  8117. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  8118. semantically close options. The options within each group are printed
  8119. in the following order: a short option, eventually followed by a list
  8120. of corresponding long option names, followed by a short description of
  8121. the option. For example, here is an excerpt from the actual @kbd{tar
  8122. --help} output:
  8123. @verbatim
  8124. Main operation mode:
  8125. -A, --catenate, --concatenate append tar files to an archive
  8126. -c, --create create a new archive
  8127. -d, --diff, --compare find differences between archive and
  8128. file system
  8129. --delete delete from the archive
  8130. @end verbatim
  8131. @vrindex ARGP_HELP_FMT, environment variable
  8132. The exact visual representation of the help output is configurable via
  8133. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  8134. is a comma-separated list of @dfn{format variable} assignments. There
  8135. are two kinds of format variables. An @dfn{offset variable} keeps the
  8136. offset of some part of help output text from the leftmost column on
  8137. the screen. A @dfn{boolean} variable is a flag that toggles some
  8138. output feature on or off. Depending on the type of the corresponding
  8139. variable, there are two kinds of assignments:
  8140. @table @asis
  8141. @item Offset assignment
  8142. The assignment to an offset variable has the following syntax:
  8143. @smallexample
  8144. @var{variable}=@var{value}
  8145. @end smallexample
  8146. @noindent
  8147. where @var{variable} is the variable name, and @var{value} is a
  8148. numeric value to be assigned to the variable.
  8149. @item Boolean assignment
  8150. To assign @code{true} value to a variable, simply put this variable name. To
  8151. assign @code{false} value, prefix the variable name with @samp{no-}. For
  8152. example:
  8153. @smallexample
  8154. @group
  8155. # Assign @code{true} value:
  8156. dup-args
  8157. # Assign @code{false} value:
  8158. no-dup-args
  8159. @end group
  8160. @end smallexample
  8161. @end table
  8162. Following variables are declared:
  8163. @deftypevr {Help Output} boolean dup-args
  8164. If true, arguments for an option are shown with both short and long
  8165. options, even when a given option has both forms, for example:
  8166. @smallexample
  8167. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  8168. @end smallexample
  8169. If false, then if an option has both short and long forms, the
  8170. argument is only shown with the long one, for example:
  8171. @smallexample
  8172. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8173. @end smallexample
  8174. @noindent
  8175. and a message indicating that the argument is applicable to both
  8176. forms is printed below the options. This message can be disabled
  8177. using @code{dup-args-note} (see below).
  8178. The default is false.
  8179. @end deftypevr
  8180. @deftypevr {Help Output} boolean dup-args-note
  8181. If this variable is true, which is the default, the following notice
  8182. is displayed at the end of the help output:
  8183. @quotation
  8184. Mandatory or optional arguments to long options are also mandatory or
  8185. optional for any corresponding short options.
  8186. @end quotation
  8187. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  8188. variables @code{dup-args} or @code{dup-args-note} should be set.
  8189. @end deftypevr
  8190. @deftypevr {Help Output} offset short-opt-col
  8191. Column in which short options start. Default is 2.
  8192. @smallexample
  8193. @group
  8194. $ @kbd{tar --help|grep ARCHIVE}
  8195. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8196. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  8197. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8198. @end group
  8199. @end smallexample
  8200. @end deftypevr
  8201. @deftypevr {Help Output} offset long-opt-col
  8202. Column in which long options start. Default is 6. For example:
  8203. @smallexample
  8204. @group
  8205. $ @kbd{tar --help|grep ARCHIVE}
  8206. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8207. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  8208. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8209. @end group
  8210. @end smallexample
  8211. @end deftypevr
  8212. @deftypevr {Help Output} offset doc-opt-col
  8213. Column in which @dfn{doc options} start. A doc option isn't actually
  8214. an option, but rather an arbitrary piece of documentation that is
  8215. displayed in much the same manner as the options. For example, in
  8216. the description of @option{--format} option:
  8217. @smallexample
  8218. @group
  8219. -H, --format=FORMAT create archive of the given format.
  8220. FORMAT is one of the following:
  8221. gnu GNU tar 1.13.x format
  8222. oldgnu GNU format as per tar <= 1.12
  8223. pax POSIX 1003.1-2001 (pax) format
  8224. posix same as pax
  8225. ustar POSIX 1003.1-1988 (ustar) format
  8226. v7 old V7 tar format
  8227. @end group
  8228. @end smallexample
  8229. @noindent
  8230. the format names are doc options. Thus, if you set
  8231. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  8232. will look as follows:
  8233. @smallexample
  8234. @group
  8235. -H, --format=FORMAT create archive of the given format.
  8236. FORMAT is one of the following:
  8237. gnu GNU tar 1.13.x format
  8238. oldgnu GNU format as per tar <= 1.12
  8239. pax POSIX 1003.1-2001 (pax) format
  8240. posix same as pax
  8241. ustar POSIX 1003.1-1988 (ustar) format
  8242. v7 old V7 tar format
  8243. @end group
  8244. @end smallexample
  8245. @end deftypevr
  8246. @deftypevr {Help Output} offset opt-doc-col
  8247. Column in which option description starts. Default is 29.
  8248. @smallexample
  8249. @group
  8250. $ @kbd{tar --help|grep ARCHIVE}
  8251. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8252. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  8253. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8254. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  8255. -f, --file=ARCHIVE
  8256. use archive file or device ARCHIVE
  8257. @end group
  8258. @end smallexample
  8259. @noindent
  8260. Notice, that the description starts on a separate line if
  8261. @code{opt-doc-col} value is too small.
  8262. @end deftypevr
  8263. @deftypevr {Help Output} offset header-col
  8264. Column in which @dfn{group headers} are printed. A group header is a
  8265. descriptive text preceding an option group. For example, in the
  8266. following text:
  8267. @verbatim
  8268. Main operation mode:
  8269. -A, --catenate, --concatenate append tar files to
  8270. an archive
  8271. -c, --create create a new archive
  8272. @end verbatim
  8273. @noindent
  8274. @samp{Main operation mode:} is the group header.
  8275. The default value is 1.
  8276. @end deftypevr
  8277. @deftypevr {Help Output} offset usage-indent
  8278. Indentation of wrapped usage lines. Affects @option{--usage}
  8279. output. Default is 12.
  8280. @end deftypevr
  8281. @deftypevr {Help Output} offset rmargin
  8282. Right margin of the text output. Used for wrapping.
  8283. @end deftypevr
  8284. @node Genfile
  8285. @appendix Genfile
  8286. @include genfile.texi
  8287. @node Tar Internals
  8288. @appendix Tar Internals
  8289. @include intern.texi
  8290. @node Free Software Needs Free Documentation
  8291. @appendix Free Software Needs Free Documentation
  8292. @include freemanuals.texi
  8293. @node Copying This Manual
  8294. @appendix Copying This Manual
  8295. @menu
  8296. * GNU Free Documentation License:: License for copying this manual
  8297. @end menu
  8298. @include fdl.texi
  8299. @node Index of Command Line Options
  8300. @appendix Index of Command Line Options
  8301. This appendix contains an index of all @GNUTAR{} long command line
  8302. options. The options are listed without the preceeding double-dash.
  8303. @FIXME{@itemize
  8304. @item Make sure @emph{all} options are indexed.
  8305. @item Provide an index of short options
  8306. @end itemize}
  8307. @printindex op
  8308. @node Index
  8309. @appendix Index
  8310. @printindex cp
  8311. @summarycontents
  8312. @contents
  8313. @bye
  8314. @c Local variables:
  8315. @c texinfo-column-for-description: 32
  8316. @c End: