tar.texi 373 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766
  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 rendition.texi
  11. @include value.texi
  12. @c Put everything in one index (arbitrarily chosen to be the concept index).
  13. @syncodeindex fn cp
  14. @syncodeindex ky cp
  15. @syncodeindex pg cp
  16. @syncodeindex vr cp
  17. @defindex op
  18. @copying
  19. This manual is for @acronym{GNU} @command{tar} (version
  20. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  21. from archives.
  22. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  23. 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.1 or
  27. any later version published by the Free Software Foundation; with no
  28. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  29. and with the Back-Cover Texts as in (a) below. A copy of the license
  30. is included in the section entitled "GNU Free Documentation License".
  31. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  32. this GNU Manual. Buying copies from GNU Press supports the FSF in
  33. developing GNU and promoting software freedom.''
  34. @end quotation
  35. @end copying
  36. @dircategory Archiving
  37. @direntry
  38. * Tar: (tar). Making tape (or disk) archives.
  39. @end direntry
  40. @dircategory Individual utilities
  41. @direntry
  42. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  43. @end direntry
  44. @shorttitlepage @acronym{GNU} @command{tar}
  45. @titlepage
  46. @title @acronym{GNU} tar: an archiver tool
  47. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  48. @author John Gilmore, Jay Fenlason et al.
  49. @page
  50. @vskip 0pt plus 1filll
  51. @insertcopying
  52. @end titlepage
  53. @ifnottex
  54. @node Top
  55. @top @acronym{GNU} tar: an archiver tool
  56. @insertcopying
  57. @cindex file archival
  58. @cindex archiving files
  59. The first part of this master menu lists the major nodes in this Info
  60. document. The rest of the menu lists all the lower level nodes.
  61. @end ifnottex
  62. @c The master menu, created with texinfo-master-menu, goes here.
  63. @c (However, getdate.texi's menu is interpolated by hand.)
  64. @menu
  65. * Introduction::
  66. * Tutorial::
  67. * tar invocation::
  68. * operations::
  69. * Backups::
  70. * Choosing::
  71. * Date input formats::
  72. * Formats::
  73. * Media::
  74. Appendices
  75. * Changes::
  76. * Configuring Help Summary::
  77. * Genfile::
  78. * Snapshot Files::
  79. * Free Software Needs Free Documentation::
  80. * Copying This Manual::
  81. * Index of Command Line Options::
  82. * Index::
  83. @detailmenu
  84. --- The Detailed Node Listing ---
  85. Introduction
  86. * Book Contents:: What this Book Contains
  87. * Definitions:: Some Definitions
  88. * What tar Does:: What @command{tar} Does
  89. * Naming tar Archives:: How @command{tar} Archives are Named
  90. * Authors:: @GNUTAR{} Authors
  91. * Reports:: Reporting bugs or suggestions
  92. Tutorial Introduction to @command{tar}
  93. * assumptions::
  94. * stylistic conventions::
  95. * basic tar options:: Basic @command{tar} Operations and Options
  96. * frequent operations::
  97. * Two Frequent Options::
  98. * create:: How to Create Archives
  99. * list:: How to List Archives
  100. * extract:: How to Extract Members from an Archive
  101. * going further::
  102. Two Frequently Used Options
  103. * file tutorial::
  104. * verbose tutorial::
  105. * help tutorial::
  106. How to Create Archives
  107. * prepare for examples::
  108. * Creating the archive::
  109. * create verbose::
  110. * short create::
  111. * create dir::
  112. How to List Archives
  113. * list dir::
  114. How to Extract Members from an Archive
  115. * extracting archives::
  116. * extracting files::
  117. * extract dir::
  118. * failing commands::
  119. Invoking @GNUTAR{}
  120. * Synopsis::
  121. * using tar options::
  122. * Styles::
  123. * All Options::
  124. * help::
  125. * defaults::
  126. * verbose::
  127. * interactive::
  128. The Three Option Styles
  129. * Mnemonic Options:: Mnemonic Option Style
  130. * Short Options:: Short Option Style
  131. * Old Options:: Old Option Style
  132. * Mixing:: Mixing Option Styles
  133. All @command{tar} Options
  134. * Operation Summary::
  135. * Option Summary::
  136. * Short Option Summary::
  137. @GNUTAR{} Operations
  138. * Basic tar::
  139. * Advanced tar::
  140. * create options::
  141. * extract options::
  142. * backup::
  143. * Applications::
  144. * looking ahead::
  145. Advanced @GNUTAR{} Operations
  146. * Operations::
  147. * append::
  148. * update::
  149. * concatenate::
  150. * delete::
  151. * compare::
  152. How to Add Files to Existing Archives: @option{--append}
  153. * appending files:: Appending Files to an Archive
  154. * multiple::
  155. Updating an Archive
  156. * how to update::
  157. Options Used by @option{--create}
  158. * Ignore Failed Read::
  159. Options Used by @option{--extract}
  160. * Reading:: Options to Help Read Archives
  161. * Writing:: Changing How @command{tar} Writes Files
  162. * Scarce:: Coping with Scarce Resources
  163. Options to Help Read Archives
  164. * read full records::
  165. * Ignore Zeros::
  166. Changing How @command{tar} Writes Files
  167. * Dealing with Old Files::
  168. * Overwrite Old Files::
  169. * Keep Old Files::
  170. * Keep Newer Files::
  171. * Unlink First::
  172. * Recursive Unlink::
  173. * Data Modification Times::
  174. * Setting Access Permissions::
  175. * Writing to Standard Output::
  176. * remove files::
  177. Coping with Scarce Resources
  178. * Starting File::
  179. * Same Order::
  180. Performing Backups and Restoring Files
  181. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  182. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  183. * Backup Levels:: Levels of Backups
  184. * Backup Parameters:: Setting Parameters for Backups and Restoration
  185. * Scripted Backups:: Using the Backup Scripts
  186. * Scripted Restoration:: Using the Restore Script
  187. Setting Parameters for Backups and Restoration
  188. * General-Purpose Variables::
  189. * Magnetic Tape Control::
  190. * User Hooks::
  191. * backup-specs example:: An Example Text of @file{Backup-specs}
  192. Choosing Files and Names for @command{tar}
  193. * file:: Choosing the Archive's Name
  194. * Selecting Archive Members::
  195. * files:: Reading Names from a File
  196. * exclude:: Excluding Some Files
  197. * Wildcards::
  198. * after:: Operating Only on New Files
  199. * recurse:: Descending into Directories
  200. * one:: Crossing File System Boundaries
  201. Reading Names from a File
  202. * nul::
  203. Excluding Some Files
  204. * controlling pattern-matching with exclude::
  205. * problems with exclude::
  206. Crossing File System Boundaries
  207. * directory:: Changing Directory
  208. * absolute:: Absolute File Names
  209. Date input formats
  210. * General date syntax:: Common rules.
  211. * Calendar date items:: 19 Dec 1994.
  212. * Time of day items:: 9:20pm.
  213. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  214. * Day of week items:: Monday and others.
  215. * Relative items in date strings:: next tuesday, 2 years ago.
  216. * Pure numbers in date strings:: 19931219, 1440.
  217. * Seconds since the Epoch:: @@1078100502.
  218. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  219. Controlling the Archive Format
  220. * Portability:: Making @command{tar} Archives More Portable
  221. * Compression:: Using Less Space through Compression
  222. * Attributes:: Handling File Attributes
  223. * Standard:: The Standard Format
  224. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  225. * cpio:: Comparison of @command{tar} and @command{cpio}
  226. Making @command{tar} Archives More Portable
  227. * Portable Names:: Portable Names
  228. * dereference:: Symbolic Links
  229. * old:: Old V7 Archives
  230. * posix:: @acronym{POSIX} archives
  231. * Checksumming:: Checksumming Problems
  232. * Large or Negative Values:: Large files, negative time stamps, etc.
  233. Using Less Space through Compression
  234. * gzip:: Creating and Reading Compressed Archives
  235. * sparse:: Archiving Sparse Files
  236. Tapes and Other Archive Media
  237. * Device:: Device selection and switching
  238. * Remote Tape Server::
  239. * Common Problems and Solutions::
  240. * Blocking:: Blocking
  241. * Many:: Many archives on one tape
  242. * Using Multiple Tapes:: Using Multiple Tapes
  243. * label:: Including a Label in the Archive
  244. * verify::
  245. * Write Protection::
  246. Blocking
  247. * Format Variations:: Format Variations
  248. * Blocking Factor:: The Blocking Factor of an Archive
  249. Many Archives on One Tape
  250. * Tape Positioning:: Tape Positions and Tape Marks
  251. * mt:: The @command{mt} Utility
  252. Using Multiple Tapes
  253. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  254. * Tape Files:: Tape Files
  255. * Tarcat:: Concatenate Volumes into a Single Archive
  256. GNU tar internals and development
  257. * Genfile::
  258. * Snapshot Files::
  259. Copying This Manual
  260. * Free Software Needs Free Documentation::
  261. * GNU Free Documentation License:: License for copying this manual
  262. @end detailmenu
  263. @end menu
  264. @node Introduction
  265. @chapter Introduction
  266. @GNUTAR{} creates
  267. and manipulates @dfn{archives} which are actually collections of
  268. many other files; the program provides users with an organized and
  269. systematic method for controlling a large amount of data.
  270. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  271. archives need not (and these days, typically do not) reside on tapes.
  272. @menu
  273. * Book Contents:: What this Book Contains
  274. * Definitions:: Some Definitions
  275. * What tar Does:: What @command{tar} Does
  276. * Naming tar Archives:: How @command{tar} Archives are Named
  277. * Authors:: @GNUTAR{} Authors
  278. * Reports:: Reporting bugs or suggestions
  279. @end menu
  280. @node Book Contents
  281. @section What this Book Contains
  282. The first part of this chapter introduces you to various terms that will
  283. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  284. and its documentation, and where you should send bug reports
  285. or comments.
  286. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  287. gentle introduction for people who are new to using @command{tar}. It is
  288. meant to be self contained, not requiring any reading from subsequent
  289. chapters to make sense. It moves from topic to topic in a logical,
  290. progressive order, building on information already explained.
  291. Although the tutorial is paced and structured to allow beginners to
  292. learn how to use @command{tar}, it is not intended solely for beginners.
  293. The tutorial explains how to use the three most frequently used
  294. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  295. two frequently used options (@samp{file} and @samp{verbose}). The other
  296. chapters do not refer to the tutorial frequently; however, if a section
  297. discusses something which is a complex variant of a basic concept, there
  298. may be a cross reference to that basic concept. (The entire book,
  299. including the tutorial, assumes that the reader understands some basic
  300. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  301. The third chapter presents the remaining five operations, and
  302. information about using @command{tar} options and option syntax.
  303. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  304. than the reality. should think about whether this makes sense to say
  305. here, or not.} The other chapters are meant to be used as a
  306. reference. Each chapter presents everything that needs to be said
  307. about a specific topic.
  308. One of the chapters (@pxref{Date input formats}) exists in its
  309. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  310. In addition, one section of this manual (@pxref{Standard}) contains a
  311. big quote which is taken directly from @command{tar} sources.
  312. In general, we give both long and short (abbreviated) option names
  313. at least once in each section where the relevant option is covered, so
  314. that novice readers will become familiar with both styles. (A few
  315. options have no short versions, and the relevant sections will
  316. indicate this.)
  317. @node Definitions
  318. @section Some Definitions
  319. @cindex archive
  320. @cindex tar archive
  321. The @command{tar} program is used to create and manipulate @command{tar}
  322. archives. An @dfn{archive} is a single file which contains the contents
  323. of many files, while still identifying the names of the files, their
  324. owner(s), and so forth. (In addition, archives record access
  325. permissions, user and group, size in bytes, and data modification time.
  326. Some archives also record the file names in each archived directory, as
  327. well as other file and directory information.) You can use @command{tar}
  328. to @dfn{create} a new archive in a specified directory.
  329. @cindex member
  330. @cindex archive member
  331. @cindex file name
  332. @cindex member name
  333. The files inside an archive are called @dfn{members}. Within this
  334. manual, we use the term @dfn{file} to refer only to files accessible in
  335. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  336. @dfn{member} to refer only to the members of an archive. Similarly, a
  337. @dfn{file name} is the name of a file, as it resides in the file system,
  338. and a @dfn{member name} is the name of an archive member within the
  339. archive.
  340. @cindex extraction
  341. @cindex unpacking
  342. The term @dfn{extraction} refers to the process of copying an archive
  343. member (or multiple members) into a file in the file system. Extracting
  344. all the members of an archive is often called @dfn{extracting the
  345. archive}. The term @dfn{unpack} can also be used to refer to the
  346. extraction of many or all the members of an archive. Extracting an
  347. archive does not destroy the archive's structure, just as creating an
  348. archive does not destroy the copies of the files that exist outside of
  349. the archive. You may also @dfn{list} the members in a given archive
  350. (this is often thought of as ``printing'' them to the standard output,
  351. or the command line), or @dfn{append} members to a pre-existing archive.
  352. All of these operations can be performed using @command{tar}.
  353. @node What tar Does
  354. @section What @command{tar} Does
  355. @cindex tar
  356. The @command{tar} program provides the ability to create @command{tar}
  357. archives, as well as various other kinds of manipulation. For example,
  358. you can use @command{tar} on previously created archives to extract files,
  359. to store additional files, or to update or list files which were already
  360. stored.
  361. Initially, @command{tar} archives were used to store files conveniently on
  362. magnetic tape. The name @command{tar} comes from this use; it stands for
  363. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  364. direct its output to available devices, files, or other programs (using
  365. pipes). @command{tar} may even access remote devices or files (as archives).
  366. @FIXME{the following table entries need a bit of work..}
  367. You can use @command{tar} archives in many ways. We want to stress a few
  368. of them: storage, backup, and transportation.
  369. @table @asis
  370. @item Storage
  371. Often, @command{tar} archives are used to store related files for
  372. convenient file transfer over a network. For example, the
  373. @acronym{GNU} Project distributes its software bundled into
  374. @command{tar} archives, so that all the files relating to a particular
  375. program (or set of related programs) can be transferred as a single
  376. unit.
  377. A magnetic tape can store several files in sequence. However, the tape
  378. has no names for these files; it only knows their relative position on
  379. the tape. One way to store several files on one tape and retain their
  380. names is by creating a @command{tar} archive. Even when the basic transfer
  381. mechanism can keep track of names, as FTP can, the nuisance of handling
  382. multiple files, directories, and multiple links makes @command{tar}
  383. archives useful.
  384. Archive files are also used for long-term storage. You can think of
  385. this as transportation from the present into the future. (It is a
  386. science-fiction idiom that you can move through time as well as in
  387. space; the idea here is that @command{tar} can be used to move archives in
  388. all dimensions, even time!)
  389. @item Backup
  390. Because the archive created by @command{tar} is capable of preserving
  391. file information and directory structure, @command{tar} is commonly
  392. used for performing full and incremental backups of disks. A backup
  393. puts a collection of files (possibly pertaining to many users and
  394. projects) together on a disk or a tape. This guards against
  395. accidental destruction of the information in those files.
  396. @GNUTAR{} has special features that allow it to be
  397. used to make incremental and full dumps of all the files in a
  398. file system.
  399. @item Transportation
  400. You can create an archive on one system, transfer it to another system,
  401. and extract the contents there. This allows you to transport a group of
  402. files from one system to another.
  403. @end table
  404. @node Naming tar Archives
  405. @section How @command{tar} Archives are Named
  406. Conventionally, @command{tar} archives are given names ending with
  407. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  408. but this manual follows that convention in order to accustom readers to
  409. it and to make examples more clear.
  410. @cindex tar file
  411. @cindex entry
  412. @cindex tar entry
  413. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  414. archive members as ``files'' or ``entries''. For people familiar with
  415. the operation of @command{tar}, this causes no difficulty. However, in
  416. this manual, we consistently refer to ``archives'' and ``archive
  417. members'' to make learning to use @command{tar} easier for novice users.
  418. @node Authors
  419. @section @GNUTAR{} Authors
  420. @GNUTAR{} was originally written by John Gilmore,
  421. and modified by many people. The @acronym{GNU} enhancements were
  422. written by Jay Fenlason, then Joy Kendall, and the whole package has
  423. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  424. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  425. numerous and kind users.
  426. We wish to stress that @command{tar} is a collective work, and owes much to
  427. all those people who reported problems, offered solutions and other
  428. insights, or shared their thoughts and suggestions. An impressive, yet
  429. partial list of those contributors can be found in the @file{THANKS}
  430. file from the @GNUTAR{} distribution.
  431. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  432. sure i want to spell out the history in this detail, at least not for
  433. the printed book. i'm just not sure it needs to be said this way.
  434. i'll think about it.}
  435. @FIXME{History is more important, and surely more interesting, than
  436. actual names. Quoting names without history would be meaningless. FP}
  437. Jay Fenlason put together a draft of a @GNUTAR{}
  438. manual, borrowing notes from the original man page from John Gilmore.
  439. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  440. Gorin worked on a tutorial and manual for @GNUTAR{}.
  441. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  442. taking information from all these sources and merging them. Melissa
  443. Weisshaus finally edited and redesigned the book to create version
  444. 1.12. @FIXME{update version number as necessary; i'm being
  445. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  446. maybe melissa? maybe julie sussman?] needs to properly index the
  447. thing.}
  448. For version 1.12, Daniel Hagerty contributed a great deal of technical
  449. consulting. In particular, he is the primary author of @ref{Backups}.
  450. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  451. (see @url{http://savannah.gnu.org/projects/tar}), and
  452. active development and maintenance work has started
  453. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  454. Poznyakoff and Jeff Bailey.
  455. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  456. @node Reports
  457. @section Reporting bugs or suggestions
  458. @cindex bug reports
  459. @cindex reporting bugs
  460. If you find problems or have suggestions about this program or manual,
  461. please report them to @file{bug-tar@@gnu.org}.
  462. When reporting a bug, please be sure to include as much detail as
  463. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  464. like to make this node as detailed as 'Bug reporting' node in Emacs
  465. manual}.
  466. @node Tutorial
  467. @chapter Tutorial Introduction to @command{tar}
  468. This chapter guides you through some basic examples of three @command{tar}
  469. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  470. you already know how to use some other version of @command{tar}, then you
  471. may not need to read this chapter. This chapter omits most complicated
  472. details about how @command{tar} works.
  473. @menu
  474. * assumptions::
  475. * stylistic conventions::
  476. * basic tar options:: Basic @command{tar} Operations and Options
  477. * frequent operations::
  478. * Two Frequent Options::
  479. * create:: How to Create Archives
  480. * list:: How to List Archives
  481. * extract:: How to Extract Members from an Archive
  482. * going further::
  483. @end menu
  484. @node assumptions
  485. @section Assumptions this Tutorial Makes
  486. This chapter is paced to allow beginners to learn about @command{tar}
  487. slowly. At the same time, we will try to cover all the basic aspects of
  488. these three operations. In order to accomplish both of these tasks, we
  489. have made certain assumptions about your knowledge before reading this
  490. manual, and the hardware you will be using:
  491. @itemize @bullet
  492. @item
  493. Before you start to work through this tutorial, you should understand
  494. what the terms ``archive'' and ``archive member'' mean
  495. (@pxref{Definitions}). In addition, you should understand something
  496. about how Unix-type operating systems work, and you should know how to
  497. use some basic utilities. For example, you should know how to create,
  498. list, copy, rename, edit, and delete files and directories; how to
  499. change between directories; and how to figure out where you are in the
  500. file system. You should have some basic understanding of directory
  501. structure and how files are named according to which directory they are
  502. in. You should understand concepts such as standard output and standard
  503. input, what various definitions of the term ``argument'' mean, and the
  504. differences between relative and absolute path names. @FIXME{and what
  505. else?}
  506. @item
  507. This manual assumes that you are working from your own home directory
  508. (unless we state otherwise). In this tutorial, you will create a
  509. directory to practice @command{tar} commands in. When we show path names,
  510. we will assume that those paths are relative to your home directory.
  511. For example, my home directory path is @file{/home/fsf/melissa}. All of
  512. my examples are in a subdirectory of the directory named by that path
  513. name; the subdirectory is called @file{practice}.
  514. @item
  515. In general, we show examples of archives which exist on (or can be
  516. written to, or worked with from) a directory on a hard disk. In most
  517. cases, you could write those archives to, or work with them on any other
  518. device, such as a tape drive. However, some of the later examples in
  519. the tutorial and next chapter will not work on tape drives.
  520. Additionally, working with tapes is much more complicated than working
  521. with hard disks. For these reasons, the tutorial does not cover working
  522. with tape drives. @xref{Media}, for complete information on using
  523. @command{tar} archives with tape drives.
  524. @FIXME{this is a cop out. need to add some simple tape drive info.}
  525. @end itemize
  526. @node stylistic conventions
  527. @section Stylistic Conventions
  528. In the examples, @samp{$} represents a typical shell prompt. It
  529. precedes lines you should type; to make this more clear, those lines are
  530. shown in @kbd{this font}, as opposed to lines which represent the
  531. computer's response; those lines are shown in @code{this font}, or
  532. sometimes @samp{like this}.
  533. @c When we have lines which are too long to be
  534. @c displayed in any other way, we will show them like this:
  535. @node basic tar options
  536. @section Basic @command{tar} Operations and Options
  537. @command{tar} can take a wide variety of arguments which specify and define
  538. the actions it will have on the particular set of files or the archive.
  539. The main types of arguments to @command{tar} fall into one of two classes:
  540. operations, and options.
  541. Some arguments fall into a class called @dfn{operations}; exactly one of
  542. these is both allowed and required for any instance of using @command{tar};
  543. you may @emph{not} specify more than one. People sometimes speak of
  544. @dfn{operating modes}. You are in a particular operating mode when you
  545. have specified the operation which specifies it; there are eight
  546. operations in total, and thus there are eight operating modes.
  547. The other arguments fall into the class known as @dfn{options}. You are
  548. not required to specify any options, and you are allowed to specify more
  549. than one at a time (depending on the way you are using @command{tar} at
  550. that time). Some options are used so frequently, and are so useful for
  551. helping you type commands more carefully that they are effectively
  552. ``required''. We will discuss them in this chapter.
  553. You can write most of the @command{tar} operations and options in any
  554. of three forms: long (mnemonic) form, short form, and old style. Some
  555. of the operations and options have no short or ``old'' forms; however,
  556. the operations and options which we will cover in this tutorial have
  557. corresponding abbreviations. @FIXME{make sure this is still the case,
  558. at the end}We will indicate those abbreviations appropriately to get
  559. you used to seeing them. (Note that the ``old style'' option forms
  560. exist in @GNUTAR{} for compatibility with Unix
  561. @command{tar}. In this book we present a full discussion of this way
  562. of writing options and operations (@pxref{Old Options}), and we discuss
  563. the other two styles of writing options (@xref{Mnemonic Options}, and
  564. @pxref{Short Options}).
  565. In the examples and in the text of this tutorial, we usually use the
  566. long forms of operations and options; but the ``short'' forms produce
  567. the same result and can make typing long @command{tar} commands easier.
  568. For example, instead of typing
  569. @smallexample
  570. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  571. @end smallexample
  572. @noindent
  573. you can type
  574. @smallexample
  575. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  576. @end smallexample
  577. @noindent
  578. or even
  579. @smallexample
  580. @kbd{tar -cvf afiles.tar apple angst aspic}
  581. @end smallexample
  582. @noindent
  583. For more information on option syntax, see @ref{Advanced tar}. In
  584. discussions in the text, when we name an option by its long form, we
  585. also give the corresponding short option in parentheses.
  586. The term, ``option'', can be confusing at times, since ``operations''
  587. are often lumped in with the actual, @emph{optional} ``options'' in certain
  588. general class statements. For example, we just talked about ``short and
  589. long forms of options and operations''. However, experienced @command{tar}
  590. users often refer to these by shorthand terms such as, ``short and long
  591. options''. This term assumes that the ``operations'' are included, also.
  592. Context will help you determine which definition of ``options'' to use.
  593. Similarly, the term ``command'' can be confusing, as it is often used in
  594. two different ways. People sometimes refer to @command{tar} ``commands''.
  595. A @command{tar} @dfn{command} is the entire command line of user input
  596. which tells @command{tar} what to do --- including the operation, options,
  597. and any arguments (file names, pipes, other commands, etc). However,
  598. you will also sometimes hear the term ``the @command{tar} command''. When
  599. the word ``command'' is used specifically like this, a person is usually
  600. referring to the @command{tar} @emph{operation}, not the whole line.
  601. Again, use context to figure out which of the meanings the speaker
  602. intends.
  603. @node frequent operations
  604. @section The Three Most Frequently Used Operations
  605. Here are the three most frequently used operations (both short and long
  606. forms), as well as a brief description of their meanings. The rest of
  607. this chapter will cover how to use these operations in detail. We will
  608. present the rest of the operations in the next chapter.
  609. @table @option
  610. @item --create
  611. @itemx -c
  612. Create a new @command{tar} archive.
  613. @item --list
  614. @itemx -t
  615. List the contents of an archive.
  616. @item --extract
  617. @itemx -x
  618. Extract one or more members from an archive.
  619. @end table
  620. @node Two Frequent Options
  621. @section Two Frequently Used Options
  622. To understand how to run @command{tar} in the three operating modes listed
  623. previously, you also need to understand how to use two of the options to
  624. @command{tar}: @option{--file} (which takes an archive file as an argument)
  625. and @option{--verbose}. (You are usually not @emph{required} to specify
  626. either of these options when you run @command{tar}, but they can be very
  627. useful in making things more clear and helping you avoid errors.)
  628. @menu
  629. * file tutorial::
  630. * verbose tutorial::
  631. * help tutorial::
  632. @end menu
  633. @node file tutorial
  634. @unnumberedsubsec The @option{--file} Option
  635. @table @option
  636. @opindex file, tutorial
  637. @item --file=@var{archive-name}
  638. @itemx -f @var{archive-name}
  639. Specify the name of an archive file.
  640. @end table
  641. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  642. use @command{tar}; this option determines the name of the archive file
  643. that @command{tar} will work on.
  644. @vrindex TAPE
  645. If you don't specify this argument, then @command{tar} will examine
  646. the environment variable @env{TAPE}. If it is set, its value will be
  647. used as the archive name. Otherwise, @command{tar} will use the
  648. default archive, determined at the compile time. Usually it is
  649. standard output or some physical tape drive attached to your machine
  650. (you can verify what the default is by running @kbd{tar
  651. --show-defaults}, @pxref{defaults}). If there is no tape drive
  652. attached, or the default is not meaningful, then @command{tar} will
  653. print an error message. The error message might look roughly like one
  654. of the following:
  655. @smallexample
  656. tar: can't open /dev/rmt8 : No such device or address
  657. tar: can't open /dev/rsmt0 : I/O error
  658. @end smallexample
  659. @noindent
  660. To avoid confusion, we recommend that you always specify an archive file
  661. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  662. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  663. @ref{file}.
  664. @node verbose tutorial
  665. @unnumberedsubsec The @option{--verbose} Option
  666. @table @option
  667. @opindex verbose, introduced
  668. @item --verbose
  669. @itemx -v
  670. Show the files being worked on as @command{tar} is running.
  671. @end table
  672. @option{--verbose} (@option{-v}) shows details about the results of running
  673. @command{tar}. This can be especially useful when the results might not be
  674. obvious. For example, if you want to see the progress of @command{tar} as
  675. it writes files into the archive, you can use the @option{--verbose}
  676. option. In the beginning, you may find it useful to use
  677. @option{--verbose} at all times; when you are more accustomed to
  678. @command{tar}, you will likely want to use it at certain times but not at
  679. others. We will use @option{--verbose} at times to help make something
  680. clear, and we will give many examples both using and not using
  681. @option{--verbose} to show the differences.
  682. Sometimes, a single instance of @option{--verbose} on the command line
  683. will show a full, @samp{ls} style listing of an archive or files,
  684. giving sizes, owners, and similar information. @FIXME{Describe the
  685. exact output format, e.g., how hard links are displayed.}
  686. Other times, @option{--verbose} will only show files or members that the particular
  687. operation is operating on at the time. In the latter case, you can
  688. use @option{--verbose} twice in a command to get a listing such as that
  689. in the former case. For example, instead of saying
  690. @smallexample
  691. @kbd{tar -cvf afiles.tar apple angst aspic}
  692. @end smallexample
  693. @noindent
  694. above, you might say
  695. @smallexample
  696. @kbd{tar -cvvf afiles.tar apple angst aspic}
  697. @end smallexample
  698. @noindent
  699. This works equally well using short or long forms of options. Using
  700. long forms, you would simply write out the mnemonic form of the option
  701. twice, like this:
  702. @smallexample
  703. $ @kbd{tar --create --verbose --verbose @dots{}}
  704. @end smallexample
  705. @noindent
  706. Note that you must double the hyphens properly each time.
  707. Later in the tutorial, we will give examples using @w{@option{--verbose
  708. --verbose}}.
  709. @node help tutorial
  710. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  711. @table @option
  712. @opindex help
  713. @item --help
  714. The @option{--help} option to @command{tar} prints out a very brief list of
  715. all operations and option available for the current version of
  716. @command{tar} available on your system.
  717. @end table
  718. @node create
  719. @section How to Create Archives
  720. @UNREVISED
  721. @cindex Creation of the archive
  722. @cindex Archive, creation of
  723. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  724. you use to create a @command{tar} archive. We will explain
  725. @option{--create} first because, in order to learn about the other
  726. operations, you will find it useful to have an archive available to
  727. practice on.
  728. To make this easier, in this section you will first create a directory
  729. containing three files. Then, we will show you how to create an
  730. @emph{archive} (inside the new directory). Both the directory, and
  731. the archive are specifically for you to practice on. The rest of this
  732. chapter and the next chapter will show many examples using this
  733. directory and the files you will create: some of those files may be
  734. other directories and other archives.
  735. The three files you will archive in this example are called
  736. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  737. @file{collection.tar}.
  738. This section will proceed slowly, detailing how to use @option{--create}
  739. in @code{verbose} mode, and showing examples using both short and long
  740. forms. In the rest of the tutorial, and in the examples in the next
  741. chapter, we will proceed at a slightly quicker pace. This section
  742. moves more slowly to allow beginning users to understand how
  743. @command{tar} works.
  744. @menu
  745. * prepare for examples::
  746. * Creating the archive::
  747. * create verbose::
  748. * short create::
  749. * create dir::
  750. @end menu
  751. @node prepare for examples
  752. @subsection Preparing a Practice Directory for Examples
  753. To follow along with this and future examples, create a new directory
  754. called @file{practice} containing files called @file{blues}, @file{folk}
  755. and @file{jazz}. The files can contain any information you like:
  756. ideally, they should contain information which relates to their names,
  757. and be of different lengths. Our examples assume that @file{practice}
  758. is a subdirectory of your home directory.
  759. Now @command{cd} to the directory named @file{practice}; @file{practice}
  760. is now your @dfn{working directory}. (@emph{Please note}: Although
  761. the full path name of this directory is
  762. @file{/@var{homedir}/practice}, in our examples we will refer to
  763. this directory as @file{practice}; the @var{homedir} is presumed.
  764. In general, you should check that the files to be archived exist where
  765. you think they do (in the working directory) by running @command{ls}.
  766. Because you just created the directory and the files and have changed to
  767. that directory, you probably don't need to do that this time.
  768. It is very important to make sure there isn't already a file in the
  769. working directory with the archive name you intend to use (in this case,
  770. @samp{collection.tar}), or that you don't care about its contents.
  771. Whenever you use @samp{create}, @command{tar} will erase the current
  772. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  773. will not tell you if you are about to overwrite an archive unless you
  774. specify an option which does this (@pxref{backup}, for the
  775. information on how to do so). To add files to an existing archive,
  776. you need to use a different option, such as @option{--append} (@option{-r}); see
  777. @ref{append} for information on how to do this.
  778. @node Creating the archive
  779. @subsection Creating the Archive
  780. @opindex create, introduced
  781. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  782. archive named @file{collection.tar}, use the following command:
  783. @smallexample
  784. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  785. @end smallexample
  786. The order of the arguments is not very important, @emph{when using long
  787. option forms}. You could also say:
  788. @smallexample
  789. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  790. @end smallexample
  791. @noindent
  792. However, you can see that this order is harder to understand; this is
  793. why we will list the arguments in the order that makes the commands
  794. easiest to understand (and we encourage you to do the same when you use
  795. @command{tar}, to avoid errors).
  796. Note that the part of the command which says,
  797. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  798. If you substituted any other string of characters for
  799. @kbd{collection.tar}, then that string would become the name of the
  800. archive file you create.
  801. The order of the options becomes more important when you begin to use
  802. short forms. With short forms, if you type commands in the wrong order
  803. (even if you type them correctly in all other ways), you may end up with
  804. results you don't expect. For this reason, it is a good idea to get
  805. into the habit of typing options in the order that makes inherent sense.
  806. @xref{short create}, for more information on this.
  807. In this example, you type the command as shown above: @option{--create}
  808. is the operation which creates the new archive
  809. (@file{collection.tar}), and @option{--file} is the option which lets
  810. you give it the name you chose. The files, @file{blues}, @file{folk},
  811. and @file{jazz}, are now members of the archive, @file{collection.tar}
  812. (they are @dfn{file name arguments} to the @option{--create} operation).
  813. @FIXME{xref here to the discussion of file name args?}Now that they are
  814. in the archive, they are called @emph{archive members}, not files.
  815. (@pxref{Definitions,members}).
  816. When you create an archive, you @emph{must} specify which files you
  817. want placed in the archive. If you do not specify any archive
  818. members, @GNUTAR{} will complain.
  819. If you now list the contents of the working directory (@command{ls}), you will
  820. find the archive file listed as well as the files you saw previously:
  821. @smallexample
  822. blues folk jazz collection.tar
  823. @end smallexample
  824. @noindent
  825. Creating the archive @samp{collection.tar} did not destroy the copies of
  826. the files in the directory.
  827. Keep in mind that if you don't indicate an operation, @command{tar} will not
  828. run and will prompt you for one. If you don't name any files, @command{tar}
  829. will complain. You must have write access to the working directory,
  830. or else you will not be able to create an archive in that directory.
  831. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  832. an existing archive; it will delete the archive and write a new one.
  833. Use @option{--append} (@option{-r}) instead. @xref{append}.
  834. @node create verbose
  835. @subsection Running @option{--create} with @option{--verbose}
  836. @opindex create, using with @option{--verbose}
  837. @opindex verbose, using with @option{--create}
  838. If you include the @option{--verbose} (@option{-v}) option on the command line,
  839. @command{tar} will list the files it is acting on as it is working. In
  840. verbose mode, the @code{create} example above would appear as:
  841. @smallexample
  842. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  843. blues
  844. folk
  845. jazz
  846. @end smallexample
  847. This example is just like the example we showed which did not use
  848. @option{--verbose}, except that @command{tar} generated the remaining lines
  849. @iftex
  850. (note the different font styles).
  851. @end iftex
  852. @ifinfo
  853. .
  854. @end ifinfo
  855. In the rest of the examples in this chapter, we will frequently use
  856. @code{verbose} mode so we can show actions or @command{tar} responses that
  857. you would otherwise not see, and which are important for you to
  858. understand.
  859. @node short create
  860. @subsection Short Forms with @samp{create}
  861. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  862. basic uses of @command{tar}, and you will use it countless times.
  863. Eventually, you will probably want to use abbreviated (or ``short'')
  864. forms of options. A full discussion of the three different forms that
  865. options can take appears in @ref{Styles}; for now, here is what the
  866. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  867. using short option forms:
  868. @smallexample
  869. $ @kbd{tar -cvf collection.tar blues folk jazz}
  870. blues
  871. folk
  872. jazz
  873. @end smallexample
  874. @noindent
  875. As you can see, the system responds the same no matter whether you use
  876. long or short option forms.
  877. @FIXME{i don't like how this is worded:} One difference between using
  878. short and long option forms is that, although the exact placement of
  879. arguments following options is no more specific when using short forms,
  880. it is easier to become confused and make a mistake when using short
  881. forms. For example, suppose you attempted the above example in the
  882. following way:
  883. @smallexample
  884. $ @kbd{tar -cfv collection.tar blues folk jazz}
  885. @end smallexample
  886. @noindent
  887. In this case, @command{tar} will make an archive file called @file{v},
  888. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  889. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  890. is thus taken to be the chosen archive file name. @command{tar} will try
  891. to add a file called @file{collection.tar} to the @file{v} archive file;
  892. if the file @file{collection.tar} did not already exist, @command{tar} will
  893. report an error indicating that this file does not exist. If the file
  894. @file{collection.tar} does already exist (e.g., from a previous command
  895. you may have run), then @command{tar} will add this file to the archive.
  896. Because the @option{-v} option did not get registered, @command{tar} will not
  897. run under @samp{verbose} mode, and will not report its progress.
  898. The end result is that you may be quite confused about what happened,
  899. and possibly overwrite a file. To illustrate this further, we will show
  900. you how an example we showed previously would look using short forms.
  901. This example,
  902. @smallexample
  903. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  904. @end smallexample
  905. @noindent
  906. is confusing as it is. When shown using short forms, however, it
  907. becomes much more so:
  908. @smallexample
  909. $ @kbd{tar blues -c folk -f collection.tar jazz}
  910. @end smallexample
  911. @noindent
  912. It would be very easy to put the wrong string of characters
  913. immediately following the @option{-f}, but doing that could sacrifice
  914. valuable data.
  915. For this reason, we recommend that you pay very careful attention to
  916. the order of options and placement of file and archive names,
  917. especially when using short option forms. Not having the option name
  918. written out mnemonically can affect how well you remember which option
  919. does what, and therefore where different names have to be placed.
  920. @node create dir
  921. @subsection Archiving Directories
  922. @cindex Archiving Directories
  923. @cindex Directories, Archiving
  924. You can archive a directory by specifying its directory name as a
  925. file name argument to @command{tar}. The files in the directory will be
  926. archived relative to the working directory, and the directory will be
  927. re-created along with its contents when the archive is extracted.
  928. To archive a directory, first move to its superior directory. If you
  929. have followed the previous instructions in this tutorial, you should
  930. type:
  931. @smallexample
  932. $ @kbd{cd ..}
  933. $
  934. @end smallexample
  935. @noindent
  936. This will put you into the directory which contains @file{practice},
  937. i.e., your home directory. Once in the superior directory, you can
  938. specify the subdirectory, @file{practice}, as a file name argument. To
  939. store @file{practice} in the new archive file @file{music.tar}, type:
  940. @smallexample
  941. $ @kbd{tar --create --verbose --file=music.tar practice}
  942. @end smallexample
  943. @noindent
  944. @command{tar} should output:
  945. @smallexample
  946. practice/
  947. practice/blues
  948. practice/folk
  949. practice/jazz
  950. practice/collection.tar
  951. @end smallexample
  952. Note that the archive thus created is not in the subdirectory
  953. @file{practice}, but rather in the current working directory---the
  954. directory from which @command{tar} was invoked. Before trying to archive a
  955. directory from its superior directory, you should make sure you have
  956. write access to the superior directory itself, not only the directory
  957. you are trying archive with @command{tar}. For example, you will probably
  958. not be able to store your home directory in an archive by invoking
  959. @command{tar} from the root directory; @xref{absolute}. (Note
  960. also that @file{collection.tar}, the original archive file, has itself
  961. been archived. @command{tar} will accept any file as a file to be
  962. archived, regardless of its content. When @file{music.tar} is
  963. extracted, the archive file @file{collection.tar} will be re-written
  964. into the file system).
  965. If you give @command{tar} a command such as
  966. @smallexample
  967. $ @kbd{tar --create --file=foo.tar .}
  968. @end smallexample
  969. @noindent
  970. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  971. dumped}. This happens because @command{tar} creates the archive
  972. @file{foo.tar} in the current directory before putting any files into
  973. it. Then, when @command{tar} attempts to add all the files in the
  974. directory @file{.} to the archive, it notices that the file
  975. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  976. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  977. will continue in this case, and create the archive
  978. normally, except for the exclusion of that one file. (@emph{Please
  979. note:} Other versions of @command{tar} are not so clever; they will
  980. enter an infinite loop when this happens, so you should not depend on
  981. this behavior unless you are certain you are running @GNUTAR{}.)
  982. @FIXME{bob doesn't like this sentence, since he does
  983. it all the time, and we've been doing it in the editing passes for
  984. this manual: In general, make sure that the archive is not inside a
  985. directory being dumped.}
  986. @node list
  987. @section How to List Archives
  988. @opindex list
  989. Frequently, you will find yourself wanting to determine exactly what a
  990. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  991. to get the member names as they currently appear in the archive, as well
  992. as various attributes of the files at the time they were archived. For
  993. example, you can examine the archive @file{collection.tar} that you
  994. created in the last section with the command,
  995. @smallexample
  996. $ @kbd{tar --list --file=collection.tar}
  997. @end smallexample
  998. @noindent
  999. The output of @command{tar} would then be:
  1000. @smallexample
  1001. blues
  1002. folk
  1003. jazz
  1004. @end smallexample
  1005. @FIXME{we hope this will change. if it doesn't, need to show the
  1006. creation of bfiles somewhere above!!! : }
  1007. @noindent
  1008. The archive @file{bfiles.tar} would list as follows:
  1009. @smallexample
  1010. ./birds
  1011. baboon
  1012. ./box
  1013. @end smallexample
  1014. @noindent
  1015. Be sure to use a @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option just as with @option{--create} (@option{-c})
  1016. to specify the name of the archive.
  1017. @opindex list, using with @option{--verbose}
  1018. @opindex verbose, using with @option{--list}
  1019. If you use the @option{--verbose} (@option{-v}) option with @option{--list}, then
  1020. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1021. showing owner, file size, and so forth.
  1022. If you had used @option{--verbose} (@option{-v}) mode, the example above would look
  1023. like:
  1024. @smallexample
  1025. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1026. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1027. @end smallexample
  1028. @cindex listing member and file names
  1029. @anchor{listing member and file names}
  1030. It is important to notice that the output of @kbd{tar --list
  1031. --verbose} does not necessarily match that produced by @kbd{tar
  1032. --create --verbose} while creating the archive. It is because
  1033. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1034. prefixes from file names before storing them in the archive
  1035. (@xref{absolute}, for more information). In other
  1036. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1037. an archive and @dfn{member names} when listing it. Consider this
  1038. example:
  1039. @smallexample
  1040. @group
  1041. $ @kbd{tar cfv archive /etc/mail}
  1042. tar: Removing leading `/' from member names
  1043. /etc/mail/
  1044. /etc/mail/sendmail.cf
  1045. /etc/mail/aliases
  1046. $ @kbd{tar tf archive}
  1047. etc/mail/
  1048. etc/mail/sendmail.cf
  1049. etc/mail/aliases
  1050. @end group
  1051. @end smallexample
  1052. @opindex show-stored-names
  1053. This default behavior can sometimes be inconvenient. You can force
  1054. @GNUTAR{} show member names when creating archive by supplying
  1055. @option{--show-stored-names} option.
  1056. @table @option
  1057. @item --show-stored-names
  1058. Print member (as opposed to @emph{file}) names when creating the archive.
  1059. @end table
  1060. @cindex File name arguments, using @option{--list} with
  1061. @opindex list, using with file name arguments
  1062. You can specify one or more individual member names as arguments when
  1063. using @samp{list}. In this case, @command{tar} will only list the
  1064. names of members you identify. For example, @w{@kbd{tar --list
  1065. --file=afiles.tar apple}} would only print @file{apple}.
  1066. @FIXME{we hope the relevant aspects of this will change:}Because
  1067. @command{tar} preserves paths, file names must be specified as they appear
  1068. in the archive (ie., relative to the directory from which the archive
  1069. was created). Therefore, it is essential when specifying member names
  1070. to @command{tar} that you give the exact member names. For example,
  1071. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1072. something like @samp{tar: birds: Not found in archive}, because there is
  1073. no member named @file{birds}, only one named @file{./birds}. While the
  1074. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1075. names are compared using a simplistic name comparison, in which an exact
  1076. match is necessary. @xref{absolute}.
  1077. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1078. with @file{folk}, because @file{folk} is in the archive file
  1079. @file{collection.tar}. If you are not sure of the exact file name, try
  1080. listing all the files in the archive and searching for the one you
  1081. expect to find; remember that if you use @option{--list} with no file
  1082. names as arguments, @command{tar} will print the names of all the members
  1083. stored in the specified archive.
  1084. @menu
  1085. * list dir::
  1086. @end menu
  1087. @node list dir
  1088. @unnumberedsubsec Listing the Contents of a Stored Directory
  1089. To get information about the contents of an archived directory,
  1090. use the directory name as a file name argument in conjunction with
  1091. @option{--list} (@option{-t}). To find out file attributes, include the
  1092. @option{--verbose} (@option{-v}) option.
  1093. For example, to find out about files in the directory @file{practice}, in
  1094. the archive file @file{music.tar}, type:
  1095. @smallexample
  1096. $ @kbd{tar --list --verbose --file=music.tar practice}
  1097. @end smallexample
  1098. @command{tar} responds:
  1099. @smallexample
  1100. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1101. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1102. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1103. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1104. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1105. @end smallexample
  1106. When you use a directory name as a file name argument, @command{tar} acts on
  1107. all the files (including sub-directories) in that directory.
  1108. @node extract
  1109. @section How to Extract Members from an Archive
  1110. @UNREVISED
  1111. @cindex Extraction
  1112. @cindex Retrieving files from an archive
  1113. @cindex Resurrecting files from an archive
  1114. @opindex extract
  1115. Creating an archive is only half the job---there is no point in storing
  1116. files in an archive if you can't retrieve them. The act of retrieving
  1117. members from an archive so they can be used and manipulated as
  1118. unarchived files again is called @dfn{extraction}. To extract files
  1119. from an archive, use the @option{--extract} (@option{--get} or
  1120. @option{-x}) operation. As with @option{--create}, specify the name
  1121. of the archive with @option{--file} (@option{-f}) option. Extracting
  1122. an archive does not modify the archive in any way; you can extract it
  1123. multiple times if you want or need to.
  1124. Using @option{--extract}, you can extract an entire archive, or specific
  1125. files. The files can be directories containing other files, or not. As
  1126. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1127. long form of the operation without affecting the performance.
  1128. @menu
  1129. * extracting archives::
  1130. * extracting files::
  1131. * extract dir::
  1132. * extracting untrusted archives::
  1133. * failing commands::
  1134. @end menu
  1135. @node extracting archives
  1136. @subsection Extracting an Entire Archive
  1137. To extract an entire archive, specify the archive file name only, with
  1138. no individual file names as arguments. For example,
  1139. @smallexample
  1140. $ @kbd{tar -xvf collection.tar}
  1141. @end smallexample
  1142. @noindent
  1143. produces this:
  1144. @smallexample
  1145. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1146. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1147. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1148. @end smallexample
  1149. @node extracting files
  1150. @subsection Extracting Specific Files
  1151. To extract specific archive members, give their exact member names as
  1152. arguments, as printed by @option{--list} (@option{-t}). If you had mistakenly deleted
  1153. one of the files you had placed in the archive @file{collection.tar}
  1154. earlier (say, @file{blues}), you can extract it from the archive without
  1155. changing the archive's structure. Its contents will be identical to the
  1156. original file @file{blues} that you deleted.
  1157. First, make sure you are in the @file{practice} directory, and list the
  1158. files in the directory. Now, delete the file, @samp{blues}, and list
  1159. the files in the directory again.
  1160. You can now extract the member @file{blues} from the archive file
  1161. @file{collection.tar} like this:
  1162. @smallexample
  1163. $ @kbd{tar --extract --file=collection.tar blues}
  1164. @end smallexample
  1165. @noindent
  1166. If you list the files in the directory again, you will see that the file
  1167. @file{blues} has been restored, with its original permissions, data modification
  1168. times, and owner.@FIXME{This is only accidentally true, but not in
  1169. general. In most cases, one has to be root for restoring the owner, and
  1170. use a special option for restoring permissions. Here, it just happens
  1171. that the restoring user is also the owner of the archived members, and
  1172. that the current @code{umask} is compatible with original permissions.}
  1173. (These parameters will be identical to those which
  1174. the file had when you originally placed it in the archive; any changes
  1175. you may have made before deleting the file from the file system,
  1176. however, will @emph{not} have been made to the archive member.) The
  1177. archive file, @samp{collection.tar}, is the same as it was before you
  1178. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1179. @option{--list} (@option{-t}).
  1180. @FIXME{we hope this will change:}Remember that as with other operations,
  1181. specifying the exact member name is important. @w{@kbd{tar --extract
  1182. --file=bfiles.tar birds}} will fail, because there is no member named
  1183. @file{birds}. To extract the member named @file{./birds}, you must
  1184. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1185. exact member names of the members of an archive, use @option{--list} (@option{-t})
  1186. (@pxref{list}).
  1187. You can extract a file to standard output by combining the above options
  1188. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1189. Output}).
  1190. If you give the @option{--verbose} option, then @option{--extract}
  1191. will print the names of the archive members as it extracts them.
  1192. @node extract dir
  1193. @subsection Extracting Files that are Directories
  1194. Extracting directories which are members of an archive is similar to
  1195. extracting other files. The main difference to be aware of is that if
  1196. the extracted directory has the same name as any directory already in
  1197. the working directory, then files in the extracted directory will be
  1198. placed into the directory of the same name. Likewise, if there are
  1199. files in the pre-existing directory with the same names as the members
  1200. which you extract, the files from the extracted archive will replace
  1201. the files already in the working directory (and possible
  1202. subdirectories). This will happen regardless of whether or not the
  1203. files in the working directory were more recent than those extracted
  1204. (there exist, however, special options that alter this behavior
  1205. @pxref{Writing}).
  1206. However, if a file was stored with a directory name as part of its file
  1207. name, and that directory does not exist under the working directory when
  1208. the file is extracted, @command{tar} will create the directory.
  1209. We can demonstrate how to use @option{--extract} to extract a directory
  1210. file with an example. Change to the @file{practice} directory if you
  1211. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1212. go back to the parent directory and extract the archive
  1213. @file{music.tar}. You may either extract the entire archive, or you may
  1214. extract only the files you just deleted. To extract the entire archive,
  1215. don't give any file names as arguments after the archive name
  1216. @file{music.tar}. To extract only the files you deleted, use the
  1217. following command:
  1218. @smallexample
  1219. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1220. practice/folk
  1221. practice/jazz
  1222. @end smallexample
  1223. @noindent
  1224. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1225. would have displayed more detail about the extracted files, as shown
  1226. in the example below:
  1227. @smallexample
  1228. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1229. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1230. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1231. @end smallexample
  1232. @noindent
  1233. Because you created the directory with @file{practice} as part of the
  1234. file names of each of the files by archiving the @file{practice}
  1235. directory as @file{practice}, you must give @file{practice} as part
  1236. of the file names when you extract those files from the archive.
  1237. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1238. will be.}
  1239. @node extracting untrusted archives
  1240. @subsection Extracting Archives from Untrusted Sources
  1241. Extracting files from archives can overwrite files that already exist.
  1242. If you receive an archive from an untrusted source, you should make a
  1243. new directory and extract into that directory, so that you don't have
  1244. to worry about the extraction overwriting one of your existing files.
  1245. For example, if @file{untrusted.tar} came from somewhere else on the
  1246. Internet, and you don't necessarily trust its contents, you can
  1247. extract it as follows:
  1248. @smallexample
  1249. $ @kbd{mkdir newdir}
  1250. $ @kbd{cd newdir}
  1251. $ @kbd{tar -xvf ../untrusted.tar}
  1252. @end smallexample
  1253. It is also a good practice to examine contents of the archive
  1254. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1255. with @option{--verbose} (@option{-v}).
  1256. @node failing commands
  1257. @subsection Commands That Will Fail
  1258. Here are some sample commands you might try which will not work, and why
  1259. they won't work.
  1260. If you try to use this command,
  1261. @smallexample
  1262. $ @kbd{tar -xvf music.tar folk jazz}
  1263. @end smallexample
  1264. @noindent
  1265. you will get the following response:
  1266. @smallexample
  1267. tar: folk: Not found in archive
  1268. tar: jazz: Not found in archive
  1269. $
  1270. @end smallexample
  1271. @noindent
  1272. This is because these files were not originally @emph{in} the parent
  1273. directory @file{..}, where the archive is located; they were in the
  1274. @file{practice} directory, and their file names reflect this:
  1275. @smallexample
  1276. $ @kbd{tar -tvf music.tar}
  1277. practice/folk
  1278. practice/jazz
  1279. practice/rock
  1280. @end smallexample
  1281. @FIXME{make sure the above works when going through the examples in
  1282. order...}
  1283. @noindent
  1284. Likewise, if you try to use this command,
  1285. @smallexample
  1286. $ @kbd{tar -tvf music.tar folk jazz}
  1287. @end smallexample
  1288. @noindent
  1289. you would get a similar response. Members with those names are not in the
  1290. archive. You must use the correct member names in order to extract the
  1291. files from the archive.
  1292. If you have forgotten the correct names of the files in the archive,
  1293. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1294. @FIXME{more examples, here? hag thinks it's a good idea.}
  1295. @node going further
  1296. @section Going Further Ahead in this Manual
  1297. @FIXME{need to write up a node here about the things that are going to
  1298. be in the rest of the manual.}
  1299. @node tar invocation
  1300. @chapter Invoking @GNUTAR{}
  1301. @UNREVISED
  1302. This chapter is about how one invokes the @GNUTAR{}
  1303. command, from the command synopsis (@pxref{Synopsis}). There are
  1304. numerous options, and many styles for writing them. One mandatory
  1305. option specifies the operation @command{tar} should perform
  1306. (@pxref{Operation Summary}), other options are meant to detail how
  1307. this operation should be performed (@pxref{Option Summary}).
  1308. Non-option arguments are not always interpreted the same way,
  1309. depending on what the operation is.
  1310. You will find in this chapter everything about option styles and rules for
  1311. writing them (@pxref{Styles}). On the other hand, operations and options
  1312. are fully described elsewhere, in other chapters. Here, you will find
  1313. only synthetic descriptions for operations and options, together with
  1314. pointers to other parts of the @command{tar} manual.
  1315. Some options are so special they are fully described right in this
  1316. chapter. They have the effect of inhibiting the normal operation of
  1317. @command{tar} or else, they globally alter the amount of feedback the user
  1318. receives about what is going on. These are the @option{--help} and
  1319. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1320. and @option{--interactive} options (@pxref{interactive}).
  1321. @menu
  1322. * Synopsis::
  1323. * using tar options::
  1324. * Styles::
  1325. * All Options::
  1326. * help::
  1327. * defaults::
  1328. * verbose::
  1329. * interactive::
  1330. @end menu
  1331. @node Synopsis
  1332. @section General Synopsis of @command{tar}
  1333. The @GNUTAR{} program is invoked as either one of:
  1334. @smallexample
  1335. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1336. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1337. @end smallexample
  1338. The second form is for when old options are being used.
  1339. You can use @command{tar} to store files in an archive, to extract them from
  1340. an archive, and to do other types of archive manipulation. The primary
  1341. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1342. which action to take. The other arguments to @command{tar} are either
  1343. @dfn{options}, which change the way @command{tar} performs an operation,
  1344. or file names or archive members, which specify the files or members
  1345. @command{tar} is to act on.
  1346. You can actually type in arguments in any order, even if in this manual
  1347. the options always precede the other arguments, to make examples easier
  1348. to understand. Further, the option stating the main operation mode
  1349. (the @command{tar} main command) is usually given first.
  1350. Each @var{name} in the synopsis above is interpreted as an archive member
  1351. name when the main command is one of @option{--compare}
  1352. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1353. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1354. @option{--update} (@option{-u}). When naming archive members, you
  1355. must give the exact name of the member in the archive, as it is
  1356. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1357. @option{--create} (@option{-c}), these @var{name} arguments specify
  1358. the names of either files or directory hierarchies to place in the archive.
  1359. These files or hierarchies should already exist in the file system,
  1360. prior to the execution of the @command{tar} command.
  1361. @command{tar} interprets relative file names as being relative to the
  1362. working directory. @command{tar} will make all file names relative
  1363. (by removing leading slashes when archiving or restoring files),
  1364. unless you specify otherwise (using the @option{--absolute-names}
  1365. option). @xref{absolute}, for more information about
  1366. @option{--absolute-names}.
  1367. If you give the name of a directory as either a file name or a member
  1368. name, then @command{tar} acts recursively on all the files and directories
  1369. beneath that directory. For example, the name @file{/} identifies all
  1370. the files in the file system to @command{tar}.
  1371. The distinction between file names and archive member names is especially
  1372. important when shell globbing is used, and sometimes a source of confusion
  1373. for newcomers. @xref{Wildcards}, for more information about globbing.
  1374. The problem is that shells may only glob using existing files in the
  1375. file system. Only @command{tar} itself may glob on archive members, so when
  1376. needed, you must ensure that wildcard characters reach @command{tar} without
  1377. being interpreted by the shell first. Using a backslash before @samp{*}
  1378. or @samp{?}, or putting the whole argument between quotes, is usually
  1379. sufficient for this.
  1380. Even if @var{name}s are often specified on the command line, they
  1381. can also be read from a text file in the file system, using the
  1382. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1383. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1384. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1385. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1386. will usually yield a diagnostic and inhibit @command{tar} execution.
  1387. The other operations of @command{tar} (@option{--list},
  1388. @option{--extract}, @option{--compare}, and @option{--update})
  1389. will act on the entire contents of the archive.
  1390. @cindex exit status
  1391. @cindex return status
  1392. Besides successful exits, @GNUTAR{} may fail for
  1393. many reasons. Some reasons correspond to bad usage, that is, when the
  1394. @command{tar} command is improperly written. Errors may be
  1395. encountered later, while encountering an error processing the archive
  1396. or the files. Some errors are recoverable, in which case the failure
  1397. is delayed until @command{tar} has completed all its work. Some
  1398. errors are such that it would not meaningful, or at least risky, to
  1399. continue processing: @command{tar} then aborts processing immediately.
  1400. All abnormal exits, whether immediate or delayed, should always be
  1401. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1402. the error.
  1403. @GNUTAR{} returns only a few exit statuses. I'm really
  1404. aiming simplicity in that area, for now. If you are not using the
  1405. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1406. that everything went well, besides maybe innocuous warnings. Nonzero
  1407. means that something went wrong. Right now, as of today, ``nonzero''
  1408. is almost always 2, except for remote operations, where it may be
  1409. 128.
  1410. @node using tar options
  1411. @section Using @command{tar} Options
  1412. @GNUTAR{} has a total of eight operating modes which
  1413. allow you to perform a variety of tasks. You are required to choose
  1414. one operating mode each time you employ the @command{tar} program by
  1415. specifying one, and only one operation as an argument to the
  1416. @command{tar} command (two lists of four operations each may be found
  1417. at @ref{frequent operations} and @ref{Operations}). Depending on
  1418. circumstances, you may also wish to customize how the chosen operating
  1419. mode behaves. For example, you may wish to change the way the output
  1420. looks, or the format of the files that you wish to archive may require
  1421. you to do something special in order to make the archive look right.
  1422. You can customize and control @command{tar}'s performance by running
  1423. @command{tar} with one or more options (such as @option{--verbose}
  1424. (@option{-v}), which we used in the tutorial). As we said in the
  1425. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1426. their name suggests) optional. Depending on the operating mode, you
  1427. may specify one or more options. Different options will have different
  1428. effects, but in general they all change details of the operation, such
  1429. as archive format, archive name, or level of user interaction. Some
  1430. options make sense with all operating modes, while others are
  1431. meaningful only with particular modes. You will likely use some
  1432. options frequently, while you will only use others infrequently, or
  1433. not at all. (A full list of options is available in @pxref{All Options}.)
  1434. @vrindex TAR_OPTIONS, environment variable
  1435. @anchor{TAR_OPTIONS}
  1436. The @env{TAR_OPTIONS} environment variable specifies default options to
  1437. be placed in front of any explicit options. For example, if
  1438. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1439. if the two options @option{-v} and @option{--unlink-first} had been
  1440. specified before any explicit options. Option specifications are
  1441. separated by whitespace. A backslash escapes the next character, so it
  1442. can be used to specify an option containing whitespace or a backslash.
  1443. Note that @command{tar} options are case sensitive. For example, the
  1444. options @option{-T} and @option{-t} are different; the first requires an
  1445. argument for stating the name of a file providing a list of @var{name}s,
  1446. while the second does not require an argument and is another way to
  1447. write @option{--list} (@option{-t}).
  1448. In addition to the eight operations, there are many options to
  1449. @command{tar}, and three different styles for writing both: long (mnemonic)
  1450. form, short form, and old style. These styles are discussed below.
  1451. Both the options and the operations can be written in any of these three
  1452. styles.
  1453. @FIXME{menu at end of this node. need to think of an actual outline
  1454. for this chapter; probably do that after stuff from chapter 4 is
  1455. incorporated.}
  1456. @node Styles
  1457. @section The Three Option Styles
  1458. There are three styles for writing operations and options to the command
  1459. line invoking @command{tar}. The different styles were developed at
  1460. different times during the history of @command{tar}. These styles will be
  1461. presented below, from the most recent to the oldest.
  1462. Some options must take an argument. (For example, @option{--file}
  1463. (@option{-f})) takes the name of an archive file as an argument. If
  1464. you do not supply an archive file name, @command{tar} will use a
  1465. default, but this can be confusing; thus, we recommend that you always
  1466. supply a specific archive file name.) Where you @emph{place} the
  1467. arguments generally depends on which style of options you choose. We
  1468. will detail specific information relevant to each option style in the
  1469. sections on the different option styles, below. The differences are
  1470. subtle, yet can often be very important; incorrect option placement
  1471. can cause you to overwrite a number of important files. We urge you
  1472. to note these differences, and only use the option style(s) which
  1473. makes the most sense to you until you feel comfortable with the others.
  1474. Some options @emph{may} take an argument (currently, there are
  1475. two such options: @option{--backup} and @option{--occurrence}). Such
  1476. options may have at most long and short forms, they do not have old style
  1477. equivalent. The rules for specifying an argument for such options
  1478. are stricter than those for specifying mandatory arguments. Please,
  1479. pay special attention to them.
  1480. @menu
  1481. * Mnemonic Options:: Mnemonic Option Style
  1482. * Short Options:: Short Option Style
  1483. * Old Options:: Old Option Style
  1484. * Mixing:: Mixing Option Styles
  1485. @end menu
  1486. @node Mnemonic Options
  1487. @subsection Mnemonic Option Style
  1488. @FIXME{have to decide whether or not to replace other occurrences of
  1489. "mnemonic" with "long", or *ugh* vice versa.}
  1490. Each option has at least one long (or mnemonic) name starting with two
  1491. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1492. their corresponding short or old names. It sometimes happens that a
  1493. single mnemonic option has many different different names which are
  1494. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1495. long option names can be given unique abbreviations. For example,
  1496. @option{--cre} can be used in place of @option{--create} because there is no
  1497. other mnemonic option which begins with @samp{cre}. (One way to find
  1498. this out is by trying it and seeing what happens; if a particular
  1499. abbreviation could represent more than one option, @command{tar} will tell
  1500. you that that abbreviation is ambiguous and you'll know that that
  1501. abbreviation won't work. You may also choose to run @samp{tar --help}
  1502. to see a list of options. Be aware that if you run @command{tar} with a
  1503. unique abbreviation for the long name of an option you didn't want to
  1504. use, you are stuck; @command{tar} will perform the command as ordered.)
  1505. Mnemonic options are meant to be obvious and easy to remember, and their
  1506. meanings are generally easier to discern than those of their
  1507. corresponding short options (see below). For example:
  1508. @smallexample
  1509. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1510. @end smallexample
  1511. @noindent
  1512. gives a fairly good set of hints about what the command does, even
  1513. for those not fully acquainted with @command{tar}.
  1514. Mnemonic options which require arguments take those arguments
  1515. immediately following the option name. There are two ways of
  1516. specifying a mandatory argument. It can be separated from the
  1517. option name either by an equal sign, or by any amount of
  1518. white space characters. For example, the @option{--file} option (which
  1519. tells the name of the @command{tar} archive) is given a file such as
  1520. @file{archive.tar} as argument by using any of the following notations:
  1521. @option{--file=archive.tar} or @option{--file archive.tar}.
  1522. In contrast, optional arguments must always be introduced using
  1523. an equal sign. For example, the @option{--backup} option takes
  1524. an optional argument specifying backup type. It must be used
  1525. as @option{--backup=@var{backup-type}}.
  1526. @node Short Options
  1527. @subsection Short Option Style
  1528. Most options also have a short option name. Short options start with
  1529. a single dash, and are followed by a single character, e.g., @option{-t}
  1530. (which is equivalent to @option{--list}). The forms are absolutely
  1531. identical in function; they are interchangeable.
  1532. The short option names are faster to type than long option names.
  1533. Short options which require arguments take their arguments immediately
  1534. following the option, usually separated by white space. It is also
  1535. possible to stick the argument right after the short option name, using
  1536. no intervening space. For example, you might write @w{@option{-f
  1537. archive.tar}} or @option{-farchive.tar} instead of using
  1538. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1539. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1540. specific archive, here named @file{archive.tar}.
  1541. Short options which take optional arguments take their arguments
  1542. immediately following the option letter, @emph{without any intervening
  1543. white space characters}.
  1544. Short options' letters may be clumped together, but you are not
  1545. required to do this (as compared to old options; see below). When
  1546. short options are clumped as a set, use one (single) dash for them
  1547. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1548. such a set is allowed to have an argument@footnote{Clustering many
  1549. options, the last of which has an argument, is a rather opaque way to
  1550. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1551. even be made helpful enough for considering such usages as invalid.}.
  1552. When the options are separated, the argument for each option which requires
  1553. an argument directly follows that option, as is usual for Unix programs.
  1554. For example:
  1555. @smallexample
  1556. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1557. @end smallexample
  1558. If you reorder short options' locations, be sure to move any arguments
  1559. that belong to them. If you do not move the arguments properly, you may
  1560. end up overwriting files.
  1561. @node Old Options
  1562. @subsection Old Option Style
  1563. @UNREVISED
  1564. Like short options, old options are single letters. However, old options
  1565. must be written together as a single clumped set, without spaces separating
  1566. them or dashes preceding them@footnote{Beware that if you precede options
  1567. with a dash, you are announcing the short option style instead of the
  1568. old option style; short options are decoded differently.}. This set
  1569. of letters must be the first to appear on the command line, after the
  1570. @command{tar} program name and some white space; old options cannot appear
  1571. anywhere else. The letter of an old option is exactly the same letter as
  1572. the corresponding short option. For example, the old option @samp{t} is
  1573. the same as the short option @option{-t}, and consequently, the same as the
  1574. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1575. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1576. @FIXME{bob suggests having an uglier example. :-) }
  1577. When options that need arguments are given together with the command,
  1578. all the associated arguments follow, in the same order as the options.
  1579. Thus, the example given previously could also be written in the old
  1580. style as follows:
  1581. @smallexample
  1582. $ @kbd{tar cvbf 20 /dev/rmt0}
  1583. @end smallexample
  1584. @noindent
  1585. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1586. the argument of @option{-f}.
  1587. On the other hand, this old style syntax makes it difficult to match
  1588. option letters with their corresponding arguments, and is often
  1589. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1590. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1591. argument for @option{-f}, and @option{-v} does not have a corresponding
  1592. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1593. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1594. pertain to.
  1595. If you want to reorder the letters in the old option argument, be
  1596. sure to reorder any corresponding argument appropriately.
  1597. This old way of writing @command{tar} options can surprise even experienced
  1598. users. For example, the two commands:
  1599. @smallexample
  1600. @kbd{tar cfz archive.tar.gz file}
  1601. @kbd{tar -cfz archive.tar.gz file}
  1602. @end smallexample
  1603. @noindent
  1604. are quite different. The first example uses @file{archive.tar.gz} as
  1605. the value for option @samp{f} and recognizes the option @samp{z}. The
  1606. second example, however, uses @file{z} as the value for option
  1607. @samp{f} --- probably not what was intended.
  1608. Old options are kept for compatibility with old versions of @command{tar}.
  1609. This second example could be corrected in many ways, among which the
  1610. following are equivalent:
  1611. @smallexample
  1612. @kbd{tar -czf archive.tar.gz file}
  1613. @kbd{tar -cf archive.tar.gz -z file}
  1614. @kbd{tar cf archive.tar.gz -z file}
  1615. @end smallexample
  1616. @FIXME{still could explain this better; it's redundant:}
  1617. @cindex option syntax, traditional
  1618. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1619. non-@acronym{GNU}, support old options. @GNUTAR{}
  1620. supports them not only for historical reasons, but also because many
  1621. people are used to them. For compatibility with Unix @command{tar},
  1622. the first argument is always treated as containing command and option
  1623. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1624. equivalent to @w{@samp{tar -c}:} both of them specify the
  1625. @option{--create} (@option{-c}) command to create an archive.
  1626. @node Mixing
  1627. @subsection Mixing Option Styles
  1628. All three styles may be intermixed in a single @command{tar} command,
  1629. so long as the rules for each style are fully
  1630. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1631. a bug prevented intermixing old style options with mnemonic options in
  1632. some cases.}. Old style options and either of the modern styles of
  1633. options may be mixed within a single @command{tar} command. However,
  1634. old style options must be introduced as the first arguments only,
  1635. following the rule for old options (old options must appear directly
  1636. after the @command{tar} command and some white space). Modern options
  1637. may be given only after all arguments to the old options have been
  1638. collected. If this rule is not respected, a modern option might be
  1639. falsely interpreted as the value of the argument to one of the old
  1640. style options.
  1641. For example, all the following commands are wholly equivalent, and
  1642. illustrate the many combinations and orderings of option styles.
  1643. @smallexample
  1644. @kbd{tar --create --file=archive.tar}
  1645. @kbd{tar --create -f archive.tar}
  1646. @kbd{tar --create -farchive.tar}
  1647. @kbd{tar --file=archive.tar --create}
  1648. @kbd{tar --file=archive.tar -c}
  1649. @kbd{tar -c --file=archive.tar}
  1650. @kbd{tar -c -f archive.tar}
  1651. @kbd{tar -c -farchive.tar}
  1652. @kbd{tar -cf archive.tar}
  1653. @kbd{tar -cfarchive.tar}
  1654. @kbd{tar -f archive.tar --create}
  1655. @kbd{tar -f archive.tar -c}
  1656. @kbd{tar -farchive.tar --create}
  1657. @kbd{tar -farchive.tar -c}
  1658. @kbd{tar c --file=archive.tar}
  1659. @kbd{tar c -f archive.tar}
  1660. @kbd{tar c -farchive.tar}
  1661. @kbd{tar cf archive.tar}
  1662. @kbd{tar f archive.tar --create}
  1663. @kbd{tar f archive.tar -c}
  1664. @kbd{tar fc archive.tar}
  1665. @end smallexample
  1666. On the other hand, the following commands are @emph{not} equivalent to
  1667. the previous set:
  1668. @smallexample
  1669. @kbd{tar -f -c archive.tar}
  1670. @kbd{tar -fc archive.tar}
  1671. @kbd{tar -fcarchive.tar}
  1672. @kbd{tar -farchive.tarc}
  1673. @kbd{tar cfarchive.tar}
  1674. @end smallexample
  1675. @noindent
  1676. These last examples mean something completely different from what the
  1677. user intended (judging based on the example in the previous set which
  1678. uses long options, whose intent is therefore very clear). The first
  1679. four specify that the @command{tar} archive would be a file named
  1680. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1681. respectively. The first two examples also specify a single non-option,
  1682. @var{name} argument having the value @samp{archive.tar}. The last
  1683. example contains only old style option letters (repeating option
  1684. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1685. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1686. the first sentence of this paragraph..}
  1687. @node All Options
  1688. @section All @command{tar} Options
  1689. The coming manual sections contain an alphabetical listing of all
  1690. @command{tar} operations and options, with brief descriptions and cross
  1691. references to more in-depth explanations in the body of the manual.
  1692. They also contain an alphabetically arranged table of the short option
  1693. forms with their corresponding long option. You can use this table as
  1694. a reference for deciphering @command{tar} commands in scripts.
  1695. @menu
  1696. * Operation Summary::
  1697. * Option Summary::
  1698. * Short Option Summary::
  1699. @end menu
  1700. @node Operation Summary
  1701. @subsection Operations
  1702. @table @option
  1703. @opindex append, summary
  1704. @item --append
  1705. @itemx -r
  1706. Appends files to the end of the archive. @xref{append}.
  1707. @opindex catenate, summary
  1708. @item --catenate
  1709. @itemx -A
  1710. Same as @option{--concatenate}. @xref{concatenate}.
  1711. @opindex compare, summary
  1712. @item --compare
  1713. @itemx -d
  1714. Compares archive members with their counterparts in the file
  1715. system, and reports differences in file size, mode, owner,
  1716. modification date and contents. @xref{compare}.
  1717. @opindex concatenate, summary
  1718. @item --concatenate
  1719. @itemx -A
  1720. Appends other @command{tar} archives to the end of the archive.
  1721. @xref{concatenate}.
  1722. @opindex create, summary
  1723. @item --create
  1724. @itemx -c
  1725. Creates a new @command{tar} archive. @xref{create}.
  1726. @opindex delete, summary
  1727. @item --delete
  1728. Deletes members from the archive. Don't try this on a archive on a
  1729. tape! @xref{delete}.
  1730. @opindex diff, summary
  1731. @item --diff
  1732. @itemx -d
  1733. Same @option{--compare}. @xref{compare}.
  1734. @opindex extract, summary
  1735. @item --extract
  1736. @itemx -x
  1737. Extracts members from the archive into the file system. @xref{extract}.
  1738. @opindex get, summary
  1739. @item --get
  1740. @itemx -x
  1741. Same as @option{--extract}. @xref{extract}.
  1742. @opindex list, summary
  1743. @item --list
  1744. @itemx -t
  1745. Lists the members in an archive. @xref{list}.
  1746. @opindex update, summary
  1747. @item --update
  1748. @itemx -u
  1749. @FIXME{It was: A combination of the @option{--compare} and
  1750. @option{--append} operations. This is not true and rather misleading,
  1751. as @option{--compare} (@option{--diff}, @option{-d}) does a lot more than @option{--update} (@option{-u}) for
  1752. ensuring files are identical.} Adds files to the end of the archive,
  1753. but only if they are newer than their counterparts already in the
  1754. archive, or if they do not already exist in the archive.
  1755. @xref{update}.
  1756. @end table
  1757. @node Option Summary
  1758. @subsection @command{tar} Options
  1759. @table @option
  1760. @opindex absolute-names, summary
  1761. @item --absolute-names
  1762. @itemx -P
  1763. Normally when creating an archive, @command{tar} strips an initial
  1764. @samp{/} from member names. This option disables that behavior.
  1765. @xref{absolute}.
  1766. @opindex after-date, summary
  1767. @item --after-date
  1768. (See @option{--newer}, @pxref{after})
  1769. @opindex anchored, summary
  1770. @item --anchored
  1771. An exclude pattern must match an initial subsequence of the name's components.
  1772. @xref{controlling pattern-matching with exclude}.
  1773. @opindex atime-preserve, summary
  1774. @item --atime-preserve
  1775. @itemx --atime-preserve=replace
  1776. @itemx --atime-preserve=system
  1777. Attempt to preserve the access time of files when reading them. This
  1778. option currently is effective only on files that you own, unless you
  1779. have superuser privileges.
  1780. @option{--atime-preserve=replace} remembers the access time of a file
  1781. before reading it, and then restores the access time afterwards. This
  1782. may cause problems if other programs are reading the file at the same
  1783. time, as the times of their accesses will be lost. On most platforms
  1784. restoring the access time also requires @command{tar} to restore the
  1785. data modification time too, so this option may also cause problems if
  1786. other programs are writing the file at the same time. (Tar attempts
  1787. to detect this situation, but cannot do so reliably due to race
  1788. conditions.) Worse, on most platforms restoring the access time also
  1789. updates the status change time, which means that this option is
  1790. incompatible with incremental backups.
  1791. @option{--atime-preserve=system} avoids changing time stamps on files,
  1792. without interfering with time stamp updates
  1793. caused by other programs, so it works better with incremental backups.
  1794. However, it requires a special @code{O_NOATIME} option from the
  1795. underlying operating and file system implementation, and it also requires
  1796. that searching directories does not update their access times. As of
  1797. this writing (November 2005) this works only with Linux, and only with
  1798. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1799. way to know whether this feature actually works. Sometimes
  1800. @command{tar} knows that it does not work, and if you use
  1801. @option{--atime-preserve=system} then @command{tar} complains and
  1802. exits right away. But other times @command{tar} might think that the
  1803. option works when it actually does not.
  1804. Currently @option{--atime-preserve} with no operand defaults to
  1805. @option{--atime-preserve=replace}, but this may change in the future
  1806. as support for @option{--atime-preserve=system} improves.
  1807. If your operating system does not support
  1808. @option{--atime-preserve=system}, you might be able to preserve access
  1809. times reliably by by using the @command{mount} command. For example,
  1810. you can mount the file system read-only, or access the file system via
  1811. a read-only loopback mount, or use the @samp{noatime} mount option
  1812. available on some systems. However, mounting typically requires
  1813. superuser privileges and can be a pain to manage.
  1814. @opindex backup, summary
  1815. @item --backup=@var{backup-type}
  1816. Rather than deleting files from the file system, @command{tar} will
  1817. back them up using simple or numbered backups, depending upon
  1818. @var{backup-type}. @xref{backup}.
  1819. @opindex block-number, summary
  1820. @item --block-number
  1821. @itemx -R
  1822. With this option present, @command{tar} prints error messages for read errors
  1823. with the block number in the archive file. @xref{block-number}.
  1824. @opindex blocking-factor, summary
  1825. @item --blocking-factor=@var{blocking}
  1826. @itemx -b @var{blocking}
  1827. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1828. record. @xref{Blocking Factor}.
  1829. @opindex bzip2, summary
  1830. @item --bzip2
  1831. @itemx -j
  1832. This option tells @command{tar} to read or write archives through
  1833. @code{bzip2}. @xref{gzip}.
  1834. @opindex checkpoint, summary
  1835. @item --checkpoint
  1836. This option directs @command{tar} to print periodic checkpoint messages as it
  1837. reads through the archive. Its intended for when you want a visual
  1838. indication that @command{tar} is still running, but don't want to see
  1839. @option{--verbose} output. @FIXME-xref{}
  1840. @opindex check-links, summary
  1841. @item --check-links
  1842. @itemx -l
  1843. If this option was given, @command{tar} will check the number of links
  1844. dumped for each processed file. If this number does not match the
  1845. total number of hard links for the file, a warning message will be
  1846. output.
  1847. Future versions will take @option{-l} as a short version of
  1848. @option{--check-links}. However, current release still retains the old
  1849. semantics for @option{-l}.
  1850. @xref{Changes}, for more information.
  1851. @opindex compress, summary
  1852. @opindex uncompress, summary
  1853. @item --compress
  1854. @itemx --uncompress
  1855. @itemx -Z
  1856. @command{tar} will use the @command{compress} program when reading or
  1857. writing the archive. This allows you to directly act on archives
  1858. while saving space. @xref{gzip}.
  1859. @opindex confirmation, summary
  1860. @item --confirmation
  1861. (See @option{--interactive}.) @xref{interactive}.
  1862. @opindex delay-directory-restore, summary
  1863. @item --delay-directory-restore
  1864. Delay setting modification times and permissions of extracted
  1865. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1866. @opindex dereference, summary
  1867. @item --dereference
  1868. @itemx -h
  1869. When creating a @command{tar} archive, @command{tar} will archive the
  1870. file that a symbolic link points to, rather than archiving the
  1871. symlink. @xref{dereference}.
  1872. @opindex directory, summary
  1873. @item --directory=@var{dir}
  1874. @itemx -C @var{dir}
  1875. When this option is specified, @command{tar} will change its current directory
  1876. to @var{dir} before performing any operations. When this option is used
  1877. during archive creation, it is order sensitive. @xref{directory}.
  1878. @opindex exclude, summary
  1879. @item --exclude=@var{pattern}
  1880. When performing operations, @command{tar} will skip files that match
  1881. @var{pattern}. @xref{exclude}.
  1882. @opindex exclude-from, summary
  1883. @item --exclude-from=@var{file}
  1884. @itemx -X @var{file}
  1885. Similar to @option{--exclude}, except @command{tar} will use the list of
  1886. patterns in the file @var{file}. @xref{exclude}.
  1887. @opindex exclude-caches, summary
  1888. @item --exclude-caches
  1889. Automatically excludes all directories
  1890. containing a cache directory tag. @xref{exclude}.
  1891. @opindex file, summary
  1892. @item --file=@var{archive}
  1893. @itemx -f @var{archive}
  1894. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1895. performs operations on, rather than @command{tar}'s compilation dependent
  1896. default. @xref{file tutorial}.
  1897. @opindex files-from, summary
  1898. @item --files-from=@var{file}
  1899. @itemx -T @var{file}
  1900. @command{tar} will use the contents of @var{file} as a list of archive members
  1901. or files to operate on, in addition to those specified on the
  1902. command-line. @xref{files}.
  1903. @opindex force-local, summary
  1904. @item --force-local
  1905. Forces @command{tar} to interpret the filename given to @option{--file}
  1906. as a local file, even if it looks like a remote tape drive name.
  1907. @xref{local and remote archives}.
  1908. @opindex format, summary
  1909. @item --format=@var{format}
  1910. Selects output archive format. @var{Format} may be one of the
  1911. following:
  1912. @table @samp
  1913. @item v7
  1914. Creates an archive that is compatible with Unix V7 @command{tar}.
  1915. @item oldgnu
  1916. Creates an archive that is compatible with GNU @command{tar} version
  1917. 1.12 or earlier.
  1918. @item gnu
  1919. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1920. @samp{oldgnu} with the only difference in the way it handles long
  1921. numeric fields.
  1922. @item ustar
  1923. Creates a @acronym{POSIX.1-1988} compatible archive.
  1924. @item posix
  1925. Creates a @acronym{POSIX.1-2001 archive}.
  1926. @end table
  1927. @xref{Formats}, for a detailed discussion of these formats.
  1928. @opindex group, summary
  1929. @item --group=@var{group}
  1930. Files added to the @command{tar} archive will have a group id of @var{group},
  1931. rather than the group from the source file. @var{group} is first decoded
  1932. as a group symbolic name, but if this interpretation fails, it has to be
  1933. a decimal numeric group ID. @FIXME-xref{}
  1934. Also see the comments for the @option{--owner=@var{user}} option.
  1935. @opindex gzip, summary
  1936. @opindex gunzip, summary
  1937. @opindex ungzip, summary
  1938. @item --gzip
  1939. @itemx --gunzip
  1940. @itemx --ungzip
  1941. @itemx -z
  1942. This option tells @command{tar} to read or write archives through
  1943. @command{gzip}, allowing @command{tar} to directly operate on several
  1944. kinds of compressed archives transparently. @xref{gzip}.
  1945. @opindex help, summary
  1946. @item --help
  1947. @command{tar} will print out a short message summarizing the operations and
  1948. options to @command{tar} and exit. @xref{help}.
  1949. @opindex ignore-case, summary
  1950. @item --ignore-case
  1951. Ignore case when excluding files. @xref{controlling pattern-matching
  1952. with exclude}.
  1953. @opindex ignore-command-error, summary
  1954. @item --ignore-command-error
  1955. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1956. @opindex ignore-failed-read, summary
  1957. @item --ignore-failed-read
  1958. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1959. @xref{Reading}.
  1960. @opindex ignore-zeros, summary
  1961. @item --ignore-zeros
  1962. @itemx -i
  1963. With this option, @command{tar} will ignore zeroed blocks in the
  1964. archive, which normally signals EOF. @xref{Reading}.
  1965. @opindex incremental, summary
  1966. @item --incremental
  1967. @itemx -G
  1968. Used to inform @command{tar} that it is working with an old
  1969. @acronym{GNU}-format incremental backup archive. It is intended
  1970. primarily for backwards compatibility only. @FIXME{incremental and
  1971. listed-incremental}.
  1972. @opindex index-file, summary
  1973. @item --index-file=@var{file}
  1974. Send verbose output to @var{file} instead of to standard output.
  1975. @opindex info-script, summary
  1976. @opindex new-volume-script, summary
  1977. @item --info-script=@var{script-file}
  1978. @itemx --new-volume-script=@var{script-file}
  1979. @itemx -F @var{script-file}
  1980. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1981. at the end of each tape. If @var{script-file} exits with nonzero status,
  1982. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1983. discussion of @var{script-file}.
  1984. @opindex interactive, summary
  1985. @item --interactive
  1986. @itemx --confirmation
  1987. @itemx -w
  1988. Specifies that @command{tar} should ask the user for confirmation before
  1989. performing potentially destructive options, such as overwriting files.
  1990. @xref{interactive}.
  1991. @opindex keep-newer-files, summary
  1992. @item --keep-newer-files
  1993. Do not replace existing files that are newer than their archive copies
  1994. when extracting files from an archive.
  1995. @opindex keep-old-files, summary
  1996. @item --keep-old-files
  1997. @itemx -k
  1998. Do not overwrite existing files when extracting files from an archive.
  1999. @xref{Keep Old Files}.
  2000. @opindex label, summary
  2001. @item --label=@var{name}
  2002. @itemx -V @var{name}
  2003. When creating an archive, instructs @command{tar} to write @var{name}
  2004. as a name record in the archive. When extracting or listing archives,
  2005. @command{tar} will only operate on archives that have a label matching
  2006. the pattern specified in @var{name}. @xref{Tape Files}.
  2007. @opindex listed-incremental, summary
  2008. @item --listed-incremental=@var{snapshot-file}
  2009. @itemx -g @var{snapshot-file}
  2010. During a @option{--create} operation, specifies that the archive that
  2011. @command{tar} creates is a new @acronym{GNU}-format incremental
  2012. backup, using @var{snapshot-file} to determine which files to backup.
  2013. With other operations, informs @command{tar} that the archive is in
  2014. incremental format. @FIXME{incremental and listed-incremental}.
  2015. @opindex mode, summary
  2016. @item --mode=@var{permissions}
  2017. When adding files to an archive, @command{tar} will use
  2018. @var{permissions} for the archive members, rather than the permissions
  2019. from the files. The program @command{chmod} and this @command{tar}
  2020. option share the same syntax for what @var{permissions} might be.
  2021. @xref{File permissions, Permissions, File permissions, fileutils,
  2022. @acronym{GNU} file utilities}. This reference also has useful
  2023. information for those not being overly familiar with the Unix
  2024. permission system.
  2025. Of course, @var{permissions} might be plainly specified as an octal number.
  2026. However, by using generic symbolic modifications to mode bits, this allows
  2027. more flexibility. For example, the value @samp{a+rw} adds read and write
  2028. permissions for everybody, while retaining executable bits on directories
  2029. or on any other file already marked as executable.
  2030. @opindex multi-volume, summary
  2031. @item --multi-volume
  2032. @itemx -M
  2033. Informs @command{tar} that it should create or otherwise operate on a
  2034. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2035. @opindex new-volume-script, summary
  2036. @item --new-volume-script
  2037. (see --info-script)
  2038. @opindex seek, summary
  2039. @item --seek
  2040. @itemx -n
  2041. Assume that the archive media supports seeks to arbitrary
  2042. locations. Usually @command{tar} determines automatically whether
  2043. the archive can be seeked or not. This option is intended for use
  2044. in cases when such recognition fails.
  2045. @opindex newer, summary
  2046. @item --newer=@var{date}
  2047. @itemx --after-date=@var{date}
  2048. @itemx -N
  2049. When creating an archive, @command{tar} will only add files that have changed
  2050. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2051. is taken to be the name of a file whose data modification time specifies
  2052. the date. @xref{after}.
  2053. @opindex newer-mtime, summary
  2054. @item --newer-mtime=@var{date}
  2055. Like @option{--newer}, but add only files whose
  2056. contents have changed (as opposed to just @option{--newer}, which will
  2057. also back up files for which any status information has changed).
  2058. @opindex no-anchored, summary
  2059. @item --no-anchored
  2060. An exclude pattern can match any subsequence of the name's components.
  2061. @xref{controlling pattern-matching with exclude}.
  2062. @opindex no-delay-directory-restore, summary
  2063. @item --no-delay-directory-restore
  2064. Setting modification times and permissions of extracted
  2065. directories when all files from this directory has been
  2066. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2067. @opindex no-ignore-case, summary
  2068. @item --no-ignore-case
  2069. Use case-sensitive matching when excluding files.
  2070. @xref{controlling pattern-matching with exclude}.
  2071. @opindex no-ignore-command-error, summary
  2072. @item --no-ignore-command-error
  2073. Print warnings about subprocesses terminated with a non-zero exit
  2074. code. @xref{Writing to an External Program}.
  2075. @opindex no-quote-chars, summary
  2076. @item --no-quote-chars=@var{string}
  2077. Do not quote characters from @var{string}, even if the selected
  2078. quoting style implies they should be quoted (@FIXME-pxref{Quoting Styles}).
  2079. @opindex no-recursion, summary
  2080. @item --no-recursion
  2081. With this option, @command{tar} will not recurse into directories.
  2082. @xref{recurse}.
  2083. @opindex no-same-owner, summary
  2084. @item --no-same-owner
  2085. @itemx -o
  2086. When extracting an archive, do not attempt to preserve the owner
  2087. specified in the @command{tar} archive. This the default behavior
  2088. for ordinary users.
  2089. @opindex no-same-permissions, summary
  2090. @item --no-same-permissions
  2091. When extracting an archive, subtract the user's umask from files from
  2092. the permissions specified in the archive. This is the default behavior
  2093. for ordinary users.
  2094. @opindex no-wildcards, summary
  2095. @item --no-wildcards
  2096. Do not use wildcards when excluding files.
  2097. @xref{controlling pattern-matching with exclude}.
  2098. @opindex no-wildcards-match-slash, summary
  2099. @item --no-wildcards-match-slash
  2100. Wildcards do not match @samp{/} when excluding files.
  2101. @xref{controlling pattern-matching with exclude}.
  2102. @opindex null, summary
  2103. @item --null
  2104. When @command{tar} is using the @option{--files-from} option, this option
  2105. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2106. @command{tar} can correctly work with file names that contain newlines.
  2107. @xref{nul}.
  2108. @opindex numeric-owner, summary
  2109. @item --numeric-owner
  2110. This option will notify @command{tar} that it should use numeric user
  2111. and group IDs when creating a @command{tar} file, rather than names.
  2112. @xref{Attributes}.
  2113. @item -o
  2114. When extracting files, this option is a synonym for
  2115. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2116. restoring ownership of files being extracted.
  2117. When creating an archive, @option{-o} is a synonym for
  2118. @option{--old-archive}. This behavior is for compatibility
  2119. with previous versions of @GNUTAR{}, and will be
  2120. removed in the future releases.
  2121. @xref{Changes}, for more information.
  2122. @opindex occurrence, summary
  2123. @item --occurrence[=@var{number}]
  2124. This option can be used in conjunction with one of the subcommands
  2125. @option{--delete}, @option{--diff}, @option{--extract} or
  2126. @option{--list} when a list of files is given either on the command
  2127. line or via @option{-T} option.
  2128. This option instructs @command{tar} to process only the @var{number}th
  2129. occurrence of each named file. @var{Number} defaults to 1, so
  2130. @smallexample
  2131. tar -x -f archive.tar --occurrence filename
  2132. @end smallexample
  2133. @noindent
  2134. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2135. and will terminate without scanning to the end of the archive.
  2136. @opindex old-archive, summary
  2137. @item --old-archive
  2138. Synonym for @option{--format=v7}.
  2139. @opindex one-file-system, summary
  2140. @item --one-file-system
  2141. @itemx -l
  2142. Used when creating an archive. Prevents @command{tar} from recursing into
  2143. directories that are on different file systems from the current
  2144. directory.
  2145. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2146. synonym for @option{--one-file-system}. Although such usage is still
  2147. allowed in the present version, it is @emph{strongly discouraged}.
  2148. The future versions of @GNUTAR{} will use @option{-l} as
  2149. a synonym for @option{--check-links}.
  2150. @xref{Changes}, for more information.
  2151. @opindex overwrite, summary
  2152. @item --overwrite
  2153. Overwrite existing files and directory metadata when extracting files
  2154. from an archive. @xref{Overwrite Old Files}.
  2155. @opindex overwrite-dir, summary
  2156. @item --overwrite-dir
  2157. Overwrite the metadata of existing directories when extracting files
  2158. from an archive. @xref{Overwrite Old Files}.
  2159. @opindex owner, summary
  2160. @item --owner=@var{user}
  2161. Specifies that @command{tar} should use @var{user} as the owner of members
  2162. when creating archives, instead of the user associated with the source
  2163. file. @var{user} is first decoded as a user symbolic name, but if
  2164. this interpretation fails, it has to be a decimal numeric user ID.
  2165. @FIXME-xref{}
  2166. There is no value indicating a missing number, and @samp{0} usually means
  2167. @code{root}. Some people like to force @samp{0} as the value to offer in
  2168. their distributions for the owner of files, because the @code{root} user is
  2169. anonymous anyway, so that might as well be the owner of anonymous archives.
  2170. This option does not affect extraction from archives.
  2171. @opindex quote-chars, summary
  2172. @item --quote-chars=@var{string}
  2173. Always quote characters from @var{string}, even if the selected
  2174. quoting style would not quote them (@FIXME-pxref{Quoting Styles}).
  2175. @opindex quoting-style, summary
  2176. @item --quoting-style=@var{style}
  2177. Set quoting style to use when printing member and file names
  2178. (@FIXME-pxref{Quoting Styles}). Valid @var{style} values are:
  2179. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2180. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2181. style is @code{escape}, unless overridden while configuring the
  2182. package.
  2183. @opindex pax-option, summary
  2184. @item --pax-option=@var{keyword-list}
  2185. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2186. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2187. (@pxref{posix}). It modifies the way @command{tar} handles the
  2188. extended header keywords. @var{Keyword-list} is a comma-separated
  2189. list of keyword options, each keyword option taking one of
  2190. the following forms:
  2191. @table @asis
  2192. @item delete=@var{pattern}
  2193. When used with one of archive-creation commands,
  2194. this option instructs @command{tar} to omit from extended header records
  2195. that it produces any keywords matching the string @var{pattern}.
  2196. When used in extract or list mode, this option instructs tar
  2197. to ignore any keywords matching the given @var{pattern} in the extended
  2198. header records. In both cases, matching is performed using the pattern
  2199. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2200. (See @cite{glob(7)}). For example:
  2201. @smallexample
  2202. --pax-option delete=security.*
  2203. @end smallexample
  2204. would suppress security-related information.
  2205. @item exthdr.name=@var{string}
  2206. This keyword allows user control over the name that is written into the
  2207. ustar header blocks for the extended headers. The name is obtained
  2208. from @var{string} after making the following substitutions:
  2209. @multitable @columnfractions .30 .70
  2210. @headitem Meta-character @tab Replaced By
  2211. @item %d @tab The directory name of the file, equivalent to the
  2212. result of the @command{dirname} utility on the translated pathname.
  2213. @item %f @tab The filename of the file, equivalent to the result
  2214. of the @command{basename} utility on the translated pathname.
  2215. @item %p @tab The process ID of the @command{tar} process.
  2216. @item %% @tab A @samp{%} character.
  2217. @end multitable
  2218. Any other @samp{%} characters in @var{string} produce undefined
  2219. results.
  2220. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2221. will use the following default value:
  2222. @smallexample
  2223. %d/PaxHeaders.%p/%f
  2224. @end smallexample
  2225. @item globexthdr.name=@var{string}
  2226. This keyword allows user control over the name that is written into
  2227. the ustar header blocks for global extended header records. The name
  2228. is obtained from the contents of @var{string}, after making
  2229. the following substitutions:
  2230. @multitable @columnfractions .30 .70
  2231. @headitem Meta-character @tab Replaced By
  2232. @item %n @tab An integer that represents the
  2233. sequence number of the global extended header record in the archive,
  2234. starting at 1.
  2235. @item %p @tab The process ID of the @command{tar} process.
  2236. @item %% @tab A @samp{%} character.
  2237. @end multitable
  2238. Any other @samp{%} characters in @var{string} produce undefined results.
  2239. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2240. will use the following default value:
  2241. @smallexample
  2242. $TMPDIR/GlobalHead.%p.%n
  2243. @end smallexample
  2244. @noindent
  2245. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2246. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2247. uses @samp{/tmp}.
  2248. @item @var{keyword}=@var{value}
  2249. When used with one of archive-creation commands, these keyword/value pairs
  2250. will be included at the beginning of the archive in a global extended
  2251. header record. When used with one of archive-reading commands,
  2252. @command{tar} will behave as if it has encountered these keyword/value
  2253. pairs at the beginning of the archive in a global extended header
  2254. record.
  2255. @item @var{keyword}:=@var{value}
  2256. When used with one of archive-creation commands, these keyword/value pairs
  2257. will be included as records at the beginning of an extended header for
  2258. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2259. form except that it creates no global extended header records.
  2260. When used with one of archive-reading commands, @command{tar} will
  2261. behave as if these keyword/value pairs were included as records at the
  2262. end of each extended header; thus, they will override any global or
  2263. file-specific extended header record keywords of the same names.
  2264. For example, in the command:
  2265. @smallexample
  2266. tar --format=posix --create \
  2267. --file archive --pax-option gname:=user .
  2268. @end smallexample
  2269. the group name will be forced to a new value for all files
  2270. stored in the archive.
  2271. @end table
  2272. @opindex portability, summary
  2273. @item --portability
  2274. @itemx --old-archive
  2275. Synonym for @option{--format=v7}.
  2276. @opindex posix, summary
  2277. @item --posix
  2278. Same as @option{--format=posix}.
  2279. @opindex preserve, summary
  2280. @item --preserve
  2281. Synonymous with specifying both @option{--preserve-permissions} and
  2282. @option{--same-order}. @xref{Setting Access Permissions}.
  2283. @opindex preserve-order, summary
  2284. @item --preserve-order
  2285. (See @option{--same-order}; @pxref{Reading}.)
  2286. @opindex preserve-permissions, summary
  2287. @opindex same-permissions, summary
  2288. @item --preserve-permissions
  2289. @itemx --same-permissions
  2290. @itemx -p
  2291. When @command{tar} is extracting an archive, it normally subtracts the
  2292. users' umask from the permissions specified in the archive and uses
  2293. that number as the permissions to create the destination file.
  2294. Specifying this option instructs @command{tar} that it should use the
  2295. permissions directly from the archive. @xref{Setting Access Permissions}.
  2296. @opindex read-full-records, summary
  2297. @item --read-full-records
  2298. @itemx -B
  2299. Specifies that @command{tar} should reblock its input, for reading
  2300. from pipes on systems with buggy implementations. @xref{Reading}.
  2301. @opindex record-size, summary
  2302. @item --record-size=@var{size}
  2303. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2304. archive. @xref{Blocking Factor}.
  2305. @opindex recursion, summary
  2306. @item --recursion
  2307. With this option, @command{tar} recurses into directories.
  2308. @xref{recurse}.
  2309. @opindex recursive-unlink, summary
  2310. @item --recursive-unlink
  2311. Remove existing
  2312. directory hierarchies before extracting directories of the same name
  2313. from the archive. @xref{Recursive Unlink}.
  2314. @opindex remove-files, summary
  2315. @item --remove-files
  2316. Directs @command{tar} to remove the source file from the file system after
  2317. appending it to an archive. @xref{remove files}.
  2318. @opindex restrict, summary
  2319. @item --restrict
  2320. Disable use of some potentially harmful @command{tar} options.
  2321. Currently this option disables shell invocaton from multi-volume menu
  2322. (@pxref{Using Multiple Tapes}).
  2323. @opindex rmt-command, summary
  2324. @item --rmt-command=@var{cmd}
  2325. Notifies @command{tar} that it should use @var{cmd} instead of
  2326. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2327. @opindex rsh-command, summary
  2328. @item --rsh-command=@var{cmd}
  2329. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2330. devices. @xref{Device}.
  2331. @opindex same-order, summary
  2332. @item --same-order
  2333. @itemx --preserve-order
  2334. @itemx -s
  2335. This option is an optimization for @command{tar} when running on machines with
  2336. small amounts of memory. It informs @command{tar} that the list of file
  2337. arguments has already been sorted to match the order of files in the
  2338. archive. @xref{Reading}.
  2339. @opindex same-owner, summary
  2340. @item --same-owner
  2341. When extracting an archive, @command{tar} will attempt to preserve the owner
  2342. specified in the @command{tar} archive with this option present.
  2343. This is the default behavior for the superuser; this option has an
  2344. effect only for ordinary users. @xref{Attributes}.
  2345. @opindex same-permissions, summary
  2346. @item --same-permissions
  2347. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2348. @opindex show-defaults, summary
  2349. @item --show-defaults
  2350. Displays the default options used by @command{tar} and exits
  2351. successfully. This option is intended for use in shell scripts.
  2352. Here is an example of what you can see using this option:
  2353. @smallexample
  2354. $ tar --show-defaults
  2355. --format=gnu -f- -b20 --quoting-style=escape \
  2356. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2357. @end smallexample
  2358. @opindex show-omitted-dirs, summary
  2359. @item --show-omitted-dirs
  2360. Instructs @command{tar} to mention directories its skipping over when
  2361. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2362. @opindex show-stored-names, summary
  2363. @item --show-stored-names
  2364. This option has effect only when used in conjunction with one of
  2365. archive creation operations. It instructs tar to list the member names
  2366. stored in the archive, as opposed to the actual file
  2367. names. @xref{listing member and file names}.
  2368. @opindex sparse, summary
  2369. @item --sparse
  2370. @itemx -S
  2371. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2372. sparse files efficiently. @xref{sparse}.
  2373. @opindex starting-file, summary
  2374. @item --starting-file=@var{name}
  2375. @itemx -K @var{name}
  2376. This option affects extraction only; @command{tar} will skip extracting
  2377. files in the archive until it finds one that matches @var{name}.
  2378. @xref{Scarce}.
  2379. @opindex strip-components, summary
  2380. @item --strip-components=@var{number}
  2381. Strip given @var{number} of leading components from file names before
  2382. extraction.@footnote{This option was called @option{--strip-path} in
  2383. version 1.14.} For example, if archive @file{archive.tar} contained
  2384. @file{/some/file/name}, then running
  2385. @smallexample
  2386. tar --extract --file archive.tar --strip-components=2
  2387. @end smallexample
  2388. @noindent
  2389. would extracted this file to file @file{name}.
  2390. @opindex suffix, summary
  2391. @item --suffix=@var{suffix}
  2392. Alters the suffix @command{tar} uses when backing up files from the default
  2393. @samp{~}. @xref{backup}.
  2394. @opindex tape-length, summary
  2395. @item --tape-length=@var{num}
  2396. @itemx -L @var{num}
  2397. Specifies the length of tapes that @command{tar} is writing as being
  2398. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2399. @opindex test-label, summary
  2400. @item --test-label
  2401. Reads the volume label. If an argument is specified, test whether it
  2402. matches the volume label. @xref{--test-label option}.
  2403. @opindex to-command, summary
  2404. @item --to-command=@var{command}
  2405. During extraction @command{tar} will pipe extracted files to the
  2406. standard input of @var{command}. @xref{Writing to an External Program}.
  2407. @opindex to-stdout, summary
  2408. @item --to-stdout
  2409. @itemx -O
  2410. During extraction, @command{tar} will extract files to stdout rather
  2411. than to the file system. @xref{Writing to Standard Output}.
  2412. @opindex totals, summary
  2413. @item --totals
  2414. Displays the total number of bytes written after creating an archive.
  2415. @xref{verbose}.
  2416. @opindex touch, summary
  2417. @item --touch
  2418. @itemx -m
  2419. Sets the data modification time of extracted files to the extraction time,
  2420. rather than the data modification time stored in the archive.
  2421. @xref{Data Modification Times}.
  2422. @opindex uncompress, summary
  2423. @item --uncompress
  2424. (See @option{--compress}. @pxref{gzip})
  2425. @opindex ungzip, summary
  2426. @item --ungzip
  2427. (See @option{--gzip}. @pxref{gzip})
  2428. @opindex unlink-first, summary
  2429. @item --unlink-first
  2430. @itemx -U
  2431. Directs @command{tar} to remove the corresponding file from the file
  2432. system before extracting it from the archive. @xref{Unlink First}.
  2433. @opindex use-compress-program, summary
  2434. @item --use-compress-program=@var{prog}
  2435. Instructs @command{tar} to access the archive through @var{prog}, which is
  2436. presumed to be a compression program of some sort. @xref{gzip}.
  2437. @opindex utc, summary
  2438. @item --utc
  2439. Display file modification dates in @acronym{UTC}. This option implies
  2440. @option{--verbose}.
  2441. @opindex verbose, summary
  2442. @item --verbose
  2443. @itemx -v
  2444. Specifies that @command{tar} should be more verbose about the operations its
  2445. performing. This option can be specified multiple times for some
  2446. operations to increase the amount of information displayed.
  2447. @xref{verbose}.
  2448. @opindex verify, summary
  2449. @item --verify
  2450. @itemx -W
  2451. Verifies that the archive was correctly written when creating an
  2452. archive. @xref{verify}.
  2453. @opindex version, summary
  2454. @item --version
  2455. Print information about the program's name, version, origin and legal
  2456. status, all on standard output, and then exit successfully.
  2457. @xref{help}.
  2458. @opindex volno-file, summary
  2459. @item --volno-file=@var{file}
  2460. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2461. of which volume of a multi-volume archive its working in @var{file}.
  2462. @xref{volno-file}.
  2463. @opindex wildcards, summary
  2464. @item --wildcards
  2465. Use wildcards when excluding files.
  2466. @xref{controlling pattern-matching with exclude}.
  2467. @opindex wildcards-match-slash, summary
  2468. @item --wildcards-match-slash
  2469. Wildcards match @samp{/} when excluding files.
  2470. @xref{controlling pattern-matching with exclude}.
  2471. @end table
  2472. @node Short Option Summary
  2473. @subsection Short Options Cross Reference
  2474. Here is an alphabetized list of all of the short option forms, matching
  2475. them with the equivalent long option.
  2476. @table @option
  2477. @item -A
  2478. @option{--concatenate}
  2479. @item -B
  2480. @option{--read-full-records}
  2481. @item -C
  2482. @option{--directory}
  2483. @item -F
  2484. @option{--info-script}
  2485. @item -G
  2486. @option{--incremental}
  2487. @item -K
  2488. @option{--starting-file}
  2489. @item -L
  2490. @option{--tape-length}
  2491. @item -M
  2492. @option{--multi-volume}
  2493. @item -N
  2494. @option{--newer}
  2495. @item -O
  2496. @option{--to-stdout}
  2497. @item -P
  2498. @option{--absolute-names}
  2499. @item -R
  2500. @option{--block-number}
  2501. @item -S
  2502. @option{--sparse}
  2503. @item -T
  2504. @option{--files-from}
  2505. @item -U
  2506. @option{--unlink-first}
  2507. @item -V
  2508. @option{--label}
  2509. @item -W
  2510. @option{--verify}
  2511. @item -X
  2512. @option{--exclude-from}
  2513. @item -Z
  2514. @option{--compress}
  2515. @item -b
  2516. @option{--blocking-factor}
  2517. @item -c
  2518. @option{--create}
  2519. @item -d
  2520. @option{--compare}
  2521. @item -f
  2522. @option{--file}
  2523. @item -g
  2524. @option{--listed-incremental}
  2525. @item -h
  2526. @option{--dereference}
  2527. @item -i
  2528. @option{--ignore-zeros}
  2529. @item -j
  2530. @option{--bzip2}
  2531. @item -k
  2532. @option{--keep-old-files}
  2533. @item -l
  2534. @option{--one-file-system}. Use of this short option is deprecated. It
  2535. is retained for compatibility with the earlier versions of GNU
  2536. @command{tar}, and will be changed in future releases.
  2537. @xref{Changes}, for more information.
  2538. @item -m
  2539. @option{--touch}
  2540. @item -o
  2541. When creating --- @option{--no-same-owner}, when extracting ---
  2542. @option{--portability}.
  2543. The later usage is deprecated. It is retained for compatibility with
  2544. the earlier versions of @GNUTAR{}. In the future releases
  2545. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2546. @item -p
  2547. @option{--preserve-permissions}
  2548. @item -r
  2549. @option{--append}
  2550. @item -s
  2551. @option{--same-order}
  2552. @item -t
  2553. @option{--list}
  2554. @item -u
  2555. @option{--update}
  2556. @item -v
  2557. @option{--verbose}
  2558. @item -w
  2559. @option{--interactive}
  2560. @item -x
  2561. @option{--extract}
  2562. @item -z
  2563. @option{--gzip}
  2564. @end table
  2565. @node help
  2566. @section @GNUTAR{} documentation
  2567. @cindex Getting program version number
  2568. @opindex version
  2569. @cindex Version of the @command{tar} program
  2570. Being careful, the first thing is really checking that you are using
  2571. @GNUTAR{}, indeed. The @option{--version} option
  2572. causes @command{tar} to print information about its name, version,
  2573. origin and legal status, all on standard output, and then exit
  2574. successfully. For example, @w{@samp{tar --version}} might print:
  2575. @smallexample
  2576. tar (GNU tar) 1.15.2
  2577. Copyright (C) 2006 Free Software Foundation, Inc.
  2578. This is free software. You may redistribute copies of it under the terms of
  2579. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2580. There is NO WARRANTY, to the extent permitted by law.
  2581. Written by John Gilmore and Jay Fenlason.
  2582. @end smallexample
  2583. @noindent
  2584. The first occurrence of @samp{tar} in the result above is the program
  2585. name in the package (for example, @command{rmt} is another program),
  2586. while the second occurrence of @samp{tar} is the name of the package
  2587. itself, containing possibly many programs. The package is currently
  2588. named @samp{tar}, after the name of the main program it
  2589. contains@footnote{There are plans to merge the @command{cpio} and
  2590. @command{tar} packages into a single one which would be called
  2591. @code{paxutils}. So, who knows if, one of this days, the
  2592. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2593. paxutils) 3.2}}}.
  2594. @cindex Obtaining help
  2595. @cindex Listing all @command{tar} options
  2596. @opindex help, introduction
  2597. Another thing you might want to do is checking the spelling or meaning
  2598. of some particular @command{tar} option, without resorting to this
  2599. manual, for once you have carefully read it. @GNUTAR{}
  2600. has a short help feature, triggerable through the
  2601. @option{--help} option. By using this option, @command{tar} will
  2602. print a usage message listing all available options on standard
  2603. output, then exit successfully, without doing anything else and
  2604. ignoring all other options. Even if this is only a brief summary, it
  2605. may be several screens long. So, if you are not using some kind of
  2606. scrollable window, you might prefer to use something like:
  2607. @smallexample
  2608. $ @kbd{tar --help | less}
  2609. @end smallexample
  2610. @noindent
  2611. presuming, here, that you like using @command{less} for a pager. Other
  2612. popular pagers are @command{more} and @command{pg}. If you know about some
  2613. @var{keyword} which interests you and do not want to read all the
  2614. @option{--help} output, another common idiom is doing:
  2615. @smallexample
  2616. tar --help | grep @var{keyword}
  2617. @end smallexample
  2618. @noindent
  2619. for getting only the pertinent lines. Notice, however, that some
  2620. @command{tar} options have long description lines and the above
  2621. command will list only the first of them.
  2622. The exact look of the option summary displayed by @kbd{tar --help} is
  2623. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2624. @opindex usage
  2625. If you only wish to check the spelling of an option, running @kbd{tar
  2626. --usage} may be a better choice. This will display a terse list of
  2627. @command{tar} option without accompanying explanations.
  2628. The short help output is quite succinct, and you might have to get
  2629. back to the full documentation for precise points. If you are reading
  2630. this paragraph, you already have the @command{tar} manual in some
  2631. form. This manual is available in a variety of forms from
  2632. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2633. distribution, provided you have @TeX{} already installed somewhere,
  2634. and a laser printer around. Just configure the distribution, execute
  2635. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2636. usual way (contact your local guru to know how). If @GNUTAR{}
  2637. has been conveniently installed at your place, this
  2638. manual is also available in interactive, hypertextual form as an Info
  2639. file. Just call @w{@samp{info tar}} or, if you do not have the
  2640. @command{info} program handy, use the Info reader provided within
  2641. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2642. There is currently no @code{man} page for @GNUTAR{}.
  2643. If you observe such a @code{man} page on the system you are running,
  2644. either it does not belong to @GNUTAR{}, or it has not
  2645. been produced by @acronym{GNU}. Some package maintainers convert
  2646. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2647. any case, please bear in mind that the authoritative source of
  2648. information about @GNUTAR{} is this Texinfo documentation.
  2649. @node defaults
  2650. @section Obtaining @GNUTAR{} default values
  2651. @opindex show-defaults
  2652. @GNUTAR{} has some predefined defaults that are used when you do not
  2653. explicitely specify another values. To obtain a list of such
  2654. defaults, use @option{--show-defaults} option. This will output the
  2655. values in the form of @command{tar} command line options:
  2656. @smallexample
  2657. @group
  2658. @kbd{tar --show-defaults}
  2659. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2660. @end group
  2661. @end smallexample
  2662. @noindent
  2663. The above output shows that this version of @GNUTAR{} defaults to
  2664. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2665. output as the archive, if no @option{--file} option has been given
  2666. (@pxref{file tutorial}), the default blocking factor is 20
  2667. (@pxref{Blocking Factor}). It also shows the default locations where
  2668. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2669. @node verbose
  2670. @section Checking @command{tar} progress
  2671. Typically, @command{tar} performs most operations without reporting any
  2672. information to the user except error messages. When using @command{tar}
  2673. with many options, particularly ones with complicated or
  2674. difficult-to-predict behavior, it is possible to make serious mistakes.
  2675. @command{tar} provides several options that make observing @command{tar}
  2676. easier. These options cause @command{tar} to print information as it
  2677. progresses in its job, and you might want to use them just for being
  2678. more careful about what is going on, or merely for entertaining
  2679. yourself. If you have encountered a problem when operating on an
  2680. archive, however, you may need more information than just an error
  2681. message in order to solve the problem. The following options can be
  2682. helpful diagnostic tools.
  2683. @cindex Verbose operation
  2684. @opindex verbose
  2685. Normally, the @option{--list} (@option{-t}) command to list an archive
  2686. prints just the file names (one per line) and the other commands are
  2687. silent. When used with most operations, the @option{--verbose}
  2688. (@option{-v}) option causes @command{tar} to print the name of each
  2689. file or archive member as it is processed. This and the other options
  2690. which make @command{tar} print status information can be useful in
  2691. monitoring @command{tar}.
  2692. With @option{--create} or @option{--extract}, @option{--verbose} used
  2693. once just prints the names of the files or members as they are processed.
  2694. Using it twice causes @command{tar} to print a longer listing
  2695. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2696. already prints the names of the members, @option{--verbose} used once
  2697. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2698. type listing of the files in the archive. The following examples both
  2699. extract members with long list output:
  2700. @smallexample
  2701. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2702. $ @kbd{tar xvvf archive.tar}
  2703. @end smallexample
  2704. Verbose output appears on the standard output except when an archive is
  2705. being written to the standard output, as with @samp{tar --create
  2706. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2707. installer let standard output be the default archive). In that case
  2708. @command{tar} writes verbose output to the standard error stream.
  2709. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2710. verbose output to @var{file} rather than to standard output or standard
  2711. error.
  2712. @cindex Obtaining total status information
  2713. @opindex totals
  2714. The @option{--totals} option---which is only meaningful when used with
  2715. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2716. amount written to the archive, after it has been fully created.
  2717. @cindex Progress information
  2718. @opindex checkpoint
  2719. The @option{--checkpoint} option prints an occasional message
  2720. as @command{tar} reads or writes the archive. In fact, it prints
  2721. a message each 10 records read or written. It is designed for
  2722. those who don't need the more detailed (and voluminous) output of
  2723. @option{--block-number} (@option{-R}), but do want visual confirmation that @command{tar}
  2724. is actually making forward progress.
  2725. @FIXME{There is some confusion here. It seems that -R once wrote a
  2726. message at @samp{every} record read or written.}
  2727. @opindex show-omitted-dirs
  2728. @anchor{show-omitted-dirs}
  2729. The @option{--show-omitted-dirs} option, when reading an archive---with
  2730. @option{--list} or @option{--extract}, for example---causes a message
  2731. to be printed for each directory in the archive which is skipped.
  2732. This happens regardless of the reason for skipping: the directory might
  2733. not have been named on the command line (implicitly or explicitly),
  2734. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2735. some other reason.
  2736. @opindex block-number
  2737. @cindex Block number where error occurred
  2738. @anchor{block-number}
  2739. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2740. every message it would normally produce, the block number within the
  2741. archive where the message was triggered. Also, supplementary messages
  2742. are triggered when reading blocks full of NULs, or when hitting end of
  2743. file on the archive. As of now, if the archive if properly terminated
  2744. with a NUL block, the reading of the file may stop before end of file
  2745. is met, so the position of end of file will not usually show when
  2746. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2747. drains the archive before exiting when reading the
  2748. archive from a pipe.
  2749. @cindex Error message, block number of
  2750. This option is especially useful when reading damaged archives, since
  2751. it helps pinpoint the damaged sections. It can also be used with
  2752. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2753. choose among several backup tapes when retrieving a file later, in
  2754. favor of the tape where the file appears earliest (closest to the
  2755. front of the tape). @xref{backup}.
  2756. @node interactive
  2757. @section Asking for Confirmation During Operations
  2758. @cindex Interactive operation
  2759. Typically, @command{tar} carries out a command without stopping for
  2760. further instructions. In some situations however, you may want to
  2761. exclude some files and archive members from the operation (for instance
  2762. if disk or storage space is tight). You can do this by excluding
  2763. certain files automatically (@pxref{Choosing}), or by performing
  2764. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2765. @command{tar} also accepts @option{--confirmation} for this option.
  2766. @opindex interactive
  2767. When the @option{--interactive} (@option{-w}) option is specified, before
  2768. reading, writing, or deleting files, @command{tar} first prints a message
  2769. for each such file, telling what operation it intends to take, then asks
  2770. for confirmation on the terminal. The actions which require
  2771. confirmation include adding a file to the archive, extracting a file
  2772. from the archive, deleting a file from the archive, and deleting a file
  2773. from disk. To confirm the action, you must type a line of input
  2774. beginning with @samp{y}. If your input line begins with anything other
  2775. than @samp{y}, @command{tar} skips that file.
  2776. If @command{tar} is reading the archive from the standard input,
  2777. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2778. communications.
  2779. Verbose output is normally sent to standard output, separate from
  2780. other error messages. However, if the archive is produced directly
  2781. on standard output, then verbose output is mixed with errors on
  2782. @code{stderr}. Producing the archive on standard output may be used
  2783. as a way to avoid using disk space, when the archive is soon to be
  2784. consumed by another process reading it, say. Some people felt the need
  2785. of producing an archive on stdout, still willing to segregate between
  2786. verbose output and error output. A possible approach would be using a
  2787. named pipe to receive the archive, and having the consumer process to
  2788. read from that named pipe. This has the advantage of letting standard
  2789. output free to receive verbose output, all separate from errors.
  2790. @node operations
  2791. @chapter @GNUTAR{} Operations
  2792. @menu
  2793. * Basic tar::
  2794. * Advanced tar::
  2795. * create options::
  2796. * extract options::
  2797. * backup::
  2798. * Applications::
  2799. * looking ahead::
  2800. @end menu
  2801. @node Basic tar
  2802. @section Basic @GNUTAR{} Operations
  2803. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2804. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2805. @option{-x}), are currently presented and described in the tutorial
  2806. chapter of this manual. This section provides some complementary notes
  2807. for these operations.
  2808. @table @option
  2809. @opindex create, complementary notes
  2810. @item --create
  2811. @itemx -c
  2812. Creating an empty archive would have some kind of elegance. One can
  2813. initialize an empty archive and later use @option{--append}
  2814. (@option{-r}) for adding all members. Some applications would not
  2815. welcome making an exception in the way of adding the first archive
  2816. member. On the other hand, many people reported that it is
  2817. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2818. an empty archive@footnote{This is well described in @cite{Unix-haters
  2819. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2820. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2821. @enumerate
  2822. @item
  2823. Mistakingly using @code{create} instead of @code{extract}, when the
  2824. intent was to extract the full contents of an archive. This error
  2825. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2826. the QWERTY keyboard. Instead of being unpacked, the archive then
  2827. gets wholly destroyed. When users speak about @dfn{exploding} an
  2828. archive, they usually mean something else :-).
  2829. @item
  2830. Forgetting the argument to @code{file}, when the intent was to create
  2831. an archive with a single file in it. This error is likely because a
  2832. tired user can easily add the @kbd{f} key to the cluster of option
  2833. letters, by the mere force of habit, without realizing the full
  2834. consequence of doing so. The usual consequence is that the single
  2835. file, which was meant to be saved, is rather destroyed.
  2836. @end enumerate
  2837. So, recognizing the likelihood and the catastrophical nature of these
  2838. errors, @GNUTAR{} now takes some distance from elegance, and
  2839. cowardly refuses to create an archive when @option{--create} option is
  2840. given, there are no arguments besides options, and
  2841. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2842. around the cautiousness of @GNUTAR{} and nevertheless create an
  2843. archive with nothing in it, one may still use, as the value for the
  2844. @option{--files-from} option, a file with no names in it, as shown in
  2845. the following commands:
  2846. @smallexample
  2847. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2848. @kbd{tar cfT empty-archive.tar /dev/null}
  2849. @end smallexample
  2850. @opindex extract, complementary notes
  2851. @item --extract
  2852. @itemx --get
  2853. @itemx -x
  2854. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2855. @item @option{--list} (@option{-t})
  2856. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2857. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2858. people should get used to ISO 8601 dates. Local American dates should
  2859. be made available again with full date localization support, once
  2860. ready. In the meantime, programs not being localizable for dates
  2861. should prefer international dates, that's really the way to go.
  2862. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2863. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2864. @end table
  2865. @node Advanced tar
  2866. @section Advanced @GNUTAR{} Operations
  2867. Now that you have learned the basics of using @GNUTAR{}, you may want
  2868. to learn about further ways in which @command{tar} can help you.
  2869. This chapter presents five, more advanced operations which you probably
  2870. won't use on a daily basis, but which serve more specialized functions.
  2871. We also explain the different styles of options and why you might want
  2872. to use one or another, or a combination of them in your @command{tar}
  2873. commands. Additionally, this chapter includes options which allow you to
  2874. define the output from @command{tar} more carefully, and provide help and
  2875. error correction in special circumstances.
  2876. @FIXME{check this after the chapter is actually revised to make sure
  2877. it still introduces the info in the chapter correctly : ).}
  2878. @menu
  2879. * Operations::
  2880. * append::
  2881. * update::
  2882. * concatenate::
  2883. * delete::
  2884. * compare::
  2885. @end menu
  2886. @node Operations
  2887. @subsection The Five Advanced @command{tar} Operations
  2888. @UNREVISED
  2889. In the last chapter, you learned about the first three operations to
  2890. @command{tar}. This chapter presents the remaining five operations to
  2891. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2892. @option{--delete}, and @option{--compare}.
  2893. You are not likely to use these operations as frequently as those
  2894. covered in the last chapter; however, since they perform specialized
  2895. functions, they are quite useful when you do need to use them. We
  2896. will give examples using the same directory and files that you created
  2897. in the last chapter. As you may recall, the directory is called
  2898. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2899. @samp{rock}, and the two archive files you created are
  2900. @samp{collection.tar} and @samp{music.tar}.
  2901. We will also use the archive files @samp{afiles.tar} and
  2902. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2903. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2904. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2905. Unless we state otherwise, all practicing you do and examples you follow
  2906. in this chapter will take place in the @file{practice} directory that
  2907. you created in the previous chapter; see @ref{prepare for examples}.
  2908. (Below in this section, we will remind you of the state of the examples
  2909. where the last chapter left them.)
  2910. The five operations that we will cover in this chapter are:
  2911. @table @option
  2912. @item --append
  2913. @itemx -r
  2914. Add new entries to an archive that already exists.
  2915. @item --update
  2916. @itemx -r
  2917. Add more recent copies of archive members to the end of an archive, if
  2918. they exist.
  2919. @item --concatenate
  2920. @itemx --catenate
  2921. @itemx -A
  2922. Add one or more pre-existing archives to the end of another archive.
  2923. @item --delete
  2924. Delete items from an archive (does not work on tapes).
  2925. @item --compare
  2926. @itemx --diff
  2927. @itemx -d
  2928. Compare archive members to their counterparts in the file system.
  2929. @end table
  2930. @node append
  2931. @subsection How to Add Files to Existing Archives: @option{--append}
  2932. @UNREVISED
  2933. @opindex append
  2934. If you want to add files to an existing archive, you don't need to
  2935. create a new archive; you can use @option{--append} (@option{-r}).
  2936. The archive must already exist in order to use @option{--append}. (A
  2937. related operation is the @option{--update} operation; you can use this
  2938. to add newer versions of archive members to an existing archive. To learn how to
  2939. do this with @option{--update}, @pxref{update}.)
  2940. If you use @option{--append} to add a file that has the same name as an
  2941. archive member to an archive containing that archive member, then the
  2942. old member is not deleted. What does happen, however, is somewhat
  2943. complex. @command{tar} @emph{allows} you to have infinite number of files
  2944. with the same name. Some operations treat these same-named members no
  2945. differently than any other set of archive members: for example, if you
  2946. view an archive with @option{--list} (@option{-t}), you will see all
  2947. of those members listed, with their data modification times, owners, etc.
  2948. Other operations don't deal with these members as perfectly as you might
  2949. prefer; if you were to use @option{--extract} to extract the archive,
  2950. only the most recently added copy of a member with the same name as four
  2951. other members would end up in the working directory. This is because
  2952. @option{--extract} extracts an archive in the order the members appeared
  2953. in the archive; the most recently archived members will be extracted
  2954. last. Additionally, an extracted member will @emph{replace} a file of
  2955. the same name which existed in the directory already, and @command{tar}
  2956. will not prompt you about this@footnote{Unless you give it
  2957. @option{--keep-old-files} option, or the disk copy is newer than the
  2958. the one in the archive and you invoke @command{tar} with
  2959. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2960. member will end up being extracted, as it will replace the one
  2961. extracted before it, and so on.
  2962. There exists a special option that allows you to get around this
  2963. behavior and extract (or list) only a particular copy of the file.
  2964. This is @option{--occurrence} option. If you run @command{tar} with
  2965. this option, it will extract only the first copy of the file. You
  2966. may also give this option an argument specifying the number of
  2967. copy to be extracted. Thus, for example if the archive
  2968. @file{archive.tar} contained three copies of file @file{myfile}, then
  2969. the command
  2970. @smallexample
  2971. tar --extract --file archive.tar --occurrence=2 myfile
  2972. @end smallexample
  2973. @noindent
  2974. would extract only the second copy. @xref{Option
  2975. Summary,---occurrence}, for the description of @option{--occurrence}
  2976. option.
  2977. @FIXME{ hag -- you might want to incorporate some of the above into the
  2978. MMwtSN node; not sure. i didn't know how to make it simpler...
  2979. There are a few ways to get around this. (maybe xref Multiple Members
  2980. with the Same Name.}
  2981. @cindex Members, replacing with other members
  2982. @cindex Replacing members with other members
  2983. If you want to replace an archive member, use @option{--delete} to
  2984. delete the member you want to remove from the archive, , and then use
  2985. @option{--append} to add the member you want to be in the archive. Note
  2986. that you can not change the order of the archive; the most recently
  2987. added member will still appear last. In this sense, you cannot truly
  2988. ``replace'' one member with another. (Replacing one member with another
  2989. will not work on certain types of media, such as tapes; see @ref{delete}
  2990. and @ref{Media}, for more information.)
  2991. @menu
  2992. * appending files:: Appending Files to an Archive
  2993. * multiple::
  2994. @end menu
  2995. @node appending files
  2996. @subsubsection Appending Files to an Archive
  2997. @UNREVISED
  2998. @cindex Adding files to an Archive
  2999. @cindex Appending files to an Archive
  3000. @cindex Archives, Appending files to
  3001. The simplest way to add a file to an already existing archive is the
  3002. @option{--append} (@option{-r}) operation, which writes specified files into the
  3003. archive whether or not they are already among the archived files.
  3004. When you use @option{--append}, you @emph{must} specify file name
  3005. arguments, as there is no default. If you specify a file that already
  3006. exists in the archive, another copy of the file will be added to the
  3007. end of the archive. As with other operations, the member names of the
  3008. newly added files will be exactly the same as their names given on the
  3009. command line. The @option{--verbose} (@option{-v}) option will print
  3010. out the names of the files as they are written into the archive.
  3011. @option{--append} cannot be performed on some tape drives, unfortunately,
  3012. due to deficiencies in the formats those tape drives use. The archive
  3013. must be a valid @command{tar} archive, or else the results of using this
  3014. operation will be unpredictable. @xref{Media}.
  3015. To demonstrate using @option{--append} to add a file to an archive,
  3016. create a file called @file{rock} in the @file{practice} directory.
  3017. Make sure you are in the @file{practice} directory. Then, run the
  3018. following @command{tar} command to add @file{rock} to
  3019. @file{collection.tar}:
  3020. @smallexample
  3021. $ @kbd{tar --append --file=collection.tar rock}
  3022. @end smallexample
  3023. @noindent
  3024. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3025. @file{rock} has been added to the archive:
  3026. @smallexample
  3027. $ @kbd{tar --list --file=collection.tar}
  3028. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3029. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3030. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3031. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3032. @end smallexample
  3033. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3034. title claims it will become...}
  3035. @node multiple
  3036. @subsubsection Multiple Files with the Same Name
  3037. You can use @option{--append} (@option{-r}) to add copies of files which have been
  3038. updated since the archive was created. (However, we do not recommend
  3039. doing this since there is another @command{tar} option called
  3040. @option{--update}; @pxref{update} for more information. We describe this
  3041. use of @option{--append} here for the sake of completeness.) @FIXME{is
  3042. this really a good idea, to give this whole description for something
  3043. which i believe is basically a Stupid way of doing something? certain
  3044. aspects of it show ways in which tar is more broken than i'd personally
  3045. like to admit to, specifically the last sentence. On the other hand, i
  3046. don't think it's a good idea to be saying that we explicitly don't
  3047. recommend using something, but i can't see any better way to deal with
  3048. the situation.}When you extract the archive, the older version will be
  3049. effectively lost. This works because files are extracted from an
  3050. archive in the order in which they were archived. Thus, when the
  3051. archive is extracted, a file archived later in time will replace a
  3052. file of the same name which was archived earlier, even though the older
  3053. version of the file will remain in the archive unless you delete all
  3054. versions of the file.
  3055. Supposing you change the file @file{blues} and then append the changed
  3056. version to @file{collection.tar}. As you saw above, the original
  3057. @file{blues} is in the archive @file{collection.tar}. If you change the
  3058. file and append the new version of the file to the archive, there will
  3059. be two copies in the archive. When you extract the archive, the older
  3060. version of the file will be extracted first, and then replaced by the
  3061. newer version when it is extracted.
  3062. You can append the new, changed copy of the file @file{blues} to the
  3063. archive in this way:
  3064. @smallexample
  3065. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3066. blues
  3067. @end smallexample
  3068. @noindent
  3069. Because you specified the @option{--verbose} option, @command{tar} has
  3070. printed the name of the file being appended as it was acted on. Now
  3071. list the contents of the archive:
  3072. @smallexample
  3073. $ @kbd{tar --list --verbose --file=collection.tar}
  3074. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3075. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3076. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3077. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3078. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3079. @end smallexample
  3080. @noindent
  3081. The newest version of @file{blues} is now at the end of the archive
  3082. (note the different creation dates and file sizes). If you extract
  3083. the archive, the older version of the file @file{blues} will be
  3084. replaced by the newer version. You can confirm this by extracting
  3085. the archive and running @samp{ls} on the directory.
  3086. If you wish to extract the first occurrence of the file @file{blues}
  3087. from the archive, use @option{--occurrence} option, as shown in
  3088. the following example:
  3089. @smallexample
  3090. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3091. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3092. @end smallexample
  3093. @xref{Writing}, for more information on @option{--extract} and
  3094. @xref{Option Summary, --occurrence}, for the description of
  3095. @option{--occurrence} option.
  3096. @node update
  3097. @subsection Updating an Archive
  3098. @UNREVISED
  3099. @cindex Updating an archive
  3100. @opindex update
  3101. In the previous section, you learned how to use @option{--append} to
  3102. add a file to an existing archive. A related operation is
  3103. @option{--update} (@option{-u}). The @option{--update} operation
  3104. updates a @command{tar} archive by comparing the date of the specified
  3105. archive members against the date of the file with the same name. If
  3106. the file has been modified more recently than the archive member, then
  3107. the newer version of the file is added to the archive (as with
  3108. @option{--append}).
  3109. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3110. The operation will fail.
  3111. @FIXME{other examples of media on which --update will fail? need to ask
  3112. charles and/or mib/thomas/dave shevett..}
  3113. Both @option{--update} and @option{--append} work by adding to the end
  3114. of the archive. When you extract a file from the archive, only the
  3115. version stored last will wind up in the file system, unless you use
  3116. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3117. Same Name}
  3118. @menu
  3119. * how to update::
  3120. @end menu
  3121. @node how to update
  3122. @subsubsection How to Update an Archive Using @option{--update}
  3123. You must use file name arguments with the @option{--update} (@option{-u}) operation.
  3124. If you don't specify any files, @command{tar} won't act on any files and
  3125. won't tell you that it didn't do anything (which may end up confusing
  3126. you).
  3127. @FIXME{note: the above parenthetical added because in fact, this
  3128. behavior just confused the author. :-) }
  3129. To see the @option{--update} option at work, create a new file,
  3130. @file{classical}, in your practice directory, and some extra text to the
  3131. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3132. the @samp{update} operation and the @option{--verbose} (@option{-v}) option specified,
  3133. using the names of all the files in the practice directory as file name
  3134. arguments:
  3135. @smallexample
  3136. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3137. blues
  3138. classical
  3139. $
  3140. @end smallexample
  3141. @noindent
  3142. Because we have specified verbose mode, @command{tar} prints out the names
  3143. of the files it is working on, which in this case are the names of the
  3144. files that needed to be updated. If you run @samp{tar --list} and look
  3145. at the archive, you will see @file{blues} and @file{classical} at its
  3146. end. There will be a total of two versions of the member @samp{blues};
  3147. the one at the end will be newer and larger, since you added text before
  3148. updating it.
  3149. (The reason @command{tar} does not overwrite the older file when updating
  3150. it is because writing to the middle of a section of tape is a difficult
  3151. process. Tapes are not designed to go backward. @xref{Media}, for more
  3152. information about tapes.
  3153. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3154. reasons: it does not change directory content entries, and it
  3155. lengthens the archive every time it is used. The @GNUTAR{}
  3156. options intended specifically for backups are more
  3157. efficient. If you need to run backups, please consult @ref{Backups}.
  3158. @node concatenate
  3159. @subsection Combining Archives with @option{--concatenate}
  3160. @cindex Adding archives to an archive
  3161. @cindex Concatenating Archives
  3162. @opindex concatenate
  3163. @opindex catenate
  3164. @c @cindex @option{-A} described
  3165. Sometimes it may be convenient to add a second archive onto the end of
  3166. an archive rather than adding individual files to the archive. To add
  3167. one or more archives to the end of another archive, you should use the
  3168. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3169. To use @option{--concatenate}, give the first archive with
  3170. @option{--file} option and name the rest of archives to be
  3171. concatenated on the command line. The members, and their member
  3172. names, will be copied verbatim from those archives to the first one.
  3173. @FIXME-ref{This can cause multiple members to have the same name, for
  3174. information on how this affects reading the archive, Multiple
  3175. Members with the Same Name.}
  3176. The new, concatenated archive will be called by the same name as the
  3177. one given with the @option{--file} option. As usual, if you omit
  3178. @option{--file}, @command{tar} will use the value of the environment
  3179. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3180. @FIXME{There is no way to specify a new name...}
  3181. To demonstrate how @option{--concatenate} works, create two small archives
  3182. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3183. files from @file{practice}:
  3184. @smallexample
  3185. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3186. blues
  3187. rock
  3188. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3189. folk
  3190. jazz
  3191. @end smallexample
  3192. @noindent
  3193. If you like, You can run @samp{tar --list} to make sure the archives
  3194. contain what they are supposed to:
  3195. @smallexample
  3196. $ @kbd{tar -tvf bluesrock.tar}
  3197. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3198. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3199. $ @kbd{tar -tvf jazzfolk.tar}
  3200. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3201. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3202. @end smallexample
  3203. We can concatenate these two archives with @command{tar}:
  3204. @smallexample
  3205. $ @kbd{cd ..}
  3206. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3207. @end smallexample
  3208. If you now list the contents of the @file{bluesrock.tar}, you will see
  3209. that now it also contains the archive members of @file{jazzfolk.tar}:
  3210. @smallexample
  3211. $ @kbd{tar --list --file=bluesrock.tar}
  3212. blues
  3213. rock
  3214. folk
  3215. jazz
  3216. @end smallexample
  3217. When you use @option{--concatenate}, the source and target archives must
  3218. already exist and must have been created using compatible format
  3219. parameters. Notice, that @command{tar} does not check whether the
  3220. archives it concatenates have compatible formats, it does not
  3221. even check if the files are really tar archives.
  3222. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3223. tape drives, due to deficiencies in the formats those tape drives use.
  3224. @cindex @code{concatenate} vs @command{cat}
  3225. @cindex @command{cat} vs @code{concatenate}
  3226. It may seem more intuitive to you to want or try to use @command{cat} to
  3227. concatenate two archives instead of using the @option{--concatenate}
  3228. operation; after all, @command{cat} is the utility for combining files.
  3229. However, @command{tar} archives incorporate an end-of-file marker which
  3230. must be removed if the concatenated archives are to be read properly as
  3231. one archive. @option{--concatenate} removes the end-of-archive marker
  3232. from the target archive before each new archive is appended. If you use
  3233. @command{cat} to combine the archives, the result will not be a valid
  3234. @command{tar} format archive. If you need to retrieve files from an
  3235. archive that was added to using the @command{cat} utility, use the
  3236. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3237. information on dealing with archives improperly combined using the
  3238. @command{cat} shell utility.
  3239. @node delete
  3240. @subsection Removing Archive Members Using @option{--delete}
  3241. @UNREVISED
  3242. @cindex Deleting files from an archive
  3243. @cindex Removing files from an archive
  3244. @opindex delete
  3245. You can remove members from an archive by using the @option{--delete}
  3246. option. Specify the name of the archive with @option{--file}
  3247. (@option{-f}) and then specify the names of the members to be deleted;
  3248. if you list no member names, nothing will be deleted. The
  3249. @option{--verbose} option will cause @command{tar} to print the names
  3250. of the members as they are deleted. As with @option{--extract}, you
  3251. must give the exact member names when using @samp{tar --delete}.
  3252. @option{--delete} will remove all versions of the named file from the
  3253. archive. The @option{--delete} operation can run very slowly.
  3254. Unlike other operations, @option{--delete} has no short form.
  3255. @cindex Tapes, using @option{--delete} and
  3256. @cindex Deleting from tape archives
  3257. This operation will rewrite the archive. You can only use
  3258. @option{--delete} on an archive if the archive device allows you to
  3259. write to any point on the media, such as a disk; because of this, it
  3260. does not work on magnetic tapes. Do not try to delete an archive member
  3261. from a magnetic tape; the action will not succeed, and you will be
  3262. likely to scramble the archive and damage your tape. There is no safe
  3263. way (except by completely re-writing the archive) to delete files from
  3264. most kinds of magnetic tape. @xref{Media}.
  3265. To delete all versions of the file @file{blues} from the archive
  3266. @file{collection.tar} in the @file{practice} directory, make sure you
  3267. are in that directory, and then,
  3268. @smallexample
  3269. $ @kbd{tar --list --file=collection.tar}
  3270. blues
  3271. folk
  3272. jazz
  3273. rock
  3274. practice/blues
  3275. practice/folk
  3276. practice/jazz
  3277. practice/rock
  3278. practice/blues
  3279. $ @kbd{tar --delete --file=collection.tar blues}
  3280. $ @kbd{tar --list --file=collection.tar}
  3281. folk
  3282. jazz
  3283. rock
  3284. $
  3285. @end smallexample
  3286. @FIXME{I changed the order of these nodes around and haven't had a chance
  3287. to fix the above example's results, yet. I have to play with this and
  3288. follow it and see what it actually does!}
  3289. The @option{--delete} option has been reported to work properly when
  3290. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3291. @node compare
  3292. @subsection Comparing Archive Members with the File System
  3293. @cindex Verifying the currency of an archive
  3294. @UNREVISED
  3295. @opindex compare
  3296. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3297. specified archive members against files with the same names, and then
  3298. reports differences in file size, mode, owner, modification date and
  3299. contents. You should @emph{only} specify archive member names, not file
  3300. names. If you do not name any members, then @command{tar} will compare the
  3301. entire archive. If a file is represented in the archive but does not
  3302. exist in the file system, @command{tar} reports a difference.
  3303. You have to specify the record size of the archive when modifying an
  3304. archive with a non-default record size.
  3305. @command{tar} ignores files in the file system that do not have
  3306. corresponding members in the archive.
  3307. The following example compares the archive members @file{rock},
  3308. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3309. files of the same name in the file system. (Note that there is no file,
  3310. @file{funk}; @command{tar} will report an error message.)
  3311. @smallexample
  3312. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3313. rock
  3314. blues
  3315. tar: funk not found in archive
  3316. @end smallexample
  3317. The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
  3318. archive represents the current state of files on disk, more than validating
  3319. the integrity of the archive media. For this later goal, @xref{verify}.
  3320. @node create options
  3321. @section Options Used by @option{--create}
  3322. @opindex create, additional options
  3323. The previous chapter described the basics of how to use
  3324. @option{--create} (@option{-c}) to create an archive from a set of files.
  3325. @xref{create}. This section described advanced options to be used with
  3326. @option{--create}.
  3327. @menu
  3328. * Ignore Failed Read::
  3329. @end menu
  3330. @node Ignore Failed Read
  3331. @subsection Ignore Fail Read
  3332. @table @option
  3333. @item --ignore-failed-read
  3334. Do not exit with nonzero on unreadable files or directories.
  3335. @end table
  3336. @node extract options
  3337. @section Options Used by @option{--extract}
  3338. @UNREVISED
  3339. @FIXME{i need to get dan to go over these options with me and see if
  3340. there's a better way of organizing them.}
  3341. @opindex extract, additional options
  3342. The previous chapter showed how to use @option{--extract} to extract
  3343. an archive into the file system. Various options cause @command{tar} to
  3344. extract more information than just file contents, such as the owner,
  3345. the permissions, the modification date, and so forth. This section
  3346. presents options to be used with @option{--extract} when certain special
  3347. considerations arise. You may review the information presented in
  3348. @ref{extract} for more basic information about the
  3349. @option{--extract} operation.
  3350. @menu
  3351. * Reading:: Options to Help Read Archives
  3352. * Writing:: Changing How @command{tar} Writes Files
  3353. * Scarce:: Coping with Scarce Resources
  3354. @end menu
  3355. @node Reading
  3356. @subsection Options to Help Read Archives
  3357. @cindex Options when reading archives
  3358. @UNREVISED
  3359. @cindex Reading incomplete records
  3360. @cindex Records, incomplete
  3361. @opindex read-full-records
  3362. Normally, @command{tar} will request data in full record increments from
  3363. an archive storage device. If the device cannot return a full record,
  3364. @command{tar} will report an error. However, some devices do not always
  3365. return full records, or do not require the last record of an archive to
  3366. be padded out to the next record boundary. To keep reading until you
  3367. obtain a full record, or to accept an incomplete record if it contains
  3368. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3369. in conjunction with the @option{--extract} or @option{--list} operations.
  3370. @xref{Blocking}.
  3371. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3372. @command{tar} reads an archive from standard input, or from a remote
  3373. machine. This is because on BSD Unix systems, attempting to read a
  3374. pipe returns however much happens to be in the pipe, even if it is
  3375. less than was requested. If this option were not enabled, @command{tar}
  3376. would fail as soon as it read an incomplete record from the pipe.
  3377. If you're not sure of the blocking factor of an archive, you can
  3378. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3379. @option{--blocking-factor=@var{512-size}} (@option{-b
  3380. @var{512-size}}), using a blocking factor larger than what the archive
  3381. uses. This lets you avoid having to determine the blocking factor
  3382. of an archive. @xref{Blocking Factor}.
  3383. @menu
  3384. * read full records::
  3385. * Ignore Zeros::
  3386. @end menu
  3387. @node read full records
  3388. @unnumberedsubsubsec Reading Full Records
  3389. @FIXME{need sentence or so of intro here}
  3390. @table @option
  3391. @opindex read-full-records
  3392. @item --read-full-records
  3393. @item -B
  3394. Use in conjunction with @option{--extract} (@option{--get},
  3395. @option{-x}) to read an archive which contains incomplete records, or
  3396. one which has a blocking factor less than the one specified.
  3397. @end table
  3398. @node Ignore Zeros
  3399. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3400. @cindex End-of-archive blocks, ignoring
  3401. @cindex Ignoring end-of-archive blocks
  3402. @opindex ignore-zeros
  3403. Normally, @command{tar} stops reading when it encounters a block of zeros
  3404. between file entries (which usually indicates the end of the archive).
  3405. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3406. completely read an archive which contains a block of zeros before the
  3407. end (i.e., a damaged archive, or one that was created by concatenating
  3408. several archives together).
  3409. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3410. versions of @command{tar} write garbage after the end-of-archive entry,
  3411. since that part of the media is never supposed to be read. @GNUTAR{}
  3412. does not write after the end of an archive, but seeks to
  3413. maintain compatiblity among archiving utilities.
  3414. @table @option
  3415. @item --ignore-zeros
  3416. @itemx -i
  3417. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3418. encountered while reading an archive. Use in conjunction with
  3419. @option{--extract} or @option{--list}.
  3420. @end table
  3421. @node Writing
  3422. @subsection Changing How @command{tar} Writes Files
  3423. @UNREVISED
  3424. @FIXME{Introductory paragraph}
  3425. @menu
  3426. * Dealing with Old Files::
  3427. * Overwrite Old Files::
  3428. * Keep Old Files::
  3429. * Keep Newer Files::
  3430. * Unlink First::
  3431. * Recursive Unlink::
  3432. * Data Modification Times::
  3433. * Setting Access Permissions::
  3434. * Directory Modification Times and Permissions::
  3435. * Writing to Standard Output::
  3436. * Writing to an External Program::
  3437. * remove files::
  3438. @end menu
  3439. @node Dealing with Old Files
  3440. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3441. @opindex overwrite-dir, introduced
  3442. When extracting files, if @command{tar} discovers that the extracted
  3443. file already exists, it normally replaces the file by removing it before
  3444. extracting it, to prevent confusion in the presence of hard or symbolic
  3445. links. (If the existing file is a symbolic link, it is removed, not
  3446. followed.) However, if a directory cannot be removed because it is
  3447. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3448. permission, etc.). The @option{--overwrite-dir} option enables this
  3449. default behavior. To be more cautious and preserve the metadata of
  3450. such a directory, use the @option{--no-overwrite-dir} option.
  3451. @cindex Overwriting old files, prevention
  3452. @opindex keep-old-files, introduced
  3453. To be even more cautious and prevent existing files from being replaced, use
  3454. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3455. to replace or update a file that already exists, i.e., a file with the
  3456. same name as an archive member prevents extraction of that archive
  3457. member. Instead, it reports an error.
  3458. @opindex overwrite, introduced
  3459. To be more aggressive about altering existing files, use the
  3460. @option{--overwrite} option. It causes @command{tar} to overwrite
  3461. existing files and to follow existing symbolic links when extracting.
  3462. @cindex Protecting old files
  3463. Some people argue that @GNUTAR{} should not hesitate
  3464. to overwrite files with other files when extracting. When extracting
  3465. a @command{tar} archive, they expect to see a faithful copy of the
  3466. state of the file system when the archive was created. It is debatable
  3467. that this would always be a proper behavior. For example, suppose one
  3468. has an archive in which @file{usr/local} is a link to
  3469. @file{usr/local2}. Since then, maybe the site removed the link and
  3470. renamed the whole hierarchy from @file{/usr/local2} to
  3471. @file{/usr/local}. Such things happen all the time. I guess it would
  3472. not be welcome at all that @GNUTAR{} removes the
  3473. whole hierarchy just to make room for the link to be reinstated
  3474. (unless it @emph{also} simultaneously restores the full
  3475. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3476. able to remove a whole hierarchy to reestablish a symbolic link, for
  3477. example, but @emph{only if} @option{--recursive-unlink} is specified
  3478. to allow this behavior. In any case, single files are silently
  3479. removed.
  3480. @opindex unlink-first, introduced
  3481. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3482. some cases by causing @command{tar} to remove files unconditionally
  3483. before extracting them.
  3484. @node Overwrite Old Files
  3485. @unnumberedsubsubsec Overwrite Old Files
  3486. @table @option
  3487. @opindex overwrite
  3488. @item --overwrite
  3489. Overwrite existing files and directory metadata when extracting files
  3490. from an archive.
  3491. This causes @command{tar} to write extracted files into the file system without
  3492. regard to the files already on the system; i.e., files with the same
  3493. names as archive members are overwritten when the archive is extracted.
  3494. It also causes @command{tar} to extract the ownership, permissions,
  3495. and time stamps onto any preexisting files or directories.
  3496. If the name of a corresponding file name is a symbolic link, the file
  3497. pointed to by the symbolic link will be overwritten instead of the
  3498. symbolic link itself (if this is possible). Moreover, special devices,
  3499. empty directories and even symbolic links are automatically removed if
  3500. they are in the way of extraction.
  3501. Be careful when using the @option{--overwrite} option, particularly when
  3502. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3503. can change the contents, ownership or permissions of any file on your
  3504. system. Also, many systems do not take kindly to overwriting files that
  3505. are currently being executed.
  3506. @opindex overwrite-dir
  3507. @item --overwrite-dir
  3508. Overwrite the metadata of directories when extracting files from an
  3509. archive, but remove other files before extracting.
  3510. @end table
  3511. @node Keep Old Files
  3512. @unnumberedsubsubsec Keep Old Files
  3513. @table @option
  3514. @opindex keep-old-files
  3515. @item --keep-old-files
  3516. @itemx -k
  3517. Do not replace existing files from archive. The
  3518. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3519. from replacing existing files with files with the same name from the
  3520. archive. The @option{--keep-old-files} option is meaningless with
  3521. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3522. files in the file system during extraction.
  3523. @end table
  3524. @node Keep Newer Files
  3525. @unnumberedsubsubsec Keep Newer Files
  3526. @table @option
  3527. @opindex keep-newer-files
  3528. @item --keep-newer-files
  3529. Do not replace existing files that are newer than their archive
  3530. copies. This option is meaningless with @option{--list} (@option{-t}).
  3531. @end table
  3532. @node Unlink First
  3533. @unnumberedsubsubsec Unlink First
  3534. @table @option
  3535. @opindex unlink-first
  3536. @item --unlink-first
  3537. @itemx -U
  3538. Remove files before extracting over them.
  3539. This can make @command{tar} run a bit faster if you know in advance
  3540. that the extracted files all need to be removed. Normally this option
  3541. slows @command{tar} down slightly, so it is disabled by default.
  3542. @end table
  3543. @node Recursive Unlink
  3544. @unnumberedsubsubsec Recursive Unlink
  3545. @table @option
  3546. @opindex recursive-unlink
  3547. @item --recursive-unlink
  3548. When this option is specified, try removing files and directory hierarchies
  3549. before extracting over them. @emph{This is a dangerous option!}
  3550. @end table
  3551. If you specify the @option{--recursive-unlink} option,
  3552. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3553. as far as current permissions will allow it. This could include removal
  3554. of the contents of a full directory hierarchy.
  3555. @node Data Modification Times
  3556. @unnumberedsubsubsec Setting Data Modification Times
  3557. @cindex Data modification times of extracted files
  3558. @cindex Modification times of extracted files
  3559. Normally, @command{tar} sets the data modification times of extracted
  3560. files to the corresponding times recorded for the files in the archive, but
  3561. limits the permissions of extracted files by the current @code{umask}
  3562. setting.
  3563. To set the data modification times of extracted files to the time when
  3564. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3565. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3566. @table @option
  3567. @opindex touch
  3568. @item --touch
  3569. @itemx -m
  3570. Sets the data modification time of extracted archive members to the time
  3571. they were extracted, not the time recorded for them in the archive.
  3572. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3573. @end table
  3574. @node Setting Access Permissions
  3575. @unnumberedsubsubsec Setting Access Permissions
  3576. @cindex Permissions of extracted files
  3577. @cindex Modes of extracted files
  3578. To set the modes (access permissions) of extracted files to those
  3579. recorded for those files in the archive, use @option{--same-permissions}
  3580. in conjunction with the @option{--extract} (@option{--get},
  3581. @option{-x}) operation. @FIXME{Should be aliased to ignore-umask.}
  3582. @table @option
  3583. @opindex preserve-permission
  3584. @opindex same-permission
  3585. @item --preserve-permission
  3586. @itemx --same-permission
  3587. @c @itemx --ignore-umask
  3588. @itemx -p
  3589. Set modes of extracted archive members to those recorded in the
  3590. archive, instead of current umask settings. Use in conjunction with
  3591. @option{--extract} (@option{--get}, @option{-x}).
  3592. @end table
  3593. @node Directory Modification Times and Permissions
  3594. @unnumberedsubsubsec Directory Modification Times and Permissions
  3595. After sucessfully extracting a file member, @GNUTAR{} normally
  3596. restores its permissions and modification times, as described in the
  3597. previous sections. This cannot be done for directories, because
  3598. after extracting a directory @command{tar} will almost certainly
  3599. extract files into that directory and this will cause the directory
  3600. modification time to be updated. Moreover, restoring that directory
  3601. permissions may not permit file creation within it. Thus, restoring
  3602. directory permissions and modification times must be delayed at least
  3603. until all files have been extracted into that directory. @GNUTAR{}
  3604. restores directories using the following approach.
  3605. The extracted directories are created with the mode specified in the
  3606. archive, as modified by the umask of the user, which gives sufficient
  3607. permissions to allow file creation. The meta-information about the
  3608. directory is recorded in the temporary list of directories. When
  3609. preparing to extract next archive member, @GNUTAR{} checks if the
  3610. directory prefix of this file contains the remembered directory. If
  3611. it does not, the program assumes that all files have been extracted
  3612. into that directory, restores its modification time and permissions
  3613. and removes its entry from the internal list. This approach allows
  3614. to correctly restore directory meta-information in the majority of
  3615. cases, while keeping memory requirements sufficiently small. It is
  3616. based on the fact, that most @command{tar} archives use the predefined
  3617. order of members: first the directory, then all the files and
  3618. subdirectories in that directory.
  3619. However, this is not always true. The most important exception are
  3620. incremental archives (@pxref{Incremental Dumps}). The member order in
  3621. an incremental archive is reversed: first all directory members are
  3622. stored, followed by other (non-directory) members. So, when extracting
  3623. from incremental archives, @GNUTAR{} alters the above procedure. It
  3624. remebers all restored directories, and restores their meta-data
  3625. only after the entire archive has been processed. Notice, that you do
  3626. not need to specity any special options for that, as @GNUTAR{}
  3627. automatically detects archives in incremental format.
  3628. There may be cases, when such processing is required for normal archives
  3629. too. Consider the following example:
  3630. @smallexample
  3631. @group
  3632. $ @kbd{tar --no-recursion -cvf archive \
  3633. foo foo/file1 bar bar/file foo/file2}
  3634. foo/
  3635. foo/file1
  3636. bar/
  3637. bar/file
  3638. foo/file2
  3639. @end group
  3640. @end smallexample
  3641. During the normal operation, after encountering @file{bar}
  3642. @GNUTAR{} will assume that all files from the directory @file{foo}
  3643. were already extracted and will therefore restore its timestamp and
  3644. permission bits. However, after extracting @file{foo/file2} the
  3645. directory timestamp will be offset again.
  3646. To correctly restore directory meta-information in such cases, use
  3647. @option{delay-directory-restore} command line option:
  3648. @table @option
  3649. @opindex delay-directory-restore
  3650. @item --delay-directory-restore
  3651. Delays restoring of the modification times and permissions of extracted
  3652. directories until the end of extraction. This way, correct
  3653. meta-information is restored even if the archive has unusual member
  3654. ordering.
  3655. @opindex no-delay-directory-restore
  3656. @item --no-delay-directory-restore
  3657. Cancel the effect of the previous @option{--delay-directory-restore}.
  3658. Use this option if you have used @option{--delay-directory-restore} in
  3659. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3660. temporarily disable it.
  3661. @end table
  3662. @node Writing to Standard Output
  3663. @unnumberedsubsubsec Writing to Standard Output
  3664. @cindex Writing extracted files to standard output
  3665. @cindex Standard output, writing extracted files to
  3666. To write the extracted files to the standard output, instead of
  3667. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3668. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3669. extracting files to send them through a pipe, and do not need to
  3670. preserve them in the file system. If you extract multiple members,
  3671. they appear on standard output concatenated, in the order they are
  3672. found in the archive.
  3673. @table @option
  3674. @opindex to-stdout
  3675. @item --to-stdout
  3676. @itemx -O
  3677. Writes files to the standard output. Use only in conjunction with
  3678. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3679. used, instead of creating the files specified, @command{tar} writes
  3680. the contents of the files extracted to its standard output. This may
  3681. be useful if you are only extracting the files in order to send them
  3682. through a pipe. This option is meaningless with @option{--list}
  3683. (@option{-t}).
  3684. @end table
  3685. This can be useful, for example, if you have a tar archive containing
  3686. a big file and don't want to store the file on disk before processing
  3687. it. You can use a command like this:
  3688. @smallexample
  3689. tar -xOzf foo.tgz bigfile | process
  3690. @end smallexample
  3691. or even like this if you want to process the concatenation of the files:
  3692. @smallexample
  3693. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3694. @end smallexample
  3695. Hovewer, @option{--to-command} may be more convenient for use with
  3696. multiple files. See the next section.
  3697. @node Writing to an External Program
  3698. @unnumberedsubsubsec Writing to an External Program
  3699. You can instruct @command{tar} to send the contents of each extracted
  3700. file to the standard input of an external program:
  3701. @table @option
  3702. @opindex to-command
  3703. @item --to-command=@var{command}
  3704. Extract files and pipe their contents to the standard input of
  3705. @var{command}. When this option is used, instead of creating the
  3706. files specified, @command{tar} invokes @var{command} and pipes the
  3707. contents of the files to its standard output. @var{Command} may
  3708. contain command line arguments. The program is executed via
  3709. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3710. extracted. Non-regular files (directories, etc.) are ignored when this
  3711. option is used.
  3712. @end table
  3713. The command can obtain the information about the file it processes
  3714. from the following environment variables:
  3715. @table @var
  3716. @vrindex TAR_FILETYPE, to-command environment
  3717. @item TAR_FILETYPE
  3718. Type of the file. It is a single letter with the following meaning:
  3719. @multitable @columnfractions 0.10 0.90
  3720. @item f @tab Regular file
  3721. @item d @tab Directory
  3722. @item l @tab Symbolic link
  3723. @item h @tab Hard link
  3724. @item b @tab Block device
  3725. @item c @tab Character device
  3726. @end multitable
  3727. Currently only regular files are supported.
  3728. @vrindex TAR_MODE, to-command environment
  3729. @item TAR_MODE
  3730. File mode, an octal number.
  3731. @vrindex TAR_FILENAME, to-command environment
  3732. @item TAR_FILENAME
  3733. The name of the file.
  3734. @vrindex TAR_REALNAME, to-command environment
  3735. @item TAR_REALNAME
  3736. Name of the file as stored in the archive.
  3737. @vrindex TAR_UNAME, to-command environment
  3738. @item TAR_UNAME
  3739. Name of the file owner.
  3740. @vrindex TAR_GNAME, to-command environment
  3741. @item TAR_GNAME
  3742. Name of the file owner group.
  3743. @vrindex TAR_ATIME, to-command environment
  3744. @item TAR_ATIME
  3745. Time of last access. It is a decimal number, representing seconds
  3746. since the epoch. If the archive provides times with nanosecond
  3747. precision, the nanoseconds are appended to the timestamp after a
  3748. decimal point.
  3749. @vrindex TAR_MTIME, to-command environment
  3750. @item TAR_MTIME
  3751. Time of last modification.
  3752. @vrindex TAR_CTIME, to-command environment
  3753. @item TAR_CTIME
  3754. Time of last status change.
  3755. @vrindex TAR_SIZE, to-command environment
  3756. @item TAR_SIZE
  3757. Size of the file.
  3758. @vrindex TAR_UID, to-command environment
  3759. @item TAR_UID
  3760. UID of the file owner.
  3761. @vrindex TAR_GID, to-command environment
  3762. @item TAR_GID
  3763. GID of the file owner.
  3764. @end table
  3765. In addition to these variables, @env{TAR_VERSION} contains the
  3766. @GNUTAR{} version number.
  3767. If @var{command} exits with a non-0 status, @command{tar} will print
  3768. an error message similar to the following:
  3769. @smallexample
  3770. tar: 2345: Child returned status 1
  3771. @end smallexample
  3772. Here, @samp{2345} is the PID of the finished process.
  3773. If this behavior is not wanted, use @option{--ignore-command-error}:
  3774. @table @option
  3775. @opindex ignore-command-error
  3776. @item --ignore-command-error
  3777. Ignore exit codes of subprocesses. Notice that if the program
  3778. exits on signal or otherwise terminates abnormally, the error message
  3779. will be printed even if this option is used.
  3780. @opindex no-ignore-command-error
  3781. @item --no-ignore-command-error
  3782. Cancel the effect of any previous @option{--ignore-command-error}
  3783. option. This option is useful if you have set
  3784. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3785. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3786. @end table
  3787. @node remove files
  3788. @unnumberedsubsubsec Removing Files
  3789. @FIXME{the various macros in the front of the manual think that this
  3790. option goes in this section. i have no idea; i only know it's nowhere
  3791. else in the book...}
  3792. @table @option
  3793. @opindex remove-files
  3794. @item --remove-files
  3795. Remove files after adding them to the archive.
  3796. @end table
  3797. @node Scarce
  3798. @subsection Coping with Scarce Resources
  3799. @UNREVISED
  3800. @cindex Small memory
  3801. @cindex Running out of space
  3802. @menu
  3803. * Starting File::
  3804. * Same Order::
  3805. @end menu
  3806. @node Starting File
  3807. @unnumberedsubsubsec Starting File
  3808. @table @option
  3809. @opindex starting-file
  3810. @item --starting-file=@var{name}
  3811. @itemx -K @var{name}
  3812. Starts an operation in the middle of an archive. Use in conjunction
  3813. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3814. @end table
  3815. @cindex Middle of the archive, starting in the
  3816. If a previous attempt to extract files failed due to lack of disk
  3817. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3818. @var{name}}) to start extracting only after member @var{name} of the
  3819. archive. This assumes, of course, that there is now free space, or
  3820. that you are now extracting into a different file system. (You could
  3821. also choose to suspend @command{tar}, remove unnecessary files from
  3822. the file system, and then restart the same @command{tar} operation.
  3823. In this case, @option{--starting-file} is not necessary.
  3824. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3825. @node Same Order
  3826. @unnumberedsubsubsec Same Order
  3827. @table @option
  3828. @cindex Large lists of file names on small machines
  3829. @opindex same-order
  3830. @opindex preserve-order
  3831. @item --same-order
  3832. @itemx --preserve-order
  3833. @itemx -s
  3834. To process large lists of file names on machines with small amounts of
  3835. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3836. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3837. (@option{--get}, @option{-x}).
  3838. @end table
  3839. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3840. names to be listed or extracted is sorted in the same order as the
  3841. files in the archive. This allows a large list of names to be used,
  3842. even on a small machine that would not otherwise be able to hold all
  3843. the names in memory at the same time. Such a sorted list can easily be
  3844. created by running @samp{tar -t} on the archive and editing its output.
  3845. This option is probably never needed on modern computer systems.
  3846. @node backup
  3847. @section Backup options
  3848. @cindex backup options
  3849. @GNUTAR{} offers options for making backups of files
  3850. before writing new versions. These options control the details of
  3851. these backups. They may apply to the archive itself before it is
  3852. created or rewritten, as well as individual extracted members. Other
  3853. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3854. and @command{mv}, for example) offer similar options.
  3855. Backup options may prove unexpectedly useful when extracting archives
  3856. containing many members having identical name, or when extracting archives
  3857. on systems having file name limitations, making different members appear
  3858. has having similar names through the side-effect of name truncation.
  3859. (This is true only if we have a good scheme for truncated backup names,
  3860. which I'm not sure at all: I suspect work is needed in this area.)
  3861. When any existing file is backed up before being overwritten by extraction,
  3862. then clashing files are automatically be renamed to be unique, and the
  3863. true name is kept for only the last file of a series of clashing files.
  3864. By using verbose mode, users may track exactly what happens.
  3865. At the detail level, some decisions are still experimental, and may
  3866. change in the future, we are waiting comments from our users. So, please
  3867. do not learn to depend blindly on the details of the backup features.
  3868. For example, currently, directories themselves are never renamed through
  3869. using these options, so, extracting a file over a directory still has
  3870. good chances to fail. Also, backup options apply to created archives,
  3871. not only to extracted members. For created archives, backups will not
  3872. be attempted when the archive is a block or character device, or when it
  3873. refers to a remote file.
  3874. For the sake of simplicity and efficiency, backups are made by renaming old
  3875. files prior to creation or extraction, and not by copying. The original
  3876. name is restored if the file creation fails. If a failure occurs after a
  3877. partial extraction of a file, both the backup and the partially extracted
  3878. file are kept.
  3879. @table @samp
  3880. @item --backup[=@var{method}]
  3881. @opindex backup
  3882. @vindex VERSION_CONTROL
  3883. @cindex backups
  3884. Back up files that are about to be overwritten or removed.
  3885. Without this option, the original versions are destroyed.
  3886. Use @var{method} to determine the type of backups made.
  3887. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3888. environment variable. And if @env{VERSION_CONTROL} is not set,
  3889. use the @samp{existing} method.
  3890. @vindex version-control @r{Emacs variable}
  3891. This option corresponds to the Emacs variable @samp{version-control};
  3892. the same values for @var{method} are accepted as in Emacs. This option
  3893. also allows more descriptive names. The valid @var{method}s are:
  3894. @table @samp
  3895. @item t
  3896. @itemx numbered
  3897. @cindex numbered @r{backup method}
  3898. Always make numbered backups.
  3899. @item nil
  3900. @itemx existing
  3901. @cindex existing @r{backup method}
  3902. Make numbered backups of files that already have them, simple backups
  3903. of the others.
  3904. @item never
  3905. @itemx simple
  3906. @cindex simple @r{backup method}
  3907. Always make simple backups.
  3908. @end table
  3909. @item --suffix=@var{suffix}
  3910. @opindex suffix
  3911. @cindex backup suffix
  3912. @vindex SIMPLE_BACKUP_SUFFIX
  3913. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3914. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3915. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3916. set, the default is @samp{~}, just as in Emacs.
  3917. @end table
  3918. Some people express the desire to @emph{always} use the @option{--backup}
  3919. option, by defining some kind of alias or script. This is not as easy
  3920. as one may think, due to the fact that old style options should appear first
  3921. and consume arguments a bit unpredictably for an alias or script. But,
  3922. if you are ready to give up using old style options, you may resort to
  3923. using something like (a Bourne shell function here):
  3924. @smallexample
  3925. tar () @{ /usr/local/bin/tar --backup $*; @}
  3926. @end smallexample
  3927. @node Applications
  3928. @section Notable @command{tar} Usages
  3929. @UNREVISED
  3930. @FIXME{Using Unix file linking capability to recreate directory
  3931. structures---linking files into one subdirectory and then
  3932. @command{tar}ring that directory.}
  3933. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3934. @findex uuencode
  3935. You can easily use archive files to transport a group of files from
  3936. one system to another: put all relevant files into an archive on one
  3937. computer system, transfer the archive to another system, and extract
  3938. the contents there. The basic transfer medium might be magnetic tape,
  3939. Internet FTP, or even electronic mail (though you must encode the
  3940. archive with @command{uuencode} in order to transport it properly by
  3941. mail). Both machines do not have to use the same operating system, as
  3942. long as they both support the @command{tar} program.
  3943. For example, here is how you might copy a directory's contents from
  3944. one disk to another, while preserving the dates, modes, owners and
  3945. link-structure of all the files therein. In this case, the transfer
  3946. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3947. @smallexample
  3948. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3949. @end smallexample
  3950. @noindent
  3951. The command also works using short option forms:
  3952. @smallexample
  3953. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3954. @end smallexample
  3955. @noindent
  3956. This is one of the easiest methods to transfer a @command{tar} archive.
  3957. @node looking ahead
  3958. @section Looking Ahead: The Rest of this Manual
  3959. You have now seen how to use all eight of the operations available to
  3960. @command{tar}, and a number of the possible options. The next chapter
  3961. explains how to choose and change file and archive names, how to use
  3962. files to store names of other files which you can then call as
  3963. arguments to @command{tar} (this can help you save time if you expect to
  3964. archive the same list of files a number of times), and so forth.
  3965. @FIXME{in case it's not obvious, i'm making this up in some sense
  3966. based on my limited memory of what the next chapter *really* does. i
  3967. just wanted to flesh out this final section a little bit so i'd
  3968. remember to stick it in here. :-)}
  3969. If there are too many files to conveniently list on the command line,
  3970. you can list the names in a file, and @command{tar} will read that file.
  3971. @xref{files}.
  3972. There are various ways of causing @command{tar} to skip over some files,
  3973. and not archive them. @xref{Choosing}.
  3974. @node Backups
  3975. @chapter Performing Backups and Restoring Files
  3976. @UNREVISED
  3977. @GNUTAR{} is distributed along with the scripts
  3978. which the Free Software Foundation uses for performing backups. There
  3979. is no corresponding scripts available yet for doing restoration of
  3980. files. Even if there is a good chance those scripts may be satisfying
  3981. to you, they are not the only scripts or methods available for doing
  3982. backups and restore. You may well create your own, or use more
  3983. sophisticated packages dedicated to that purpose.
  3984. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3985. Automatic Network Disk Archiver), a backup system developed by James
  3986. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3987. This is free software, and it is available at these places:
  3988. @smallexample
  3989. http://www.cs.umd.edu/projects/amanda/amanda.html
  3990. ftp://ftp.cs.umd.edu/pub/amanda
  3991. @end smallexample
  3992. @FIXME{
  3993. Here is a possible plan for a future documentation about the backuping
  3994. scripts which are provided within the @GNUTAR{}
  3995. distribution.
  3996. @itemize @bullet
  3997. @item dumps
  3998. @itemize @minus
  3999. @item what are dumps
  4000. @item different levels of dumps
  4001. @itemize +
  4002. @item full dump = dump everything
  4003. @item level 1, level 2 dumps etc
  4004. A level @var{n} dump dumps everything changed since the last level
  4005. @var{n}-1 dump (?)
  4006. @end itemize
  4007. @item how to use scripts for dumps (ie, the concept)
  4008. @itemize +
  4009. @item scripts to run after editing backup specs (details)
  4010. @end itemize
  4011. @item Backup Specs, what is it.
  4012. @itemize +
  4013. @item how to customize
  4014. @item actual text of script [/sp/dump/backup-specs]
  4015. @end itemize
  4016. @item Problems
  4017. @itemize +
  4018. @item rsh doesn't work
  4019. @item rtape isn't installed
  4020. @item (others?)
  4021. @end itemize
  4022. @item the @option{--incremental} option of tar
  4023. @item tapes
  4024. @itemize +
  4025. @item write protection
  4026. @item types of media, different sizes and types, useful for different things
  4027. @item files and tape marks
  4028. one tape mark between files, two at end.
  4029. @item positioning the tape
  4030. MT writes two at end of write,
  4031. backspaces over one when writing again.
  4032. @end itemize
  4033. @end itemize
  4034. @end itemize
  4035. }
  4036. This chapter documents both the provided shell scripts and @command{tar}
  4037. options which are more specific to usage as a backup tool.
  4038. To @dfn{back up} a file system means to create archives that contain
  4039. all the files in that file system. Those archives can then be used to
  4040. restore any or all of those files (for instance if a disk crashes or a
  4041. file is accidentally deleted). File system @dfn{backups} are also
  4042. called @dfn{dumps}.
  4043. @menu
  4044. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4045. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4046. * Backup Levels:: Levels of Backups
  4047. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4048. * Scripted Backups:: Using the Backup Scripts
  4049. * Scripted Restoration:: Using the Restore Script
  4050. @end menu
  4051. @node Full Dumps
  4052. @section Using @command{tar} to Perform Full Dumps
  4053. @UNREVISED
  4054. @cindex full dumps
  4055. @cindex dumps, full
  4056. @cindex corrupted archives
  4057. Full dumps should only be made when no other people or programs
  4058. are modifying files in the file system. If files are modified while
  4059. @command{tar} is making the backup, they may not be stored properly in
  4060. the archive, in which case you won't be able to restore them if you
  4061. have to. (Files not being modified are written with no trouble, and do
  4062. not corrupt the entire archive.)
  4063. You will want to use the @option{--label=@var{archive-label}}
  4064. (@option{-V @var{archive-label}}) option to give the archive a
  4065. volume label, so you can tell what this archive is even if the label
  4066. falls off the tape, or anything like that.
  4067. Unless the file system you are dumping is guaranteed to fit on
  4068. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4069. Make sure you have enough tapes on hand to complete the backup.
  4070. If you want to dump each file system separately you will need to use
  4071. the @option{--one-file-system} (@option{-l}) option to prevent
  4072. @command{tar} from crossing file system boundaries when storing
  4073. (sub)directories.
  4074. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4075. option is not needed, since this is a complete copy of everything in
  4076. the file system, and a full restore from this backup would only be
  4077. done onto a completely
  4078. empty disk.
  4079. Unless you are in a hurry, and trust the @command{tar} program (and your
  4080. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4081. option, to make sure your files really made it onto the dump properly.
  4082. This will also detect cases where the file was modified while (or just
  4083. after) it was being archived. Not all media (notably cartridge tapes)
  4084. are capable of being verified, unfortunately.
  4085. @node Incremental Dumps
  4086. @section Using @command{tar} to Perform Incremental Dumps
  4087. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4088. stores additional metadata so that exact state of the file system
  4089. can be restored when extracting the archive.
  4090. @GNUTAR{} currently offers two options for handling incremental
  4091. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4092. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4093. @opindex listed-incremental
  4094. The option @option{--listed-incremental} instructs tar to operate on
  4095. an incremental archive with additional metadata stored in a standalone
  4096. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4097. determine which files have been changed, added or deleted since the
  4098. last backup, so that the next incremental backup will contain only
  4099. modified files. The name of the snapshot file is given as an argument
  4100. to the option:
  4101. @table @option
  4102. @item --listed-incremental=@var{file}
  4103. @itemx -g @var{file}
  4104. Handle incremental backups with snapshot data in @var{file}.
  4105. @end table
  4106. To create an incremental backup, you would use
  4107. @option{--listed-incremental} together with @option{--create}
  4108. (@pxref{create}). For example:
  4109. @smallexample
  4110. $ @kbd{tar --create \
  4111. --file=archive.1.tar \
  4112. --listed-incremental=/var/log/usr.snar \
  4113. /usr}
  4114. @end smallexample
  4115. This will create in @file{archive.1.tar} an incremental backup of
  4116. the @file{/usr} file system, storing additional metadata in the file
  4117. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4118. created. The created archive will then be a @dfn{level 0 backup};
  4119. please see the next section for more on backup levels.
  4120. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4121. determines which files are modified. In this case only these files will be
  4122. stored in the archive. Suppose, for example, that after running the
  4123. above command, you delete file @file{/usr/doc/old} and create
  4124. directory @file{/usr/local/db} with the following contents:
  4125. @smallexample
  4126. $ @kbd{ls /usr/local/db}
  4127. /usr/local/db/data
  4128. /usr/local/db/index
  4129. @end smallexample
  4130. Some time later you create another incremental backup. You will
  4131. then see:
  4132. @smallexample
  4133. $ @kbd{tar --create \
  4134. --file=archive.2.tar \
  4135. --listed-incremental=/var/log/usr.snar \
  4136. /usr}
  4137. tar: usr/local/db: Directory is new
  4138. usr/local/db/
  4139. usr/local/db/data
  4140. usr/local/db/index
  4141. @end smallexample
  4142. @noindent
  4143. The created archive @file{archive.2.tar} will contain only these
  4144. three members. This archive is called a @dfn{level 1 backup}. Notice
  4145. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4146. you plan to create more @samp{level 1} backups, it is necessary to
  4147. create a working copy of the snapshot file before running
  4148. @command{tar}. The above example will then be modified as follows:
  4149. @smallexample
  4150. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4151. $ @kbd{tar --create \
  4152. --file=archive.2.tar \
  4153. --listed-incremental=/var/log/usr.snar-1 \
  4154. /usr}
  4155. @end smallexample
  4156. Incremental dumps depend crucially on time stamps, so the results are
  4157. unreliable if you modify a file's time stamps during dumping (e.g.,
  4158. with the @option{--atime-preserve=replace} option), or if you set the clock
  4159. backwards.
  4160. Metadata stored in snapshot files include device numbers, which,
  4161. obviously is supposed to be a non-volatile value. However, it turns
  4162. out that NFS devices have undependable values when an automounter
  4163. gets in the picture. This can lead to a great deal of spurious
  4164. redumping in incremental dumps, so it is somewhat useless to compare
  4165. two NFS devices numbers over time. The solution implemented currently
  4166. is to considers all NFS devices as being equal when it comes to
  4167. comparing directories; this is fairly gross, but there does not seem
  4168. to be a better way to go.
  4169. Note that incremental archives use @command{tar} extensions and may
  4170. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4171. @opindex listed-incremental, using with @option{--extract}
  4172. @opindex extract, using with @option{--listed-incremental}
  4173. To extract from the incremental dumps, use
  4174. @option{--listed-incremental} together with @option{--extract}
  4175. option (@pxref{extracting files}). In this case, @command{tar} does
  4176. not need to access snapshot file, since all the data necessary for
  4177. extraction are stored in the archive itself. So, when extracting, you
  4178. can give whatever argument to @option{--listed-incremental}, the usual
  4179. practice is to use @option{--listed-incremental=/dev/null}.
  4180. Alternatively, you can use @option{--incremental}, which needs no
  4181. arguments. In general, @option{--incremental} (@option{-G}) can be
  4182. used as a shortcut for @option{--listed-incremental} when listing or
  4183. extracting incremental backups (for more information, regarding this
  4184. option, @pxref{incremental-op}).
  4185. When extracting from the incremental backup @GNUTAR{} attempts to
  4186. restore the exact state the file system had when the archive was
  4187. created. In particular, it will @emph{delete} those files in the file
  4188. system that did not exist in their directories when the archive was
  4189. created. If you have created several levels of incremental files,
  4190. then in order to restore the exact contents the file system had when
  4191. the last level was created, you will need to restore from all backups
  4192. in turn. Continuing our example, to restore the state of @file{/usr}
  4193. file system, one would do@footnote{Notice, that since both archives
  4194. were created withouth @option{-P} option (@pxref{absolute}), these
  4195. commands should be run from the root file system.}:
  4196. @smallexample
  4197. $ @kbd{tar --extract \
  4198. --listed-incremental=/dev/null \
  4199. --file archive.1.tar}
  4200. $ @kbd{tar --extract \
  4201. --listed-incremental=/dev/null \
  4202. --file archive.2.tar}
  4203. @end smallexample
  4204. To list the contents of an incremental archive, use @option{--list}
  4205. (@pxref{list}), as usual. To obtain more information about the
  4206. archive, use @option{--listed-incremental} or @option{--incremental}
  4207. combined with two @option{--verbose} options@footnote{Two
  4208. @option{--verbose} options were selected to avoid breaking usual
  4209. verbose listing output (@option{--list --verbose}) when using in
  4210. scripts.
  4211. @opindex incremental, using with @option{--list}
  4212. @opindex listed-incremental, using with @option{--list}
  4213. @opindex list, using with @option{--incremental}
  4214. @opindex list, using with @option{--listed-incremental}
  4215. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4216. contents of the DUMPDIR header (with terminating nulls) when
  4217. @option{--incremental} or @option{--listed-incremental} option was
  4218. given, no matter what the verbosity level. This behavior, and,
  4219. especially, the binary output it produced were considered incovenient
  4220. and were changed in version 1.16}:
  4221. @smallexample
  4222. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4223. @end smallexample
  4224. This command will print, for each directory in the archive, the list
  4225. of files in that directory at the time the archive was created. This
  4226. information is put out in a format which is both human-readable and
  4227. unambiguous for a program: each file name is printed as
  4228. @smallexample
  4229. @var{x} @var{file}
  4230. @end smallexample
  4231. @noindent
  4232. where @var{x} is a letter describing the status of the file: @samp{Y}
  4233. if the file is present in the archive, @samp{N} if the file is not
  4234. included in the archive, or a @samp{D} if the file is a directory (and
  4235. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4236. line is terminated by a newline character. The last line is followed
  4237. by an additional newline to indicate the end of the data.
  4238. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4239. gives the same behavior as @option{--listed-incremental} when used
  4240. with @option{--list} and @option{--extract} options. When used with
  4241. @option{--create} option, it creates an incremental archive without
  4242. creating snapshot file. Thus, it is impossible to create several
  4243. levels of incremental backups with @option{--incremental} option.
  4244. @node Backup Levels
  4245. @section Levels of Backups
  4246. An archive containing all the files in the file system is called a
  4247. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4248. creating a full dump every day. This strategy, however, would waste a
  4249. substantial amount of archive media and user time, as unchanged files
  4250. are daily re-archived.
  4251. It is more efficient to do a full dump only occasionally. To back up
  4252. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4253. one} dump archives all the files that have changed since the last full
  4254. dump.
  4255. A typical dump strategy would be to perform a full dump once a week,
  4256. and a level one dump once a day. This means some versions of files
  4257. will in fact be archived more than once, but this dump strategy makes
  4258. it possible to restore a file system to within one day of accuracy by
  4259. only extracting two archives---the last weekly (full) dump and the
  4260. last daily (level one) dump. The only information lost would be in
  4261. files changed or created since the last daily backup. (Doing dumps
  4262. more than once a day is usually not worth the trouble).
  4263. @GNUTAR{} comes with scripts you can use to do full
  4264. and level-one (actually, even level-two and so on) dumps. Using
  4265. scripts (shell programs) to perform backups and restoration is a
  4266. convenient and reliable alternative to typing out file name lists
  4267. and @command{tar} commands by hand.
  4268. Before you use these scripts, you need to edit the file
  4269. @file{backup-specs}, which specifies parameters used by the backup
  4270. scripts and by the restore script. This file is usually located
  4271. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4272. detailed description. Once the backup parameters are set, you can
  4273. perform backups or restoration by running the appropriate script.
  4274. The name of the backup script is @code{backup}. The name of the
  4275. restore script is @code{restore}. The following sections describe
  4276. their use in detail.
  4277. @emph{Please Note:} The backup and restoration scripts are
  4278. designed to be used together. While it is possible to restore files by
  4279. hand from an archive which was created using a backup script, and to create
  4280. an archive by hand which could then be extracted using the restore script,
  4281. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4282. making such an attempt.
  4283. @node Backup Parameters
  4284. @section Setting Parameters for Backups and Restoration
  4285. The file @file{backup-specs} specifies backup parameters for the
  4286. backup and restoration scripts provided with @command{tar}. You must
  4287. edit @file{backup-specs} to fit your system configuration and schedule
  4288. before using these scripts.
  4289. Syntactically, @file{backup-specs} is a shell script, containing
  4290. mainly variable assignments. However, any valid shell construct
  4291. is allowed in this file. Particularly, you may wish to define
  4292. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4293. For more information about shell script syntax, please refer to
  4294. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4295. g_02, the definition of the Shell Command Language}. See also
  4296. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4297. The shell variables controlling behavior of @code{backup} and
  4298. @code{restore} are described in the following subsections.
  4299. @menu
  4300. * General-Purpose Variables::
  4301. * Magnetic Tape Control::
  4302. * User Hooks::
  4303. * backup-specs example:: An Example Text of @file{Backup-specs}
  4304. @end menu
  4305. @node General-Purpose Variables
  4306. @subsection General-Purpose Variables
  4307. @defvr {Backup variable} ADMINISTRATOR
  4308. The user name of the backup administrator. @code{Backup} scripts
  4309. sends a backup report to this address.
  4310. @end defvr
  4311. @defvr {Backup variable} BACKUP_HOUR
  4312. The hour at which the backups are done. This can be a number from 0
  4313. to 23, or the time specification in form @var{hours}:@var{minutes},
  4314. or the string @samp{now}.
  4315. This variable is used by @code{backup}. Its value may be overridden
  4316. using @option{--time} option (@pxref{Scripted Backups}).
  4317. @end defvr
  4318. @defvr {Backup variable} TAPE_FILE
  4319. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4320. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4321. that your @command{mt} is able to access remote devices. If @var{RSH}
  4322. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4323. invocations of @command{mt}.
  4324. @end defvr
  4325. @defvr {Backup variable} BLOCKING
  4326. The blocking factor @command{tar} will use when writing the dump archive.
  4327. @xref{Blocking Factor}.
  4328. @end defvr
  4329. @defvr {Backup variable} BACKUP_DIRS
  4330. A list of file systems to be dumped (for @code{backup}), or restored
  4331. (for @code{restore}). You can include any directory
  4332. name in the list --- subdirectories on that file system will be
  4333. included, regardless of how they may look to other networked machines.
  4334. Subdirectories on other file systems will be ignored.
  4335. The host name specifies which host to run @command{tar} on, and should
  4336. normally be the host that actually contains the file system. However,
  4337. the host machine must have @GNUTAR{} installed, and
  4338. must be able to access the directory containing the backup scripts and
  4339. their support files using the same file name that is used on the
  4340. machine where the scripts are run (ie. what @command{pwd} will print
  4341. when in that directory on that machine). If the host that contains
  4342. the file system does not have this capability, you can specify another
  4343. host as long as it can access the file system through NFS.
  4344. If the list of file systems is very long you may wish to put it
  4345. in a separate file. This file is usually named
  4346. @file{/etc/backup/dirs}, but this name may be overridden in
  4347. @file{backup-specs} using @code{DIRLIST} variable.
  4348. @end defvr
  4349. @defvr {Backup variable} DIRLIST
  4350. A path to the file containing the list of the file systems to backup
  4351. or restore. By default it is @file{/etc/backup/dirs}.
  4352. @end defvr
  4353. @defvr {Backup variable} BACKUP_FILES
  4354. A list of individual files to be dumped (for @code{backup}), or restored
  4355. (for @code{restore}). These should be accessible from the machine on
  4356. which the backup script is run.
  4357. If the list of file systems is very long you may wish to store it
  4358. in a separate file. This file is usually named
  4359. @file{/etc/backup/files}, but this name may be overridden in
  4360. @file{backup-specs} using @code{FILELIST} variable.
  4361. @end defvr
  4362. @defvr {Backup variable} FILELIST
  4363. A path to the file containing the list of the individual files to backup
  4364. or restore. By default it is @file{/etc/backup/files}.
  4365. @end defvr
  4366. @defvr {Backup variable} MT
  4367. Full file name of @command{mt} binary.
  4368. @end defvr
  4369. @defvr {Backup variable} RSH
  4370. @anchor{RSH}
  4371. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4372. set it to @code{ssh}, to improve security. In this case you will have
  4373. to use public key authentication.
  4374. @end defvr
  4375. @defvr {Backup variable} RSH_COMMAND
  4376. Full file name of @command{rsh} binary on remote mashines. This will
  4377. be passed via @option{--rsh-command} option to the remote invocation
  4378. of @GNUTAR{}.
  4379. @end defvr
  4380. @defvr {Backup variable} VOLNO_FILE
  4381. Name of temporary file to hold volume numbers. This needs to be accessible
  4382. by all the machines which have file systems to be dumped.
  4383. @end defvr
  4384. @defvr {Backup variable} XLIST
  4385. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4386. located on the remote machine and containing the list of files to
  4387. be excluded from the backup. Exclude file lists are searched in
  4388. /etc/tar-backup directory. A common use for exclude file lists
  4389. is to exclude files containing security-sensitive information
  4390. (e.g., @file{/etc/shadow} from backups).
  4391. This variable affects only @code{backup}.
  4392. @end defvr
  4393. @defvr {Backup variable} SLEEP_TIME
  4394. Time to sleep between dumps of any two successive file systems
  4395. This variable affects only @code{backup}.
  4396. @end defvr
  4397. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4398. Script to be run when it's time to insert a new tape in for the next
  4399. volume. Administrators may want to tailor this script for their site.
  4400. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4401. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4402. the console.
  4403. @end defvr
  4404. @defvr {Backup variable} SLEEP_MESSAGE
  4405. Message to display on the terminal while waiting for dump time. Usually
  4406. this will just be some literal text.
  4407. @end defvr
  4408. @defvr {Backup variable} TAR
  4409. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4410. scripts will search @command{tar} in the current shell path.
  4411. @end defvr
  4412. @node Magnetic Tape Control
  4413. @subsection Magnetic Tape Control
  4414. Backup scripts access tape device using special @dfn{hook functions}.
  4415. These functions take a single argument -- the name of the tape
  4416. device. Their names are kept in the following variables:
  4417. @defvr {Backup variable} MT_BEGIN
  4418. The name of @dfn{begin} function. This function is called before
  4419. accessing the drive. By default it retensions the tape:
  4420. @smallexample
  4421. MT_BEGIN=mt_begin
  4422. mt_begin() @{
  4423. mt -f "$1" retension
  4424. @}
  4425. @end smallexample
  4426. @end defvr
  4427. @defvr {Backup variable} MT_REWIND
  4428. The name of @dfn{rewind} function. The default definition is as
  4429. follows:
  4430. @smallexample
  4431. MT_REWIND=mt_rewind
  4432. mt_rewind() @{
  4433. mt -f "$1" rewind
  4434. @}
  4435. @end smallexample
  4436. @end defvr
  4437. @defvr {Backup variable} MT_OFFLINE
  4438. The name of the function switching the tape off line. By default
  4439. it is defined as follows:
  4440. @smallexample
  4441. MT_OFFLINE=mt_offline
  4442. mt_offline() @{
  4443. mt -f "$1" offl
  4444. @}
  4445. @end smallexample
  4446. @end defvr
  4447. @defvr {Backup variable} MT_STATUS
  4448. The name of the function used to obtain the status of the archive device,
  4449. including error count. Default definition:
  4450. @smallexample
  4451. MT_STATUS=mt_status
  4452. mt_status() @{
  4453. mt -f "$1" status
  4454. @}
  4455. @end smallexample
  4456. @end defvr
  4457. @node User Hooks
  4458. @subsection User Hooks
  4459. @dfn{User hooks} are shell functions executed before and after
  4460. each @command{tar} invocation. Thus, there are @dfn{backup
  4461. hooks}, which are executed before and after dumping each file
  4462. system, and @dfn{restore hooks}, executed before and
  4463. after restoring a file system. Each user hook is a shell function
  4464. taking four arguments:
  4465. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4466. Its arguments are:
  4467. @table @var
  4468. @item level
  4469. Current backup or restore level.
  4470. @item host
  4471. Name or IP address of the host machine being dumped or restored.
  4472. @item fs
  4473. Full path name to the file system being dumped or restored.
  4474. @item fsname
  4475. File system name with directory separators replaced with colons. This
  4476. is useful, e.g., for creating unique files.
  4477. @end table
  4478. @end deffn
  4479. Following variables keep the names of user hook functions
  4480. @defvr {Backup variable} DUMP_BEGIN
  4481. Dump begin function. It is executed before dumping the file system.
  4482. @end defvr
  4483. @defvr {Backup variable} DUMP_END
  4484. Executed after dumping the file system.
  4485. @end defvr
  4486. @defvr {Backup variable} RESTORE_BEGIN
  4487. Executed before restoring the file system.
  4488. @end defvr
  4489. @defvr {Backup variable} RESTORE_END
  4490. Executed after restoring the file system.
  4491. @end defvr
  4492. @node backup-specs example
  4493. @subsection An Example Text of @file{Backup-specs}
  4494. The following is an example of @file{backup-specs}:
  4495. @smallexample
  4496. # site-specific parameters for file system backup.
  4497. ADMINISTRATOR=friedman
  4498. BACKUP_HOUR=1
  4499. TAPE_FILE=/dev/nrsmt0
  4500. # Use @code{ssh} instead of the less secure @code{rsh}
  4501. RSH=/usr/bin/ssh
  4502. RSH_COMMAND=/usr/bin/ssh
  4503. # Override MT_STATUS function:
  4504. my_status() @{
  4505. mts -t $TAPE_FILE
  4506. @}
  4507. MT_STATUS=my_status
  4508. # Disable MT_OFFLINE function
  4509. MT_OFFLINE=:
  4510. BLOCKING=124
  4511. BACKUP_DIRS="
  4512. albert:/fs/fsf
  4513. apple-gunkies:/gd
  4514. albert:/fs/gd2
  4515. albert:/fs/gp
  4516. geech:/usr/jla
  4517. churchy:/usr/roland
  4518. albert:/
  4519. albert:/usr
  4520. apple-gunkies:/
  4521. apple-gunkies:/usr
  4522. gnu:/hack
  4523. gnu:/u
  4524. apple-gunkies:/com/mailer/gnu
  4525. apple-gunkies:/com/archive/gnu"
  4526. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4527. @end smallexample
  4528. @node Scripted Backups
  4529. @section Using the Backup Scripts
  4530. The syntax for running a backup script is:
  4531. @smallexample
  4532. backup --level=@var{level} --time=@var{time}
  4533. @end smallexample
  4534. The @option{level} option requests the dump level. Thus, to produce
  4535. a full dump, specify @code{--level=0} (this is the default, so
  4536. @option{--level} may be omitted if its value is @code{0}).
  4537. @footnote{For backward compatibility, the @code{backup} will also
  4538. try to deduce the requested dump level from the name of the
  4539. script itself. If the name consists of a string @samp{level-}
  4540. followed by a single decimal digit, that digit is taken as
  4541. the dump level number. Thus, you may create a link from @code{backup}
  4542. to @code{level-1} and then run @code{level-1} whenever you need to
  4543. create a level one dump.}
  4544. The @option{--time} option determines when should the backup be
  4545. run. @var{Time} may take three forms:
  4546. @table @asis
  4547. @item @var{hh}:@var{mm}
  4548. The dump must be run at @var{hh} hours @var{mm} minutes.
  4549. @item @var{hh}
  4550. The dump must be run at @var{hh} hours
  4551. @item now
  4552. The dump must be run immediately.
  4553. @end table
  4554. You should start a script with a tape or disk mounted. Once you
  4555. start a script, it prompts you for new tapes or disks as it
  4556. needs them. Media volumes don't have to correspond to archive
  4557. files --- a multi-volume archive can be started in the middle of a
  4558. tape that already contains the end of another multi-volume archive.
  4559. The @code{restore} script prompts for media by its archive volume,
  4560. so to avoid an error message you should keep track of which tape
  4561. (or disk) contains which volume of the archive (@pxref{Scripted
  4562. Restoration}).
  4563. The backup scripts write two files on the file system. The first is a
  4564. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4565. to store and retrieve information about which files were dumped. This
  4566. file is not meant to be read by humans, and should not be deleted by
  4567. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4568. file.
  4569. The second file is a log file containing the names of the file systems
  4570. and files dumped, what time the backup was made, and any error
  4571. messages that were generated, as well as how much space was left in
  4572. the media volume after the last volume of the archive was written.
  4573. You should check this log file after every backup. The file name is
  4574. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4575. represents current date, and @var{n} represents current dump level number.
  4576. The script also prints the name of each system being dumped to the
  4577. standard output.
  4578. Following is the full list of options accepted by @code{backup}
  4579. script:
  4580. @table @option
  4581. @item -l @var{level}
  4582. @itemx --level=@var{level}
  4583. Do backup level @var{level} (default 0).
  4584. @item -f
  4585. @itemx --force
  4586. Force backup even if today's log file already exists.
  4587. @item -v[@var{level}]
  4588. @itemx --verbose[=@var{level}]
  4589. Set verbosity level. The higher the level is, the more debugging
  4590. information will be output during execution. Devault @var{level}
  4591. is 100, which means the highest debugging level.
  4592. @item -t @var{start-time}
  4593. @itemx --time=@var{start-time}
  4594. Wait till @var{time}, then do backup.
  4595. @item -h
  4596. @itemx --help
  4597. Display short help message and exit.
  4598. @item -V
  4599. @itemx --version
  4600. Display information about the program's name, version, origin and legal
  4601. status, all on standard output, and then exit successfully.
  4602. @end table
  4603. @node Scripted Restoration
  4604. @section Using the Restore Script
  4605. To restore files that were archived using a scripted backup, use the
  4606. @code{restore} script. Its usage is quite straightforward. In the
  4607. simplest form, invoke @code{restore --all}, it will
  4608. then restore all the file systems and files specified in
  4609. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4610. You may select the file systems (and/or files) to restore by
  4611. giving @code{restore} list of @dfn{patterns} in its command
  4612. line. For example, running
  4613. @smallexample
  4614. restore 'albert:*'
  4615. @end smallexample
  4616. @noindent
  4617. will restore all file systems on the machine @samp{albert}. A more
  4618. complicated example:
  4619. @smallexample
  4620. restore 'albert:*' '*:/var'
  4621. @end smallexample
  4622. @noindent
  4623. This command will restore all file systems on the machine @samp{albert}
  4624. as well as @file{/var} file system on all machines.
  4625. By default @code{restore} will start restoring files from the lowest
  4626. available dump level (usually zero) and will continue through
  4627. all available dump levels. There may be situations where such a
  4628. thorough restore is not necessary. For example, you may wish to
  4629. restore only files from the recent level one backup. To do so,
  4630. use @option{--level} option, as shown in the example below:
  4631. @smallexample
  4632. restore --level=1
  4633. @end smallexample
  4634. The full list of options accepted by @code{restore} follows:
  4635. @table @option
  4636. @item -a
  4637. @itemx --all
  4638. Restore all file systems and files specified in @file{backup-specs}
  4639. @item -l @var{level}
  4640. @itemx --level=@var{level}
  4641. Start restoring from the given backup level, instead of the default 0.
  4642. @item -v[@var{level}]
  4643. @itemx --verbose[=@var{level}]
  4644. Set verbosity level. The higher the level is, the more debugging
  4645. information will be output during execution. Devault @var{level}
  4646. is 100, which means the highest debugging level.
  4647. @item -h
  4648. @itemx --help
  4649. Display short help message and exit.
  4650. @item -V
  4651. @itemx --version
  4652. Display information about the program's name, version, origin and legal
  4653. status, all on standard output, and then exit successfully.
  4654. @end table
  4655. You should start the restore script with the media containing the
  4656. first volume of the archive mounted. The script will prompt for other
  4657. volumes as they are needed. If the archive is on tape, you don't need
  4658. to rewind the tape to to its beginning---if the tape head is
  4659. positioned past the beginning of the archive, the script will rewind
  4660. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4661. positioning.}
  4662. @quotation
  4663. @strong{Warning:} The script will delete files from the active file
  4664. system if they were not in the file system when the archive was made.
  4665. @end quotation
  4666. @xref{Incremental Dumps}, for an explanation of how the script makes
  4667. that determination.
  4668. @node Choosing
  4669. @chapter Choosing Files and Names for @command{tar}
  4670. @UNREVISED
  4671. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4672. Certain options to @command{tar} enable you to specify a name for your
  4673. archive. Other options let you decide which files to include or exclude
  4674. from the archive, based on when or whether files were modified, whether
  4675. the file names do or don't match specified patterns, or whether files
  4676. are in specified directories.
  4677. @menu
  4678. * file:: Choosing the Archive's Name
  4679. * Selecting Archive Members::
  4680. * files:: Reading Names from a File
  4681. * exclude:: Excluding Some Files
  4682. * Wildcards::
  4683. * after:: Operating Only on New Files
  4684. * recurse:: Descending into Directories
  4685. * one:: Crossing File System Boundaries
  4686. @end menu
  4687. @node file
  4688. @section Choosing and Naming Archive Files
  4689. @UNREVISED
  4690. @FIXME{should the title of this section actually be, "naming an
  4691. archive"?}
  4692. @cindex Naming an archive
  4693. @cindex Archive Name
  4694. @cindex Choosing an archive file
  4695. @cindex Where is the archive?
  4696. By default, @command{tar} uses an archive file name that was compiled when
  4697. it was built on the system; usually this name refers to some physical
  4698. tape drive on the machine. However, the person who installed @command{tar}
  4699. on the system may not set the default to a meaningful value as far as
  4700. most users are concerned. As a result, you will usually want to tell
  4701. @command{tar} where to find (or create) the archive. The @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4702. option allows you to either specify or name a file to use as the archive
  4703. instead of the default archive file location.
  4704. @table @option
  4705. @opindex file, short description
  4706. @item --file=@var{archive-name}
  4707. @itemx -f @var{archive-name}
  4708. Name the archive to create or operate on. Use in conjunction with
  4709. any operation.
  4710. @end table
  4711. For example, in this @command{tar} command,
  4712. @smallexample
  4713. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4714. @end smallexample
  4715. @noindent
  4716. @file{collection.tar} is the name of the archive. It must directly
  4717. follow the @option{-f} option, since whatever directly follows @option{-f}
  4718. @emph{will} end up naming the archive. If you neglect to specify an
  4719. archive name, you may end up overwriting a file in the working directory
  4720. with the archive you create since @command{tar} will use this file's name
  4721. for the archive name.
  4722. An archive can be saved as a file in the file system, sent through a
  4723. pipe or over a network, or written to an I/O device such as a tape,
  4724. floppy disk, or CD write drive.
  4725. @cindex Writing new archives
  4726. @cindex Archive creation
  4727. If you do not name the archive, @command{tar} uses the value of the
  4728. environment variable @env{TAPE} as the file name for the archive. If
  4729. that is not available, @command{tar} uses a default, compiled-in archive
  4730. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4731. @command{tar} always needs an archive name.
  4732. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4733. archive from standard input (when listing or extracting files), or
  4734. writes it to standard output (when creating an archive). If you use
  4735. @file{-} as an @var{archive-name} when modifying an archive,
  4736. @command{tar} reads the original archive from its standard input and
  4737. writes the entire new archive to its standard output.
  4738. @FIXME{might want a different example here; this is already used in
  4739. "notable tar usages".}
  4740. @smallexample
  4741. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4742. @end smallexample
  4743. @FIXME{help!}
  4744. @cindex Standard input and output
  4745. @cindex tar to standard input and output
  4746. @anchor{remote-dev}
  4747. To specify an archive file on a device attached to a remote machine,
  4748. use the following:
  4749. @smallexample
  4750. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4751. @end smallexample
  4752. @noindent
  4753. @command{tar} will complete the remote connection, if possible, and
  4754. prompt you for a username and password. If you use
  4755. @option{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4756. will complete the remote connection, if possible, using your username
  4757. as the username on the remote machine.
  4758. @cindex Local and remote archives
  4759. @anchor{local and remote archives}
  4760. If the archive file name includes a colon (@samp{:}), then it is assumed
  4761. to be a file on another machine. If the archive file is
  4762. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4763. host @var{host}. The remote host is accessed using the @command{rsh}
  4764. program, with a username of @var{user}. If the username is omitted
  4765. (along with the @samp{@@} sign), then your user name will be used.
  4766. (This is the normal @command{rsh} behavior.) It is necessary for the
  4767. remote machine, in addition to permitting your @command{rsh} access, to
  4768. have the @file{rmt} program installed (This command is included in
  4769. the @GNUTAR{} distribution and by default is installed under
  4770. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4771. installation prefix). If you need to use a file whose name includes a
  4772. colon, then the remote tape drive behavior
  4773. can be inhibited by using the @option{--force-local} option.
  4774. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4775. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4776. into what came before it well enough <<i moved it now, is it better
  4777. here?>>. bob also comments that if Amanda isn't free software, we
  4778. shouldn't mention it..}
  4779. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4780. tries to minimize input and output operations. The
  4781. Amanda backup system, when used with @GNUTAR{}, has
  4782. an initial sizing pass which uses this feature.
  4783. @node Selecting Archive Members
  4784. @section Selecting Archive Members
  4785. @cindex Specifying files to act on
  4786. @cindex Specifying archive members
  4787. @dfn{File Name arguments} specify which files in the file system
  4788. @command{tar} operates on, when creating or adding to an archive, or which
  4789. archive members @command{tar} operates on, when reading or deleting from
  4790. an archive. @xref{Operations}.
  4791. To specify file names, you can include them as the last arguments on
  4792. the command line, as follows:
  4793. @smallexample
  4794. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4795. @end smallexample
  4796. If a file name begins with dash (@samp{-}), preceede it with
  4797. @option{--add-file} option to preventit from being treated as an
  4798. option.
  4799. If you specify a directory name as a file name argument, all the files
  4800. in that directory are operated on by @command{tar}.
  4801. If you do not specify files when @command{tar} is invoked with
  4802. @option{--create} (@option{-c}), @command{tar} operates on all the non-directory files in
  4803. the working directory. If you specify either @option{--list} (@option{-t}) or
  4804. @option{--extract} (@option{--get}, @option{-x}), @command{tar} operates on all the archive members in the
  4805. archive. If you specify any operation other than one of these three,
  4806. @command{tar} does nothing.
  4807. By default, @command{tar} takes file names from the command line. However,
  4808. there are other ways to specify file or member names, or to modify the
  4809. manner in which @command{tar} selects the files or members upon which to
  4810. operate. @FIXME{add xref here}In general, these methods work both for
  4811. specifying the names of files and archive members.
  4812. @node files
  4813. @section Reading Names from a File
  4814. @cindex Reading file names from a file
  4815. @cindex Lists of file names
  4816. @cindex File Name arguments, alternatives
  4817. Instead of giving the names of files or archive members on the command
  4818. line, you can put the names into a file, and then use the
  4819. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option to @command{tar}. Give the name of the file
  4820. which contains the list of files to include as the argument to
  4821. @option{--files-from}. In the list, the file names should be separated by
  4822. newlines. You will frequently use this option when you have generated
  4823. the list of files to archive with the @command{find} utility.
  4824. @table @option
  4825. @opindex files-from
  4826. @item --files-from=@var{file name}
  4827. @itemx -T @var{file name}
  4828. Get names to extract or create from file @var{file name}.
  4829. @end table
  4830. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4831. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4832. names are read from standard input.
  4833. Unless you are running @command{tar} with @option{--create}, you can not use
  4834. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4835. command.
  4836. Any number of @option{-T} options can be given in the command line.
  4837. @FIXME{add bob's example, from his message on 2-10-97}
  4838. The following example shows how to use @command{find} to generate a list of
  4839. files smaller than 400K in length and put that list into a file
  4840. called @file{small-files}. You can then use the @option{-T} option to
  4841. @command{tar} to specify the files from that file, @file{small-files}, to
  4842. create the archive @file{little.tgz}. (The @option{-z} option to
  4843. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4844. more information.)
  4845. @smallexample
  4846. $ @kbd{find . -size -400 -print > small-files}
  4847. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4848. @end smallexample
  4849. @noindent
  4850. In the file list given by @option{-T} option, any file name beginning
  4851. with @samp{-} character is considered a @command{tar} option and is
  4852. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4853. recognized only @option{-C} option in file lists, and only if the
  4854. option and its argument occupied two consecutive lines.} For example,
  4855. the common use of this feature is to change to another directory by
  4856. specifying @option{-C} option:
  4857. @smallexample
  4858. @group
  4859. $ @kbd{cat list}
  4860. -C/etc
  4861. passwd
  4862. hosts
  4863. -C/lib
  4864. libc.a
  4865. $ @kbd{tar -c -f foo.tar --files-from list}
  4866. @end group
  4867. @end smallexample
  4868. @noindent
  4869. In this example, @command{tar} will first switch to @file{/etc}
  4870. directory and add files @file{passwd} and @file{hosts} to the
  4871. archive. Then it will change to @file{/lib} directory and will archive
  4872. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4873. contain:
  4874. @smallexample
  4875. @group
  4876. $ @kbd{tar tf foo.tar}
  4877. passwd
  4878. hosts
  4879. libc.a
  4880. @end group
  4881. @end smallexample
  4882. @noindent
  4883. @opindex directory, using in @option{--files-from} argument
  4884. Notice that the option parsing algorithm used with @option{-T} is
  4885. stricter than the one used by shell. Namely, when specifying option
  4886. arguments, you should observe the following rules:
  4887. @itemize @bullet
  4888. @item
  4889. When using short (single-letter) option form, its argument must
  4890. immediately follow the option letter, without any intervening
  4891. whitespace. For example: @code{-Cdir}.
  4892. @item
  4893. When using long option form, the option argument must be separated
  4894. from the option by a single equal sign. No whitespace is allowed on
  4895. any side of the equal sign. For example: @code{--directory=dir}.
  4896. @item
  4897. For both short and long option forms, the option argument can be given
  4898. on the next line after the option name, e.g.:
  4899. @smallexample
  4900. @group
  4901. --directory
  4902. dir
  4903. @end group
  4904. @end smallexample
  4905. @noindent
  4906. and
  4907. @smallexample
  4908. @group
  4909. -C
  4910. dir
  4911. @end group
  4912. @end smallexample
  4913. @end itemize
  4914. @opindex add-file
  4915. If you happen to have a file whose name starts with @samp{-},
  4916. precede it with @option{--add-file} option to prevent it from
  4917. being recognized as an option. For example: @code{--add-file --my-file}.
  4918. @menu
  4919. * nul::
  4920. @end menu
  4921. @node nul
  4922. @subsection @code{NUL} Terminated File Names
  4923. @cindex File names, terminated by @code{NUL}
  4924. @cindex @code{NUL} terminated file names
  4925. The @option{--null} option causes @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) to read file
  4926. names terminated by a @code{NUL} instead of a newline, so files whose
  4927. names contain newlines can be archived using @option{--files-from}.
  4928. @table @option
  4929. @opindex null
  4930. @item --null
  4931. Only consider @code{NUL} terminated file names, instead of files that
  4932. terminate in a newline.
  4933. @end table
  4934. The @option{--null} option is just like the one in @acronym{GNU}
  4935. @command{xargs} and @command{cpio}, and is useful with the
  4936. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4937. @command{tar}, @option{--null} also disables special handling for
  4938. file names that begin with dash.
  4939. This example shows how to use @command{find} to generate a list of files
  4940. larger than 800K in length and put that list into a file called
  4941. @file{long-files}. The @option{-print0} option to @command{find} is just
  4942. like @option{-print}, except that it separates files with a @code{NUL}
  4943. rather than with a newline. You can then run @command{tar} with both the
  4944. @option{--null} and @option{-T} options to specify that @command{tar} get the
  4945. files from that file, @file{long-files}, to create the archive
  4946. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  4947. @command{tar} to recognize the @code{NUL} separator between files.
  4948. @smallexample
  4949. $ @kbd{find . -size +800 -print0 > long-files}
  4950. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4951. @end smallexample
  4952. @FIXME{say anything else here to conclude the section?}
  4953. @node exclude
  4954. @section Excluding Some Files
  4955. @UNREVISED
  4956. @cindex File names, excluding files by
  4957. @cindex Excluding files by name and pattern
  4958. @cindex Excluding files by file system
  4959. To avoid operating on files whose names match a particular pattern,
  4960. use the @option{--exclude} or @option{--exclude-from} options.
  4961. @table @option
  4962. @opindex exclude
  4963. @item --exclude=@var{pattern}
  4964. Causes @command{tar} to ignore files that match the @var{pattern}.
  4965. @end table
  4966. @findex exclude
  4967. The @option{--exclude=@var{pattern}} option prevents any file or member whose name
  4968. matches the shell wildcard (@var{pattern}) from being operated on.
  4969. For example, to create an archive with all the contents of the directory
  4970. @file{src} except for files whose names end in @file{.o}, use the
  4971. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4972. You may give multiple @option{--exclude} options.
  4973. @table @option
  4974. @opindex exclude-from
  4975. @item --exclude-from=@var{file}
  4976. @itemx -X @var{file}
  4977. Causes @command{tar} to ignore files that match the patterns listed in
  4978. @var{file}.
  4979. @end table
  4980. @findex exclude-from
  4981. Use the @option{--exclude-from} option to read a
  4982. list of patterns, one per line, from @var{file}; @command{tar} will
  4983. ignore files matching those patterns. Thus if @command{tar} is
  4984. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4985. single line @file{*.o}, no files whose names end in @file{.o} will be
  4986. added to the archive.
  4987. @FIXME{do the exclude options files need to have stuff separated by
  4988. newlines the same as the files-from option does?}
  4989. @table @option
  4990. @opindex exclude-caches
  4991. @item --exclude-caches
  4992. Causes @command{tar} to ignore directories containing a cache directory tag.
  4993. @end table
  4994. @findex exclude-caches
  4995. When creating an archive, the @option{--exclude-caches} option causes
  4996. @command{tar} to exclude all directories that contain a @dfn{cache
  4997. directory tag}. A cache directory tag is a short file with the
  4998. well-known name @file{CACHEDIR.TAG} and having a standard header
  4999. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5000. Various applications write cache directory tags into directories they
  5001. use to hold regenerable, non-precious data, so that such data can be
  5002. more easily excluded from backups.
  5003. @menu
  5004. * controlling pattern-matching with exclude::
  5005. * problems with exclude::
  5006. @end menu
  5007. @node controlling pattern-matching with exclude
  5008. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  5009. Normally, a pattern matches a name if an initial subsequence of the
  5010. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5011. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5012. and wildcards can match @samp{/}.
  5013. Other than optionally stripping leading @samp{/} from names
  5014. (@pxref{absolute}), patterns and names are used as-is. For
  5015. example, trailing @samp{/} is not trimmed from a user-specified name
  5016. before deciding whether to exclude it.
  5017. However, this matching procedure can be altered by the options listed
  5018. below. These options accumulate. For example:
  5019. @smallexample
  5020. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5021. @end smallexample
  5022. ignores case when excluding @samp{makefile}, but not when excluding
  5023. @samp{readme}.
  5024. @table @option
  5025. @opindex anchored
  5026. @opindex no-anchored
  5027. @item --anchored
  5028. @itemx --no-anchored
  5029. If anchored, a pattern must match an initial subsequence
  5030. of the name's components. Otherwise, the pattern can match any
  5031. subsequence. Default is @option{--no-anchored}.
  5032. @opindex ignore-case
  5033. @opindex no-ignore-case
  5034. @item --ignore-case
  5035. @itemx --no-ignore-case
  5036. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5037. When not ignoring case (the default), matching is case-sensitive.
  5038. @opindex wildcards
  5039. @opindex no-wildcards
  5040. @item --wildcards
  5041. @itemx --no-wildcards
  5042. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  5043. are the usual shell wildcards, and @samp{\} escapes wildcards.
  5044. Otherwise, none of these characters are special, and patterns must match
  5045. names literally.
  5046. @opindex wildcards-match-slash
  5047. @opindex no-wildcards-match-slash
  5048. @item --wildcards-match-slash
  5049. @itemx --no-wildcards-match-slash
  5050. When wildcards match slash (the default), a wildcard like @samp{*} in
  5051. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  5052. matched only by @samp{/}.
  5053. @end table
  5054. The @option{--recursion} and @option{--no-recursion} options
  5055. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  5056. recursion is in effect, a pattern excludes a name if it matches any of
  5057. the name's parent directories.
  5058. @node problems with exclude
  5059. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5060. @opindex exclude, potential problems with
  5061. Some users find @samp{exclude} options confusing. Here are some common
  5062. pitfalls:
  5063. @itemize @bullet
  5064. @item
  5065. The main operating mode of @command{tar} does not act on a path name
  5066. explicitly listed on the command line if one of its file name
  5067. components is excluded. In the example above, if
  5068. you create an archive and exclude files that end with @samp{*.o}, but
  5069. explicitly name the file @samp{dir.o/foo} after all the options have been
  5070. listed, @samp{dir.o/foo} will be excluded from the archive.
  5071. @item
  5072. You can sometimes confuse the meanings of @option{--exclude} and
  5073. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5074. to be excluded are given as a pattern on the command line. Use
  5075. @option{--exclude-from} to introduce the name of a file which contains
  5076. a list of patterns, one per line; each of these patterns can exclude
  5077. zero, one, or many files.
  5078. @item
  5079. When you use @option{--exclude=@var{pattern}}, be sure to quote the @var{pattern}
  5080. parameter, so @GNUTAR{} sees wildcard characters
  5081. like @samp{*}. If you do not do this, the shell might expand the
  5082. @samp{*} itself using files at hand, so @command{tar} might receive a
  5083. list of files instead of one pattern, or none at all, making the
  5084. command somewhat illegal. This might not correspond to what you want.
  5085. For example, write:
  5086. @smallexample
  5087. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5088. @end smallexample
  5089. @noindent
  5090. rather than:
  5091. @smallexample
  5092. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5093. @end smallexample
  5094. @item
  5095. You must use use shell syntax, or globbing, rather than @code{regexp}
  5096. syntax, when using exclude options in @command{tar}. If you try to use
  5097. @code{regexp} syntax to describe files to be excluded, your command
  5098. might fail.
  5099. @item
  5100. In earlier versions of @command{tar}, what is now the
  5101. @option{--exclude-from} option was called @option{--exclude} instead.
  5102. Now, @option{--exclude} applies to patterns listed on the command
  5103. line and @option{--exclude-from} applies to patterns listed in a
  5104. file.
  5105. @end itemize
  5106. @node Wildcards
  5107. @section Wildcards Patterns and Matching
  5108. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5109. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5110. existing files matching the given pattern. However, @command{tar} often
  5111. uses wildcard patterns for matching (or globbing) archive members instead
  5112. of actual files in the file system. Wildcard patterns are also used for
  5113. verifying volume labels of @command{tar} archives. This section has the
  5114. purpose of explaining wildcard syntax for @command{tar}.
  5115. @FIXME{the next few paragraphs need work.}
  5116. A @var{pattern} should be written according to shell syntax, using wildcard
  5117. characters to effect globbing. Most characters in the pattern stand
  5118. for themselves in the matched string, and case is significant: @samp{a}
  5119. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5120. pattern matches any single character in the matched string. The character
  5121. @samp{*} in the pattern matches zero, one, or more single characters in
  5122. the matched string. The character @samp{\} says to take the following
  5123. character of the pattern @emph{literally}; it is useful when one needs to
  5124. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5125. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5126. class. A @dfn{character class} is a list of acceptable characters
  5127. for the next single character of the matched string. For example,
  5128. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5129. Note that within a character class, all of the ``special characters''
  5130. listed above other than @samp{\} lose their special meaning; for example,
  5131. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5132. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5133. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5134. @emph{last} in a character class.)
  5135. @cindex Excluding characters from a character class
  5136. @cindex Character class, excluding characters from
  5137. If the first character of the class after the opening @samp{[}
  5138. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5139. Rather than listing character to match, it lists those characters which
  5140. are @emph{forbidden} as the next single character of the matched string.
  5141. Other characters of the class stand for themselves. The special
  5142. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5143. letters, is meant to represent all characters between @var{a} and
  5144. @var{e}, inclusive.
  5145. @FIXME{need to add a sentence or so here to make this clear for those
  5146. who don't have dan around.}
  5147. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5148. special for wildcard matches. However, if a pattern completely matches
  5149. a directory prefix of a matched string, then it matches the full matched
  5150. string: excluding a directory also excludes all the files beneath it.
  5151. @node after
  5152. @section Operating Only on New Files
  5153. @UNREVISED
  5154. @cindex Excluding file by age
  5155. @cindex Data Modification time, excluding files by
  5156. @cindex Modification time, excluding files by
  5157. @cindex Age, excluding files by
  5158. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5159. @option{-N @var{date}}) option causes @command{tar} to only work on
  5160. files whose data modification or status change times are newer than
  5161. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5162. it is taken to be a file name; the data modification time of that file
  5163. is used as the date. If you use this option when creating or appending
  5164. to an archive, the archive will only include new files. If you use
  5165. @option{--after-date} when extracting an archive, @command{tar} will
  5166. only extract files newer than the @var{date} you specify.
  5167. If you only want @command{tar} to make the date comparison based on
  5168. modification of the file's data (rather than status
  5169. changes), then use the @option{--newer-mtime=@var{date}} option.
  5170. You may use these options with any operation. Note that these options
  5171. differ from the @option{--update} (@option{-u}) operation in that they
  5172. allow you to specify a particular date against which @command{tar} can
  5173. compare when deciding whether or not to archive the files.
  5174. @table @option
  5175. @opindex after-date
  5176. @opindex newer
  5177. @item --after-date=@var{date}
  5178. @itemx --newer=@var{date}
  5179. @itemx -N @var{date}
  5180. Only store files newer than @var{date}.
  5181. Acts on files only if their data modification or status change times are
  5182. later than @var{date}. Use in conjunction with any operation.
  5183. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5184. name; the data modification time of that file is used as the date.
  5185. @opindex newer-mtime
  5186. @item --newer-mtime=@var{date}
  5187. Acts like @option{--after-date}, but only looks at data modification times.
  5188. @end table
  5189. These options limit @command{tar} to operate only on files which have
  5190. been modified after the date specified. A file's status is considered to have
  5191. changed if its contents have been modified, or if its owner,
  5192. permissions, and so forth, have been changed. (For more information on
  5193. how to specify a date, see @ref{Date input formats}; remember that the
  5194. entire date argument must be quoted if it contains any spaces.)
  5195. Gurus would say that @option{--after-date} tests both the data
  5196. modification time (@code{mtime}, the time the contents of the file
  5197. were last modified) and the status change time (@code{ctime}, the time
  5198. the file's status was last changed: owner, permissions, etc.@:)
  5199. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5200. field.
  5201. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5202. @code{ctime} and processes the file if either one is more recent than
  5203. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5204. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5205. contents of the file were looked at).
  5206. Date specifiers can have embedded spaces. Because of this, you may need
  5207. to quote date arguments to keep the shell from parsing them as separate
  5208. arguments.
  5209. @FIXME{Need example of --newer-mtime with quoted argument.}
  5210. @quotation
  5211. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5212. should not be used for incremental backups. Some files (such as those
  5213. in renamed directories) are not selected properly by these options.
  5214. @xref{Incremental Dumps}.
  5215. @end quotation
  5216. @noindent
  5217. @FIXME{which tells -- need to fill this in!}
  5218. @node recurse
  5219. @section Descending into Directories
  5220. @UNREVISED
  5221. @cindex Avoiding recursion in directories
  5222. @cindex Descending directories, avoiding
  5223. @cindex Directories, avoiding recursion
  5224. @cindex Recursion in directories, avoiding
  5225. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5226. @FIXME{show dan bob's comments, from 2-10-97}
  5227. Usually, @command{tar} will recursively explore all directories (either
  5228. those given on the command line or through the @option{--files-from}
  5229. option) for the various files they contain. However, you may not always
  5230. want @command{tar} to act this way.
  5231. @opindex no-recursion
  5232. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5233. into specified directories. If you specify @option{--no-recursion}, you can
  5234. use the @command{find} utility for hunting through levels of directories to
  5235. construct a list of file names which you could then pass to @command{tar}.
  5236. @command{find} allows you to be more selective when choosing which files to
  5237. archive; see @ref{files} for more information on using @command{find} with
  5238. @command{tar}, or look.
  5239. @table @option
  5240. @item --no-recursion
  5241. Prevents @command{tar} from recursively descending directories.
  5242. @opindex recursion
  5243. @item --recursion
  5244. Requires @command{tar} to recursively descend directories.
  5245. This is the default.
  5246. @end table
  5247. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5248. directory entries themselves, but does not descend on them
  5249. recursively. Many people use @command{find} for locating files they
  5250. want to back up, and since @command{tar} @emph{usually} recursively
  5251. descends on directories, they have to use the @samp{@w{! -d}} option
  5252. to @command{find} @FIXME{needs more explanation or a cite to another
  5253. info file}as they usually do not want all the files in a directory.
  5254. They then use the @option{--files-from} option to archive the files
  5255. located via @command{find}.
  5256. The problem when restoring files archived in this manner is that the
  5257. directories themselves are not in the archive; so the
  5258. @option{--same-permissions} (@option{--preserve-permissions},
  5259. @option{-p}) option does not affect them---while users might really
  5260. like it to. Specifying @option{--no-recursion} is a way to tell
  5261. @command{tar} to grab only the directory entries given to it, adding
  5262. no new files on its own.
  5263. The @option{--no-recursion} option also applies when extracting: it
  5264. causes @command{tar} to extract only the matched directory entries, not
  5265. the files under those directories.
  5266. The @option{--no-recursion} option also affects how exclude patterns
  5267. are interpreted (@pxref{controlling pattern-matching with exclude}).
  5268. The @option{--no-recursion} and @option{--recursion} options apply to
  5269. later options and operands, and can be overridden by later occurrences
  5270. of @option{--no-recursion} and @option{--recursion}. For example:
  5271. @smallexample
  5272. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5273. @end smallexample
  5274. @noindent
  5275. creates an archive with one entry for @file{grape}, and the recursive
  5276. contents of @file{grape/concord}, but no entries under @file{grape}
  5277. other than @file{grape/concord}.
  5278. @node one
  5279. @section Crossing File System Boundaries
  5280. @cindex File system boundaries, not crossing
  5281. @UNREVISED
  5282. @command{tar} will normally automatically cross file system boundaries in
  5283. order to archive files which are part of a directory tree. You can
  5284. change this behavior by running @command{tar} and specifying
  5285. @option{--one-file-system} (@option{-l}). This option only affects files that are
  5286. archived because they are in a directory that is being archived;
  5287. @command{tar} will still archive files explicitly named on the command line
  5288. or through @option{--files-from}, regardless of where they reside.
  5289. @table @option
  5290. @opindex one-file-system
  5291. @item --one-file-system
  5292. @itemx -l
  5293. Prevents @command{tar} from crossing file system boundaries when
  5294. archiving. Use in conjunction with any write operation.
  5295. @end table
  5296. The @option{--one-file-system} option causes @command{tar} to modify its
  5297. normal behavior in archiving the contents of directories. If a file in
  5298. a directory is not on the same file system as the directory itself, then
  5299. @command{tar} will not archive that file. If the file is a directory
  5300. itself, @command{tar} will not archive anything beneath it; in other words,
  5301. @command{tar} will not cross mount points.
  5302. It is reported that using this option, the mount point is is archived,
  5303. but nothing under it.
  5304. This option is useful for making full or incremental archival backups of
  5305. a file system. If this option is used in conjunction with
  5306. @option{--verbose} (@option{-v}), files that are excluded are mentioned by name on the
  5307. standard error.
  5308. @menu
  5309. * directory:: Changing Directory
  5310. * absolute:: Absolute File Names
  5311. @end menu
  5312. @node directory
  5313. @subsection Changing the Working Directory
  5314. @UNREVISED
  5315. @FIXME{need to read over this node now for continuity; i've switched
  5316. things around some.}
  5317. @cindex Changing directory mid-stream
  5318. @cindex Directory, changing mid-stream
  5319. @cindex Working directory, specifying
  5320. To change the working directory in the middle of a list of file names,
  5321. either on the command line or in a file specified using
  5322. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5323. This will change the working directory to the specified directory
  5324. after that point in the list.
  5325. @table @option
  5326. @opindex directory
  5327. @item --directory=@var{directory}
  5328. @itemx -C @var{directory}
  5329. Changes the working directory in the middle of a command line.
  5330. @end table
  5331. For example,
  5332. @smallexample
  5333. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5334. @end smallexample
  5335. @noindent
  5336. will place the files @file{grape} and @file{prune} from the current
  5337. directory into the archive @file{jams.tar}, followed by the file
  5338. @file{cherry} from the directory @file{food}. This option is especially
  5339. useful when you have several widely separated files that you want to
  5340. store in the same archive.
  5341. Note that the file @file{cherry} is recorded in the archive under the
  5342. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5343. archive will contain three files that all appear to have come from the
  5344. same directory; if the archive is extracted with plain @samp{tar
  5345. --extract}, all three files will be written in the current directory.
  5346. Contrast this with the command,
  5347. @smallexample
  5348. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5349. @end smallexample
  5350. @noindent
  5351. which records the third file in the archive under the name
  5352. @file{red/cherry} so that, if the archive is extracted using
  5353. @samp{tar --extract}, the third file will be written in a subdirectory
  5354. named @file{orange-colored}.
  5355. You can use the @option{--directory} option to make the archive
  5356. independent of the original name of the directory holding the files.
  5357. The following command places the files @file{/etc/passwd},
  5358. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5359. @file{foo.tar}:
  5360. @smallexample
  5361. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5362. @end smallexample
  5363. @noindent
  5364. However, the names of the archive members will be exactly what they were
  5365. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5366. They will not appear to be related by file name to the original
  5367. directories where those files were located.
  5368. Note that @option{--directory} options are interpreted consecutively. If
  5369. @option{--directory} specifies a relative file name, it is interpreted
  5370. relative to the then current directory, which might not be the same as
  5371. the original current working directory of @command{tar}, due to a previous
  5372. @option{--directory} option.
  5373. When using @option{--files-from} (@pxref{files}), you can put various
  5374. @command{tar} options (including @option{-C}) in the file list. Notice,
  5375. however, that in this case the option and its argument may not be
  5376. separated by whitespace. If you use short option, its argument must
  5377. either follow the option letter immediately, without any intervening
  5378. whitespace, or occupy the next line. Otherwise, if you use long
  5379. option, separate its argument by an equal sign.
  5380. For instance, the file list for the above example will be:
  5381. @smallexample
  5382. @group
  5383. -C
  5384. /etc
  5385. passwd
  5386. hosts
  5387. -C
  5388. /lib
  5389. libc.a
  5390. @end group
  5391. @end smallexample
  5392. @noindent
  5393. To use it, you would invoke @command{tar} as follows:
  5394. @smallexample
  5395. $ @kbd{tar -c -f foo.tar --files-from list}
  5396. @end smallexample
  5397. Notice also that you can only use the short option variant in the file
  5398. list, i.e., always use @option{-C}, not @option{--directory}.
  5399. The interpretation of @option{--directory} is disabled by
  5400. @option{--null} option.
  5401. @node absolute
  5402. @subsection Absolute File Names
  5403. @UNREVISED
  5404. @table @option
  5405. @opindex absolute-names
  5406. @item --absolute-names
  5407. @itemx -P
  5408. Do not strip leading slashes from file names, and permit file names
  5409. containing a @file{..} file name component.
  5410. @end table
  5411. By default, @GNUTAR{} drops a leading @samp{/} on
  5412. input or output, and complains about file names containing a @file{..}
  5413. component. This option turns off this behavior.
  5414. When @command{tar} extracts archive members from an archive, it strips any
  5415. leading slashes (@samp{/}) from the member name. This causes absolute
  5416. member names in the archive to be treated as relative file names. This
  5417. allows you to have such members extracted wherever you want, instead of
  5418. being restricted to extracting the member in the exact directory named
  5419. in the archive. For example, if the archive member has the name
  5420. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5421. really @file{etc/passwd}.
  5422. File names containing @file{..} can cause problems when extracting, so
  5423. @command{tar} normally warns you about such files when creating an
  5424. archive, and rejects attempts to extracts such files.
  5425. Other @command{tar} programs do not do this. As a result, if you
  5426. create an archive whose member names start with a slash, they will be
  5427. difficult for other people with a non-@GNUTAR{}
  5428. program to use. Therefore, @GNUTAR{} also strips
  5429. leading slashes from member names when putting members into the
  5430. archive. For example, if you ask @command{tar} to add the file
  5431. @file{/bin/ls} to an archive, it will do so, but the member name will
  5432. be @file{bin/ls}.@footnote{A side effect of this is that when
  5433. @option{--create} is used with @option{--verbose} the resulting output
  5434. is not, generally speaking, the same as the one you'd get running
  5435. @kbd{tar --list} command. This may be important if you use some
  5436. scripts for comparing both outputs. @xref{listing member and file names},
  5437. for the information on how to handle this case.}
  5438. If you use the @option{--absolute-names} (@option{-P}) option,
  5439. @command{tar} will do none of these transformations.
  5440. To archive or extract files relative to the root directory, specify
  5441. the @option{--absolute-names} (@option{-P}) option.
  5442. Normally, @command{tar} acts on files relative to the working
  5443. directory---ignoring superior directory names when archiving, and
  5444. ignoring leading slashes when extracting.
  5445. When you specify @option{--absolute-names} (@option{-P}),
  5446. @command{tar} stores file names including all superior directory
  5447. names, and preserves leading slashes. If you only invoked
  5448. @command{tar} from the root directory you would never need the
  5449. @option{--absolute-names} option, but using this option
  5450. may be more convenient than switching to root.
  5451. @FIXME{Should be an example in the tutorial/wizardry section using this
  5452. to transfer files between systems.}
  5453. @FIXME{Is write access an issue?}
  5454. @table @option
  5455. @item --absolute-names
  5456. Preserves full file names (including superior directory names) when
  5457. archiving files. Preserves leading slash when extracting files.
  5458. @end table
  5459. @FIXME{this is still horrible; need to talk with dan on monday.}
  5460. @command{tar} prints out a message about removing the @samp{/} from
  5461. file names. This message appears once per @GNUTAR{}
  5462. invocation. It represents something which ought to be told; ignoring
  5463. what it means can cause very serious surprises, later.
  5464. Some people, nevertheless, do not want to see this message. Wanting to
  5465. play really dangerously, one may of course redirect @command{tar} standard
  5466. error to the sink. For example, under @command{sh}:
  5467. @smallexample
  5468. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5469. @end smallexample
  5470. @noindent
  5471. Another solution, both nicer and simpler, would be to change to
  5472. the @file{/} directory first, and then avoid absolute notation.
  5473. For example:
  5474. @smallexample
  5475. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5476. $ @kbd{tar -c -f archive.tar -C / home}
  5477. @end smallexample
  5478. @include getdate.texi
  5479. @node Formats
  5480. @chapter Controlling the Archive Format
  5481. @cindex Tar archive formats
  5482. Due to historical reasons, there are several formats of tar archives.
  5483. All of them are based on the same principles, but have some subtle
  5484. differences that often make them incompatible with each other.
  5485. GNU tar is able to create and handle archives in a variety of formats.
  5486. The most frequently used formats are (in alphabetical order):
  5487. @table @asis
  5488. @item gnu
  5489. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5490. from an early @acronym{POSIX} standard, adding some improvements such as
  5491. sparse file handling and incremental archives. Unfortunately these
  5492. features were implemented in a way incompatible with other archive
  5493. formats.
  5494. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5495. length.
  5496. @item oldgnu
  5497. Format used by @GNUTAR{} of versions prior to 1.12.
  5498. @item v7
  5499. Archive format, compatible with the V7 implementation of tar. This
  5500. format imposes a number of limitations. The most important of them
  5501. are:
  5502. @enumerate
  5503. @item The maximum length of a file name is limited to 99 characters.
  5504. @item The maximum length of a symbolic link is limited to 99 characters.
  5505. @item It is impossible to store special files (block and character
  5506. devices, fifos etc.)
  5507. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5508. octal)
  5509. @item V7 archives do not contain symbolic ownership information (user
  5510. and group name of the file owner).
  5511. @end enumerate
  5512. This format has traditionally been used by Automake when producing
  5513. Makefiles. This practice will change in the future, in the meantime,
  5514. however this means that projects containing filenames more than 99
  5515. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5516. Automake prior to 1.9.
  5517. @item ustar
  5518. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5519. symbolic ownership information. It is also able to store
  5520. special files. However, it imposes several restrictions as well:
  5521. @enumerate
  5522. @item The maximum length of a file name is limited to 256 characters,
  5523. provided that the filename can be split at directory separator in
  5524. two parts, first of them being at most 155 bytes long. So, in most
  5525. cases the maximum file name length will be shorter than 256
  5526. characters.
  5527. @item The maximum length of a symbolic link name is limited to
  5528. 100 characters.
  5529. @item Maximum size of a file the archive is able to accomodate
  5530. is 8GB
  5531. @item Maximum value of UID/GID is 2097151.
  5532. @item Maximum number of bits in device major and minor numbers is 21.
  5533. @end enumerate
  5534. @item star
  5535. Format used by J@"org Schilling @command{star}
  5536. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5537. currently does not produce them.
  5538. @item posix
  5539. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5540. most flexible and feature-rich format. It does not impose any
  5541. restrictions on file sizes or filename lengths. This format is quite
  5542. recent, so not all tar implementations are able to handle it properly.
  5543. However, this format is designed in such a way that any tar
  5544. implementation able to read @samp{ustar} archives will be able to read
  5545. most @samp{posix} archives as well, with the only exception that any
  5546. additional information (such as long file names etc.) will in such
  5547. case be extracted as plain text files along with the files it refers to.
  5548. This archive format will be the default format for future versions
  5549. of @GNUTAR{}.
  5550. @end table
  5551. The following table summarizes the limitations of each of these
  5552. formats:
  5553. @multitable @columnfractions .10 .20 .20 .20 .20
  5554. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5555. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5556. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5557. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5558. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5559. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5560. @end multitable
  5561. The default format for @GNUTAR{} is defined at compilation
  5562. time. You may check it by running @command{tar --help}, and examining
  5563. the last lines of its output. Usually, @GNUTAR{} is configured
  5564. to create archives in @samp{gnu} format, however, future version will
  5565. switch to @samp{posix}.
  5566. @menu
  5567. * Portability:: Making @command{tar} Archives More Portable
  5568. * Compression:: Using Less Space through Compression
  5569. * Attributes:: Handling File Attributes
  5570. * Standard:: The Standard Format
  5571. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5572. * cpio:: Comparison of @command{tar} and @command{cpio}
  5573. @end menu
  5574. @node Portability
  5575. @section Making @command{tar} Archives More Portable
  5576. Creating a @command{tar} archive on a particular system that is meant to be
  5577. useful later on many other machines and with other versions of @command{tar}
  5578. is more challenging than you might think. @command{tar} archive formats
  5579. have been evolving since the first versions of Unix. Many such formats
  5580. are around, and are not always compatible with each other. This section
  5581. discusses a few problems, and gives some advice about making @command{tar}
  5582. archives more portable.
  5583. One golden rule is simplicity. For example, limit your @command{tar}
  5584. archives to contain only regular files and directories, avoiding
  5585. other kind of special files. Do not attempt to save sparse files or
  5586. contiguous files as such. Let's discuss a few more problems, in turn.
  5587. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5588. archives and archive labels) in GNU and PAX formats.}
  5589. @menu
  5590. * Portable Names:: Portable Names
  5591. * dereference:: Symbolic Links
  5592. * old:: Old V7 Archives
  5593. * ustar:: Ustar Archives
  5594. * gnu:: GNU and old GNU format archives.
  5595. * posix:: @acronym{POSIX} archives
  5596. * Checksumming:: Checksumming Problems
  5597. * Large or Negative Values:: Large files, negative time stamps, etc.
  5598. @end menu
  5599. @node Portable Names
  5600. @subsection Portable Names
  5601. Use portable file and member names. A name is portable if it contains
  5602. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5603. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5604. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5605. old Unix hosts, limit your file name components to 14 characters or
  5606. less.
  5607. If you intend to have your @command{tar} archives to be read under
  5608. MSDOS, you should not rely on case distinction for file names, and you
  5609. might use the @acronym{GNU} @command{doschk} program for helping you
  5610. further diagnosing illegal MSDOS names, which are even more limited
  5611. than System V's.
  5612. @node dereference
  5613. @subsection Symbolic Links
  5614. @cindex File names, using symbolic links
  5615. @cindex Symbolic link as file name
  5616. @opindex dereference
  5617. Normally, when @command{tar} archives a symbolic link, it writes a
  5618. block to the archive naming the target of the link. In that way, the
  5619. @command{tar} archive is a faithful record of the file system contents.
  5620. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5621. @command{tar} to archive the files symbolic links point to, instead of
  5622. the links themselves. When this option is used, when @command{tar}
  5623. encounters a symbolic link, it will archive the linked-to file,
  5624. instead of simply recording the presence of a symbolic link.
  5625. The name under which the file is stored in the file system is not
  5626. recorded in the archive. To record both the symbolic link name and
  5627. the file name in the system, archive the file under both names. If
  5628. all links were recorded automatically by @command{tar}, an extracted file
  5629. might be linked to a file name that no longer exists in the file
  5630. system.
  5631. If a linked-to file is encountered again by @command{tar} while creating
  5632. the same archive, an entire second copy of it will be stored. (This
  5633. @emph{might} be considered a bug.)
  5634. So, for portable archives, do not archive symbolic links as such,
  5635. and use @option{--dereference} (@option{-h}): many systems do not support
  5636. symbolic links, and moreover, your distribution might be unusable if
  5637. it contains unresolved symbolic links.
  5638. @node old
  5639. @subsection Old V7 Archives
  5640. @cindex Format, old style
  5641. @cindex Old style format
  5642. @cindex Old style archives
  5643. @cindex v7 archive format
  5644. Certain old versions of @command{tar} cannot handle additional
  5645. information recorded by newer @command{tar} programs. To create an
  5646. archive in V7 format (not ANSI), which can be read by these old
  5647. versions, specify the @option{--format=v7} option in
  5648. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5649. accepts @option{--portability} or @samp{op-old-archive} for this
  5650. option). When you specify it,
  5651. @command{tar} leaves out information about directories, pipes, fifos,
  5652. contiguous files, and device files, and specifies file ownership by
  5653. group and user IDs instead of group and user names.
  5654. When updating an archive, do not use @option{--format=v7}
  5655. unless the archive was created using this option.
  5656. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5657. @command{tar} program without serious trouble, so this option should
  5658. seldom be needed. On the other hand, most modern @command{tar}s are
  5659. able to read old format archives, so it might be safer for you to
  5660. always use @option{--format=v7} for your distributions.
  5661. @node ustar
  5662. @subsection Ustar Archive Format
  5663. @cindex ustar archive format
  5664. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5665. @code{ustar}. Although it is more flexible than the V7 format, it
  5666. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5667. description of @code{ustar} format). Along with V7 format,
  5668. @code{ustar} format is a good choice for archives intended to be read
  5669. with other implementations of @command{tar}.
  5670. To create archive in @code{ustar} format, use @option{--format=ustar}
  5671. option in conjunction with the @option{--create} (@option{-c}).
  5672. @node gnu
  5673. @subsection @acronym{GNU} and old @GNUTAR{} format
  5674. @cindex GNU archive format
  5675. @cindex Old GNU archive format
  5676. @GNUTAR{} was based on an early draft of the
  5677. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5678. @command{tar}, such as the support for file names longer than 100
  5679. characters, use portions of the @command{tar} header record which were
  5680. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5681. @acronym{POSIX} have allocated the same parts of the header record for
  5682. other purposes. As a result, @GNUTAR{} format is
  5683. incompatible with the current @acronym{POSIX} specification, and with
  5684. @command{tar} programs that follow it.
  5685. In the majority of cases, @command{tar} will be configured to create
  5686. this format by default. This will change in the future releases, since
  5687. we plan to make @samp{posix} format the default.
  5688. To force creation a @GNUTAR{} archive, use option
  5689. @option{--format=gnu}.
  5690. @node posix
  5691. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5692. @cindex POSIX archive format
  5693. @cindex PAX archive format
  5694. The version @value{VERSION} of @GNUTAR{} is able
  5695. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5696. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5697. was given @option{--format=posix} option.
  5698. @node Checksumming
  5699. @subsection Checksumming Problems
  5700. SunOS and HP-UX @command{tar} fail to accept archives created using
  5701. @GNUTAR{} and containing non-ASCII file names, that
  5702. is, file names having characters with the eight bit set, because they
  5703. use signed checksums, while @GNUTAR{} uses unsigned
  5704. checksums while creating archives, as per @acronym{POSIX} standards. On
  5705. reading, @GNUTAR{} computes both checksums and
  5706. accept any. It is somewhat worrying that a lot of people may go
  5707. around doing backup of their files using faulty (or at least
  5708. non-standard) software, not learning about it until it's time to
  5709. restore their missing files with an incompatible file extractor, or
  5710. vice versa.
  5711. @GNUTAR{} compute checksums both ways, and accept
  5712. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5713. wrong checksums. @GNUTAR{} produces the standard
  5714. checksum, however, raising incompatibilities with Sun. That is to
  5715. say, @GNUTAR{} has not been modified to
  5716. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5717. I've been told that more recent Sun @command{tar} now read standard
  5718. archives, so maybe Sun did a similar patch, after all?
  5719. The story seems to be that when Sun first imported @command{tar}
  5720. sources on their system, they recompiled it without realizing that
  5721. the checksums were computed differently, because of a change in
  5722. the default signing of @code{char}'s in their compiler. So they
  5723. started computing checksums wrongly. When they later realized their
  5724. mistake, they merely decided to stay compatible with it, and with
  5725. themselves afterwards. Presumably, but I do not really know, HP-UX
  5726. has chosen that their @command{tar} archives to be compatible with Sun's.
  5727. The current standards do not favor Sun @command{tar} format. In any
  5728. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5729. a @command{tar} able to read the good archives they receive.
  5730. @node Large or Negative Values
  5731. @subsection Large or Negative Values
  5732. @cindex large values
  5733. @cindex future time stamps
  5734. @cindex negative time stamps
  5735. @UNREVISED{}
  5736. The above sections suggest to use @samp{oldest possible} archive
  5737. format if in doubt. However, sometimes it is not possible. If you
  5738. attempt to archive a file whose metadata cannot be represented using
  5739. required format, @GNUTAR{} will print error message and ignore such a
  5740. file. You will than have to switch to a format that is able to
  5741. handle such values. The format summary table (@pxref{Formats}) will
  5742. help you to do so.
  5743. In particular, when trying to archive files larger than 8GB or with
  5744. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  5745. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  5746. @acronym{POSIX} archive formats. When considering which format to
  5747. choose, bear in mind that the @acronym{GNU} format uses
  5748. two's-complement base-256 notation to store values that do not fit
  5749. into standard @acronym{ustar} range. Such archives can generally be
  5750. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  5751. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  5752. example, using two's complement representation for negative time
  5753. stamps that assumes a signed 32-bit @code{time_t} generates archives
  5754. that are not portable to hosts with differing @code{time_t}
  5755. representations.
  5756. On the other hand, @acronym{POSIX} archives, generally speaking, can
  5757. be extracted by any tar implementation that understands older
  5758. @acronym{ustar} format. The only exception are files larger than 8GB.
  5759. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  5760. POSIX-aware tars.}
  5761. @node Compression
  5762. @section Using Less Space through Compression
  5763. @menu
  5764. * gzip:: Creating and Reading Compressed Archives
  5765. * sparse:: Archiving Sparse Files
  5766. @end menu
  5767. @node gzip
  5768. @subsection Creating and Reading Compressed Archives
  5769. @cindex Compressed archives
  5770. @cindex Storing archives in compressed format
  5771. @GNUTAR{} is able to create and read compressed archives. It supports
  5772. @command{gzip} and @command{bzip2} compression programs. For backward
  5773. compatibilty, it also supports @command{compress} command, although
  5774. we strongly recommend against using it, since there is a patent
  5775. covering the algorithm it uses and you could be sued for patent
  5776. infringement merely by running @command{compress}! Besides, it is less
  5777. effective than @command{gzip} and @command{bzip2}.
  5778. Creating a compressed archive is simple: you just specify a
  5779. @dfn{compression option} along with the usual archive creation
  5780. commands. The compression option is @option{-z} (@option{--gzip}) to
  5781. create a @command{gzip} compressed archive, @option{-j}
  5782. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  5783. @option{-Z} (@option{--compress}) to use @command{compress} program.
  5784. For example:
  5785. @smallexample
  5786. $ @kbd{tar cfz archive.tar.gz .}
  5787. @end smallexample
  5788. Reading compressed archive is even simpler: you don't need to specify
  5789. any additional options as @GNUTAR{} recognizes its format
  5790. automatically. Thus, the following commands will list and extract the
  5791. archive created in previous example:
  5792. @smallexample
  5793. # List the compressed archive
  5794. $ @kbd{tar tf archive.tar.gz}
  5795. # Extract the compressed archive
  5796. $ @kbd{tar xf archive.tar.gz}
  5797. @end smallexample
  5798. The only case when you have to specify a decompression option while
  5799. reading the archive is when reading from a pipe or from a tape drive
  5800. that does not support random access. However, in this case @GNUTAR{}
  5801. will indicate which option you should use. For example:
  5802. @smallexample
  5803. $ @kbd{cat archive.tar.gz | tar tf -}
  5804. tar: Archive is compressed. Use -z option
  5805. tar: Error is not recoverable: exiting now
  5806. @end smallexample
  5807. If you see such diagnostics, just add the suggested option to the
  5808. invocation of @GNUTAR{}:
  5809. @smallexample
  5810. $ @kbd{cat archive.tar.gz | tar tfz -}
  5811. @end smallexample
  5812. Notice also, that there are several restrictions on operations on
  5813. compressed archives. First of all, compressed archives cannot be
  5814. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  5815. (@option{--delete}) members from them. Likewise, you cannot append
  5816. another @command{tar} archive to a compressed archive using
  5817. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  5818. compressed.
  5819. The following table summarizes compression options used by @GNUTAR{}.
  5820. @table @option
  5821. @opindex gzip
  5822. @opindex ungzip
  5823. @item -z
  5824. @itemx --gzip
  5825. @itemx --ungzip
  5826. Filter the archive through @command{gzip}.
  5827. You can use @option{--gzip} and @option{--gunzip} on physical devices
  5828. (tape drives, etc.) and remote files as well as on normal files; data
  5829. to or from such devices or remote files is reblocked by another copy
  5830. of the @command{tar} program to enforce the specified (or default) record
  5831. size. The default compression parameters are used; if you need to
  5832. override them, set @env{GZIP} environment variable, e.g.:
  5833. @smallexample
  5834. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  5835. @end smallexample
  5836. @noindent
  5837. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  5838. @command{gzip} explicitly:
  5839. @smallexample
  5840. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  5841. @end smallexample
  5842. @cindex corrupted archives
  5843. About corrupted compressed archives: @command{gzip}'ed files have no
  5844. redundancy, for maximum compression. The adaptive nature of the
  5845. compression scheme means that the compression tables are implicitly
  5846. spread all over the archive. If you lose a few blocks, the dynamic
  5847. construction of the compression tables becomes unsynchronized, and there
  5848. is little chance that you could recover later in the archive.
  5849. There are pending suggestions for having a per-volume or per-file
  5850. compression in @GNUTAR{}. This would allow for viewing the
  5851. contents without decompression, and for resynchronizing decompression at
  5852. every volume or file, in case of corrupted archives. Doing so, we might
  5853. lose some compressibility. But this would have make recovering easier.
  5854. So, there are pros and cons. We'll see!
  5855. @opindex bzip2
  5856. @item -j
  5857. @itemx --bzip2
  5858. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  5859. @opindex compress
  5860. @opindex uncompress
  5861. @item -Z
  5862. @itemx --compress
  5863. @itemx --uncompress
  5864. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  5865. The @acronym{GNU} Project recommends you not use
  5866. @command{compress}, because there is a patent covering the algorithm it
  5867. uses. You could be sued for patent infringement merely by running
  5868. @command{compress}.
  5869. @opindex use-compress-program
  5870. @item --use-compress-program=@var{prog}
  5871. Use external compression program @var{prog}. Use this option if you
  5872. have a compression program that @GNUTAR{} does not support. There
  5873. are two requirements to which @var{prog} should comply:
  5874. First, when called without options, it should read data from standard
  5875. input, compress it and output it on standard output.
  5876. Secondly, if called with @option{-d} argument, it should do exactly
  5877. the opposite, i.e., read the compressed data from the standard input
  5878. and produce uncompressed data on the standard output.
  5879. @end table
  5880. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5881. to do it now. I would like to use @option{--gzip}, but I'd also like
  5882. the output to be fed through a program like @acronym{GNU}
  5883. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5884. to use :-)), basically adding ECC protection on top of compression.
  5885. It seems as if this should be quite easy to do, but I can't work out
  5886. exactly how to go about it. Of course, I can pipe the standard output
  5887. of @command{tar} through @command{ecc}, but then I lose (though I
  5888. haven't started using it yet, I confess) the ability to have
  5889. @command{tar} use @command{rmt} for it's I/O (I think).
  5890. I think the most straightforward thing would be to let me specify a
  5891. general set of filters outboard of compression (preferably ordered,
  5892. so the order can be automatically reversed on input operations, and
  5893. with the options they require specifiable), but beggars shouldn't be
  5894. choosers and anything you decide on would be fine with me.
  5895. By the way, I like @command{ecc} but if (as the comments say) it can't
  5896. deal with loss of block sync, I'm tempted to throw some time at adding
  5897. that capability. Supposing I were to actually do such a thing and
  5898. get it (apparently) working, do you accept contributed changes to
  5899. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5900. Isn't that exactly the role of the @option{--use-compress-prog=@var{program}} option?
  5901. I never tried it myself, but I suspect you may want to write a
  5902. @var{prog} script or program able to filter stdin to stdout to
  5903. way you want. It should recognize the @option{-d} option, for when
  5904. extraction is needed rather than creation.
  5905. It has been reported that if one writes compressed data (through the
  5906. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  5907. the DLT compression mode, the data will actually get bigger and one will
  5908. end up with less space on the tape.}
  5909. @node sparse
  5910. @subsection Archiving Sparse Files
  5911. @cindex Sparse Files
  5912. @UNREVISED
  5913. @table @option
  5914. @opindex sparse
  5915. @item -S
  5916. @itemx --sparse
  5917. Handle sparse files efficiently.
  5918. @end table
  5919. This option causes all files to be put in the archive to be tested for
  5920. sparseness, and handled specially if they are. The @option{--sparse}
  5921. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  5922. backed up. Using this option dramatically decreases the amount of
  5923. space needed to store such a file.
  5924. In later versions, this option may be removed, and the testing and
  5925. treatment of sparse files may be done automatically with any special
  5926. @acronym{GNU} options. For now, it is an option needing to be specified on
  5927. the command line with the creation or updating of an archive.
  5928. Files in the file system occasionally have ``holes.'' A hole in a file
  5929. is a section of the file's contents which was never written. The
  5930. contents of a hole read as all zeros. On many operating systems,
  5931. actual disk storage is not allocated for holes, but they are counted
  5932. in the length of the file. If you archive such a file, @command{tar}
  5933. could create an archive longer than the original. To have @command{tar}
  5934. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  5935. you use this option, then, for any file using less disk space than
  5936. would be expected from its length, @command{tar} searches the file for
  5937. consecutive stretches of zeros. It then records in the archive for
  5938. the file where the consecutive stretches of zeros are, and only
  5939. archives the ``real contents'' of the file. On extraction (using
  5940. @option{--sparse} is not needed on extraction) any such
  5941. files have holes created wherever the continuous stretches of zeros
  5942. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  5943. won't take more space than the original.
  5944. A file is sparse if it contains blocks of zeros whose existence is
  5945. recorded, but that have no space allocated on disk. When you specify
  5946. the @option{--sparse} option in conjunction with the @option{--create}
  5947. (@option{-c}) operation, @command{tar} tests all files for sparseness
  5948. while archiving. If @command{tar} finds a file to be sparse, it uses a
  5949. sparse representation of the file in the archive. @xref{create}, for
  5950. more information about creating archives.
  5951. @option{--sparse} is useful when archiving files, such as dbm files,
  5952. likely to contain many nulls. This option dramatically
  5953. decreases the amount of space needed to store such an archive.
  5954. @quotation
  5955. @strong{Please Note:} Always use @option{--sparse} when performing file
  5956. system backups, to avoid archiving the expanded forms of files stored
  5957. sparsely in the system.
  5958. Even if your system has no sparse files currently, some may be
  5959. created in the future. If you use @option{--sparse} while making file
  5960. system backups as a matter of course, you can be assured the archive
  5961. will never take more space on the media than the files take on disk
  5962. (otherwise, archiving a disk filled with sparse files might take
  5963. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5964. @end quotation
  5965. @command{tar} ignores the @option{--sparse} option when reading an archive.
  5966. @table @option
  5967. @item --sparse
  5968. @itemx -S
  5969. Files stored sparsely in the file system are represented sparsely in
  5970. the archive. Use in conjunction with write operations.
  5971. @end table
  5972. However, users should be well aware that at archive creation time,
  5973. @GNUTAR{} still has to read whole disk file to
  5974. locate the @dfn{holes}, and so, even if sparse files use little space
  5975. on disk and in the archive, they may sometimes require inordinate
  5976. amount of time for reading and examining all-zero blocks of a file.
  5977. Although it works, it's painfully slow for a large (sparse) file, even
  5978. though the resulting tar archive may be small. (One user reports that
  5979. dumping a @file{core} file of over 400 megabytes, but with only about
  5980. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5981. ELC, with full CPU utilization.)
  5982. This reading is required in all cases and is not related to the fact
  5983. the @option{--sparse} option is used or not, so by merely @emph{not}
  5984. using the option, you are not saving time@footnote{Well! We should say
  5985. the whole truth, here. When @option{--sparse} is selected while creating
  5986. an archive, the current @command{tar} algorithm requires sparse files to be
  5987. read twice, not once. We hope to develop a new archive format for saving
  5988. sparse files in which one pass will be sufficient.}.
  5989. Programs like @command{dump} do not have to read the entire file; by
  5990. examining the file system directly, they can determine in advance
  5991. exactly where the holes are and thus avoid reading through them. The
  5992. only data it need read are the actual allocated data blocks.
  5993. @GNUTAR{} uses a more portable and straightforward
  5994. archiving approach, it would be fairly difficult that it does
  5995. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5996. 1990-12-10:
  5997. @quotation
  5998. What I did say is that you cannot tell the difference between a hole and an
  5999. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6000. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6001. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6002. to name one that does?), they may also care where the holes are (I have
  6003. no examples of this one either, but it's equally imaginable).
  6004. I conclude from this that good archivers are not portable. One can
  6005. arguably conclude that if you want a portable program, you can in good
  6006. conscience restore files with as many holes as possible, since you can't
  6007. get it right.
  6008. @end quotation
  6009. @node Attributes
  6010. @section Handling File Attributes
  6011. @UNREVISED
  6012. When @command{tar} reads files, it updates their access times. To
  6013. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6014. reset the access time retroactively or avoid changing it in the first
  6015. place.
  6016. Handling of file attributes
  6017. @table @option
  6018. @opindex atime-preserve
  6019. @item --atime-preserve
  6020. @itemx --atime-preserve=replace
  6021. @itemx --atime-preserve=system
  6022. Preserve the access times of files that are read. This works only for
  6023. files that you own, unless you have superuser privileges.
  6024. @option{--atime-preserve=replace} works on most systems, but it also
  6025. restores the data modification time and updates the status change
  6026. time. Hence it doesn't interact with incremental dumps nicely
  6027. (@pxref{Backups}), and it can set access or data modification times
  6028. incorrectly if other programs access the file while @command{tar} is
  6029. running.
  6030. @option{--atime-preserve=system} avoids changing the access time in
  6031. the first place, if the operating system supports this.
  6032. Unfortunately, this may or may not work on any given operating system
  6033. or file system. If @command{tar} knows for sure it won't work, it
  6034. complains right away.
  6035. Currently @option{--atime-preserve} with no operand defaults to
  6036. @option{--atime-preserve=replace}, but this is intended to change to
  6037. @option{--atime-preserve=system} when the latter is better-supported.
  6038. @opindex touch
  6039. @item -m
  6040. @itemx --touch
  6041. Do not extract data modification time.
  6042. When this option is used, @command{tar} leaves the data modification times
  6043. of the files it extracts as the times when the files were extracted,
  6044. instead of setting it to the times recorded in the archive.
  6045. This option is meaningless with @option{--list} (@option{-t}).
  6046. @opindex same-owner
  6047. @item --same-owner
  6048. Create extracted files with the same ownership they have in the
  6049. archive.
  6050. This is the default behavior for the superuser,
  6051. so this option is meaningful only for non-root users, when @command{tar}
  6052. is executed on those systems able to give files away. This is
  6053. considered as a security flaw by many people, at least because it
  6054. makes quite difficult to correctly account users for the disk space
  6055. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6056. files are easily and silently lost when files are given away.
  6057. When writing an archive, @command{tar} writes the user id and user name
  6058. separately. If it can't find a user name (because the user id is not
  6059. in @file{/etc/passwd}), then it does not write one. When restoring,
  6060. and doing a @code{chmod} like when you use @option{--same-permissions},
  6061. @FIXME{same-owner?}it tries to look the name (if one was written)
  6062. up in @file{/etc/passwd}. If it fails, then it uses the user id
  6063. stored in the archive instead.
  6064. @opindex no-same-owner
  6065. @item --no-same-owner
  6066. @itemx -o
  6067. Do not attempt to restore ownership when extracting. This is the
  6068. default behavior for ordinary users, so this option has an effect
  6069. only for the superuser.
  6070. @opindex numeric-owner
  6071. @item --numeric-owner
  6072. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6073. without user/group name information or such information to be ignored
  6074. when extracting. It effectively disables the generation and/or use
  6075. of user/group name information. This option forces extraction using
  6076. the numeric ids from the archive, ignoring the names.
  6077. This is useful in certain circumstances, when restoring a backup from
  6078. an emergency floppy with different passwd/group files for example.
  6079. It is otherwise impossible to extract files with the right ownerships
  6080. if the password file in use during the extraction does not match the
  6081. one belonging to the file system(s) being extracted. This occurs,
  6082. for example, if you are restoring your files after a major crash and
  6083. had booted from an emergency floppy with no password file or put your
  6084. disk into another machine to do the restore.
  6085. The numeric ids are @emph{always} saved into @command{tar} archives.
  6086. The identifying names are added at create time when provided by the
  6087. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6088. used when moving archives between a collection of machines using
  6089. a centralized management for attribution of numeric ids to users
  6090. and groups. This is often made through using the NIS capabilities.
  6091. When making a @command{tar} file for distribution to other sites, it
  6092. is sometimes cleaner to use a single owner for all files in the
  6093. distribution, and nicer to specify the write permission bits of the
  6094. files as stored in the archive independently of their actual value on
  6095. the file system. The way to prepare a clean distribution is usually
  6096. to have some Makefile rule creating a directory, copying all needed
  6097. files in that directory, then setting ownership and permissions as
  6098. wanted (there are a lot of possible schemes), and only then making a
  6099. @command{tar} archive out of this directory, before cleaning
  6100. everything out. Of course, we could add a lot of options to
  6101. @GNUTAR{} for fine tuning permissions and ownership.
  6102. This is not the good way, I think. @GNUTAR{} is
  6103. already crowded with options and moreover, the approach just explained
  6104. gives you a great deal of control already.
  6105. @opindex same-permissions, short description
  6106. @opindex preserve-permissions, short description
  6107. @item -p
  6108. @itemx --same-permissions
  6109. @itemx --preserve-permissions
  6110. Extract all protection information.
  6111. This option causes @command{tar} to set the modes (access permissions) of
  6112. extracted files exactly as recorded in the archive. If this option
  6113. is not used, the current @code{umask} setting limits the permissions
  6114. on extracted files. This option is by default enabled when
  6115. @command{tar} is executed by a superuser.
  6116. This option is meaningless with @option{--list} (@option{-t}).
  6117. @opindex preserve
  6118. @item --preserve
  6119. Same as both @option{--same-permissions} and @option{--same-order}.
  6120. The @option{--preserve} option has no equivalent short option name.
  6121. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6122. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  6123. @end table
  6124. @node Standard
  6125. @section Basic Tar Format
  6126. @UNREVISED
  6127. While an archive may contain many files, the archive itself is a
  6128. single ordinary file. Like any other file, an archive file can be
  6129. written to a storage device such as a tape or disk, sent through a
  6130. pipe or over a network, saved on the active file system, or even
  6131. stored in another archive. An archive file is not easy to read or
  6132. manipulate without using the @command{tar} utility or Tar mode in
  6133. @acronym{GNU} Emacs.
  6134. Physically, an archive consists of a series of file entries terminated
  6135. by an end-of-archive entry, which consists of two 512 blocks of zero
  6136. bytes. A file
  6137. entry usually describes one of the files in the archive (an
  6138. @dfn{archive member}), and consists of a file header and the contents
  6139. of the file. File headers contain file names and statistics, checksum
  6140. information which @command{tar} uses to detect file corruption, and
  6141. information about file types.
  6142. Archives are permitted to have more than one member with the same
  6143. member name. One way this situation can occur is if more than one
  6144. version of a file has been stored in the archive. For information
  6145. about adding new versions of a file to an archive, see @ref{update}.
  6146. @FIXME-xref{To learn more about having more than one archive member with the
  6147. same name, see -backup node, when it's written.}
  6148. In addition to entries describing archive members, an archive may
  6149. contain entries which @command{tar} itself uses to store information.
  6150. @xref{label}, for an example of such an archive entry.
  6151. A @command{tar} archive file contains a series of blocks. Each block
  6152. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6153. of as being on magnetic tape, other media are often used.
  6154. Each file archived is represented by a header block which describes
  6155. the file, followed by zero or more blocks which give the contents
  6156. of the file. At the end of the archive file there are two 512-byte blocks
  6157. filled with binary zeros as an end-of-file marker. A reasonable system
  6158. should write such end-of-file marker at the end of an archive, but
  6159. must not assume that such a block exists when reading an archive. In
  6160. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6161. The blocks may be @dfn{blocked} for physical I/O operations.
  6162. Each record of @var{n} blocks (where @var{n} is set by the
  6163. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6164. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6165. such a write is a single record. When writing an archive,
  6166. the last record of blocks should be written at the full size, with
  6167. blocks after the zero block containing all zeros. When reading
  6168. an archive, a reasonable system should properly handle an archive
  6169. whose last record is shorter than the rest, or which contains garbage
  6170. records after a zero block.
  6171. The header block is defined in C as follows. In the @GNUTAR{}
  6172. distribution, this is part of file @file{src/tar.h}:
  6173. @smallexample
  6174. @include header.texi
  6175. @end smallexample
  6176. All characters in header blocks are represented by using 8-bit
  6177. characters in the local variant of ASCII. Each field within the
  6178. structure is contiguous; that is, there is no padding used within
  6179. the structure. Each character on the archive medium is stored
  6180. contiguously.
  6181. Bytes representing the contents of files (after the header block
  6182. of each file) are not translated in any way and are not constrained
  6183. to represent characters in any character set. The @command{tar} format
  6184. does not distinguish text files from binary files, and no translation
  6185. of file contents is performed.
  6186. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6187. @code{gname} are null-terminated character strings. All other fields
  6188. are zero-filled octal numbers in ASCII. Each numeric field of width
  6189. @var{w} contains @var{w} minus 1 digits, and a null.
  6190. The @code{name} field is the file name of the file, with directory names
  6191. (if any) preceding the file name, separated by slashes.
  6192. @FIXME{how big a name before field overflows?}
  6193. The @code{mode} field provides nine bits specifying file permissions
  6194. and three bits to specify the Set UID, Set GID, and Save Text
  6195. (@dfn{sticky}) modes. Values for these bits are defined above.
  6196. When special permissions are required to create a file with a given
  6197. mode, and the user restoring files from the archive does not hold such
  6198. permissions, the mode bit(s) specifying those special permissions
  6199. are ignored. Modes which are not supported by the operating system
  6200. restoring files from the archive will be ignored. Unsupported modes
  6201. should be faked up when creating or updating an archive; e.g., the
  6202. group permission could be copied from the @emph{other} permission.
  6203. The @code{uid} and @code{gid} fields are the numeric user and group
  6204. ID of the file owners, respectively. If the operating system does
  6205. not support numeric user or group IDs, these fields should be ignored.
  6206. The @code{size} field is the size of the file in bytes; linked files
  6207. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6208. particular the @option{--incremental} (@option{-G}) option.}
  6209. The @code{mtime} field is the data modification time of the file at
  6210. the time it was archived. It is the ASCII representation of the octal
  6211. value of the last time the file's contents were modified, represented
  6212. as an integer number of
  6213. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6214. The @code{chksum} field is the ASCII representation of the octal value
  6215. of the simple sum of all bytes in the header block. Each 8-bit
  6216. byte in the header is added to an unsigned integer, initialized to
  6217. zero, the precision of which shall be no less than seventeen bits.
  6218. When calculating the checksum, the @code{chksum} field is treated as
  6219. if it were all blanks.
  6220. The @code{typeflag} field specifies the type of file archived. If a
  6221. particular implementation does not recognize or permit the specified
  6222. type, the file will be extracted as if it were a regular file. As this
  6223. action occurs, @command{tar} issues a warning to the standard error.
  6224. The @code{atime} and @code{ctime} fields are used in making incremental
  6225. backups; they store, respectively, the particular file's access and
  6226. status change times.
  6227. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6228. making a multi-volume archive. The offset is number of bytes into
  6229. the file that we need to restart at to continue the file on the next
  6230. tape, i.e., where we store the location that a continued file is
  6231. continued at.
  6232. The following fields were added to deal with sparse files. A file
  6233. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6234. represented as zeros, i.e., no useful data. A test to see if a file
  6235. is sparse is to look at the number blocks allocated for it versus the
  6236. number of characters in the file; if there are fewer blocks allocated
  6237. for the file than would normally be allocated for a file of that
  6238. size, then the file is sparse. This is the method @command{tar} uses to
  6239. detect a sparse file, and once such a file is detected, it is treated
  6240. differently from non-sparse files.
  6241. Sparse files are often @code{dbm} files, or other database-type files
  6242. which have data at some points and emptiness in the greater part of
  6243. the file. Such files can appear to be very large when an @samp{ls
  6244. -l} is done on them, when in truth, there may be a very small amount
  6245. of important data contained in the file. It is thus undesirable
  6246. to have @command{tar} think that it must back up this entire file, as
  6247. great quantities of room are wasted on empty blocks, which can lead
  6248. to running out of room on a tape far earlier than is necessary.
  6249. Thus, sparse files are dealt with so that these empty blocks are
  6250. not written to the tape. Instead, what is written to the tape is a
  6251. description, of sorts, of the sparse file: where the holes are, how
  6252. big the holes are, and how much data is found at the end of the hole.
  6253. This way, the file takes up potentially far less room on the tape,
  6254. and when the file is extracted later on, it will look exactly the way
  6255. it looked beforehand. The following is a description of the fields
  6256. used to handle a sparse file:
  6257. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6258. sparse} contains two 12-character strings which represent an offset
  6259. into the file and a number of bytes to be written at that offset.
  6260. The offset is absolute, and not relative to the offset in preceding
  6261. array element.
  6262. The header can hold four of these @code{struct sparse} at the moment;
  6263. if more are needed, they are not stored in the header.
  6264. The @code{isextended} flag is set when an @code{extended_header}
  6265. is needed to deal with a file. Note that this means that this flag
  6266. can only be set when dealing with a sparse file, and it is only set
  6267. in the event that the description of the file will not fit in the
  6268. allotted room for sparse structures in the header. In other words,
  6269. an extended_header is needed.
  6270. The @code{extended_header} structure is used for sparse files which
  6271. need more sparse structures than can fit in the header. The header can
  6272. fit 4 such structures; if more are needed, the flag @code{isextended}
  6273. gets set and the next block is an @code{extended_header}.
  6274. Each @code{extended_header} structure contains an array of 21
  6275. sparse structures, along with a similar @code{isextended} flag
  6276. that the header had. There can be an indeterminate number of such
  6277. @code{extended_header}s to describe a sparse file.
  6278. @table @asis
  6279. @item @code{REGTYPE}
  6280. @itemx @code{AREGTYPE}
  6281. These flags represent a regular file. In order to be compatible
  6282. with older versions of @command{tar}, a @code{typeflag} value of
  6283. @code{AREGTYPE} should be silently recognized as a regular file.
  6284. New archives should be created using @code{REGTYPE}. Also, for
  6285. backward compatibility, @command{tar} treats a regular file whose name
  6286. ends with a slash as a directory.
  6287. @item @code{LNKTYPE}
  6288. This flag represents a file linked to another file, of any type,
  6289. previously archived. Such files are identified in Unix by each
  6290. file having the same device and inode number. The linked-to name is
  6291. specified in the @code{linkname} field with a trailing null.
  6292. @item @code{SYMTYPE}
  6293. This represents a symbolic link to another file. The linked-to name
  6294. is specified in the @code{linkname} field with a trailing null.
  6295. @item @code{CHRTYPE}
  6296. @itemx @code{BLKTYPE}
  6297. These represent character special files and block special files
  6298. respectively. In this case the @code{devmajor} and @code{devminor}
  6299. fields will contain the major and minor device numbers respectively.
  6300. Operating systems may map the device specifications to their own
  6301. local specification, or may ignore the entry.
  6302. @item @code{DIRTYPE}
  6303. This flag specifies a directory or sub-directory. The directory
  6304. name in the @code{name} field should end with a slash. On systems where
  6305. disk allocation is performed on a directory basis, the @code{size} field
  6306. will contain the maximum number of bytes (which may be rounded to
  6307. the nearest disk block allocation unit) which the directory may
  6308. hold. A @code{size} field of zero indicates no such limiting. Systems
  6309. which do not support limiting in this manner should ignore the
  6310. @code{size} field.
  6311. @item @code{FIFOTYPE}
  6312. This specifies a FIFO special file. Note that the archiving of a
  6313. FIFO file archives the existence of this file and not its contents.
  6314. @item @code{CONTTYPE}
  6315. This specifies a contiguous file, which is the same as a normal
  6316. file except that, in operating systems which support it, all its
  6317. space is allocated contiguously on the disk. Operating systems
  6318. which do not allow contiguous allocation should silently treat this
  6319. type as a normal file.
  6320. @item @code{A} @dots{} @code{Z}
  6321. These are reserved for custom implementations. Some of these are
  6322. used in the @acronym{GNU} modified format, as described below.
  6323. @end table
  6324. Other values are reserved for specification in future revisions of
  6325. the P1003 standard, and should not be used by any @command{tar} program.
  6326. The @code{magic} field indicates that this archive was output in
  6327. the P1003 archive format. If this field contains @code{TMAGIC},
  6328. the @code{uname} and @code{gname} fields will contain the ASCII
  6329. representation of the owner and group of the file respectively.
  6330. If found, the user and group IDs are used rather than the values in
  6331. the @code{uid} and @code{gid} fields.
  6332. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6333. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6334. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6335. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6336. @node Extensions
  6337. @section @acronym{GNU} Extensions to the Archive Format
  6338. @UNREVISED
  6339. The @acronym{GNU} format uses additional file types to describe new types of
  6340. files in an archive. These are listed below.
  6341. @table @code
  6342. @item GNUTYPE_DUMPDIR
  6343. @itemx 'D'
  6344. This represents a directory and a list of files created by the
  6345. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6346. size of the associated list of files. Each file name is preceded by
  6347. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6348. (The file is a directory, or is not stored in the archive.) Each file
  6349. name is terminated by a null. There is an additional null after the
  6350. last file name.
  6351. @item GNUTYPE_MULTIVOL
  6352. @itemx 'M'
  6353. This represents a file continued from another volume of a multi-volume
  6354. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6355. type of the file is not given here. The @code{size} field gives the
  6356. maximum size of this piece of the file (assuming the volume does
  6357. not end before the file is written out). The @code{offset} field
  6358. gives the offset from the beginning of the file where this part of
  6359. the file begins. Thus @code{size} plus @code{offset} should equal
  6360. the original size of the file.
  6361. @item GNUTYPE_SPARSE
  6362. @itemx 'S'
  6363. This flag indicates that we are dealing with a sparse file. Note
  6364. that archiving a sparse file requires special operations to find
  6365. holes in the file, which mark the positions of these holes, along
  6366. with the number of bytes of data to be found after the hole.
  6367. @item GNUTYPE_VOLHDR
  6368. @itemx 'V'
  6369. This file type is used to mark the volume header that was given with
  6370. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6371. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6372. The @code{size} field is zero. Only the first file in each volume
  6373. of an archive should have this type.
  6374. @end table
  6375. You may have trouble reading a @acronym{GNU} format archive on a
  6376. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6377. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6378. used when writing the archive. In general, if @command{tar} does not
  6379. use the @acronym{GNU}-added fields of the header, other versions of
  6380. @command{tar} should be able to read the archive. Otherwise, the
  6381. @command{tar} program will give an error, the most likely one being a
  6382. checksum error.
  6383. @node cpio
  6384. @section Comparison of @command{tar} and @command{cpio}
  6385. @UNREVISED
  6386. @FIXME{Reorganize the following material}
  6387. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6388. pathname lengths. The binary and old ASCII formats have a max path
  6389. length of 256, and the new ASCII and CRC ASCII formats have a max
  6390. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6391. with arbitrary pathname lengths, but other @command{cpio} implementations
  6392. may crash unexplainedly trying to read them.
  6393. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6394. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6395. in System V prior to SVR4, and some vendors may have added symlinks
  6396. to their system without enhancing @command{cpio} to know about them.
  6397. Others may have enhanced it in a way other than the way I did it
  6398. at Sun, and which was adopted by AT&T (and which is, I think, also
  6399. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6400. into a later BSD release---I think I gave them my changes).
  6401. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6402. can handle @command{tar} format input, and write it on output, and it
  6403. probably handles symbolic links. They may not have bothered doing
  6404. anything to enhance @command{tar} as a result.)
  6405. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6406. @command{tar} comes with V7, System III, System V, and BSD source;
  6407. @command{cpio} comes only with System III, System V, and later BSD
  6408. (4.3-tahoe and later).
  6409. @command{tar}'s way of handling multiple hard links to a file can handle
  6410. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6411. @command{cpio}s way requires you to play some games (in its "binary"
  6412. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6413. they're 18 bits---it would have to play games with the "file system ID"
  6414. field of the header to make sure that the file system ID/i-number pairs
  6415. of different files were always different), and I don't know which
  6416. @command{cpio}s, if any, play those games. Those that don't might get
  6417. confused and think two files are the same file when they're not, and
  6418. make hard links between them.
  6419. @command{tar}s way of handling multiple hard links to a file places only
  6420. one copy of the link on the tape, but the name attached to that copy
  6421. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6422. way puts one copy for every link, but you can retrieve it using any
  6423. of the names.
  6424. @quotation
  6425. What type of check sum (if any) is used, and how is this calculated.
  6426. @end quotation
  6427. See the attached manual pages for @command{tar} and @command{cpio} format.
  6428. @command{tar} uses a checksum which is the sum of all the bytes in the
  6429. @command{tar} header for a file; @command{cpio} uses no checksum.
  6430. @quotation
  6431. If anyone knows why @command{cpio} was made when @command{tar} was present
  6432. at the unix scene,
  6433. @end quotation
  6434. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6435. generally-available version of UNIX had @command{tar} at the time. I don't
  6436. know whether any version that was generally available @emph{within AT&T}
  6437. had @command{tar}, or, if so, whether the people within AT&T who did
  6438. @command{cpio} knew about it.
  6439. On restore, if there is a corruption on a tape @command{tar} will stop at
  6440. that point, while @command{cpio} will skip over it and try to restore the
  6441. rest of the files.
  6442. The main difference is just in the command syntax and header format.
  6443. @command{tar} is a little more tape-oriented in that everything is blocked
  6444. to start on a record boundary.
  6445. @quotation
  6446. Is there any differences between the ability to recover crashed
  6447. archives between the two of them. (Is there any chance of recovering
  6448. crashed archives at all.)
  6449. @end quotation
  6450. Theoretically it should be easier under @command{tar} since the blocking
  6451. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6452. However, modern @command{cpio}'s and variations have an option to just
  6453. search for the next file header after an error with a reasonable chance
  6454. of resyncing. However, lots of tape driver software won't allow you to
  6455. continue past a media error which should be the only reason for getting
  6456. out of sync unless a file changed sizes while you were writing the
  6457. archive.
  6458. @quotation
  6459. If anyone knows why @command{cpio} was made when @command{tar} was present
  6460. at the unix scene, please tell me about this too.
  6461. @end quotation
  6462. Probably because it is more media efficient (by not blocking everything
  6463. and using only the space needed for the headers where @command{tar}
  6464. always uses 512 bytes per file header) and it knows how to archive
  6465. special files.
  6466. You might want to look at the freely available alternatives. The
  6467. major ones are @command{afio}, @GNUTAR{}, and
  6468. @command{pax}, each of which have their own extensions with some
  6469. backwards compatibility.
  6470. Sparse files were @command{tar}red as sparse files (which you can
  6471. easily test, because the resulting archive gets smaller, and
  6472. @acronym{GNU} @command{cpio} can no longer read it).
  6473. @node Media
  6474. @chapter Tapes and Other Archive Media
  6475. @UNREVISED
  6476. A few special cases about tape handling warrant more detailed
  6477. description. These special cases are discussed below.
  6478. Many complexities surround the use of @command{tar} on tape drives. Since
  6479. the creation and manipulation of archives located on magnetic tape was
  6480. the original purpose of @command{tar}, it contains many features making
  6481. such manipulation easier.
  6482. Archives are usually written on dismountable media---tape cartridges,
  6483. mag tapes, or floppy disks.
  6484. The amount of data a tape or disk holds depends not only on its size,
  6485. but also on how it is formatted. A 2400 foot long reel of mag tape
  6486. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6487. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6488. Magnetic media are re-usable---once the archive on a tape is no longer
  6489. needed, the archive can be erased and the tape or disk used over.
  6490. Media quality does deteriorate with use, however. Most tapes or disks
  6491. should be discarded when they begin to produce data errors. EXABYTE
  6492. tape cartridges should be discarded when they generate an @dfn{error
  6493. count} (number of non-usable bits) of more than 10k.
  6494. Magnetic media are written and erased using magnetic fields, and
  6495. should be protected from such fields to avoid damage to stored data.
  6496. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6497. not a good idea.
  6498. @menu
  6499. * Device:: Device selection and switching
  6500. * Remote Tape Server::
  6501. * Common Problems and Solutions::
  6502. * Blocking:: Blocking
  6503. * Many:: Many archives on one tape
  6504. * Using Multiple Tapes:: Using Multiple Tapes
  6505. * label:: Including a Label in the Archive
  6506. * verify::
  6507. * Write Protection::
  6508. @end menu
  6509. @node Device
  6510. @section Device Selection and Switching
  6511. @UNREVISED
  6512. @table @option
  6513. @item -f [@var{hostname}:]@var{file}
  6514. @itemx --file=[@var{hostname}:]@var{file}
  6515. Use archive file or device @var{file} on @var{hostname}.
  6516. @end table
  6517. This option is used to specify the file name of the archive @command{tar}
  6518. works on.
  6519. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6520. input (when listing or extracting), or writes it to standard output
  6521. (when creating). If the @samp{-} file name is given when updating an
  6522. archive, @command{tar} will read the original archive from its standard
  6523. input, and will write the entire new archive to its standard output.
  6524. If the file name contains a @samp{:}, it is interpreted as
  6525. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6526. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6527. either case, @command{tar} will invoke the command @command{rsh} (or
  6528. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6529. machine. If you give an alternate login name, it will be given to the
  6530. @command{rsh}.
  6531. Naturally, the remote machine must have an executable
  6532. @command{/usr/libexec/rmt}. This program is free software from the
  6533. University of California, and a copy of the source code can be found
  6534. with the sources for @command{tar}; it's compiled and installed by default.
  6535. The exact path to this utility is determined when configuring the package.
  6536. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6537. your installation prefix. This location may also be overridden at
  6538. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6539. ---rmt-command}, for detailed description of this option. @xref{Remote
  6540. Tape Server}, for the description of @command{rmt} command).
  6541. If this option is not given, but the environment variable @env{TAPE}
  6542. is set, its value is used; otherwise, old versions of @command{tar}
  6543. used a default archive name (which was picked when @command{tar} was
  6544. compiled). The default is normally set up to be the @dfn{first} tape
  6545. drive or other transportable I/O medium on the system.
  6546. Starting with version 1.11.5, @GNUTAR{} uses
  6547. standard input and standard output as the default device, and I will
  6548. not try anymore supporting automatic device detection at installation
  6549. time. This was failing really in too many cases, it was hopeless.
  6550. This is now completely left to the installer to override standard
  6551. input and standard output for default device, if this seems
  6552. preferable. Further, I think @emph{most} actual usages of
  6553. @command{tar} are done with pipes or disks, not really tapes,
  6554. cartridges or diskettes.
  6555. Some users think that using standard input and output is running
  6556. after trouble. This could lead to a nasty surprise on your screen if
  6557. you forget to specify an output file name---especially if you are going
  6558. through a network or terminal server capable of buffering large amounts
  6559. of output. We had so many bug reports in that area of configuring
  6560. default tapes automatically, and so many contradicting requests, that
  6561. we finally consider the problem to be portably intractable. We could
  6562. of course use something like @samp{/dev/tape} as a default, but this
  6563. is @emph{also} running after various kind of trouble, going from hung
  6564. processes to accidental destruction of real tapes. After having seen
  6565. all this mess, using standard input and output as a default really
  6566. sounds like the only clean choice left, and a very useful one too.
  6567. @GNUTAR{} reads and writes archive in records, I
  6568. suspect this is the main reason why block devices are preferred over
  6569. character devices. Most probably, block devices are more efficient
  6570. too. The installer could also check for @samp{DEFTAPE} in
  6571. @file{<sys/mtio.h>}.
  6572. @table @option
  6573. @opindex force-local, short description
  6574. @item --force-local
  6575. Archive file is local even if it contains a colon.
  6576. @opindex rsh-command
  6577. @item --rsh-command=@var{command}
  6578. Use remote @var{command} instead of @command{rsh}. This option exists
  6579. so that people who use something other than the standard @command{rsh}
  6580. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6581. When this command is not used, the shell command found when
  6582. the @command{tar} program was installed is used instead. This is
  6583. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6584. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6585. The installer may have overridden this by defining the environment
  6586. variable @env{RSH} @emph{at installation time}.
  6587. @item -[0-7][lmh]
  6588. Specify drive and density.
  6589. @opindex multi-volume, short description
  6590. @item -M
  6591. @itemx --multi-volume
  6592. Create/list/extract multi-volume archive.
  6593. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6594. that may be larger than will fit on the medium used to hold it.
  6595. @xref{Multi-Volume Archives}.
  6596. @opindex tape-length, short description
  6597. @item -L @var{num}
  6598. @itemx --tape-length=@var{num}
  6599. Change tape after writing @var{num} x 1024 bytes.
  6600. This option might be useful when your tape drivers do not properly
  6601. detect end of physical tapes. By being slightly conservative on the
  6602. maximum tape length, you might avoid the problem entirely.
  6603. @opindex info-script, short description
  6604. @opindex new-volume-script, short description
  6605. @item -F @var{file}
  6606. @itemx --info-script=@var{file}
  6607. @itemx --new-volume-script=@var{file}
  6608. Execute @file{file} at end of each tape. This implies
  6609. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6610. description of this option.
  6611. @end table
  6612. @node Remote Tape Server
  6613. @section The Remote Tape Server
  6614. @cindex remote tape drive
  6615. @pindex rmt
  6616. In order to access the tape drive on a remote machine, @command{tar}
  6617. uses the remote tape server written at the University of California at
  6618. Berkeley. The remote tape server must be installed as
  6619. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6620. want to use. @command{tar} calls @command{rmt} by running an
  6621. @command{rsh} or @command{remsh} to the remote machine, optionally
  6622. using a different login name if one is supplied.
  6623. A copy of the source for the remote tape server is provided. It is
  6624. Copyright @copyright{} 1983 by the Regents of the University of
  6625. California, but can be freely distributed. It is compiled and
  6626. installed by default.
  6627. @cindex absolute file names
  6628. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6629. @GNUTAR{} will not allow you to create an archive that contains
  6630. absolute file names (a file name beginning with @samp{/}.) If you try,
  6631. @command{tar} will automatically remove the leading @samp{/} from the
  6632. file names it stores in the archive. It will also type a warning
  6633. message telling you what it is doing.
  6634. When reading an archive that was created with a different
  6635. @command{tar} program, @GNUTAR{} automatically
  6636. extracts entries in the archive which have absolute file names as if
  6637. the file names were not absolute. This is an important feature. A
  6638. visitor here once gave a @command{tar} tape to an operator to restore;
  6639. the operator used Sun @command{tar} instead of @GNUTAR{},
  6640. and the result was that it replaced large portions of
  6641. our @file{/bin} and friends with versions from the tape; needless to
  6642. say, we were unhappy about having to recover the file system from
  6643. backup tapes.
  6644. For example, if the archive contained a file @file{/usr/bin/computoy},
  6645. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6646. relative to the current directory. If you want to extract the files in
  6647. an archive to the same absolute names that they had when the archive
  6648. was created, you should do a @samp{cd /} before extracting the files
  6649. from the archive, or you should either use the @option{--absolute-names}
  6650. option, or use the command @samp{tar -C / @dots{}}.
  6651. @cindex Ultrix 3.1 and write failure
  6652. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6653. can claim that a short write near the end of a tape succeeded,
  6654. when it actually failed. This will result in the -M option not
  6655. working correctly. The best workaround at the moment is to use a
  6656. significantly larger blocking factor than the default 20.
  6657. In order to update an archive, @command{tar} must be able to backspace the
  6658. archive in order to reread or rewrite a record that was just read (or
  6659. written). This is currently possible only on two kinds of files: normal
  6660. disk files (or any other file that can be backspaced with @samp{lseek}),
  6661. and industry-standard 9-track magnetic tape (or any other kind of tape
  6662. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6663. This means that the @option{--append}, @option{--concatenate}, and
  6664. @option{--delete} commands will not work on any other kind of file.
  6665. Some media simply cannot be backspaced, which means these commands and
  6666. options will never be able to work on them. These non-backspacing
  6667. media include pipes and cartridge tape drives.
  6668. Some other media can be backspaced, and @command{tar} will work on them
  6669. once @command{tar} is modified to do so.
  6670. Archives created with the @option{--multi-volume}, @option{--label}, and
  6671. @option{--incremental} (@option{-G}) options may not be readable by other version
  6672. of @command{tar}. In particular, restoring a file that was split over
  6673. a volume boundary will require some careful work with @command{dd}, if
  6674. it can be done at all. Other versions of @command{tar} may also create
  6675. an empty file whose name is that of the volume header. Some versions
  6676. of @command{tar} may create normal files instead of directories archived
  6677. with the @option{--incremental} (@option{-G}) option.
  6678. @node Common Problems and Solutions
  6679. @section Some Common Problems and their Solutions
  6680. @ifclear PUBLISH
  6681. @format
  6682. errors from system:
  6683. permission denied
  6684. no such file or directory
  6685. not owner
  6686. errors from @command{tar}:
  6687. directory checksum error
  6688. header format error
  6689. errors from media/system:
  6690. i/o error
  6691. device busy
  6692. @end format
  6693. @end ifclear
  6694. @node Blocking
  6695. @section Blocking
  6696. @UNREVISED
  6697. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6698. is also confusing to the expert reader. On the other hand, readers
  6699. who are new to the field have a fresh mind, and they may safely skip
  6700. the next two paragraphs, as the remainder of this manual uses those
  6701. two terms in a quite consistent way.
  6702. John Gilmore, the writer of the public domain @command{tar} from which
  6703. @GNUTAR{} was originally derived, wrote (June 1995):
  6704. @quotation
  6705. The nomenclature of tape drives comes from IBM, where I believe
  6706. they were invented for the IBM 650 or so. On IBM mainframes, what
  6707. is recorded on tape are tape blocks. The logical organization of
  6708. data is into records. There are various ways of putting records into
  6709. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6710. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6711. to a block), @code{VB} (variable size records, @var{n} to a block),
  6712. @code{VSB} (variable spanned blocked: variable sized records that can
  6713. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6714. parameter specified this to the operating system.
  6715. The Unix man page on @command{tar} was totally confused about this.
  6716. When I wrote @code{PD TAR}, I used the historically correct terminology
  6717. (@command{tar} writes data records, which are grouped into blocks).
  6718. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6719. here), and now Fran@,{c}ois has migrated that terminology back
  6720. into the source code too.
  6721. @end quotation
  6722. The term @dfn{physical block} means the basic transfer chunk from or
  6723. to a device, after which reading or writing may stop without anything
  6724. being lost. In this manual, the term @dfn{block} usually refers to
  6725. a disk physical block, @emph{assuming} that each disk block is 512
  6726. bytes in length. It is true that some disk devices have different
  6727. physical blocks, but @command{tar} ignore these differences in its own
  6728. format, which is meant to be portable, so a @command{tar} block is always
  6729. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6730. The term @dfn{logical block} often represents the basic chunk of
  6731. allocation of many disk blocks as a single entity, which the operating
  6732. system treats somewhat atomically; this concept is only barely used
  6733. in @GNUTAR{}.
  6734. The term @dfn{physical record} is another way to speak of a physical
  6735. block, those two terms are somewhat interchangeable. In this manual,
  6736. the term @dfn{record} usually refers to a tape physical block,
  6737. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6738. It is true that archives may be put on disk or used with pipes,
  6739. but nevertheless, @command{tar} tries to read and write the archive one
  6740. @dfn{record} at a time, whatever the medium in use. One record is made
  6741. up of an integral number of blocks, and this operation of putting many
  6742. disk blocks into a single tape block is called @dfn{reblocking}, or
  6743. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6744. the logical organization of many characters into something meaningful
  6745. to the application. The term @dfn{unit record} describes a small set
  6746. of characters which are transmitted whole to or by the application,
  6747. and often refers to a line of text. Those two last terms are unrelated
  6748. to what we call a @dfn{record} in @GNUTAR{}.
  6749. When writing to tapes, @command{tar} writes the contents of the archive
  6750. in chunks known as @dfn{records}. To change the default blocking
  6751. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  6752. @var{512-size}}) option. Each record will then be composed of
  6753. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  6754. @xref{Standard}.) Each file written to the archive uses at least one
  6755. full record. As a result, using a larger record size can result in
  6756. more wasted space for small files. On the other hand, a larger record
  6757. size can often be read and written much more efficiently.
  6758. Further complicating the problem is that some tape drives ignore the
  6759. blocking entirely. For these, a larger record size can still improve
  6760. performance (because the software layers above the tape drive still
  6761. honor the blocking), but not as dramatically as on tape drives that
  6762. honor blocking.
  6763. When reading an archive, @command{tar} can usually figure out the
  6764. record size on itself. When this is the case, and a non-standard
  6765. record size was used when the archive was created, @command{tar} will
  6766. print a message about a non-standard blocking factor, and then operate
  6767. normally. On some tape devices, however, @command{tar} cannot figure
  6768. out the record size itself. On most of those, you can specify a
  6769. blocking factor (with @option{--blocking-factor}) larger than the
  6770. actual blocking factor, and then use the @option{--read-full-records}
  6771. (@option{-B}) option. (If you specify a blocking factor with
  6772. @option{--blocking-factor} and don't use the
  6773. @option{--read-full-records} option, then @command{tar} will not
  6774. attempt to figure out the recording size itself.) On some devices,
  6775. you must always specify the record size exactly with
  6776. @option{--blocking-factor} when reading, because @command{tar} cannot
  6777. figure it out. In any case, use @option{--list} (@option{-t}) before
  6778. doing any extractions to see whether @command{tar} is reading the archive
  6779. correctly.
  6780. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6781. putting them into records is to put a whole number of them (one or
  6782. more) into each record. @command{tar} records are all the same size;
  6783. at the end of the file there's a block containing all zeros, which
  6784. is how you tell that the remainder of the last record(s) are garbage.
  6785. In a standard @command{tar} file (no options), the block size is 512
  6786. and the record size is 10240, for a blocking factor of 20. What the
  6787. @option{--blocking-factor} option does is sets the blocking factor,
  6788. changing the record size while leaving the block size at 512 bytes.
  6789. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6790. most tape drives these days prefer much bigger records in order to
  6791. stream and not waste tape. When writing tapes for myself, some tend
  6792. to use a factor of the order of 2048, say, giving a record size of
  6793. around one megabyte.
  6794. If you use a blocking factor larger than 20, older @command{tar}
  6795. programs might not be able to read the archive, so we recommend this
  6796. as a limit to use in practice. @GNUTAR{}, however,
  6797. will support arbitrarily large record sizes, limited only by the
  6798. amount of virtual memory or the physical characteristics of the tape
  6799. device.
  6800. @menu
  6801. * Format Variations:: Format Variations
  6802. * Blocking Factor:: The Blocking Factor of an Archive
  6803. @end menu
  6804. @node Format Variations
  6805. @subsection Format Variations
  6806. @cindex Format Parameters
  6807. @cindex Format Options
  6808. @cindex Options, archive format specifying
  6809. @cindex Options, format specifying
  6810. @UNREVISED
  6811. Format parameters specify how an archive is written on the archive
  6812. media. The best choice of format parameters will vary depending on
  6813. the type and number of files being archived, and on the media used to
  6814. store the archive.
  6815. To specify format parameters when accessing or creating an archive,
  6816. you can use the options described in the following sections.
  6817. If you do not specify any format parameters, @command{tar} uses
  6818. default parameters. You cannot modify a compressed archive.
  6819. If you create an archive with the @option{--blocking-factor} option
  6820. specified (@pxref{Blocking Factor}), you must specify that
  6821. blocking-factor when operating on the archive. @xref{Formats}, for other
  6822. examples of format parameter considerations.
  6823. @node Blocking Factor
  6824. @subsection The Blocking Factor of an Archive
  6825. @cindex Blocking Factor
  6826. @cindex Record Size
  6827. @cindex Number of blocks per record
  6828. @cindex Number of bytes per record
  6829. @cindex Bytes per record
  6830. @cindex Blocks per record
  6831. @UNREVISED
  6832. @opindex blocking-factor
  6833. The data in an archive is grouped into blocks, which are 512 bytes.
  6834. Blocks are read and written in whole number multiples called
  6835. @dfn{records}. The number of blocks in a record (ie. the size of a
  6836. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6837. The @option{--blocking-factor=@var{512-size}} (@option{-b
  6838. @var{512-size}}) option specifies the blocking factor of an archive.
  6839. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  6840. can be specified at installation. To find out the blocking factor of
  6841. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  6842. This may not work on some devices.
  6843. Records are separated by gaps, which waste space on the archive media.
  6844. If you are archiving on magnetic tape, using a larger blocking factor
  6845. (and therefore larger records) provides faster throughput and allows you
  6846. to fit more data on a tape (because there are fewer gaps). If you are
  6847. archiving on cartridge, a very large blocking factor (say 126 or more)
  6848. greatly increases performance. A smaller blocking factor, on the other
  6849. hand, may be useful when archiving small files, to avoid archiving lots
  6850. of nulls as @command{tar} fills out the archive to the end of the record.
  6851. In general, the ideal record size depends on the size of the
  6852. inter-record gaps on the tape you are using, and the average size of the
  6853. files you are archiving. @xref{create}, for information on
  6854. writing archives.
  6855. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6856. Archives with blocking factors larger than 20 cannot be read
  6857. by very old versions of @command{tar}, or by some newer versions
  6858. of @command{tar} running on old machines with small address spaces.
  6859. With @GNUTAR{}, the blocking factor of an archive is limited
  6860. only by the maximum record size of the device containing the archive,
  6861. or by the amount of available virtual memory.
  6862. Also, on some systems, not using adequate blocking factors, as sometimes
  6863. imposed by the device drivers, may yield unexpected diagnostics. For
  6864. example, this has been reported:
  6865. @smallexample
  6866. Cannot write to /dev/dlt: Invalid argument
  6867. @end smallexample
  6868. @noindent
  6869. In such cases, it sometimes happen that the @command{tar} bundled by
  6870. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6871. requires an explicit specification for the block size,
  6872. which it cannot guess. This yields some people to consider
  6873. @GNUTAR{} is misbehaving, because by comparison,
  6874. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6875. for example, might resolve the problem.
  6876. If you use a non-default blocking factor when you create an archive, you
  6877. must specify the same blocking factor when you modify that archive. Some
  6878. archive devices will also require you to specify the blocking factor when
  6879. reading that archive, however this is not typically the case. Usually, you
  6880. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  6881. reports a non-default record size and then lists the archive members as
  6882. it would normally. To extract files from an archive with a non-standard
  6883. blocking factor (particularly if you're not sure what the blocking factor
  6884. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  6885. specifying a blocking factor larger then the blocking factor of the archive
  6886. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6887. @xref{list}, for more information on the @option{--list} (@option{-t})
  6888. operation. @xref{Reading}, for a more detailed explanation of that option.
  6889. @table @option
  6890. @item --blocking-factor=@var{number}
  6891. @itemx -b @var{number}
  6892. Specifies the blocking factor of an archive. Can be used with any
  6893. operation, but is usually not necessary with @option{--list} (@option{-t}).
  6894. @end table
  6895. Device blocking
  6896. @table @option
  6897. @item -b @var{blocks}
  6898. @itemx --blocking-factor=@var{blocks}
  6899. Set record size to @math{@var{blocks} * 512} bytes.
  6900. This option is used to specify a @dfn{blocking factor} for the archive.
  6901. When reading or writing the archive, @command{tar}, will do reads and writes
  6902. of the archive in records of @math{@var{block}*512} bytes. This is true
  6903. even when the archive is compressed. Some devices requires that all
  6904. write operations be a multiple of a certain size, and so, @command{tar}
  6905. pads the archive out to the next record boundary.
  6906. The default blocking factor is set when @command{tar} is compiled, and is
  6907. typically 20. Blocking factors larger than 20 cannot be read by very
  6908. old versions of @command{tar}, or by some newer versions of @command{tar}
  6909. running on old machines with small address spaces.
  6910. With a magnetic tape, larger records give faster throughput and fit
  6911. more data on a tape (because there are fewer inter-record gaps).
  6912. If the archive is in a disk file or a pipe, you may want to specify
  6913. a smaller blocking factor, since a large one will result in a large
  6914. number of null bytes at the end of the archive.
  6915. When writing cartridge or other streaming tapes, a much larger
  6916. blocking factor (say 126 or more) will greatly increase performance.
  6917. However, you must specify the same blocking factor when reading or
  6918. updating the archive.
  6919. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6920. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6921. seems to disappear. Id est, we are using block size of 112 right
  6922. now, and we haven't had the problem since we switched@dots{}
  6923. With @GNUTAR{} the blocking factor is limited only
  6924. by the maximum record size of the device containing the archive, or by
  6925. the amount of available virtual memory.
  6926. However, deblocking or reblocking is virtually avoided in a special
  6927. case which often occurs in practice, but which requires all the
  6928. following conditions to be simultaneously true:
  6929. @itemize @bullet
  6930. @item
  6931. the archive is subject to a compression option,
  6932. @item
  6933. the archive is not handled through standard input or output, nor
  6934. redirected nor piped,
  6935. @item
  6936. the archive is directly handled to a local disk, instead of any special
  6937. device,
  6938. @item
  6939. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  6940. invocation.
  6941. @end itemize
  6942. If the output goes directly to a local disk, and not through
  6943. stdout, then the last write is not extended to a full record size.
  6944. Otherwise, reblocking occurs. Here are a few other remarks on this
  6945. topic:
  6946. @itemize @bullet
  6947. @item
  6948. @command{gzip} will complain about trailing garbage if asked to
  6949. uncompress a compressed archive on tape, there is an option to turn
  6950. the message off, but it breaks the regularity of simply having to use
  6951. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6952. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6953. Gailly, by sending a copy of this message to him.
  6954. @item
  6955. @command{compress} does not show this problem, but as Jean-loup pointed
  6956. out to Michael, @samp{compress -d} silently adds garbage after
  6957. the result of decompression, which tar ignores because it already
  6958. recognized its end-of-file indicator. So this bug may be safely
  6959. ignored.
  6960. @item
  6961. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6962. but will still return an exit status of 2 which tar reports in turn.
  6963. @command{tar} might ignore the exit status returned, but I hate doing
  6964. that, as it weakens the protection @command{tar} offers users against
  6965. other possible problems at decompression time. If @command{gzip} was
  6966. silently skipping trailing zeros @emph{and} also avoiding setting the
  6967. exit status in this innocuous case, that would solve this situation.
  6968. @item
  6969. @command{tar} should become more solid at not stopping to read a pipe at
  6970. the first null block encountered. This inelegantly breaks the pipe.
  6971. @command{tar} should rather drain the pipe out before exiting itself.
  6972. @end itemize
  6973. @opindex ignore-zeros, short description
  6974. @item -i
  6975. @itemx --ignore-zeros
  6976. Ignore blocks of zeros in archive (means EOF).
  6977. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  6978. of zeros in the archive. Normally a block of zeros indicates the
  6979. end of the archive, but when reading a damaged archive, or one which
  6980. was created by concatenating several archives together, this option
  6981. allows @command{tar} to read the entire archive. This option is not on
  6982. by default because many versions of @command{tar} write garbage after
  6983. the zeroed blocks.
  6984. Note that this option causes @command{tar} to read to the end of the
  6985. archive file, which may sometimes avoid problems when multiple files
  6986. are stored on a single physical tape.
  6987. @opindex read-full-records, short description
  6988. @item -B
  6989. @itemx --read-full-records
  6990. Reblock as we read (for reading 4.2BSD pipes).
  6991. If @option{--read-full-records} is used, @command{tar}
  6992. will not panic if an attempt to read a record from the archive does
  6993. not return a full record. Instead, @command{tar} will keep reading
  6994. until it has obtained a full
  6995. record.
  6996. This option is turned on by default when @command{tar} is reading
  6997. an archive from standard input, or from a remote machine. This is
  6998. because on BSD Unix systems, a read of a pipe will return however
  6999. much happens to be in the pipe, even if it is less than @command{tar}
  7000. requested. If this option was not used, @command{tar} would fail as
  7001. soon as it read an incomplete record from the pipe.
  7002. This option is also useful with the commands for updating an archive.
  7003. @end table
  7004. Tape blocking
  7005. @FIXME{Appropriate options should be moved here from elsewhere.}
  7006. @cindex blocking factor
  7007. @cindex tape blocking
  7008. When handling various tapes or cartridges, you have to take care of
  7009. selecting a proper blocking, that is, the number of disk blocks you
  7010. put together as a single tape block on the tape, without intervening
  7011. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7012. with no information on it, used for decelerating the tape to a
  7013. full stop, and for later regaining the reading or writing speed.
  7014. When the tape driver starts reading a record, the record has to
  7015. be read whole without stopping, as a tape gap is needed to stop the
  7016. tape motion without loosing information.
  7017. @cindex Exabyte blocking
  7018. @cindex DAT blocking
  7019. Using higher blocking (putting more disk blocks per tape block) will use
  7020. the tape more efficiently as there will be less tape gaps. But reading
  7021. such tapes may be more difficult for the system, as more memory will be
  7022. required to receive at once the whole record. Further, if there is a
  7023. reading error on a huge record, this is less likely that the system will
  7024. succeed in recovering the information. So, blocking should not be too
  7025. low, nor it should be too high. @command{tar} uses by default a blocking of
  7026. 20 for historical reasons, and it does not really matter when reading or
  7027. writing to disk. Current tape technology would easily accommodate higher
  7028. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7029. We were told that for some DLT drives, the blocking should be a multiple
  7030. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7031. Other manufacturers may use different recommendations for the same tapes.
  7032. This might also depends of the buffering techniques used inside modern
  7033. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7034. Others request blocking to be some exponent of two.
  7035. So, there is no fixed rule for blocking. But blocking at read time
  7036. should ideally be the same as blocking used at write time. At one place
  7037. I know, with a wide variety of equipment, they found it best to use a
  7038. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7039. I was also told that, for recycled tapes, prior erasure (by the same
  7040. drive unit that will be used to create the archives) sometimes lowers
  7041. the error rates observed at rewriting time.
  7042. I might also use @option{--number-blocks} instead of
  7043. @option{--block-number}, so @option{--block} will then expand to
  7044. @option{--blocking-factor} unambiguously.
  7045. @node Many
  7046. @section Many Archives on One Tape
  7047. @FIXME{Appropriate options should be moved here from elsewhere.}
  7048. @findex ntape @r{device}
  7049. Most tape devices have two entries in the @file{/dev} directory, or
  7050. entries that come in pairs, which differ only in the minor number for
  7051. this device. Let's take for example @file{/dev/tape}, which often
  7052. points to the only or usual tape device of a given system. There might
  7053. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7054. name is the @emph{rewinding} version of the device, while the name
  7055. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7056. device.
  7057. A rewinding tape device will bring back the tape to its beginning point
  7058. automatically when this device is opened or closed. Since @command{tar}
  7059. opens the archive file before using it and closes it afterwards, this
  7060. means that a simple:
  7061. @smallexample
  7062. $ @kbd{tar cf /dev/tape @var{directory}}
  7063. @end smallexample
  7064. @noindent
  7065. will reposition the tape to its beginning both prior and after saving
  7066. @var{directory} contents to it, thus erasing prior tape contents and
  7067. making it so that any subsequent write operation will destroy what has
  7068. just been saved.
  7069. @cindex tape positioning
  7070. So, a rewinding device is normally meant to hold one and only one file.
  7071. If you want to put more than one @command{tar} archive on a given tape, you
  7072. will need to avoid using the rewinding version of the tape device. You
  7073. will also have to pay special attention to tape positioning. Errors in
  7074. positioning may overwrite the valuable data already on your tape. Many
  7075. people, burnt by past experiences, will only use rewinding devices and
  7076. limit themselves to one file per tape, precisely to avoid the risk of
  7077. such errors. Be fully aware that writing at the wrong position on a
  7078. tape loses all information past this point and most probably until the
  7079. end of the tape, and this destroyed information @emph{cannot} be
  7080. recovered.
  7081. To save @var{directory-1} as a first archive at the beginning of a
  7082. tape, and leave that tape ready for a second archive, you should use:
  7083. @smallexample
  7084. $ @kbd{mt -f /dev/nrtape rewind}
  7085. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7086. @end smallexample
  7087. @cindex tape marks
  7088. @dfn{Tape marks} are special magnetic patterns written on the tape
  7089. media, which are later recognizable by the reading hardware. These
  7090. marks are used after each file, when there are many on a single tape.
  7091. An empty file (that is to say, two tape marks in a row) signal the
  7092. logical end of the tape, after which no file exist. Usually,
  7093. non-rewinding tape device drivers will react to the close request issued
  7094. by @command{tar} by first writing two tape marks after your archive, and by
  7095. backspacing over one of these. So, if you remove the tape at that time
  7096. from the tape drive, it is properly terminated. But if you write
  7097. another file at the current position, the second tape mark will be
  7098. erased by the new information, leaving only one tape mark between files.
  7099. So, you may now save @var{directory-2} as a second archive after the
  7100. first on the same tape by issuing the command:
  7101. @smallexample
  7102. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7103. @end smallexample
  7104. @noindent
  7105. and so on for all the archives you want to put on the same tape.
  7106. Another usual case is that you do not write all the archives the same
  7107. day, and you need to remove and store the tape between two archive
  7108. sessions. In general, you must remember how many files are already
  7109. saved on your tape. Suppose your tape already has 16 files on it, and
  7110. that you are ready to write the 17th. You have to take care of skipping
  7111. the first 16 tape marks before saving @var{directory-17}, say, by using
  7112. these commands:
  7113. @smallexample
  7114. $ @kbd{mt -f /dev/nrtape rewind}
  7115. $ @kbd{mt -f /dev/nrtape fsf 16}
  7116. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7117. @end smallexample
  7118. In all the previous examples, we put aside blocking considerations, but
  7119. you should do the proper things for that as well. @xref{Blocking}.
  7120. @menu
  7121. * Tape Positioning:: Tape Positions and Tape Marks
  7122. * mt:: The @command{mt} Utility
  7123. @end menu
  7124. @node Tape Positioning
  7125. @subsection Tape Positions and Tape Marks
  7126. @UNREVISED
  7127. Just as archives can store more than one file from the file system,
  7128. tapes can store more than one archive file. To keep track of where
  7129. archive files (or any other type of file stored on tape) begin and
  7130. end, tape archive devices write magnetic @dfn{tape marks} on the
  7131. archive media. Tape drives write one tape mark between files,
  7132. two at the end of all the file entries.
  7133. If you think of data as a series of records "rrrr"'s, and tape marks as
  7134. "*"'s, a tape might look like the following:
  7135. @smallexample
  7136. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7137. @end smallexample
  7138. Tape devices read and write tapes using a read/write @dfn{tape
  7139. head}---a physical part of the device which can only access one
  7140. point on the tape at a time. When you use @command{tar} to read or
  7141. write archive data from a tape device, the device will begin reading
  7142. or writing from wherever on the tape the tape head happens to be,
  7143. regardless of which archive or what part of the archive the tape
  7144. head is on. Before writing an archive, you should make sure that no
  7145. data on the tape will be overwritten (unless it is no longer needed).
  7146. Before reading an archive, you should make sure the tape head is at
  7147. the beginning of the archive you want to read. You can do it manually
  7148. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7149. that automatically (@pxref{Scripted Restoration}).
  7150. If you want to add new archive file entries to a tape, you should
  7151. advance the tape to the end of the existing file entries, backspace
  7152. over the last tape mark, and write the new archive file. If you were
  7153. to add two archives to the example above, the tape might look like the
  7154. following:
  7155. @smallexample
  7156. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7157. @end smallexample
  7158. @node mt
  7159. @subsection The @command{mt} Utility
  7160. @UNREVISED
  7161. @FIXME{Is it true that this only works on non-block devices?
  7162. should explain the difference, (fixed or variable).}
  7163. @xref{Blocking Factor}.
  7164. You can use the @command{mt} utility to advance or rewind a tape past a
  7165. specified number of archive files on the tape. This will allow you
  7166. to move to the beginning of an archive before extracting or reading
  7167. it, or to the end of all the archives before writing a new one.
  7168. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7169. together"?}
  7170. The syntax of the @command{mt} command is:
  7171. @smallexample
  7172. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7173. @end smallexample
  7174. where @var{tapename} is the name of the tape device, @var{number} is
  7175. the number of times an operation is performed (with a default of one),
  7176. and @var{operation} is one of the following:
  7177. @FIXME{is there any use for record operations?}
  7178. @table @option
  7179. @item eof
  7180. @itemx weof
  7181. Writes @var{number} tape marks at the current position on the tape.
  7182. @item fsf
  7183. Moves tape position forward @var{number} files.
  7184. @item bsf
  7185. Moves tape position back @var{number} files.
  7186. @item rewind
  7187. Rewinds the tape. (Ignores @var{number}).
  7188. @item offline
  7189. @itemx rewoff1
  7190. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7191. @item status
  7192. Prints status information about the tape unit.
  7193. @end table
  7194. @FIXME{Is there a better way to frob the spacing on the list?}
  7195. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7196. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7197. @file{/dev/rmt12}.
  7198. @command{mt} returns a 0 exit status when the operation(s) were
  7199. successful, 1 if the command was unrecognized, and 2 if an operation
  7200. failed.
  7201. @node Using Multiple Tapes
  7202. @section Using Multiple Tapes
  7203. @UNREVISED
  7204. Often you might want to write a large archive, one larger than will fit
  7205. on the actual tape you are using. In such a case, you can run multiple
  7206. @command{tar} commands, but this can be inconvenient, particularly if you
  7207. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7208. Therefore, @command{tar} supports multiple tapes automatically.
  7209. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7210. then @command{tar} will, when it reaches the end of the tape, prompt
  7211. for another tape, and continue the archive. Each tape will have an
  7212. independent archive, and can be read without needing the other. (As
  7213. an exception to this, the file that @command{tar} was archiving when
  7214. it ran out of tape will usually be split between the two archives; in
  7215. this case you need to extract from the first archive, using
  7216. @option{--multi-volume}, and then put in the second tape when
  7217. prompted, so @command{tar} can restore both halves of the file.)
  7218. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7219. You need @GNUTAR{} at both ends to process them properly.
  7220. When prompting for a new tape, @command{tar} accepts any of the following
  7221. responses:
  7222. @table @kbd
  7223. @item ?
  7224. Request @command{tar} to explain possible responses
  7225. @item q
  7226. Request @command{tar} to exit immediately.
  7227. @item n @var{file name}
  7228. Request @command{tar} to write the next volume on the file @var{file name}.
  7229. @item !
  7230. Request @command{tar} to run a subshell. This option can be disabled
  7231. by giving @option{--restrict} command line option to @command{tar}.
  7232. @item y
  7233. Request @command{tar} to begin writing the next volume.
  7234. @end table
  7235. (You should only type @samp{y} after you have changed the tape;
  7236. otherwise @command{tar} will write over the volume it just finished.)
  7237. @cindex End-of-archive info script
  7238. @cindex Info script
  7239. @anchor{info-script}
  7240. @opindex info-script
  7241. @opindex new-volume-script
  7242. If you want more elaborate behavior than this, give @command{tar} the
  7243. @option{--info-script=@var{script-name}}
  7244. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7245. @var{script-name}}) option. The file @var{script-name} is expected to
  7246. be a program (or shell script) to be run instead of the normal
  7247. prompting procedure. It is executed without any command line
  7248. arguments. Additional data is passed to it via the following
  7249. environment variables:
  7250. @table @env
  7251. @vrindex TAR_VERSION, info script environment variable
  7252. @item TAR_VERSION
  7253. @GNUTAR{} version number.
  7254. @vrindex TAR_ARCHIVE, info script environment variable
  7255. @item TAR_ARCHIVE
  7256. The name of the archive @command{tar} is processing.
  7257. @vrindex TAR_VOLUME, info script environment variable
  7258. @item TAR_VOLUME
  7259. Ordinal number of the volume @command{tar} is about to start.
  7260. @vrindex TAR_SUBCOMMAND, info script environment variable
  7261. @item TAR_SUBCOMMAND
  7262. Short option describing the operation @command{tar} is executed.
  7263. @xref{Operations}, for a complete list of subcommand options.
  7264. @vrindex TAR_FORMAT, info script environment variable
  7265. @item TAR_FORMAT
  7266. Format of the archive being processed. @xref{Formats}, for a complete
  7267. list of archive format names.
  7268. @end table
  7269. The info script can instruct @command{tar} to use new archive name,
  7270. by writing in to file descriptor 3 (see below for an
  7271. example).
  7272. If the info script fails, @command{tar} exits; otherwise, it begins
  7273. writing the next volume.
  7274. The method @command{tar} uses to detect end of tape is not perfect, and
  7275. fails on some operating systems or on some devices. You can use the
  7276. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7277. @command{tar} can't detect the end of the tape itself. This option
  7278. selects @option{--multi-volume} (@option{-M}) automatically. The
  7279. @var{size} argument should then be the usable size of the tape in
  7280. units of 1024 bytes. But for many devices, and floppy disks in
  7281. particular, this option is never required for real, as far as we know.
  7282. @cindex Volume number file
  7283. @cindex volno file
  7284. @anchor{volno-file}
  7285. @opindex volno-file
  7286. The volume number used by @command{tar} in its tape-change prompt
  7287. can be changed; if you give the
  7288. @option{--volno-file=@var{file-of-number}} option, then
  7289. @var{file-of-number} should be an unexisting file to be created, or
  7290. else, a file already containing a decimal number. That number will be
  7291. used as the volume number of the first volume written. When
  7292. @command{tar} is finished, it will rewrite the file with the
  7293. now-current volume number. (This does not change the volume number
  7294. written on a tape label, as per @ref{label}, it @emph{only} affects
  7295. the number used in the prompt.)
  7296. If you want @command{tar} to cycle through a series of files or tape
  7297. drives, there are three approaches to choose from. First of all, you
  7298. can give @command{tar} multiple @option{--file} options. In this case
  7299. the specified files will be used, in sequence, as the successive
  7300. volumes of the archive. Only when the first one in the sequence needs
  7301. to be used again will @command{tar} prompt for a tape change (or run
  7302. the info script). Secondly, you can use the @samp{n} response to the
  7303. tape-change prompt, and, finally, you can use an info script, that
  7304. writes new archive name to file descriptor. The following example
  7305. illustrates this approach:
  7306. @smallexample
  7307. @group
  7308. #! /bin/sh
  7309. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7310. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7311. case $TAR_SUBCOMMAND in
  7312. -c) ;;
  7313. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7314. ;;
  7315. *) exit 1
  7316. esac
  7317. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7318. @end group
  7319. @end smallexample
  7320. Each volume of a multi-volume archive is an independent @command{tar}
  7321. archive, complete in itself. For example, you can list or extract any
  7322. volume alone; just don't specify @option{--multi-volume}
  7323. (@option{-M}). However, if one file in the archive is split across
  7324. volumes, the only way to extract it successfully is with a
  7325. multi-volume extract command @option{--extract --multi-volume}
  7326. (@option{-xM}) starting on or before the volume where the file begins.
  7327. For example, let's presume someone has two tape drives on a system
  7328. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7329. to switch to the second drive when it needs to write the
  7330. second tape, and then back to the first tape, etc., just do either of:
  7331. @smallexample
  7332. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7333. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7334. @end smallexample
  7335. @menu
  7336. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7337. * Tape Files:: Tape Files
  7338. * Tarcat:: Concatenate Volumes into a Single Archive
  7339. @end menu
  7340. @node Multi-Volume Archives
  7341. @subsection Archives Longer than One Tape or Disk
  7342. @cindex Multi-volume archives
  7343. @UNREVISED
  7344. @opindex multi-volume
  7345. To create an archive that is larger than will fit on a single unit of
  7346. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7347. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7348. archive can be manipulated like any other archive (provided the
  7349. @option{--multi-volume} option is specified), but is stored on more
  7350. than one tape or disk.
  7351. When you specify @option{--multi-volume}, @command{tar} does not report an
  7352. error when it comes to the end of an archive volume (when reading), or
  7353. the end of the media (when writing). Instead, it prompts you to load
  7354. a new storage volume. If the archive is on a magnetic tape, you
  7355. should change tapes when you see the prompt; if the archive is on a
  7356. floppy disk, you should change disks; etc.
  7357. You can read each individual volume of a multi-volume archive as if it
  7358. were an archive by itself. For example, to list the contents of one
  7359. volume, use @option{--list}, without @option{--multi-volume} specified.
  7360. To extract an archive member from one volume (assuming it is described
  7361. that volume), use @option{--extract}, again without
  7362. @option{--multi-volume}.
  7363. If an archive member is split across volumes (ie. its entry begins on
  7364. one volume of the media and ends on another), you need to specify
  7365. @option{--multi-volume} to extract it successfully. In this case, you
  7366. should load the volume where the archive member starts, and use
  7367. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7368. volumes as it needs them. @xref{extracting archives}, for more
  7369. information about extracting archives.
  7370. @option{--info-script=@var{script-name}}
  7371. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7372. @var{script-name}}) (@pxref{info-script}) is like
  7373. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7374. not prompt you directly to change media volumes when a volume is
  7375. full---instead, @command{tar} runs commands you have stored in
  7376. @var{script-name}. For example, this option can be used to eject
  7377. cassettes, or to broadcast messages such as @samp{Someone please come
  7378. change my tape} when performing unattended backups. When
  7379. @var{script-name} is done, @command{tar} will assume that the media
  7380. has been changed.
  7381. Multi-volume archives can be modified like any other archive. To add
  7382. files to a multi-volume archive, you need to only mount the last
  7383. volume of the archive media (and new volumes, if needed). For all
  7384. other operations, you need to use the entire archive.
  7385. If a multi-volume archive was labeled using
  7386. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7387. (@pxref{label}) when it was created, @command{tar} will not
  7388. automatically label volumes which are added later. To label
  7389. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7390. in conjunction with the @option{--append}, @option{--update} or
  7391. @option{--concatenate} operation.
  7392. @cindex Labeling multi-volume archives
  7393. @FIXME{example}
  7394. @FIXME{There should be a sample program here, including an exit
  7395. before end. Is the exit status even checked in tar? :-(}
  7396. @table @option
  7397. @item --multi-volume
  7398. @itemx -M
  7399. Creates a multi-volume archive, when used in conjunction with
  7400. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7401. archive, specify @option{--multi-volume} in conjunction with that
  7402. operation.
  7403. @item --info-script=@var{program-file}
  7404. @itemx --new-volume-script=@var{program-file}
  7405. @itemx -F @var{program-file}
  7406. Creates a multi-volume archive via a script. Used in conjunction with
  7407. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7408. @end table
  7409. Beware that there is @emph{no} real standard about the proper way, for
  7410. a @command{tar} archive, to span volume boundaries. If you have a
  7411. multi-volume created by some vendor's @command{tar}, there is almost
  7412. no chance you could read all the volumes with @GNUTAR{}.
  7413. The converse is also true: you may not expect
  7414. multi-volume archives created by @GNUTAR{} to be
  7415. fully recovered by vendor's @command{tar}. Since there is little
  7416. chance that, in mixed system configurations, some vendor's
  7417. @command{tar} will work on another vendor's machine, and there is a
  7418. great chance that @GNUTAR{} will work on most of
  7419. them, your best bet is to install @GNUTAR{} on all
  7420. machines between which you know exchange of files is possible.
  7421. @node Tape Files
  7422. @subsection Tape Files
  7423. @UNREVISED
  7424. To give the archive a name which will be recorded in it, use the
  7425. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7426. option. This will write a special block identifying
  7427. @var{volume-label} as the name of the archive to the front of the
  7428. archive which will be displayed when the archive is listed with
  7429. @option{--list}. If you are creating a multi-volume archive with
  7430. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7431. volume label will have @samp{Volume @var{nnn}} appended to the name
  7432. you give, where @var{nnn} is the number of the volume of the archive.
  7433. (If you use the @option{--label=@var{volume-label}}) option when
  7434. reading an archive, it checks to make sure the label on the tape
  7435. matches the one you give. @xref{label}.
  7436. When @command{tar} writes an archive to tape, it creates a single
  7437. tape file. If multiple archives are written to the same tape, one
  7438. after the other, they each get written as separate tape files. When
  7439. extracting, it is necessary to position the tape at the right place
  7440. before running @command{tar}. To do this, use the @command{mt} command.
  7441. For more information on the @command{mt} command and on the organization
  7442. of tapes into a sequence of tape files, see @ref{mt}.
  7443. People seem to often do:
  7444. @smallexample
  7445. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7446. @end smallexample
  7447. or such, for pushing a common date in all volumes or an archive set.
  7448. @node Tarcat
  7449. @subsection Concatenate Volumes into a Single Archive
  7450. @pindex tarcat
  7451. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7452. archive to a single @command{tar} archive. Simply concatenating all
  7453. volumes into one will not work, since each volume carries an additional
  7454. information at the beginning. @GNUTAR{} is shipped with the shell
  7455. script @command{tarcat} designed for this purpose.
  7456. The script takes a list of files comprising a multi-volume archive
  7457. and creates the resulting archive at the standard output. For example:
  7458. @smallexample
  7459. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7460. @end smallexample
  7461. The script implements a simple heuristics to determine the format of
  7462. the first volume file and to decide how to process the rest of the
  7463. files. However, it makes no attempt to verify whether the files are
  7464. given in order or even if they are valid @command{tar} archives.
  7465. It uses @command{dd} and does not filter its standard error, so you
  7466. will usually see lots of spurious messages.
  7467. @FIXME{The script is not installed. Should we install it?}
  7468. @node label
  7469. @section Including a Label in the Archive
  7470. @cindex Labeling an archive
  7471. @cindex Labels on the archive media
  7472. @UNREVISED
  7473. @opindex label
  7474. To avoid problems caused by misplaced paper labels on the archive
  7475. media, you can include a @dfn{label} entry---an archive member which
  7476. contains the name of the archive---in the archive itself. Use the
  7477. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7478. option in conjunction with the @option{--create} operation to include
  7479. a label entry in the archive as it is being created.
  7480. @table @option
  7481. @item --label=@var{archive-label}
  7482. @itemx -V @var{archive-label}
  7483. Includes an @dfn{archive-label} at the beginning of the archive when
  7484. the archive is being created, when used in conjunction with the
  7485. @option{--create} operation. Checks to make sure the archive label
  7486. matches the one specified (when used in conjunction with any other
  7487. operation.
  7488. @end table
  7489. If you create an archive using both
  7490. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7491. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7492. will have an archive label of the form @samp{@var{archive-label}
  7493. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7494. next, and so on. @xref{Using Multiple Tapes}, for information on
  7495. creating multiple volume archives.
  7496. @cindex Volume label, listing
  7497. @cindex Listing volume label
  7498. The volume label will be displayed by @option{--list} along with
  7499. the file contents. If verbose display is requested, it will also be
  7500. explicitely marked as in the example below:
  7501. @smallexample
  7502. @group
  7503. $ @kbd{tar --verbose --list --file=iamanarchive}
  7504. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7505. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7506. @end group
  7507. @end smallexample
  7508. @opindex test-label
  7509. @anchor{--test-label option}
  7510. However, @option{--list} option will cause listing entire
  7511. contents of the archive, which may be undesirable (for example, if the
  7512. archive is stored on a tape). You can request checking only the volume
  7513. by specifying @option{--test-label} option. This option reads only the
  7514. first block of an archive, so it can be used with slow storage
  7515. devices. For example:
  7516. @smallexample
  7517. @group
  7518. $ @kbd{tar --test-label --file=iamanarchive}
  7519. iamalabel
  7520. @end group
  7521. @end smallexample
  7522. If @option{--test-label} is used with a single command line
  7523. argument, @command{tar} compares the volume label with the
  7524. argument. It exits with code 0 if the two strings match, and with code
  7525. 2 otherwise. In this case no output is displayed. For example:
  7526. @smallexample
  7527. @group
  7528. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7529. @result{} 0
  7530. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7531. @result{} 1
  7532. @end group
  7533. @end smallexample
  7534. If you request any operation, other than @option{--create}, along
  7535. with using @option{--label} option, @command{tar} will first check if
  7536. the archive label matches the one specified and will refuse to proceed
  7537. if it does not. Use this as a safety precaution to avoid accidentally
  7538. overwriting existing archives. For example, if you wish to add files
  7539. to @file{archive}, presumably labelled with string @samp{My volume},
  7540. you will get:
  7541. @smallexample
  7542. @group
  7543. $ @kbd{tar -rf archive --label 'My volume' .}
  7544. tar: Archive not labeled to match `My volume'
  7545. @end group
  7546. @end smallexample
  7547. @noindent
  7548. in case its label does not match. This will work even if
  7549. @file{archive} is not labelled at all.
  7550. Similarly, @command{tar} will refuse to list or extract the
  7551. archive if its label doesn't match the @var{archive-label}
  7552. specified. In those cases, @var{archive-label} argument is interpreted
  7553. as a globbing-style pattern which must match the actual magnetic
  7554. volume label. @xref{exclude}, for a precise description of how match
  7555. is attempted@footnote{Previous versions of @command{tar} used full
  7556. regular expression matching, or before that, only exact string
  7557. matching, instead of wildcard matchers. We decided for the sake of
  7558. simplicity to use a uniform matching device through
  7559. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7560. the volume label matcher will also suffix @var{archive-label} by
  7561. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7562. up. Since the volume numbering is automatically added in labels at
  7563. creation time, it sounded logical to equally help the user taking care
  7564. of it when the archive is being read.
  7565. The @option{--label} was once called @option{--volume}, but is not
  7566. available under that name anymore.
  7567. You can also use @option{--label} to get a common information on
  7568. all tapes of a series. For having this information different in each
  7569. series created through a single script used on a regular basis, just
  7570. manage to get some date string as part of the label. For example:
  7571. @smallexample
  7572. @group
  7573. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7574. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7575. --volume="Daily backup for `date +%Y-%m-%d`"}
  7576. @end group
  7577. @end smallexample
  7578. Also note that each label has its own date and time, which corresponds
  7579. to when @GNUTAR{} initially attempted to write it,
  7580. often soon after the operator launches @command{tar} or types the
  7581. carriage return telling that the next tape is ready. Comparing date
  7582. labels does give an idea of tape throughput only if the delays for
  7583. rewinding tapes and the operator switching them were negligible, which
  7584. is usually not the case.
  7585. @node verify
  7586. @section Verifying Data as It is Stored
  7587. @cindex Verifying a write operation
  7588. @cindex Double-checking a write operation
  7589. @table @option
  7590. @item -W
  7591. @itemx --verify
  7592. @opindex verify, short description
  7593. Attempt to verify the archive after writing.
  7594. @end table
  7595. This option causes @command{tar} to verify the archive after writing it.
  7596. Each volume is checked after it is written, and any discrepancies
  7597. are recorded on the standard error output.
  7598. Verification requires that the archive be on a back-space-able medium.
  7599. This means pipes, some cartridge tape drives, and some other devices
  7600. cannot be verified.
  7601. You can insure the accuracy of an archive by comparing files in the
  7602. system with archive members. @command{tar} can compare an archive to the
  7603. file system as the archive is being written, to verify a write
  7604. operation, or can compare a previously written archive, to insure that
  7605. it is up to date.
  7606. @opindex verify, using with @option{--create}
  7607. @opindex create, using with @option{--verify}
  7608. To check for discrepancies in an archive immediately after it is
  7609. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7610. the @option{--create} operation. When this option is
  7611. specified, @command{tar} checks archive members against their counterparts
  7612. in the file system, and reports discrepancies on the standard error.
  7613. To verify an archive, you must be able to read it from before the end
  7614. of the last written entry. This option is useful for detecting data
  7615. errors on some tapes. Archives written to pipes, some cartridge tape
  7616. drives, and some other devices cannot be verified.
  7617. One can explicitly compare an already made archive with the file
  7618. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7619. option, instead of using the more automatic @option{--verify} option.
  7620. @xref{compare}.
  7621. Note that these two options have a slightly different intent. The
  7622. @option{--compare} option checks how identical are the logical contents of some
  7623. archive with what is on your disks, while the @option{--verify} option is
  7624. really for checking if the physical contents agree and if the recording
  7625. media itself is of dependable quality. So, for the @option{--verify}
  7626. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7627. the archive, while it lets the speed optimization undisturbed for the
  7628. @option{--compare} option. If you nevertheless use @option{--compare} for
  7629. media verification, you may have to defeat the in-memory cache yourself,
  7630. maybe by opening and reclosing the door latch of your recording unit,
  7631. forcing some doubt in your operating system about the fact this is really
  7632. the same volume as the one just written or read.
  7633. The @option{--verify} option would not be necessary if drivers were indeed
  7634. able to detect dependably all write failures. This sometimes require many
  7635. magnetic heads, some able to read after the writes occurred. One would
  7636. not say that drivers unable to detect all cases are necessarily flawed,
  7637. as long as programming is concerned.
  7638. The @option{--verify} (@option{-W}) option will not work in
  7639. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7640. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7641. and @option{--delete} operations. @xref{Operations}, for more
  7642. information on these operations.
  7643. Also, since @command{tar} normally strips leading @samp{/} from file
  7644. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7645. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7646. @file{/}, as @command{tar} uses the archive's relative member names
  7647. (e.g., @file{etc/motd}) when verifying the archive.
  7648. @node Write Protection
  7649. @section Write Protection
  7650. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7651. be @dfn{write protected}, to protect data on them from being changed.
  7652. Once an archive is written, you should write protect the media to prevent
  7653. the archive from being accidentally overwritten or deleted. (This will
  7654. protect the archive from being changed with a tape or floppy drive---it
  7655. will not protect it from magnet fields or other physical hazards).
  7656. The write protection device itself is usually an integral part of the
  7657. physical media, and can be a two position (write enabled/write
  7658. disabled) switch, a notch which can be popped out or covered, a ring
  7659. which can be removed from the center of a tape reel, or some other
  7660. changeable feature.
  7661. @node Changes
  7662. @appendix Changes
  7663. This appendix lists some important user-visible changes between
  7664. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  7665. version of this document is available at
  7666. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  7667. @GNUTAR{} documentation page}.
  7668. @table @asis
  7669. @item Use of short option @option{-o}.
  7670. Earlier versions of @GNUTAR{} understood @option{-o} command line
  7671. option as a synonym for @option{--old-archive}.
  7672. @GNUTAR{} starting from version 1.13.90 understands this option as
  7673. a synonym for @option{--no-same-owner}. This is compatible with
  7674. UNIX98 @command{tar} implementations.
  7675. However, to facilitate transition, @option{-o} option retains its
  7676. old semantics when it is used with one of archive-creation commands.
  7677. Users are encouraged to use @option{--format=oldgnu} instead.
  7678. It is especially important, since versions of @acronym{GNU} Automake
  7679. up to and including 1.8.4 invoke tar with this option to produce
  7680. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  7681. of this issue and its implications.
  7682. Future versions of @GNUTAR{} will understand @option{-o} only as a
  7683. synonym for @option{--no-same-owner}.
  7684. @item Use of short option @option{-l}
  7685. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  7686. synonym for @option{--one-file-system}. Such usage is deprecated.
  7687. For compatibility with other implementations future versions of
  7688. @GNUTAR{} will understand this option as a synonym for
  7689. @option{--check-links}.
  7690. @item Use of options @option{--portability} and @option{--old-archive}
  7691. These options are deprecated. Please use @option{--format=v7} instead.
  7692. @item Use of option @option{--posix}
  7693. This option is deprecated. Please use @option{--format=posix} instead.
  7694. @end table
  7695. @node Configuring Help Summary
  7696. @appendix Configuring Help Summary
  7697. Running @kbd{tar --help} displays the short @command{tar} option
  7698. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  7699. semantically close options. The options within each group are printed
  7700. in the following order: a short option, eventually followed by a list
  7701. of corresponding long option names, followed by a short description of
  7702. the option. For example, here is an excerpt from the actual @kbd{tar
  7703. --help} output:
  7704. @verbatim
  7705. Main operation mode:
  7706. -A, --catenate, --concatenate append tar files to an archive
  7707. -c, --create create a new archive
  7708. -d, --diff, --compare find differences between archive and
  7709. file system
  7710. --delete delete from the archive
  7711. @end verbatim
  7712. @vrindex ARGP_HELP_FMT, environment variable
  7713. The exact visual representation of the help output is configurable via
  7714. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  7715. is a comma-separated list of @dfn{format variable} assignments. There
  7716. are two kinds of format variables. An @dfn{offset variable} keeps the
  7717. offset of some part of help output text from the leftmost column on
  7718. the screen. A @dfn{boolean} variable is a flag that toggles some
  7719. output feature on or off. Depending on the type of the corresponding
  7720. variable, there are two kinds of assignments:
  7721. @table @asis
  7722. @item Offset assignment
  7723. The assignment to an offset variable has the following syntax:
  7724. @smallexample
  7725. @var{variable}=@var{value}
  7726. @end smallexample
  7727. @noindent
  7728. where @var{variable} is the variable name, and @var{value} is a
  7729. numeric value to be assigned to the variable.
  7730. @item Boolean assignment
  7731. To assign @code{true} value to a variable, simply put this variable name. To
  7732. assign @code{false} value, prefix the variable name with @samp{no-}. For
  7733. example:
  7734. @smallexample
  7735. @group
  7736. # Assign @code{true} value:
  7737. dup-args
  7738. # Assign @code{false} value:
  7739. no-dup-args
  7740. @end group
  7741. @end smallexample
  7742. @end table
  7743. Following variables are declared:
  7744. @deftypevr {Help Output} boolean dup-args
  7745. If true, arguments for an option are shown with both short and long
  7746. options, even when a given option has both forms, for example:
  7747. @smallexample
  7748. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  7749. @end smallexample
  7750. If false, then if an option has both short and long forms, the
  7751. argument is only shown with the long one, for example:
  7752. @smallexample
  7753. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7754. @end smallexample
  7755. @noindent
  7756. and a message indicating that the argument is applicable to both
  7757. forms is printed below the options. This message can be disabled
  7758. using @code{dup-args-note} (see below).
  7759. The default is false.
  7760. @end deftypevr
  7761. @deftypevr {Help Output} boolean dup-args-note
  7762. If this variable is true, which is the default, the following notice
  7763. is displayed at the end of the help output:
  7764. @quotation
  7765. Mandatory or optional arguments to long options are also mandatory or
  7766. optional for any corresponding short options.
  7767. @end quotation
  7768. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  7769. variables @code{dup-args} or @code{dup-args-note} should be set.
  7770. @end deftypevr
  7771. @deftypevr {Help Output} offset short-opt-col
  7772. Column in which short options start. Default is 2.
  7773. @smallexample
  7774. @group
  7775. $ @kbd{tar --help|grep ARCHIVE}
  7776. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7777. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  7778. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7779. @end group
  7780. @end smallexample
  7781. @end deftypevr
  7782. @deftypevr {Help Output} offset long-opt-col
  7783. Column in which long options start. Default is 6. For example:
  7784. @smallexample
  7785. @group
  7786. $ @kbd{tar --help|grep ARCHIVE}
  7787. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7788. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  7789. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7790. @end group
  7791. @end smallexample
  7792. @end deftypevr
  7793. @deftypevr {Help Output} offset doc-opt-col
  7794. Column in which @dfn{doc options} start. A doc option isn't actually
  7795. an option, but rather an arbitrary piece of documentation that is
  7796. displayed in much the same manner as the options. For example, in
  7797. the description of @option{--format} option:
  7798. @smallexample
  7799. @group
  7800. -H, --format=FORMAT create archive of the given format.
  7801. FORMAT is one of the following:
  7802. gnu GNU tar 1.13.x format
  7803. oldgnu GNU format as per tar <= 1.12
  7804. pax POSIX 1003.1-2001 (pax) format
  7805. posix same as pax
  7806. ustar POSIX 1003.1-1988 (ustar) format
  7807. v7 old V7 tar format
  7808. @end group
  7809. @end smallexample
  7810. @noindent
  7811. the format names are doc options. Thus, if you set
  7812. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  7813. will look as follows:
  7814. @smallexample
  7815. @group
  7816. -H, --format=FORMAT create archive of the given format.
  7817. FORMAT is one of the following:
  7818. gnu GNU tar 1.13.x format
  7819. oldgnu GNU format as per tar <= 1.12
  7820. pax POSIX 1003.1-2001 (pax) format
  7821. posix same as pax
  7822. ustar POSIX 1003.1-1988 (ustar) format
  7823. v7 old V7 tar format
  7824. @end group
  7825. @end smallexample
  7826. @end deftypevr
  7827. @deftypevr {Help Output} offset opt-doc-col
  7828. Column in which option description starts. Default is 29.
  7829. @smallexample
  7830. @group
  7831. $ @kbd{tar --help|grep ARCHIVE}
  7832. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7833. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  7834. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7835. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  7836. -f, --file=ARCHIVE
  7837. use archive file or device ARCHIVE
  7838. @end group
  7839. @end smallexample
  7840. @noindent
  7841. Notice, that the description starts on a separate line if
  7842. @code{opt-doc-col} value is too small.
  7843. @end deftypevr
  7844. @deftypevr {Help Output} offset header-col
  7845. Column in which @dfn{group headers} are printed. A group header is a
  7846. descriptive text preceding an option group. For example, in the
  7847. following text:
  7848. @verbatim
  7849. Main operation mode:
  7850. -A, --catenate, --concatenate append tar files to
  7851. an archive
  7852. -c, --create create a new archive
  7853. @end verbatim
  7854. @noindent
  7855. @samp{Main operation mode:} is the group header.
  7856. The default value is 1.
  7857. @end deftypevr
  7858. @deftypevr {Help Output} offset usage-indent
  7859. Indentation of wrapped usage lines. Affects @option{--usage}
  7860. output. Default is 12.
  7861. @end deftypevr
  7862. @deftypevr {Help Output} offset rmargin
  7863. Right margin of the text output. Used for wrapping.
  7864. @end deftypevr
  7865. @node Genfile
  7866. @appendix Genfile
  7867. @include genfile.texi
  7868. @node Snapshot Files
  7869. @appendix Format of the Incremental Snapshot Files
  7870. @include snapshot.texi
  7871. @node Free Software Needs Free Documentation
  7872. @appendix Free Software Needs Free Documentation
  7873. @include freemanuals.texi
  7874. @node Copying This Manual
  7875. @appendix Copying This Manual
  7876. @menu
  7877. * GNU Free Documentation License:: License for copying this manual
  7878. @end menu
  7879. @include fdl.texi
  7880. @node Index of Command Line Options
  7881. @appendix Index of Command Line Options
  7882. This appendix contains an index of all @GNUTAR{} long command line
  7883. options. The options are listed without the preceeding double-dash.
  7884. @FIXME{@itemize
  7885. @item Make sure @emph{all} options are indexed.
  7886. @item Provide an index of short options
  7887. @end itemize}
  7888. @printindex op
  7889. @node Index
  7890. @appendix Index
  7891. @printindex cp
  7892. @summarycontents
  7893. @contents
  7894. @bye
  7895. @c Local variables:
  7896. @c texinfo-column-for-description: 32
  7897. @c End: